public async Task ShouldInstantiateAndRetrieveClientsDefault()
        {
            PaymentLinkRequest  paymentLinkRequest  = new PaymentLinkRequest();
            PaymentLinkResponse paymentLinkResponse = new PaymentLinkResponse
            {
                Id        = "1",
                ExpiresOn = DateTime.Now,
                Reference = "ref1234"
            };


            _apiClient.Setup(apiClient =>
                             apiClient.Post <PaymentLinkResponse>(PaymentLinksPath, _authorization, paymentLinkRequest, CancellationToken.None, null))
            .ReturnsAsync(() => paymentLinkResponse);

            IPaymentLinksClient paymentLinksClient = new PaymentLinksClient(_apiClient.Object, _configuration.Object);

            var response = await paymentLinksClient.Create(paymentLinkRequest, CancellationToken.None);

            response.ShouldNotBeNull();
            response.Id.ShouldNotBeNull();
            response.Id.ShouldBe("1");
            response.ExpiresOn.ShouldNotBeNull();
            response.Reference.ShouldNotBeNull();
            response.Reference.ShouldBe("ref1234");
            response.ShouldBeSameAs(paymentLinkResponse);
        }
Ejemplo n.º 2
0
 public Task <PaymentLinkResponse> Create(PaymentLinkRequest paymentLinkRequest,
                                          CancellationToken cancellationToken = default)
 {
     CheckoutUtils.ValidateParams("paymentLinkRequest", paymentLinkRequest);
     return(ApiClient.Post <PaymentLinkResponse>(PaymentLinksPath, SdkAuthorization(), paymentLinkRequest,
                                                 cancellationToken, null));
 }
Ejemplo n.º 3
0
        private async Task ShouldCreateAndGetPaymentLink()
        {
            var paymentLinkRequest = new PaymentLinkRequest
            {
                Amount  = 10,
                Billing = new BillingInformation {
                    Address = GetAddress()
                },
                Capture   = true,
                CaptureOn = DateTime.Now,
                Currency  = Currency.GBP,
                Customer  = new CustomerRequest {
                    Id = "Id", Email = GenerateRandomEmail(), Name = "name"
                },
                Description = "description",
                ExpiresIn   = 1,
                Locale      = "locale",
                Reference   = "referene",
                ThreeDs     = new ThreeDsRequest
                {
                    Enabled            = true,
                    AttemptN3D         = false,
                    Eci                = "05",
                    Cryptogram         = "AgAAAAAAAIR8CQrXcIhbQAAAAAA",
                    Xid                = "MDAwMDAwMDAwMDAwMDAwMzIyNzY=",
                    Version            = "2.0.1",
                    ChallengeIndicator = ChallengeIndicatorType.NoPreference
                },
                PaymentType         = PaymentType.Regular,
                AllowPaymentMethods = new List <PaymentSourceType> {
                    PaymentSourceType.Card, PaymentSourceType.Ideal
                }
            };

            var response = await DefaultApi.PaymentLinksClient().Create(paymentLinkRequest);

            response.ShouldNotBeNull();
            response.Id.ShouldNotBeNull();
            response.Links.ShouldNotBeNull();
            response.Links.Count.ShouldBe(2);
            response.Reference.ShouldNotBeNull();
            response.Warnings.Count.ShouldBe(1);

            var responseGet = await DefaultApi.PaymentLinksClient().Get(response.Id);

            responseGet.ShouldNotBeNull();
            responseGet.Id.ShouldNotBeNull();
            responseGet.Amount.ShouldBe(10);
            responseGet.Billing.ShouldNotBeNull();
            responseGet.CreatedOn.ShouldNotBeNull();
            responseGet.Currency.ShouldNotBeNull();
            responseGet.Customer.ShouldNotBeNull();
            responseGet.Status.ShouldNotBeNull();
            responseGet.Reference.ShouldNotBeNullOrEmpty();
            responseGet.Description.ShouldNotBeNullOrEmpty();
            responseGet.Links.ShouldNotBeNull();
            responseGet.Links.Count.ShouldBe(2);
            responseGet.Reference.ShouldNotBeNull();
            responseGet.Metadata.ShouldNotBeNull();
            responseGet.Metadata.Count.ShouldBe(0);
        }