protected void but_getCardList_Click(object sender, EventArgs e) { // Create APIClient instance with your secret key ckoAPIClient = new APIClient(); #region Retrieves card ID dropdown list Checkout.ApiServices.Cards.ResponseModels.CardList cardlist = new Checkout.ApiServices.Cards.ResponseModels.CardList(); string custId = dropdown_custId.SelectedValue; HttpResponse <Checkout.ApiServices.Cards.ResponseModels.CardList> cardlistresponse = ckoAPIClient.CardService.GetCardList(custId); string cardlisttext = ""; if (!cardlistresponse.HasError) { // Access the response object retrieved from the api var cardlistrsp = cardlistresponse.Model; List <Checkout.ApiServices.Cards.ResponseModels.Card> cards = cardlistrsp.Data; foreach (Checkout.ApiServices.Cards.ResponseModels.Card c in cards) { cardlisttext += string.Format("Payment Method: {0} | Last 4: {1} | Card ID: {2} | Customer ID: {3}\n\n", c.PaymentMethod, c.Last4, c.Id, c.CustomerId); } tb_chargeRsp.Text = cardlisttext; } else { tb_chargeRsp.Text = cardlistresponse.Error.Message; } #endregion }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { return; } // Create APIClient instance with your secret key ckoAPIClient = new APIClient(); #region Populates card ID dropdown list Checkout.ApiServices.Cards.ResponseModels.CardList cardlist = new Checkout.ApiServices.Cards.ResponseModels.CardList(); string custId = tb_custId.Text; 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_cardIDs.DataTextField = "Id"; dropdown_cardIDs.DataValueField = "Id"; dropdown_cardIDs.DataSource = cards; dropdown_cardIDs.DataBind(); dropdown_cardIDs.Items.Insert(0, new ListItem(" Select one", "0")); } else { tb_custId.Text = cardlistresponse.Error.Message; } #endregion }
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; } }