コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack)
        {
            return;
        }

        ckoAPIClient = new APIClient();

        #region Populates customer dropdown list
        // Submit your request and receive an apiResponse
        Checkout.ApiServices.Customers.RequestModels.CustomerGetList cgl = new Checkout.ApiServices.Customers.RequestModels.CustomerGetList();
        cgl.Count    = 10;
        cgl.FromDate = DateTime.Now.AddYears(-2);
        cgl.ToDate   = DateTime.Now;
        cgl.Offset   = 0;

        HttpResponse <Checkout.ApiServices.Customers.ResponseModels.CustomerList> apiResponse = ckoAPIClient.CustomerService.GetCustomerList(cgl);

        if (!apiResponse.HasError)
        {
            // Access the response object retrieved from the api
            var customer = apiResponse.Model;

            List <Customer> customers = customer.Data;

            dropdown_customerlist.DataTextField  = "Name";
            dropdown_customerlist.DataValueField = "Id";
            dropdown_customerlist.DataSource     = customers;
            dropdown_customerlist.DataBind();
        }
        else
        {
            // Api has returned an error object. You can access the details in the error property of the apiResponse.
            // apiResponse.error
            tb_createRsp.Text = apiResponse.Error.Message;
        }
        #endregion
    }
コード例 #2
0
    private void LoadDropDownLists()
    {
        if (dropdown_customerlist.Items.Count < 1)
        {
            ckoAPIClient = new APIClient();

            // Submit your request and receive an apiResponse
            Checkout.ApiServices.Customers.RequestModels.CustomerGetList cgl = new Checkout.ApiServices.Customers.RequestModels.CustomerGetList();
            cgl.Count    = 10;
            cgl.FromDate = DateTime.Now.AddMonths(-1);
            cgl.ToDate   = DateTime.Now;
            cgl.Offset   = 0;

            HttpResponse <Checkout.ApiServices.Customers.ResponseModels.CustomerList> apiResponse = ckoAPIClient.CustomerService.GetCustomerList(cgl);

            if (!apiResponse.HasError)
            {
                // Access the response object retrieved from the api
                var customer = apiResponse.Model;

                List <Customer> customers = customer.Data;

                int count = 0;

                foreach (Customer c in customers)
                {
                    dropdown_customerlist.Items.Insert(count++, new ListItem(c.Name, c.Id));
                }

                dropdown_customerlist.Items.Insert(0, new ListItem(" Select one", "0"));
                //dropdown_customerlist.Items[0].Selected = true;
                dropdown_customerlist.Items[0].Enabled = true;

                dropdown_customerlist.AutoPostBack    = true;
                dropdown_customerlist.EnableViewState = true;
                dropdown_customerlist.ViewStateMode   = ViewStateMode.Enabled;

                Checkout.ApiServices.Cards.ResponseModels.CardList cardlist = new Checkout.ApiServices.Cards.ResponseModels.CardList();

                string custId = dropdown_customerlist.SelectedValue;

                HttpResponse <Checkout.ApiServices.Cards.ResponseModels.CardList> cardlistresponse = ckoAPIClient.CardService.GetCardList(custId);

                if (!cardlistresponse.HasError)
                {
                    // Access the response object retrieved from the api
                    var cardlistrsp = cardlistresponse.Model;

                    List <Checkout.ApiServices.Cards.ResponseModels.Card> cards = cardlistrsp.Data;

                    dropdown_testCard.DataSource     = cards;
                    dropdown_testCard.DataTextField  = "Id";
                    dropdown_testCard.DataValueField = "Last4";
                    dropdown_testCard.DataBind();
                }
                else
                {
                    tb_updateRsp.Text = cardlistresponse.Error.Message;
                }
            }
        }
        else
        {
            return;
        }
    }