Esempio n. 1
0
        public void deleteCustomer()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""+5215544443333"",
                  ""email"": ""*****@*****.**"",
                  ""plan_id"": ""gold-plan"",
                  ""corporate"": true,
                  ""payment_sources"": [{
                  ""token_id"": ""tok_test_visa_4242"",
                  ""type"": ""card""
                  }]
                  }");

            Assert.AreEqual(customer.corporate, true);

            customer = new Customer().find(customer.id);

            Assert.AreEqual(customer.corporate, true);

            customer = customer.destroy();

            Assert.AreEqual(customer.corporate, true);
        }
Esempio n. 2
0
        public void statesSubscription()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""+5215544443333"",
                  ""email"": ""*****@*****.**"",
                  ""corporate"": true,
                  ""payment_sources"": [{
                  ""token_id"": ""tok_test_visa_4242"",
                  ""type"": ""card""
                  }]
                  }");

            Subscription subscription = customer.createSubscription(@"{
                ""plan"": ""gold-plan""
                }");

            Assert.AreEqual(subscription.status, "in_trial");

            subscription = subscription.pause();

            Assert.AreEqual(subscription.status, "paused");

            subscription = subscription.resume();

            Assert.AreEqual(subscription.status, "in_trial");

            subscription = subscription.cancel();

            Assert.AreEqual(subscription.status, "canceled");
        }
Esempio n. 3
0
        public void createCustomerWithOfflineRecurrentReference()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""+5215544443333"",
                  ""email"": ""*****@*****.**"",
                  ""corporate"": true,
                  ""payment_sources"": [{
                    ""expires_at"": 1553273553,
                    ""type"": ""oxxo_recurrent""
                  }]
                  }");

            PaymentSource             paymentSource = customer.payment_sources[0];
            OfflineRecurrentReference reference     = paymentSource as OfflineRecurrentReference;

            Assert.IsNotNull(reference.reference);
            Assert.IsNotNull(reference.barcode);
            Assert.IsNotNull(reference.barcode_url);
            Assert.IsNotNull(reference.provider);
            Assert.AreEqual(reference.expires_at, "1553273553");
        }
Esempio n. 4
0
        public void updateShippingContact()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""5575553322"",
                  ""email"": ""*****@*****.**"",
                  ""corporate"": true
                  }");

            ShippingContact shipping_contact = customer.createShippingContact(@"{
                ""phone"": ""5575553322"",
                ""receiver"": ""Marvin Fuller"",
                ""between_streets"": ""Ackerman Crescent"",
                ""address"": {
                ""street1"": ""250 Alexis St"",
                ""street2"": ""fake street"",
                ""city"": ""Red Deer"",
                ""state"": ""Alberta"",
                ""country"": ""CA"",
                ""postal_code"": ""T4N 0B8"",
                ""residential"": true
                }
                }");

            shipping_contact = shipping_contact.update(@"{
                ""phone"": ""5575553324""
                }");

            Assert.AreEqual(shipping_contact.phone, "5575553324");
        }
Esempio n. 5
0
        public void updateCustomer()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""5575553322"",
                  ""email"": ""*****@*****.**"",
                  ""corporate"": true
                  }");

            Assert.AreEqual(customer.corporate, true);
            Assert.AreEqual(customer.name, "Emiliano Cabrera");

            customer = new Customer().find(customer.id);

            Assert.AreEqual(customer.corporate, true);
            Assert.AreEqual(customer.name, "Emiliano Cabrera");

            customer = customer.update(@"{
                ""corporate"": false,
                ""name"": ""Juan Perez""
                }");

            Assert.AreEqual(customer.name, "Juan Perez");
            Assert.AreEqual(customer.corporate, false);
        }
Esempio n. 6
0
        public void deletePaymentSource()
        {
            conekta.Api.apiKey  = "key_eYvWV7gSDkNYXsmr";
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
			    ""name"": ""Emiliano Cabrera"",
			    ""phone"": ""+5215544443333"",
			    ""email"": ""*****@*****.**""
			}"            );

            PaymentSource payment_source = customer.createPaymentSource(@"{
			    ""token_id"": ""tok_test_visa_4242"",
			    ""type"": ""card""
			}"            );

            payment_source = payment_source.update(@"{
				""name"": ""Emiliano Suarez""
			}"            );

            Assert.AreEqual(payment_source.name, "Emiliano Suarez");

            payment_source = payment_source.destroy();

            Assert.AreEqual(payment_source.name, "Emiliano Suarez");
        }
Esempio n. 7
0
        public void updateSubscription()
        {
            conekta.Api.apiKey  = "key_eYvWV7gSDkNYXsmr";
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
			    ""name"": ""Emiliano Cabrera"",
			    ""phone"": ""+5215544443333"",
			    ""email"": ""*****@*****.**"",
			    ""corporate"": true,
			    ""payment_sources"": [{
					""token_id"": ""tok_test_visa_4242"",
			        ""type"": ""card""
				}]
			}"            );

            Subscription subscription = customer.createSubscription(@"{
			    ""plan"": ""jul-plan""
			}"            );

            Assert.AreEqual(subscription.plan_id, "jul-plan");

            subscription = subscription.update(@"{
				""plan"": ""opal-plan""
			}"            );

            Assert.AreEqual(subscription.plan_id, "opal-plan");
        }
