Пример #1
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";
                string       orderID      = "12345";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client         client = new Client(connector);
                ICheckoutOrder order  = client.NewCheckoutOrder(orderID);

                try
                {
                    CheckoutOrderData orderData = order.Fetch();
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Пример #2
0
        public void Client_NewCheckoutOrder()
        {
            ICheckoutOrder checkout = this.client.NewCheckoutOrder();

            Assert.NotNull(checkout);
            Assert.IsNull(checkout.Location);
        }
Пример #3
0
        public void Client_NewCheckoutOrder_Url()
        {
            ICheckoutOrder checkout = this.client.NewCheckoutOrder(this.orderId);

            Assert.NotNull(checkout);
            Assert.NotNull(checkout.Location);
            Assert.AreEqual(((CheckoutOrder)checkout).Path + "/" + this.orderId, checkout.Location.ToString());
        }
Пример #4
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client         client   = new Client(connector);
                ICheckoutOrder checkout = client.NewCheckoutOrder();

                OrderLine orderLine = new OrderLine
                {
                    Type           = OrderLineType.Physical,
                    Reference      = "123050",
                    Name           = "Tomatoes",
                    Quantity       = 10,
                    QuantityUnit   = "kg",
                    UnitPrice      = 600,
                    TaxRate        = 2500,
                    TotalAmount    = 6000,
                    TotalTaxAmount = 1200
                };

                OrderLine orderLine2 = new OrderLine
                {
                    Type                = OrderLineType.Physical,
                    Reference           = "543670",
                    Name                = "Bananas",
                    Quantity            = 1,
                    QuantityUnit        = "bag",
                    UnitPrice           = 5000,
                    TaxRate             = 2500,
                    TotalAmount         = 4000,
                    TotalDiscountAmount = 1000,
                    TotalTaxAmount      = 800
                };

                MerchantUrls merchantUrls = new MerchantUrls
                {
                    Terms        = new Uri("http://www.merchant.com/toc"),
                    Checkout     = new Uri("http://www.merchant.com/checkout?klarna_order_id={checkout.order.id}"),
                    Confirmation = new Uri("http://www.merchant.com/thank-you?klarna_order_id={checkout.order.id}"),
                    Push         = new Uri("http://www.merchant.com/create_order?klarna_order_id={checkout.order.id}")
                };

                CheckoutOrderData orderData = new CheckoutOrderData()
                {
                    PurchaseCountry  = "gb",
                    PurchaseCurrency = "gbp",
                    Locale           = "en-gb",
                    OrderAmount      = 10000,
                    OrderTaxAmount   = 2000,
                    OrderLines       = new List <OrderLine> {
                        orderLine, orderLine2
                    },
                    MerchantUrls = merchantUrls
                };

                try
                {
                    checkout.Create(orderData);
                    orderData = checkout.Fetch();

                    string orderID = orderData.OrderId;
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Пример #5
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";
                string       orderID      = "12345";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client         client   = new Client(connector);
                ICheckoutOrder checkout = client.NewCheckoutOrder(orderID);

                CheckoutOrderData orderData = new CheckoutOrderData();

                orderData.OrderAmount    = 11000;
                orderData.OrderTaxAmount = 2200;

                List <OrderLine> lines = new List <OrderLine>();

                lines.Add(new OrderLine()
                {
                    Type           = OrderLineType.Physical,
                    Reference      = "123050",
                    Name           = "Tomatoes",
                    Quantity       = 10,
                    QuantityUnit   = "kg",
                    UnitPrice      = 600,
                    TaxRate        = 2500,
                    TotalAmount    = 6000,
                    TotalTaxAmount = 1200
                });

                lines.Add(new OrderLine()
                {
                    Type                = OrderLineType.Physical,
                    Reference           = "543670",
                    Name                = "Bananas",
                    Quantity            = 1,
                    QuantityUnit        = "bag",
                    UnitPrice           = 5000,
                    TaxRate             = 2500,
                    TotalAmount         = 4000,
                    TotalDiscountAmount = 1000,
                    TotalTaxAmount      = 800
                });

                lines.Add(new OrderLine()
                {
                    Type           = OrderLineType.ShippingFee,
                    Name           = "Express delivery",
                    Quantity       = 1,
                    UnitPrice      = 1000,
                    TaxRate        = 2500,
                    TotalAmount    = 1000,
                    TotalTaxAmount = 200
                });

                orderData.OrderLines = lines;

                try
                {
                    orderData = checkout.Update(orderData);
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Пример #6
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client         client   = new Client(connector);
                ICheckoutOrder checkout = client.NewCheckoutOrder();

                OrderLine orderLine = new OrderLine
                {
                    Type           = OrderLineType.Physical,
                    Reference      = "123050",
                    Name           = "Tomatoes",
                    Quantity       = 10,
                    QuantityUnit   = "kg",
                    UnitPrice      = 600,
                    TaxRate        = 2500,
                    TotalAmount    = 6000,
                    TotalTaxAmount = 1200
                };

                OrderLine orderLine2 = new OrderLine
                {
                    Type                = OrderLineType.Physical,
                    Reference           = "543670",
                    Name                = "Bananas",
                    Quantity            = 1,
                    QuantityUnit        = "bag",
                    UnitPrice           = 5000,
                    TaxRate             = 2500,
                    TotalAmount         = 4000,
                    TotalDiscountAmount = 1000,
                    TotalTaxAmount      = 800
                };

                MerchantUrls merchantUrls = new MerchantUrls
                {
                    Terms        = new Uri("http://www.merchant.com/toc"),
                    Checkout     = new Uri("http://www.merchant.com/checkout?klarna_order_id={checkout.order.id}"),
                    Confirmation = new Uri("http://www.merchant.com/thank-you?klarna_order_id={checkout.order.id}"),
                    Push         = new Uri("http://www.merchant.com/create_order?klarna_order_id={checkout.order.id}")
                };

                List <PaymentHistoryFull> purchaseHistoryFull = new List <PaymentHistoryFull>
                {
                    new PaymentHistoryFull
                    {
                        UniqueAccountIdentifier  = "Test Testperson",
                        PaymentOption            = "card",
                        NumberPaidPurchases      = 1,
                        TotalAmountPaidPurchases = 10000,
                        DateOfLastPaidPurchase   = DateTime.Now,
                        DateOfFirstPaidPurchase  = DateTime.Now
                    }
                };

                ExtraMerchantData extraMerchantData = new ExtraMerchantData
                {
                    Body = new ExtraMerchantDataBody
                    {
                        PaymentHistoryFull = purchaseHistoryFull
                    }
                };

                CheckoutOrderData orderData = new CheckoutOrderData()
                {
                    PurchaseCountry  = "gb",
                    PurchaseCurrency = "gbp",
                    Locale           = "en-gb",
                    OrderAmount      = 10000,
                    OrderTaxAmount   = 2000,
                    OrderLines       = new List <OrderLine> {
                        orderLine, orderLine2
                    },
                    MerchantUrls = merchantUrls,
                    Attachment   = extraMerchantData
                };

                try
                {
                    checkout.Create(orderData);
                    orderData = checkout.Fetch();

                    string            orderID = orderData.OrderId;
                    ExtraMerchantData emd     = orderData.Attachment;
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Пример #7
0
 public LoggingCheckoutOrder(ICheckoutOrder inner)
 {
     _inner = inner ?? throw new ArgumentNullException(nameof(inner));
 }