Exemplo n.º 1
0
        public void PostFlightIntegrationTest()
        {
            Konduto konduto = new Konduto("T738D516F09CAB3A2C1EE");

            KondutoCustomer Customer = new KondutoCustomer
            {
                Id    = "28372",
                Name  = "KdtUser",
                Email = "*****@*****.**"
            };

            KondutoOrder order = new KondutoOrder
            {
                Id          = ((Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds).ToString(),
                Visitor     = "38a9412f0b01b4dd1762ae424169a3e490d75c7a",
                TotalAmount = 100.00,
                Customer    = Customer,
                Travel      = KondutoFlightFactory.CreateFlight(),
                Analyze     = true
            };

            try
            {
                konduto.Analyze(order);
                Assert.IsTrue(order.Recommendation != KondutoRecommendation.none);
            }
            catch (KondutoException ex)
            {
                Assert.Fail("Konduto exception shouldn't happen here.");
            }
        }
        public void InvalidEntityExceptionMessageTest()
        {
            KondutoCustomer customer = new KondutoCustomer();

            customer.IsValid(); // triggers errors
            KondutoInvalidEntityException exception = new KondutoInvalidEntityException(customer);

            Assert.AreEqual(String.Format("{0} is invalid: {1}", customer.ToString(), customer.GetError()),
                            exception.Message, "incorrect expected exception message");
        }
Exemplo n.º 3
0
        public void SerializationTest()
        {
            KondutoCustomer customer     = KondutoCustomerFactory.CompleteCustomer();
            String          customerJSON = KondutoUtils.LoadJson <KondutoCustomer>(Properties.Resources.customer).ToJson();

            try
            {
                var v = customer.ToJson();
                Assert.AreEqual(customerJSON, customer.ToJson(), "serialization failed");
            }
            catch (KondutoInvalidEntityException e) {
                Debug.WriteLine(e.Message);
            }

            KondutoCustomer deserializedCustomer = KondutoModel.FromJson <KondutoCustomer>(customerJSON);

            Assert.AreEqual(customer, deserializedCustomer, "deserialization failed");
        }
Exemplo n.º 4
0
        public void PutIntegrationTest()
        {
            String id = ((Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds).ToString();

            Konduto konduto = new Konduto("T738D516F09CAB3A2C1EE");

            KondutoCustomer Customer = new KondutoCustomer
            {
                Id    = "28372",
                Name  = "KdtUser",
                Email = "*****@*****.**"
            };

            KondutoOrder order = new KondutoOrder
            {
                Id          = id,
                Visitor     = "38a9412f0b01b4dd1762ae424169a3e490d75c7a",
                TotalAmount = 100.00,
                Customer    = Customer,
                Analyze     = true
            };

            try
            {
                konduto.Analyze(order);
                Assert.IsTrue(order.Recommendation != KondutoRecommendation.none);
            }
            catch (KondutoException ex)
            {
                Assert.Fail("Konduto exception shouldn't happen here.");
            }

            try
            {
                konduto.UpdateOrderStatus(id, KondutoOrderStatus.fraud, "Manual Review");
            }
            catch (KondutoException ex)
            {
                Assert.Fail("Konduto exception shouldn't happen here.");
            }

            try
            {
                konduto.UpdateOrderStatus(id, KondutoOrderStatus.not_authorized, "Manual Review");
            }
            catch (KondutoException ex)
            {
                Assert.Fail("Konduto exception shouldn't happen here.");
            }
            catch (Exception e)
            {
                Assert.Fail("Exception: " + e.ToString());
            }

            try
            {
                KondutoOrder updatedOrder = konduto.GetOrder(id);
            }
            catch (KondutoException ex)
            {
                Assert.Fail("Konduto exception shouldn't happen here.");
            }
        }
Exemplo n.º 5
0
        public void FullJsonIntegrationTest()
        {
            Konduto konduto = new Konduto("T738D516F09CAB3A2C1EE");

            KondutoCustomer Customer = new KondutoCustomer
            {
                Id        = "28372",
                Name      = "KdtUser",
                Email     = "*****@*****.**",
                TaxId     = "613.815.776-10",
                Phone1    = "+559912345678",
                Phone2    = "(11)1234-5678",
                IsNew     = false,
                IsVip     = false,
                CreatedAt = "2014-12-21"
            };

            KondutoPayment payment = new KondutoCreditCardPayment
            {
                Type           = KondutoPaymentType.credit,
                Status         = KondutoCreditCardPaymentStatus.approved,
                Bin            = "490172",
                Last4          = "0012",
                ExpirationDate = "052026"
            };

            KondutoAddress billing = new KondutoAddress
            {
                Name     = "Mark Thompson",
                Address1 = "101 Maple Road",
                Address2 = "Apto 33",
                City     = "Mato Grosso",
                State    = "Cuiabá",
                Zip      = "302798",
                Country  = "BR"
            };

            KondutoAddress shipping = new KondutoAddress
            {
                Name     = "Mark Thompson",
                Address1 = "101 Maple Road",
                Address2 = "Apto 33",
                City     = "Mato Grosso",
                State    = "Cuiabá",
                Zip      = "302798",
                Country  = "BR"
            };

            List <KondutoPayment> payments = new List <KondutoPayment> {
                payment
            };

            KondutoItem item1 = new KondutoItem
            {
                Sku         = "9919023",
                ProductCode = "123456789999",
                Category    = 100,
                Name        = "Xbox One",
                Description = "Xbox One Promoção Com 2 Controles",
                UnitCost    = 1999.99,
                Quantity    = 1,
                CreatedAt   = "2014-12-21"
            };

            KondutoItem item2 = new KondutoItem
            {
                Sku         = "0017273",
                Category    = 201,
                Name        = "CD Nirvana Nevermind",
                Description = "CD Nirvana Nevermind",
                UnitCost    = 29.90,
                Quantity    = 2,
                Discount    = 5.00
            };

            KondutoSeller seller = new KondutoSeller
            {
                Id        = "seller",
                Name      = "SampleSeller",
                CreatedAt = "2017-01-01"
            };

            KondutoOrder order = new KondutoOrder
            {
                Id                = ((Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds).ToString(),
                Visitor           = "38a9412f0b01b4dd1762ae424169a3e490d75c7a",
                TotalAmount       = 100.00,
                ShippingAmount    = 6.00,
                TaxAmount         = 12.00,
                Ip                = "201.27.127.73",
                Currency          = "BRL",
                Customer          = Customer,
                Payments          = payments,
                BillingAddress    = billing,
                ShippingAddress   = shipping,
                MessagesExchanged = 2,
                PurchasedAt       = "2014-12-31T13:00:00Z",
                FirstMessage      = "2014-12-31T13:00:00Z",
                Seller            = seller,
                ShoppingCart      = new List <KondutoItem> {
                    item1,
                    item2
                },
                Analyze = true
            };

            try
            {
                konduto.Analyze(order);
                Assert.IsTrue(order.Recommendation != KondutoRecommendation.none);
            }
            catch (KondutoException ex)
            {
                Assert.Fail("Konduto exception shouldn't happen here.");
            }

            try
            {
                KondutoOrder getOrder = konduto.GetOrder(order.Id);
                Assert.IsNotNull(getOrder);
            }
            catch (KondutoException ex)
            {
                Assert.Fail("Konduto exception shouldn't happen here.");
            }
        }