예제 #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.");
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start Konduto SDK");
            Konduto      konduto = new Konduto("T1234567890ABCDEFGHIJ");
            KondutoOrder order   = new KondutoOrder
            {
                Id             = "orderID",
                Visitor        = "",
                TotalAmount    = 123.4,
                ShippingAmount = 12.23,
                TaxAmount      = 1.23,
                Currency       = "BRL",
                Installments   = 3,
                Ip             = "192.0.0.1",
                Analyze        = true,
                Customer       = new KondutoCustomer
                {
                    Id     = "DotnetCustomer",
                    Name   = "Bill Gates",
                    Email  = "*****@*****.**",
                    TaxId  = "12345678990",
                    Phone1 = "(11)912345678",
                    Phone2 = "(12)998765432",
                    IsNew  = true,
                    IsVip  = true
                },
                Payments = new List <KondutoPayment> {
                    new KondutoCreditCardPayment {
                        Status         = KondutoCreditCardPaymentStatus.approved,
                        Bin            = "123445",
                        Last4          = "1234",
                        ExpirationDate = "022020"
                    }
                }
            };

            if (!order.IsValid())
            {
                Console.WriteLine(order.GetError());
            }
            try
            {
                konduto.Analyze(order);

                Console.WriteLine("Order Recommendation: " + order.Recommendation);
                Console.WriteLine("Order Score: " + order.Score);

                if (order.TriggeredRules != null && order.TriggeredRules.Count > 0)
                {
                    Console.WriteLine("Triggered Rules:");
                    foreach (KondutoTriggeredRules TriggeredRule in order.TriggeredRules)
                    {
                        Console.WriteLine(" " + TriggeredRule.Name);
                    }
                }
                else
                {
                    Console.WriteLine("Order has no triggered rules");
                }

                if (order.TriggeredDecisionList != null && order.TriggeredDecisionList.Count > 0)
                {
                    Console.WriteLine("Triggered DecisionList:");
                    foreach (KondutoTriggeredDecisionList TriggeredDecisionList in order.TriggeredDecisionList)
                    {
                        Console.WriteLine(" " + TriggeredDecisionList.Type + " Decision:" + TriggeredDecisionList.Decision);
                    }
                }
                else
                {
                    Console.WriteLine("Order has no triggered decision list");
                }

                if (order.BureauxQueries != null && order.BureauxQueries.Count > 0)
                {
                    Console.WriteLine("Bureaux Queries:");
                    foreach (KondutoBureauxQueries BureauxQuery in order.BureauxQueries)
                    {
                        Console.WriteLine(" " + BureauxQuery.Service + " response:" + BureauxQuery.Response);
                    }
                }
                else
                {
                    Console.WriteLine("Order has no bureaux queries");
                }

                Console.WriteLine("Order JSON: " + JsonConvert.SerializeObject(order));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            _ = Console.Read();
        }
예제 #3
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.");
            }
        }
예제 #4
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.");
            }
        }