StripeClient is a .NET library that integrates with Stripe's payment gateway, providing support for managing customers, payment methods, setup intents, and payment intents. It leverages the official Stripe .NET SDK and includes AutoMapper profiles for mapping data between Stripe's models and your application's domain.
StripeClient simplifies payment integration by offering dedicated clients for handling customer setup, payment methods, and payment processing through Stripe. It supports configuring API keys securely and integrates AutoMapper to simplify the mapping of data between the Stripe SDK and your application.
- Payment Intent Client: Allows you to create, retrieve, and confirm payment intents.
- Payment Setup Clients: Manages customers, payment methods, and setup intents.
- AutoMapper Support: Integrates AutoMapper to handle model mapping.
- API Key Configuration: Supports secure configuration of Stripe API keys.
- Backend: .NET 8
- Payment Gateway: Stripe .NET SDK
- Mapping: AutoMapper
- Dependency Injection: Used for service registrations and configurations
- Register the StripeClient: Use the provided extension methods such as
AddStripePaymentIntentClient
orAddStripeSetupPaymentClients
to register the necessary clients in the dependency injection container. - Configure API Keys: Use the
StripeClientOptions
class to set up the Stripe API key. - Invoke Services: Use the respective service clients (e.g.,
IPaymentIntentClient
,ICustomerClient
) to interact with Stripe's API.
- ApiKey: The API key for authenticating requests to Stripe.
public class StripeClientOptions
{
public string ApiKey { get; set; }
}
Registering Stripe clients and configuring options in the Startup.cs
or Program.cs
:
services.AddStripePaymentIntentClient(options =>
{
options.ApiKey = "your-stripe-api-key";
});
services.AddStripeSetupPaymentClients(options =>
{
options.ApiKey = "your-stripe-api-key";
});