Exemplo n.º 1
0
        public void Orders_CreateOrder()
        {
            // Arrange
            var url     = Settings.MultiSafePayUrl;
            var apiKey  = Settings.ApiKey;
            var client  = new MultiSafepayClient(apiKey, url);
            var orderId = Guid.NewGuid().ToString();

            var orderRequest = OrderRequest.CreateRedirect(orderId, "product description", 1000, "EUR",
                                                           new PaymentOptions("http://example.com/notify", "http://example.com/success", "http://example.com/failed"));

            orderRequest.Customer = new Customer()
            {
                FirstName = "John",
                LastName  = "Doe",
                Address1  = "Kraanspoor 39",
                City      = "Amsterdam",
                Country   = "Netherlands",
                PostCode  = "1033SC"
            };

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

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(orderRequest.OrderId, result.OrderId);
            Assert.IsFalse(String.IsNullOrEmpty(result.PaymentUrl));
        }
Exemplo n.º 2
0
        public void Order_CreateRedirect_SetsRequiredProperties()
        {
            // Act
            var order = OrderRequest.CreateRedirect("orderid", "description", 1000, "EUR",
                                                    new PaymentOptions("notificationUrl", "successRedirectUrl", "cancelRedirectUrl"));

            // Assert
            Assert.IsNotNull(order.Type);
            Assert.IsNotNull(order.OrderId);
            Assert.IsNotNull(order.Description);
            Assert.IsNotNull(order.CurrencyCode);
            Assert.IsNotNull(order.AmountInCents);
            Assert.IsNotNull(order.PaymentOptions);
            Assert.IsNotNull(order.PaymentOptions.NotificationUrl);
            Assert.IsNotNull(order.PaymentOptions.SuccessRedirectUrl);
            Assert.IsNotNull(order.PaymentOptions.CancelRedirectUrl);

            Assert.AreEqual(OrderType.Redirect, order.Type);
            Assert.AreEqual("orderid", order.OrderId);
            Assert.AreEqual("description", order.Description);
            Assert.AreEqual(1000, order.AmountInCents);
            Assert.AreEqual("EUR", order.CurrencyCode);
            Assert.AreEqual("notificationUrl", order.PaymentOptions.NotificationUrl);
            Assert.AreEqual("successRedirectUrl", order.PaymentOptions.SuccessRedirectUrl);
            Assert.AreEqual("cancelRedirectUrl", order.PaymentOptions.CancelRedirectUrl);
        }
Exemplo n.º 3
0
        public void Order_Serialize_PropertyNamesAsExpected()
        {
            // Arrange
            var order = OrderRequest.CreateRedirect(null, null, 1000, null,
                                                    new PaymentOptions("http://example.com/notify", "http://example.com/success", "http://example.com/failed"));

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

            // Assert
            Assert.AreEqual(@"{
                ""type"": ""redirect"",
                ""order_id"": null,
                ""recurring_id"": null,
                ""currency"": null,
                ""amount"": 1000,
                ""gateway"": null,
                ""description"": null,
                ""var1"": null,
                ""var2"": null,
                ""var3"": null,
                ""custom_info"": {},
                ""items"": null,
                ""manual"": null,
                ""template_id"": null,
                ""template"": null,
                ""days_active"": null,
                ""seconds_active"": 0,
                ""payment_options"": {
                    ""notification_method"": ""GET"",
                    ""notification_url"": ""http://example.com/notify"",
                    ""redirect_url"": ""http://example.com/success"",
                    ""cancel_url"": ""http://example.com/failed"",
                    ""close_window"": true
                },
                ""second_chance"": null,
                ""plugin"": null,
                ""gateway_info"": null,
                ""customer"": null,
                ""delivery"": null,
                ""affiliate"": null,
                ""shopping_cart"": null,
                ""checkout_options"": null,
                ""google_analytics"": null,
                ""custom_fields"": null
	        }"    .RemoveWhiteSpace(), serializedObject.RemoveWhiteSpace());
        }
Exemplo n.º 4
0
        public void Orders_CreateRedirect()
        {
            // Arrange
            var url          = Settings.MultiSafePayUrl;
            var apiKey       = Settings.ApiKey;
            var client       = new MultiSafepayClient(apiKey, url);
            var orderId      = Guid.NewGuid().ToString();
            var orderRequest = OrderRequest.CreateRedirect(orderId, "product description", 1000, "EUR",
                                                           new PaymentOptions("http://example.com/notify", "http://example.com/success", "http://example.com/failed"));

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

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(orderRequest.OrderId, result.OrderId);
            Assert.IsFalse(String.IsNullOrEmpty(result.PaymentUrl));
        }