How StripeClient and Global Configuration work
masterStarting with version 46, the recommended way to interact with the Stripe API is using the StripeClient class. This approach allows for better IDE discoverability and enables per-client configuration (such as different API keys or retry settings) without affecting a global state.
StripeClient Pattern (Recommended):
Instantiate a StripeClient with your secret key. All services are accessible via the .V1 property.
Global Configuration Pattern (Legacy):
Sets a global StripeConfiguration.ApiKey. While still supported, it is less flexible for applications requiring multiple configurations.
// StripeClient pattern (Recommended)
var client = new StripeClient("sk_test_...");
Customer customer = client.V1.Customers.Get("cus_1234");
// Global Configuration pattern (Legacy)
StripeConfiguration.ApiKey = "sk_test_...";
var service = new CustomerService();
Customer customer = service.Get("cus_1234");