Ejemplo n.º 1
0
        private async Task ShouldRequestPayment_IdempotencyKey()
        {
            var paymentRequest  = new PaymentRequest();
            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);
        }
Ejemplo n.º 2
0
        private async Task ShouldRequestPayment_CustomSource()
        {
            CustomSource customSource = new CustomSource {
                amount = 10L, currency = Currency.USD
            };

            var paymentRequest = new PaymentRequest();

            paymentRequest.Source = customSource;

            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);
        }