public Task <CreateInstrumentResponse> Create(CreateInstrumentRequest createInstrumentRequest, CancellationToken cancellationToken = default) { CheckoutUtils.ValidateParams("createInstrumentRequest", createInstrumentRequest); return(ApiClient.Post <CreateInstrumentResponse>( InstrumentsPath, SdkAuthorization(), createInstrumentRequest, cancellationToken)); }
private async Task <CreateInstrumentResponse> CreateTokenInstrument() { var phone = new Phone { CountryCode = "44", Number = "020 222333" }; var billingAddress = new Address { AddressLine1 = "CheckoutSdk.com", AddressLine2 = "90 Tottenham Court Road", City = "London", State = "London", Zip = "W1T 4TJ", Country = CountryCode.GB }; var cardTokenRequest = new CardTokenRequest { Name = TestCardSource.Visa.Name, Number = TestCardSource.Visa.Number, ExpiryYear = TestCardSource.Visa.ExpiryYear, ExpiryMonth = TestCardSource.Visa.ExpiryMonth, Cvv = TestCardSource.Visa.Cvv, BillingAddress = billingAddress, Phone = phone }; var cardTokenResponse = await PreviousApi.TokensClient().Request(cardTokenRequest); cardTokenResponse.ShouldNotBeNull(); var request = new CreateInstrumentRequest { Token = cardTokenResponse.Token, Customer = new InstrumentCustomerRequest { Email = "*****@*****.**", Name = "Bruce Wayne", Default = true, Phone = new Phone { CountryCode = "+1", Number = "4155552671" } } }; var createInstrumentResponse = await PreviousApi.InstrumentsClient().Create(request); createInstrumentResponse.ShouldNotBeNull(); return(createInstrumentResponse); }
private async Task ShouldCreateInstrument() { var createInstrumentRequest = new CreateInstrumentRequest(); var createInstrumentResponse = new CreateInstrumentResponse(); _apiClient.Setup(apiClient => apiClient.Post <CreateInstrumentResponse>("instruments", _authorization, createInstrumentRequest, CancellationToken.None, null)) .ReturnsAsync(() => createInstrumentResponse); IInstrumentsClient client = new InstrumentsClient(_apiClient.Object, _configuration.Object); var response = await client.Create(createInstrumentRequest); response.ShouldNotBeNull(); response.ShouldBe(createInstrumentResponse); }