Beispiel #1
0
        public void Orders_PayAfterDeliveryOrderRedirect()
        {
            // Arrange
            var url     = ConfigurationManager.AppSettings["MultiSafepayAPI"];
            var apiKey  = ConfigurationManager.AppSettings["MultiSafepayAPIKey"];
            var client  = new MultiSafepayClient(apiKey, url);
            var orderId = Guid.NewGuid().ToString();

            var orderRequest = OrderRequest.CreateRedirectPayAfterDeliveryOrder(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.IsFalse(String.IsNullOrEmpty(result.PaymentUrl));
        }
Beispiel #2
0
        public void GatewayInfo_Serialize_PropertyNamesAsExpected()
        {
            // Arrange
            var gatewayInfo = GatewayInfo.PayAfterDelivery(null, null, null, null, null, null);

            // Act
            var serializedObject = JsonConvert.SerializeObject(gatewayInfo);

            // Assert
            Assert.AreEqual(@"{
                ""issuer_id"": null,
		        ""birthday"": null,
		        ""bank_account"": null,
		        ""phone"": null,
		        ""referrer"": null,
		        ""user_agent"": null,
                ""email"": null
	        }"    .RemoveWhiteSpace(), serializedObject.RemoveWhiteSpace());
        }
        public void GatewayInfo_Serialize_PropertyNamesAsExpected()
        {
            // Arrange
            var gatewayInfo = GatewayInfo.PayAfterDelivery(null, null, null, null, null, null);

            // Act
            var serializedObject = JsonConvert.SerializeObject(gatewayInfo);

            // Assert
            Assert.AreEqual(@"{
                ""issuer_id"": null,
                ""account_id"": null,
                ""qr_size"": 0,
                ""account_holder_name"": null,
                ""account_holder_city"": null,
                ""account_holder_country"": null,
                ""account_holder_iban"": null,
                ""account_holder_swift"": null,
                ""account_holder_bic"": null,
                ""birthday"": null,
                ""bank_account"": null,
                ""phone"": null,
                ""referrer"": null,
                ""user_agent"": null,
                ""email"": null,
                ""gender"": null,
                ""personal_number"": null,
                ""card_number"": null,
                ""card_holder_name"": null,
                ""card_expiry_date"": null,
                ""card_cvc"": null,
                ""term_url"": null,
                ""emandate"": null,
                ""company"": null,
                ""po_number"": null,
                ""coc"": null,
                ""vat"": null,
                ""collecting_flow"": null,
                ""action_on_declined"": null,
                ""company_type"": null
	        }"    .RemoveWhiteSpace(), serializedObject.RemoveWhiteSpace());
        }
Beispiel #4
0
        public void Order_CreateRedirectPayAfterDelivery_SetsRequiredProperties()
        {
            // Act
            var order = OrderRequest.CreateRedirectPayAfterDeliveryOrder("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 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.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.Redirect, 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("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);
        }
        public void Orders_CreateEinvoiceOrder()
        {
            // Arrange
            var url     = ConfigurationManager.AppSettings["MultiSafepayAPI"];
            var apiKey  = ConfigurationManager.AppSettings["MultiSafepayAPIKey"];
            var client  = new MultiSafepayClient(apiKey, url);
            var orderId = Guid.NewGuid().ToString();

            var orderRequest = OrderRequest.CreateDirectEinvoiceOrder(orderId, "product description", 12100, "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", 100.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   = "Testperson-nl",
                LastName    = "Approved",
                HouseNumber = "1/XI",
                Address1    = "Neherkade",
                City        = "Gravenhage",
                Country     = "NL",
                PostCode    = "2521VA",
            },
                                                                      new DeliveryAddress()
            {
                FirstName   = "Testperson-nl",
                LastName    = "Approved",
                HouseNumber = "1/XI",
                Address1    = "Neherkade",
                City        = "Gravenhage",
                Country     = "NL",
                PostCode    = "2521VA",
            }
                                                                      );

            // 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
        }