コード例 #1
0
ファイル: KondutoTest.cs プロジェクト: wmaschette/dotnet-sdk
        public void GetOrderSuccessfullyTest()
        {
            Konduto kdt = new Konduto(API_KEY);

            var fakeResponseHandler = new FakeResponseHandler();
            var message             = new HttpResponseMessage(HttpStatusCode.OK);

            message.Content = new StringContent(ANALYZE_ORDER_RESPONSE.ToString());

            var c = kdt.KondutoGetOrderUrl(ORDER_ID);

            fakeResponseHandler.AddFakeResponse(kdt.KondutoGetOrderUrl(ORDER_ID), message);
            kdt.__MessageHandler = fakeResponseHandler;

            var v = kdt.GetOrder(ORDER_ID);

            Assert.IsTrue(ORDER_FROM_FILE.Equals(kdt.GetOrder(ORDER_ID)));
        }
コード例 #2
0
ファイル: KondutoTest.cs プロジェクト: wmaschette/dotnet-sdk
        public void GetFlightIntegrationTest()
        {
            Konduto konduto = new Konduto("T738D516F09CAB3A2C1EE");

            try
            {
                KondutoOrder order = konduto.GetOrder("1529744771");
            }
            catch (KondutoException ex)
            {
                Assert.Fail("Konduto exception shouldn't happen here.");
            }
        }
コード例 #3
0
ファイル: KondutoTest.cs プロジェクト: helderhp/dotnet-sdk
        public void GetIntegrationTest()
        {
            //Konduto konduto = new Konduto("T738D516F09CAB3A2C1EE");
            Konduto konduto = new Konduto(API_KEY);

            try
            {
                //KondutoOrder order = konduto.GetOrder("1429744771");
                KondutoOrder order = konduto.GetOrder(ORDER_ID);
            }
            catch (KondutoException ex)
            {
                Assert.Fail("Konduto exception shouldn't happen here.");
            }
        }
コード例 #4
0
ファイル: KondutoTest.cs プロジェクト: wmaschette/dotnet-sdk
        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.");
            }
        }
コード例 #5
0
ファイル: KondutoTest.cs プロジェクト: wmaschette/dotnet-sdk
        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.");
            }
        }