public static DefaultCardCharge GetCustomerDefaultCardChargeCreateModel(string customerId) { DefaultCardCharge defaultCardCharge = new DefaultCardCharge { CustomerId = customerId, AutoCapture = "Y", AutoCapTime = 10, Currency = "Usd", TrackId = "TRK12345", TransactionIndicator = "1", CustomerIp = "82.23.168.254", Description = RandomData.String, Value = RandomData.GetNumber(50, 500).ToString(), Descriptor = new BillingDescriptor { Name = "Amigo ltd.", City = "London" }, Products = GetProducts(), ShippingDetails = GetAddress(), Metadata = new Dictionary <string, string>() { { "extraInformation", RandomData.CompanyName } }, Udf1 = RandomData.String, Udf2 = RandomData.String, Udf3 = RandomData.String, Udf4 = RandomData.String, Udf5 = RandomData.String }; return(defaultCardCharge); }
/// <summary> /// Creates a charge with the default card of the customer. /// </summary> public HttpResponse <Charge> ChargeWithDefaultCustomerCard(DefaultCardCharge requestModel) { var request = new RestRequest(Endpoints.DefaultCardCharge, Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(requestModel); return(Execute <Charge>(request)); }
/// <summary> /// Creates a charge with the default card of the customer. /// </summary> public HttpResponse <Charge> ChargeWithDefaultCustomerCard(DefaultCardCharge requestModel) { return(new ApiHttpClient().PostRequest <Charge>(ApiUrls.DefaultCardCharge, AppSettings.SecretKey, requestModel)); }
public Task <HttpResponse <Charge> > ChargeWithDefaultCustomerCardAsync(DefaultCardCharge requestModel) { return(_apiHttpClient.PostRequest <Charge>(_configuration.ApiUrls.DefaultCardCharge, _configuration.SecretKey, requestModel)); }
public HttpResponse <Charge> ChargeWithDefaultCustomerCard(DefaultCardCharge requestModel) { return(_chargeServiceAsync.ChargeWithDefaultCustomerCardAsync(requestModel).Result); }
protected void but_chargeUsingDefaultCard_ID_Click(object sender, EventArgs e) { // Create payload var cardChargeRequestModel = new DefaultCardCharge() { AutoCapture = "N", AutoCapTime = 0, Currency = "Usd", TrackId = "TRK12345", TransactionIndicator = "1", CustomerIp = "82.23.168.254", Description = "Ipad for Ebs travel", Value = "100", //Email = "*****@*****.**", //email address needs to be correct! Else, use customer ID and remove email. CustomerId = dropdown_custId.SelectedValue, Products = new List <Product> { new Product() { Description = "item 1", Name = "item 1", Price = 33.5M, Quantity = 3, ShippingCost = 5.5M, Sku = "sku123" }, new Product() { Description = "item 2", Name = "item 2", Price = 31.5M, Quantity = 3, ShippingCost = 4.5M, Sku = "sku456" } }, Metadata = new Dictionary <string, string>() { { "extraInformation", "EBS travel" } }, Udf1 = "udf1 string", Udf2 = "udf2 string", Udf3 = "udf3 string", Udf4 = "udf4 string", Udf5 = "udf5 string" }; try { // Create APIClient instance with your secret key ckoAPIClient = new APIClient(); // Submit your request and receive an apiResponse HttpResponse <Checkout.ApiServices.Charges.ResponseModels.Charge> apiResponse = ckoAPIClient.ChargeService.ChargeWithDefaultCustomerCard(cardChargeRequestModel); if (!apiResponse.HasError) { // Access the response object retrieved from the api var charge = apiResponse.Model; tb_chargeRsp.Text = String.Format("Status:\n {0}! \n\nCharge ID:\n {1} \n\nCustomerId:\n {2} \n\nCustomer Name:\n {3} \n\nCustomer Email:\n {4} \n\nCard Id:\n {5} \n\nLast 4 Card Numbers:\n {6} \n\nCharge Response:\n {7} \n\nJSON Response: \n {8}", charge.Status, charge.Id, charge.Card.Name, charge.Card.Name, charge.Email, charge.Card.Id, charge.Card.Last4, charge.ResponseMessage, apiResponse.FullJsonResponse); } else { // Api has returned an error object. You can access the details in the error property of the apiResponse. // apiResponse.error tb_chargeRsp.Text = string.Format("Message:/n{0} Error Code:/n{1} ", apiResponse.Error.Message, apiResponse.Error.ErrorCode); } } catch (Exception exc) { //... Handle exception } }