예제 #1
0
        public void Oxxo()
        {
            conekta.Api.locale  = "es";
            conekta.Api.apiKey  = "key_eYvWV7gSDkNYXsmr";
            conekta.Api.version = "1.0.0";

            conekta.Charge charge = new conekta.Charge().create(@"{
                    ""description"":""Stogies"",
                    ""amount"": 20000,
                    ""currency"":""MXN"",
                    ""reference_id"":""9839-wolf_pack"",
                    ""cash"": {
                      ""type"": ""oxxo"",
                      ""expires_at"": 1476057600
                    },
                    ""details"": {
                      ""name"": ""Arnulfo Quimare"",
                      ""phone"": ""403-342-0642"",
                      ""email"": ""*****@*****.**"",
                      ""customer"": {
                        ""logged_in"": true,
                        ""successful_purchases"": 14,
                        ""created_at"": 1379784950,
                        ""updated_at"": 1379784950,
                        ""offline_payments"": 4,
                        ""score"": 9
                      },
                      ""line_items"": [{
                        ""name"": ""Box of Cohiba S1s"",
                        ""description"": ""Imported From Mex."",
                        ""unit_price"": 20000,
                        ""quantity"": 1,
                        ""sku"": ""cohb_s1"",
                        ""category"": ""food""
                      }],
                      ""billing_address"": {
                        ""street1"":""77 Mystery Lane"",
                        ""street2"": ""Suite 124"",
                        ""street3"": null,
                        ""city"": ""Darlington"",
                        ""state"":""NJ"",
                        ""zip"": ""10192"",
                        ""country"": ""Mexico"",
                        ""tax_id"": ""xmn671212drx"",
                        ""company_name"":""X-Men Inc."",
                        ""phone"": ""77-777-7777"",
                        ""email"": ""*****@*****.**""
                      }
                    }
                  }");

            Assert.AreEqual(charge.payment_method.type, "oxxo");
            Assert.AreEqual(charge.payment_method.barcode.GetType().ToString(), "System.String");
            Assert.AreEqual(charge.id.GetType().ToString(), "System.String");
        }
        private String CreateCharge(string token)
        {
            try {
                HelloConektaCard.Charge charge_params = new HelloConektaCard.Charge();

                charge_params.description   = "Stogies";
                charge_params.amount        = 2000;             //Prices in cents
                charge_params.currency      = "MXN";
                charge_params.reference_id  = "9839-wolf_pack"; //This reference can be your order_id
                charge_params.card          = token;
                charge_params.details.name  = "Arnulfo Quimare";
                charge_params.details.phone = "403-342-0642";
                charge_params.details.email = "*****@*****.**";
                charge_params.details.line_items[0].name           = "Box of Cohiba S1s";
                charge_params.details.line_items[0].description    = "Imported From Mex.";
                charge_params.details.line_items[0].quantity       = 1;
                charge_params.details.line_items[0].unit_price     = 2000;
                charge_params.details.line_items[0].category       = "food";
                charge_params.details.billing_address.street1      = "77 Mystery Lane";
                charge_params.details.billing_address.street2      = "Suite 124";
                charge_params.details.billing_address.city         = "Darlington";
                charge_params.details.billing_address.state        = "NJ";
                charge_params.details.billing_address.zip          = "10192";
                charge_params.details.billing_address.country      = "Mexico";
                charge_params.details.billing_address.tax_id       = "xmn671212drx";
                charge_params.details.billing_address.company_name = "X-Men Inc.";
                charge_params.details.billing_address.phone        = "77-777-7777";
                charge_params.details.billing_address.email        = "*****@*****.**";
                charge_params.shipment.carrier     = "estafeta";
                charge_params.shipment.service     = "international";
                charge_params.shipment.price       = 20000;
                charge_params.shipment.tracking_id = "XXYYZZ-9990000";
                charge_params.shipment.street1     = "250 Alexis St";
                charge_params.shipment.street2     = "Interior 303";
                charge_params.shipment.street3     = "Col. Condesa";
                charge_params.shipment.city        = "Red Deer";
                charge_params.shipment.state       = "Alberta";
                charge_params.shipment.zip         = "T4N 0B8";
                charge_params.shipment.country     = "Canada";

                conekta.Charge charge = new conekta.Charge().create(charge_params.ToString());

                return(charge.id.ToString());
            }
            catch (Exception ex) {
                return(ex.Message.ToString());
            }
        }