/// <summary>
        /// Creates a charge with card id.
        /// </summary>
        public HttpResponse <Charge> ChargeWithCardId(CardIdCharge requestModel)
        {
            var request = new RestRequest(Endpoints.CardCharge, Method.POST);

            request.RequestFormat = DataFormat.Json;
            request.AddBody(requestModel);
            return(Execute <Charge>(request));
        }
    protected void but_chargeUsingCardId_Click(object sender, EventArgs e)
    {
        // Create payload
        var cardChargeRequestModel = new CardIdCharge()
        {
            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 = "cust_0CDCC1FC-F947-4698-93AE-0A30F6DDD1EE",


            CardId = dropdown_cardIDs.SelectedItem.Value,

            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 <Charge> apiResponse = ckoAPIClient.ChargeService.ChargeWithCardId(cardChargeRequestModel);

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

                tb_chargeRsp.Text = String.Format("Status: {0}! \nCharge ID: {1} \nCustomerId: {2} \nCard Id: {3} \nLast 4 Card Numbers: {4}",
                                                  charge.Status, charge.Id, charge.Card.CustomerId, charge.Card.Id, charge.Card.Last4);

                label_chargeId.Text = charge.Id;
            }
            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
        }
    }
 /// <summary>
 /// Creates a charge with card id.
 /// </summary>
 public HttpResponse <Charge> ChargeWithCardId(CardIdCharge requestModel)
 {
     return(new ApiHttpClient().PostRequest <Charge>(ApiUrls.CardCharge, AppSettings.SecretKey, requestModel));
 }
Example #4
0
 public Task <HttpResponse <Charge> > ChargeWithCardIdAsync(CardIdCharge requestModel)
 {
     return(_apiHttpClient.PostRequest <Charge>(_configuration.ApiUrls.CardCharge, _configuration.SecretKey, requestModel));
 }
Example #5
0
 public HttpResponse <Charge> ChargeWithCardId(CardIdCharge requestModel)
 {
     return(_chargeServiceAsync.ChargeWithCardIdAsync(requestModel).Result);
 }