예제 #1
0
        private async Task ShouldRequestPayment_IdempotencyKey()
        {
            var paymentRequest = new PaymentRequest
            {
                Source = new RequestNetworkTokenSource
                {
                    Token          = "token",
                    Cryptogram     = "cryptogram",
                    Cvv            = "123",
                    Eci            = "eci",
                    Name           = "name",
                    Phone          = new Phone(),
                    Stored         = false,
                    BillingAddress = new Address(),
                    ExpiryMonth    = 12,
                    ExpiryYear     = 2024,
                    TokenType      = NetworkTokenType.Vts
                }
            };
            var paymentResponse = new PaymentResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Post <PaymentResponse>(PaymentsPath, _authorization, paymentRequest,
                                                              CancellationToken.None, "test"))
            .ReturnsAsync(() => paymentResponse);

            IPaymentsClient paymentsClient = new PaymentsClient(_apiClient.Object, _configuration.Object);

            var response = await paymentsClient.RequestPayment(paymentRequest, "test", CancellationToken.None);

            response.ShouldNotBeNull();
            response.ShouldBeSameAs(paymentResponse);
        }
예제 #2
0
        private async Task ShouldRequestPayment()
        {
            var paymentRequest = new PaymentRequest
            {
                Source = new RequestProviderTokenSource
                {
                    Token = "token", PaymentMethod = "method", AccountHolder = new AccountHolder()
                }
            };
            var paymentResponse = new PaymentResponse();

            _apiClient.Setup(apiClient =>
                             apiClient.Post <PaymentResponse>(PaymentsPath, _authorization, paymentRequest,
                                                              CancellationToken.None, null))
            .ReturnsAsync(() => paymentResponse);

            IPaymentsClient paymentsClient = new PaymentsClient(_apiClient.Object, _configuration.Object);

            var response = await paymentsClient.RequestPayment(paymentRequest, null, CancellationToken.None);

            response.ShouldNotBeNull();
            response.ShouldBeSameAs(paymentResponse);
        }
예제 #3
0
        private async Task ShouldRequestPayment_CustomSource()
        {
            var paymentRequest = new PaymentRequest
            {
                Customer = new CustomerRequest {
                    Phone = new Phone()
                },
                Processing =
                    new ProcessingSettings
                {
                    TaxAmount      = 500,
                    ShippingAmount = 1000,
                },
                Source = new RequestTamaraSource
                {
                    BillingAddress = new Address
                    {
                        AddressLine1 = "Cecilia Chapman",
                        AddressLine2 = "711-2880 Nulla St.",
                        City         = "Mankato",
                        State        = "Mississippi",
                        Zip          = "96522",
                        Country      = CountryCode.SA
                    }
                },
                Items = new List <Product>
                {
                    new Product
                    {
                        Name           = "Item name",
                        Quantity       = 3,
                        UnitPrice      = 100,
                        TotalAmount    = 100,
                        TaxAmount      = 19,
                        DiscountAmount = 2,
                        Reference      = "some description about item",
                        ImageUrl       = "https://some_s3bucket.com",
                        Url            = "https://some.website.com/item",
                        Sku            = "123687000111"
                    }
                }
            };
            var paymentResponse = new PaymentResponse
            {
                Customer = new CustomerResponse {
                    Id = "id", Email = "email", Name = "name", Phone = new Phone()
                },
                Processing = new PaymentProcessing {
                    PartnerPaymentId = "123456"
                }
            };

            _apiClient.Setup(apiClient =>
                             apiClient.Post <PaymentResponse>(PaymentsPath, _authorization, paymentRequest,
                                                              CancellationToken.None, null))
            .ReturnsAsync(() => paymentResponse);

            IPaymentsClient paymentsClient = new PaymentsClient(_apiClient.Object, _configuration.Object);

            var response = await paymentsClient.RequestPayment(paymentRequest, null, CancellationToken.None);

            response.ShouldNotBeNull();
            response.ShouldBeSameAs(paymentResponse);
            response.Customer.ShouldNotBeNull();
            response.Customer.Phone.ShouldNotBeNull();
        }