Esempio n. 8
0
        public void createShippingContact()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""+5215544443333"",
                  ""email"": ""*****@*****.**"",
                  ""plan_id"": ""gold-plan"",
                  ""corporate"": true,
                  ""payment_sources"": [{
                  ""token_id"": ""tok_test_visa_4242"",
                  ""type"": ""card""
                  }],
                  ""shipping_contacts"": [{
                  ""email"": ""*****@*****.**"",
                  ""phone"": ""+5215555555555"",
                  ""receiver"": ""Marvin Fuller"",
                  ""between_streets"": ""Ackerman Crescent"",
                  ""address"": {
                  ""street1"": ""250 Alexis St"",
                  ""street2"": ""fake street"",
                  ""city"": ""Red Deer"",
                  ""state"": ""Alberta"",
                  ""country"": ""CA"",
                  ""postal_code"": ""T4N 0B8"",
                  ""residential"": true
                  }
                  }],
                  ""account_age"": 300,
                  ""paid_transactions"": 5
            }");

            ShippingContact shipping_contact = customer.createShippingContact(@"{
                ""phone"": ""+5215555555555"",
                ""receiver"": ""Marvin Fuller"",
                ""between_streets"": ""Ackerman Crescent"",
                ""address"": {
                ""street1"": ""250 Alexis St"",
                ""street2"": ""fake street"",
                ""city"": ""Red Deer"",
                ""state"": ""Alberta"",
                ""country"": ""CA"",
                ""postal_code"": ""T4N 0B8"",
                ""residential"": true
                }
                }");

            Assert.AreEqual(shipping_contact.phone, "+5215555555555");
        }
Esempio n. 9
0
        public void createCustomer()
        {
            conekta.Api.apiKey  = "key_eYvWV7gSDkNYXsmr";
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
			    ""name"": ""Emiliano Cabrera"",
			    ""phone"": ""+5215544443333"",
			    ""email"": ""*****@*****.**"",
			    ""plan_id"": ""gold-plan"",
			    ""corporate"": true,
			    ""payment_sources"": [{
			        ""token_id"": ""tok_test_visa_4242"",
			        ""type"": ""card""
			    }],
			    ""shipping_contacts"": [{
			        ""phone"": ""+5215555555555"",
			        ""receiver"": ""Marvin Fuller"",
			        ""between_streets"": ""Ackerman Crescent"",
			        ""address"": {
			            ""street1"": ""250 Alexis St"",
			            ""street2"": ""fake street"",
			            ""city"": ""Red Deer"",
			            ""state"": ""Alberta"",
			            ""country"": ""CA"",
			            ""postal_code"": ""T4N 0B8"",
			            ""residential"": true
			        }

			    }],
				""antifraud_info"": {
				    ""account_age"": 300,
				    ""paid_transactions"": 5
				}
			}"            );

            Assert.AreEqual(customer.corporate, true);

            customer = new Customer().find(customer.id);

            Assert.AreEqual(customer.corporate, true);
        }
Esempio n. 10
0
        public void createCard()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""+5215544443333"",
                  ""email"": ""*****@*****.**"",
                  ""corporate"": true,
                  ""payment_sources"": []
                  }");

            Card card = (Card)customer.CreateCard(@"{
                ""token_id"": ""tok_test_visa_4242"",
                ""type"": ""card""
                }");

            Assert.AreEqual(card.type, "card");
            Assert.AreEqual(card.name, "Jorge Lopez");
        }
Esempio n. 11
0
        public void createPaymentSource()
        {
            conekta.Api.apiKey  = "key_eYvWV7gSDkNYXsmr";
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
			    ""name"": ""Emiliano Cabrera"",
			    ""phone"": ""+5215544443333"",
			    ""email"": ""*****@*****.**"",
			    ""corporate"": true,
			    ""payment_sources"": []
			}"            );

            PaymentSource payment_source = customer.createPaymentSource(@"{
			    ""token_id"": ""tok_test_visa_4242"",
			    ""type"": ""card""
			}"            );

            Assert.AreEqual(payment_source.type, "card");
            Assert.AreEqual(payment_source.name, "Jorge Lopez");
        }
Esempio n. 12
0
        public void createCustomerWithCard()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""+5215544443333"",
                  ""email"": ""*****@*****.**"",
                  ""plan_id"": ""gold-plan"",
                  ""corporate"": true,
                  ""payment_sources"": [{
                      ""token_id"": ""tok_test_visa_4242"",
                      ""type"": ""card""
                  }]
                  }");

            PaymentSource paymentSource = customer.payment_sources[0];

            Card card = paymentSource as Card;

            Assert.AreEqual(customer.corporate, true);
        }
Esempio n. 13
0
        public void updatePaymentSource()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""+5215544443333"",
                  ""email"": ""*****@*****.**"",
                  ""corporate"": true
                  }");

            Card payment_source = (Card)customer.CreateCard(@"{
                ""token_id"": ""tok_test_visa_4242"",
                ""type"": ""card""
                }");

            Card updatedPaymentSource = payment_source.Update(@"{
                ""name"": ""Emiliano Suarez""
                }");

            Assert.AreEqual(updatedPaymentSource.name, "Emiliano Suarez");
        }
Esempio n. 14
0
        public void deletePaymentSource()
        {
            getApiKey();
            conekta.Api.version = "2.0.0";

            Customer customer = new conekta.Customer().create(@"{
                  ""name"": ""Emiliano Cabrera"",
                  ""phone"": ""+5215544443333"",
                  ""email"": ""*****@*****.**""
                  }");

            PaymentSource payment_source = customer.CreateCard(@"{
                ""token_id"": ""tok_test_visa_4242"",
                ""type"": ""card""
                }");

            payment_source.destroy();

            Customer customerReloaded = new Customer().find(customer.id);



            Assert.AreEqual(customerReloaded.payment_sources, null);
        }