-
Notifications
You must be signed in to change notification settings - Fork 572
Advanced client usage
Olivier Bellone edited this page Jun 6, 2019
·
2 revisions
This page illustrates some advanced usages of StripeClient
and SystemNetHttpClient
.
Note: this documentation applies to Stripe.net v27.0.0 or more recent.
using System.Net;
using System.Net.Http;
using Stripe;
var handler = new HttpClientHandler
{
Proxy = new WebProxy(proxyUrl),
UseProxy = true,
};
var httpClient = new HttpClient(handler);
var stripeClient = new StripeClient(
stripeApiKey,
httpClient: new SystemNetHttpClient(httpClient)
);
StripeConfiguration.StripeClient = stripeClient;
E.g. to use Xamarin's AndroidClientHandler
:
using System.Net.Http;
using Stripe;
var handler = new Xamarin.Android.Net.AndroidClientHandler();
var httpClient = new HttpClient(handler);
var stripeClient = new StripeClient(
stripeApiKey,
httpClient: new SystemNetHttpClient(httpClient)
);
StripeConfiguration.StripeClient = stripeClient;
This is useful to send API requests to a local server, e.g. stripe-mock:
using Stripe;
var stripeClient = new StripeClient(
stripeApiKey,
apiBase: "http://localhost:12111",
filesBase: "http://localhost:12111",
);
StripeConfiguration.StripeClient = stripeClient;
using Stripe;
var stripeClient = new StripeClient(
stripeApiKey,
httpClient: new SystemNetHttpClient(maxNetworkRetries: 2)
);
StripeConfiguration.StripeClient = stripeClient;