public async Task MakeRequestAsync() { var responseMessage = new HttpResponseMessage(HttpStatusCode.OK); responseMessage.Content = new StringContent("Hello world!"); this.MockHttpClientFixture.MockHandler.Protected() .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(responseMessage)); var client = new SystemNetHttpClient( new HttpClient(this.MockHttpClientFixture.MockHandler.Object)); var request = new StripeRequest( this.StripeClient, HttpMethod.Post, "/foo", null, null); var response = await client.MakeRequestAsync(request); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("Hello world!", response.Content); }
public async Task Ctor_PostRequest() { var request = new StripeRequest( this.stripeClient, HttpMethod.Post, "/post", new TestOptions { String = "string!" }, new RequestOptions()); Assert.Equal(HttpMethod.Post, request.Method); Assert.Equal($"{this.stripeClient.ApiBase}/post", request.Uri.ToString()); Assert.Equal( $"Bearer {this.stripeClient.ApiKey}", request.AuthorizationHeader.ToString()); Assert.True(request.StripeHeaders.ContainsKey("Stripe-Version")); Assert.Equal(StripeConfiguration.ApiVersion, request.StripeHeaders["Stripe-Version"]); Assert.True(request.StripeHeaders.ContainsKey("Idempotency-Key")); Assert.False(request.StripeHeaders.ContainsKey("Stripe-Account")); Assert.NotNull(request.Content); var content = await request.Content.ReadAsStringAsync(); Assert.Equal("string=string!", content); }
public void Ctor_RequestOptions() { var client = new StripeClient("sk_test_123"); var requestOptions = new RequestOptions { ApiKey = "sk_override", IdempotencyKey = "idempotency_key", StripeAccount = "acct_456", BaseUrl = "https://override.example.com", StripeVersion = "2012-12-21", }; var request = new StripeRequest( this.stripeClient, HttpMethod.Get, "/get", null, requestOptions); Assert.Equal(HttpMethod.Get, request.Method); Assert.Equal($"{requestOptions.BaseUrl}/get", request.Uri.ToString()); Assert.Equal($"Bearer {requestOptions.ApiKey}", request.AuthorizationHeader.ToString()); Assert.True(request.StripeHeaders.ContainsKey("Stripe-Version")); Assert.Equal("2012-12-21", request.StripeHeaders["Stripe-Version"]); Assert.True(request.StripeHeaders.ContainsKey("Idempotency-Key")); Assert.Equal("idempotency_key", request.StripeHeaders["Idempotency-Key"]); Assert.True(request.StripeHeaders.ContainsKey("Stripe-Account")); Assert.Equal("acct_456", request.StripeHeaders["Stripe-Account"]); Assert.Null(request.Content); }
public async Task<StripeResponse<TransferReversal>> GetTransferReversal(string id, string transferId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<TransferReversal> { UrlPath = PathHelper.GetPath(Paths.Transfers, transferId, Paths.Reversals, id) }; return await _client.Get(request, cancellationToken); }
public async Task<StripeResponse<BankAccount>> GetBankAccount(string id, string accountId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<BankAccount> { UrlPath = PathHelper.GetPath(Paths.Accounts, accountId, Paths.ExternalAccounts, id) }; return await _client.Get(request, cancellationToken); }
public async Task <StripeResponse <Models.Subscription> > CancelSubscription(SubscriptionCancelArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <Models.Subscription> { UrlPath = PathHelper.GetPath(Paths.Customers, arguments.CustomerId, Paths.Subscriptions, arguments.SubscriptionId) }; return(await _client.Delete(request, cancellationToken)); }
public async Task<StripeResponse<Sku>> GetSku(string skuId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<Sku> { UrlPath = PathHelper.GetPath(Paths.Skus, skuId) }; return await _client.Get(request, cancellationToken); }
public async Task<StripeResponse<Balance>> GetBalance( CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<Balance> { UrlPath = Paths.Balance }; return await _client.Get(request, cancellationToken); }
public async Task<StripeResponse<Event>> GetEvent(string id, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<Event> { UrlPath = PathHelper.GetPath(Paths.Events, id) }; return await _client.Get(request, cancellationToken); }
public async Task<StripeResponse<BalanceTransaction>> GetBalanceTranasaction(string id, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<BalanceTransaction> { UrlPath = PathHelper.GetPath(Paths.Balance, Paths.History, id) }; return await _client.Get(request, cancellationToken); }
public async Task<StripeResponse<InvoiceItem>> GetInvoiceItem(string invoiceItemId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<InvoiceItem> { UrlPath = PathHelper.GetPath(Paths.InvoiceItems, invoiceItemId) }; return await _client.Get(request, cancellationToken); }
public async Task<StripeResponse<DeletedObject>> DeleteCustomer(string id, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<DeletedObject> { UrlPath = PathHelper.GetPath(Paths.Customers, id) }; return await _client.Delete(request, cancellationToken); }
public async Task<StripeResponse<BankAccount>> GetBankAccount(string id, string customerId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<BankAccount> { UrlPath = PathHelper.GetPath(Paths.Customers, customerId, Paths.Sources, id) }; return await _client.Get(request, cancellationToken); }
public async Task<StripeResponse<Token>> CreatePiiToken(PiiTokenCreateArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<PiiTokenCreateArguments, Token> { UrlPath = Paths.Tokens, Model = arguments }; return await _client.Post(request, cancellationToken); }
public async Task<StripeResponse<Coupon>> GetCoupon(string couponId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<Coupon> { UrlPath = PathHelper.GetPath(Paths.Coupons, couponId) }; return await _client.Get(request, cancellationToken); }
public async Task<StripeResponse<BitcoinReceiver>> GetBitcoinReceiver(string id, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<BitcoinReceiver> { UrlPath = PathHelper.GetPath(Paths.Bitcoin, Paths.Receivers, id) }; return await _client.Get(request, cancellationToken); }
public async Task<StripeResponse<ApplicationFeeRefund>> GetApplicationFeeRefund(string id, string applicationFeeId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<ApplicationFeeRefund> { UrlPath = PathHelper.GetPath(Paths.ApplicationFees, applicationFeeId, Paths.Refunds, id) }; return await _client.Get(request, cancellationToken); }
public async Task<StripeResponse<Dispute>> CloseDispute(string id, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<Dispute> { UrlPath = PathHelper.GetPath(Paths.Disputes, id, "close") }; return await _client.Post(request, cancellationToken); }
public async Task<StripeResponse<DeletedObject>> DeleteProduct(string productId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<DeletedObject> { UrlPath = PathHelper.GetPath(Paths.Products, productId) }; return await _client.Delete(request, cancellationToken); }
public async Task<StripeResponse<Card>> GetCard(string id, string recipientId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<Card> { UrlPath = PathHelper.GetPath(Paths.Recipients, recipientId, Paths.Cards, id) }; return await _client.Get(request, cancellationToken); }
public async Task<StripeResponse<DeletedObject>> DeleteInvoiceItem(string couponId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<DeletedObject> { UrlPath = PathHelper.GetPath(Paths.InvoiceItems, couponId) }; return await _client.Delete(request, cancellationToken); }
public async Task<StripeResponse<Customer>> UpdateCustomer(CustomerUpdateArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<CustomerUpdateArguments, Customer> { UrlPath = PathHelper.GetPath(Paths.Customers, arguments.CustomerId), Model = arguments }; return await _client.Post(request, cancellationToken); }
public async Task <StripeResponse <TransferReversal> > GetTransferReversal(string id, string transferId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <TransferReversal> { UrlPath = PathHelper.GetPath(Paths.Transfers, transferId, Paths.Reversals, id) }; return(await _client.Get(request, cancellationToken)); }
public async Task<StripeResponse<Charge>> CaptureCharge(ChargeCaptureArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<ChargeCaptureArguments, Charge> { UrlPath = PathHelper.GetPath(Paths.Charges, arguments.ChargeId, Paths.Capture), Model = arguments }; return await _client.Post(request, cancellationToken); }
public async Task <StripeResponse <BalanceTransaction> > GetBalanceTranasaction(string id, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <BalanceTransaction> { UrlPath = PathHelper.GetPath(Paths.Balance, Paths.History, id) }; return(await _client.Get(request, cancellationToken)); }
public async Task <StripeResponse <Card> > GetCard(string id, string recipientId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <Card> { UrlPath = PathHelper.GetPath(Paths.Recipients, recipientId, Paths.Cards, id) }; return(await _client.Get(request, cancellationToken)); }
public async Task <StripeResponse <DeletedObject> > DeleteProduct(string productId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <DeletedObject> { UrlPath = PathHelper.GetPath(Paths.Products, productId) }; return(await _client.Delete(request, cancellationToken)); }
public async Task<StripeResponse<Order>> PayOrder(OrderPayArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<OrderPayArguments, Order> { UrlPath = PathHelper.GetPath(Paths.Orders, arguments.OrderId, Paths.Pay), Model = arguments }; return await _client.Post(request, cancellationToken); }
public async Task <StripeResponse <Charge> > GetCharge(string id, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <Charge> { UrlPath = PathHelper.GetPath(Paths.Charges, id) }; return(await _client.Get(request, cancellationToken)); }
public async Task<StripeResponse<Pagination<InvoiceItem>>> GetInvoiceItems(InvoiceItemListFilter filter, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<InvoiceItemListFilter, Pagination<InvoiceItem>> { UrlPath = Paths.InvoiceItems, Model = filter }; return await _client.Get(request, cancellationToken); }
public async Task<StripeResponse<Pagination<BitcoinReceiver>>> GetBitcoinReceivers( BitcoinReceiverListFilter filter, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<BitcoinReceiverListFilter, Pagination<BitcoinReceiver>> { UrlPath = PathHelper.GetPath(Paths.Bitcoin, Paths.Receivers), Model = filter }; return await _client.Get(request, cancellationToken); }
public async Task <StripeResponse <Sku> > GetSku(string skuId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <Sku> { UrlPath = PathHelper.GetPath(Paths.Skus, skuId) }; return(await _client.Get(request, cancellationToken)); }
public async Task<StripeResponse<InvoiceItem>> UpdateInvoiceItem(InvoiceItemUpdateArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<InvoiceItemUpdateArguments, InvoiceItem> { UrlPath = PathHelper.GetPath(Paths.InvoiceItems, arguments.InvoiceItemId), Model = arguments }; return await _client.Post(request, cancellationToken); }
public async Task<StripeResponse<BitcoinReceiver>> CreateBitcoinReceiver( BitcoinReceiverCreateArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<BitcoinReceiverCreateArguments, BitcoinReceiver> { UrlPath = PathHelper.GetPath(Paths.Bitcoin, Paths.Receivers), Model = arguments }; return await _client.Post(request, cancellationToken); }
public async Task <StripeResponse <Balance> > GetBalance( CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <Balance> { UrlPath = Paths.Balance }; return(await _client.Get(request, cancellationToken)); }
public async Task <StripeResponse <BitcoinReceiver> > GetBitcoinReceiver(string id, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <BitcoinReceiver> { UrlPath = PathHelper.GetPath(Paths.Bitcoin, Paths.Receivers, id) }; return(await _client.Get(request, cancellationToken)); }
public async Task<StripeResponse<Charge>> CreateCharge(ChargeCreateArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<ChargeCreateArguments, Charge> { UrlPath = Paths.Charges, Model = arguments }; return await _client.Post(request, cancellationToken); }
public async Task <StripeResponse <ApplicationFeeRefund> > GetApplicationFeeRefund(string id, string applicationFeeId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <ApplicationFeeRefund> { UrlPath = PathHelper.GetPath(Paths.ApplicationFees, applicationFeeId, Paths.Refunds, id) }; return(await _client.Get(request, cancellationToken)); }
public async Task <StripeResponse <Dispute> > CloseDispute(string id, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <Dispute> { UrlPath = PathHelper.GetPath(Paths.Disputes, id, "close") }; return(await _client.Post(request, cancellationToken)); }
public async Task <StripeResponse <Models.Subscription> > GetSubscription(string subscriptionId, string customerId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <Models.Subscription> { UrlPath = PathHelper.GetPath(Paths.Customers, customerId, Paths.Subscriptions, subscriptionId) }; return(await _client.Get(request, cancellationToken)); }
public async Task<StripeResponse<Pagination<Customer>>> GetCustomers(CustomerListFilter filter, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<CustomerListFilter, Pagination<Customer>> { UrlPath = Paths.Customers, Model = filter }; return await _client.Get(request, cancellationToken); }
public async Task <StripeResponse <DeletedObject> > DeleteInvoiceItem(string couponId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <DeletedObject> { UrlPath = PathHelper.GetPath(Paths.InvoiceItems, couponId) }; return(await _client.Delete(request, cancellationToken)); }
public async Task <StripeResponse <DeletedObject> > DeleteCustomer(string id, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <DeletedObject> { UrlPath = PathHelper.GetPath(Paths.Customers, id) }; return(await _client.Delete(request, cancellationToken)); }
public async Task <StripeResponse <BankAccount> > GetBankAccount(string id, string customerId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <BankAccount> { UrlPath = PathHelper.GetPath(Paths.Customers, customerId, Paths.Sources, id) }; return(await _client.Get(request, cancellationToken)); }
public async Task<StripeResponse<Recipient>> UpdateRecipient(RecipientUpdateArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<RecipientUpdateArguments, Recipient> { UrlPath = PathHelper.GetPath(Paths.Recipients, arguments.Id), Model = arguments }; return await _client.Post(request, cancellationToken); }
public async Task <StripeResponse <InvoiceItem> > GetInvoiceItem(string invoiceItemId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <InvoiceItem> { UrlPath = PathHelper.GetPath(Paths.InvoiceItems, invoiceItemId) }; return(await _client.Get(request, cancellationToken)); }
public async Task<StripeResponse<Pagination<Card>>> GetCards(RecipientCardListFilter filter, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<RecipientCardListFilter, Pagination<Card>> { UrlPath = PathHelper.GetPath(Paths.Recipients, filter.RecipientId, Paths.Cards), Model = filter }; return await _client.Get(request, cancellationToken); }
public async Task <StripeResponse <TResponse> > Post <TResponse>( StripeRequest <TResponse> stripeRequest, CancellationToken cancellationToken) { var uri = await GetUri(stripeRequest.UrlPath); var message = GetHttpRequestMessage(uri, HttpMethod.Post, null, stripeRequest.IdempotencyKey); var response = await GetStripeResponse <TResponse>(message, cancellationToken); return(response); }
public async Task <StripeResponse <Coupon> > GetCoupon(string couponId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <Coupon> { UrlPath = PathHelper.GetPath(Paths.Coupons, couponId) }; return(await _client.Get(request, cancellationToken)); }
public async Task <StripeResponse <Token> > CreatePiiToken(PiiTokenCreateArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <PiiTokenCreateArguments, Token> { UrlPath = Paths.Tokens, Model = arguments }; return(await _client.Post(request, cancellationToken)); }
public async Task <StripeResponse <Invoice> > PayInvoice(string invoiceId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <Invoice> { UrlPath = PathHelper.GetPath(Paths.Invoices, invoiceId, Paths.Pay) }; return(await _client.Post(request, cancellationToken)); }
public async Task <StripeResponse <TResponse> > Get <TRequest, TResponse>( StripeRequest <TRequest, TResponse> stripeRequest, CancellationToken cancellationToken) { var uri = await GetUri(stripeRequest.UrlPath, stripeRequest.Model); var message = GetHttpRequestMessage(uri, HttpMethod.Get); var response = await GetStripeResponse <TResponse>(message, cancellationToken); return(response); }
public async Task<StripeResponse<Sku>> UpdateSku(SkuUpdateArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<SkuUpdateArguments, Sku> { UrlPath = PathHelper.GetPath(Paths.Skus, arguments.SkuId), Model = arguments }; return await _client.Post(request, cancellationToken); }
public async Task <StripeResponse <BankAccount> > GetBankAccount(string id, string accountId, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <BankAccount> { UrlPath = PathHelper.GetPath(Paths.Accounts, accountId, Paths.ExternalAccounts, id) }; return(await _client.Get(request, cancellationToken)); }
public async Task<StripeResponse<Pagination<Event>>> GetEvents(EventListFilter filter, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest<EventListFilter, Pagination<Event>> { UrlPath = Paths.Events, Model = filter }; return await _client.Get(request, cancellationToken); }
public async Task <StripeResponse <BankAccount> > CreateBankAccount(AccountBankAccountCreateArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <AccountBankAccountCreateArguments, BankAccount> { UrlPath = PathHelper.GetPath(Paths.Accounts, arguments.AccountId, Paths.ExternalAccounts), Model = arguments }; return(await _client.Post(request, cancellationToken)); }
public async Task <StripeResponse <Pagination <BankAccount> > > GetBankAccounts(AccountBankAccountListFilter filter, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <AccountBankAccountListFilter, Pagination <BankAccount> > { UrlPath = PathHelper.GetPath(Paths.Accounts, filter.AccountId, Paths.ExternalAccounts), Model = filter }; return(await _client.Get(request, cancellationToken)); }
public async Task <StripeResponse <Account> > UpdateAccount(AccountUpdateArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <AccountUpdateArguments, Account> { UrlPath = PathHelper.GetPath(Paths.Accounts, arguments.AccountId), Model = arguments }; return(await _client.Post(request, cancellationToken)); }
public async Task <StripeResponse <Pagination <Account> > > GetAccounts(AccountListFilter filter, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <AccountListFilter, Pagination <Account> > { UrlPath = Paths.Accounts, Model = filter }; return(await _client.Get(request, cancellationToken)); }
public async Task <StripeResponse <Charge> > CaptureCharge(ChargeCaptureArguments arguments, CancellationToken cancellationToken = default(CancellationToken)) { var request = new StripeRequest <ChargeCaptureArguments, Charge> { UrlPath = PathHelper.GetPath(Paths.Charges, arguments.ChargeId, Paths.Capture), Model = arguments }; return(await _client.Post(request, cancellationToken)); }