public void Orders_CreatePayAfterDeliveryOrder()
        {
            // Arrange
            var url     = Settings.MultiSafePayUrl;
            var apiKey  = Settings.ApiKey;
            var client  = new MultiSafepayClient(apiKey, url);
            var orderId = Guid.NewGuid().ToString();

            var orderRequest = OrderRequest.CreateDirectPayAfterDeliveryOrder(orderId, "product description", 24200, "EUR",
                                                                              new PaymentOptions("http://example.com/notify", "http://example.com/success", "http://example.com/failed"),
                                                                              GatewayInfo.PayAfterDelivery(new DateTime(1986, 08, 31), "NL39 RABO 0300 0652 64", "+31 (0)20 8500 500", "*****@*****.**", "referrer", "useragent"),
                                                                              new ShoppingCart
            {
                Items = new[]
                {
                    new ShoppingCartItem("Test Product", 200.0, 1, "EUR")
                }
            },
                                                                              new CheckoutOptions()
            {
                TaxTables = new TaxTables()
                {
                    DefaultTaxTable = new TaxTable()
                    {
                        Name  = "Default",
                        Rules = new [] { new TaxRateRule()
                                         {
                                             Rate = 0.21
                                         } },
                        ShippingTaxed = false
                    }
                }
            },
                                                                              new Customer()
            {
                FirstName   = "John",
                LastName    = "Doe",
                HouseNumber = "39",
                Address1    = "Kraanspoor",
                City        = "Amsterdam",
                Country     = "NL",
                PostCode    = "1033SC"
            }
                                                                              );

            // Act
            var result = client.CreateOrder(orderRequest);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(orderRequest.OrderId, result.OrderId);
            Assert.IsTrue(result.PaymentUrl.StartsWith("http://example.com/success?transactionid=")); // redirect to success URL
        }
Example #2
0
        public void Order_CreateDirectPayAfterDelivery_SetsRequiredProperties()
        {
            // Act
            var order = OrderRequest.CreateDirectPayAfterDeliveryOrder("orderid", "description", 1000, "EUR",
                                                                       new PaymentOptions("notificationUrl", "successRedirectUrl", "cancelRedirectUrl"),
                                                                       GatewayInfo.PayAfterDelivery(new DateTime(1986, 08, 31), "NL39 RABO 0300 0652 64", "+31 (0)20 8500 500", "*****@*****.**", "referrer", "useragent"),
                                                                       new ShoppingCart
            {
                Items = new[]
                {
                    new ShoppingCartItem("Test Product", 10, 2, "EUR"),
                }
            },
                                                                       new CheckoutOptions()
            {
                TaxTables = new TaxTables()
                {
                    DefaultTaxTable = new TaxTable()
                    {
                        Name  = "Default",
                        Rules = new[] { new TaxRateRule()
                                        {
                                            Rate = 0.21
                                        } },
                        ShippingTaxed = false
                    }
                }
            },
                                                                       new Customer
            {
                FirstName   = "John",
                LastName    = "Doe",
                HouseNumber = "39",
                Address1    = "Kraanspoor",
                City        = "Amsterdam",
                Country     = "NL",
                PostCode    = "1033SC"
            }
                                                                       );

            // Assert
            Assert.IsNotNull(order.Type);
            Assert.IsNotNull(order.GatewayId);
            Assert.IsNotNull(order.OrderId);
            Assert.IsNotNull(order.CurrencyCode);
            Assert.IsNotNull(order.AmountInCents);
            Assert.IsNotNull(order.Description);
            Assert.IsNotNull(order.GatewayInfo);
            Assert.IsNotNull(order.GatewayInfo.Birthday);
            Assert.IsNotNull(order.GatewayInfo.BankAccount);
            Assert.IsNotNull(order.GatewayInfo.Phone);
            Assert.IsNotNull(order.GatewayInfo.Email);
            Assert.IsNotNull(order.GatewayInfo.Referrer);
            Assert.IsNotNull(order.GatewayInfo.UserAgent);
            Assert.IsNotNull(order.PaymentOptions);
            Assert.IsNotNull(order.PaymentOptions.NotificationUrl);
            Assert.IsNotNull(order.PaymentOptions.SuccessRedirectUrl);
            Assert.IsNotNull(order.PaymentOptions.CancelRedirectUrl);
            Assert.IsNotNull(order.ShoppingCart);
            Assert.IsNotNull(order.ShoppingCart.Items);
            Assert.IsNotNull(order.ShoppingCart.Items[0]);
            Assert.IsNotNull(order.ShoppingCart.Items[0].Name);
            Assert.IsNotNull(order.ShoppingCart.Items[0].UnitPrice);
            Assert.IsNotNull(order.ShoppingCart.Items[0].Quantity);
            Assert.IsNotNull(order.CheckoutOptions.TaxTables.DefaultTaxTable);
            Assert.IsNotNull(order.Customer);
            Assert.IsNotNull(order.Customer.FirstName);
            Assert.IsNotNull(order.Customer.LastName);
            Assert.IsNotNull(order.Customer.Address1);
            Assert.IsNotNull(order.Customer.HouseNumber);
            Assert.IsNotNull(order.Customer.City);
            Assert.IsNotNull(order.Customer.Country);


            Assert.AreEqual(OrderType.Direct, order.Type);
            Assert.AreEqual("PAYAFTER", order.GatewayId);
            Assert.AreEqual("orderid", order.OrderId);
            Assert.AreEqual("EUR", order.CurrencyCode);
            Assert.AreEqual(1000, order.AmountInCents);
            Assert.AreEqual("description", order.Description);
            Assert.AreEqual(new DateTime(1986, 8, 31), order.GatewayInfo.Birthday);
            Assert.AreEqual("NL39 RABO 0300 0652 64", order.GatewayInfo.BankAccount);
            Assert.AreEqual("+31 (0)20 8500 500", order.GatewayInfo.Phone);
            Assert.AreEqual("*****@*****.**", order.GatewayInfo.Email);
            Assert.AreEqual("referrer", order.GatewayInfo.Referrer);
            Assert.AreEqual("useragent", order.GatewayInfo.UserAgent);
            Assert.AreEqual("notificationUrl", order.PaymentOptions.NotificationUrl);
            Assert.AreEqual("successRedirectUrl", order.PaymentOptions.SuccessRedirectUrl);
            Assert.AreEqual("cancelRedirectUrl", order.PaymentOptions.CancelRedirectUrl);
            Assert.AreEqual("Test Product", order.ShoppingCart.Items[0].Name);
            Assert.AreEqual(10, order.ShoppingCart.Items[0].UnitPrice);
            Assert.AreEqual(2, order.ShoppingCart.Items[0].Quantity);
            Assert.AreEqual("Default", order.CheckoutOptions.TaxTables.DefaultTaxTable.Name);
            Assert.AreEqual(0.21, order.CheckoutOptions.TaxTables.DefaultTaxTable.Rules[0].Rate);
            Assert.AreEqual("John", order.Customer.FirstName);
            Assert.AreEqual("Doe", order.Customer.LastName);
            Assert.AreEqual("Kraanspoor", order.Customer.Address1);
            Assert.AreEqual("39", order.Customer.HouseNumber);
            Assert.AreEqual("Amsterdam", order.Customer.City);
            Assert.AreEqual("NL", order.Customer.Country);
        }