The C# SDK provides convenient access to the Dodo Payments REST API from applications written in C#. It features an async Task-based API with strong typing, automatic retries, and comprehensive error handling.Documentation Index
Fetch the complete documentation index at: https://docs.dodopayments.com/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Install the package from NuGet:The SDK requires .NET 8.0 or later. It works with ASP.NET Core, Console applications, and other .NET project types.
Quick Start
Initialize the client and create a checkout session:Core Features
Async/Await
Full async Task-based API for non-blocking operations
Strong Typing
Comprehensive type safety with nullable reference types
Smart Retries
Automatic retries with exponential backoff for transient errors
Error Handling
Built-in exception hierarchy for precise error management
Configuration
Environment Variables
.env
| Property | Environment variable | Required | Default value |
|---|---|---|---|
BearerToken | DODO_PAYMENTS_API_KEY | true | - |
WebhookKey | DODO_PAYMENTS_WEBHOOK_KEY | false | - |
BaseUrl | DODO_PAYMENTS_BASE_URL | true | "https://live.dodopayments.com" |
Manual Configuration
Environments
Switch between live and test mode:Retries
The SDK automatically retries 2 times by default with exponential backoff. It retries on connection errors and status codes 408, 409, 429, and 5xx.Timeouts
Requests time out after 1 minute by default.Per-Request Overrides
Temporarily modify configuration for a single request usingWithOptions:
Common Operations
Create a Checkout Session
Manage Customers
Handle Subscriptions
Billing nécessite au minimum le code ISO à deux lettres Country. Utilisez AttachExistingCustomer pour attacher un client existant, ou NewCustomer pour en créer un. ProductPrice est dans la plus basse dénomination de monnaie.Gestion des erreurs
Le SDK déclenche des exceptions spécifiques en fonction du code d’état HTTP. Toutes les erreurs 4xx héritent deDodoPayments4xxException.
| Statut | Exception |
|---|---|
| 400 | DodoPaymentsBadRequestException |
| 401 | DodoPaymentsUnauthorizedException |
| 403 | DodoPaymentsForbiddenException |
| 404 | DodoPaymentsNotFoundException |
| 422 | DodoPaymentsUnprocessableEntityException |
| 429 | DodoPaymentsRateLimitException |
| 5xx | DodoPayments5xxException |
| autres | DodoPaymentsUnexpectedStatusCodeException |
DodoPaymentsIOException: Erreurs de réseau I/ODodoPaymentsInvalidDataException: Échec de l’interprétation des données analyséesDodoPaymentsException: Classe de base pour toutes les exceptions
Pagination
Auto-Pagination
Itérez à travers tous les résultats sur toutes les pages en utilisant la méthodePaginate, qui retourne un IAsyncEnumerable :
Pagination manuelle
Intégration ASP.NET Core
Enregistrez le client dans votre conteneur DI :Program.cs
appsettings.json
Ressources
NuGet Package
Voir le package sur NuGet Gallery
GitHub Repository
Voir le code source et contribuer
API Reference
Documentation complète de l’API
Discord Community
Obtenez de l’aide et connectez-vous avec les développeurs
Support
Besoin d’aide avec le SDK C# ?- Discord : Rejoignez notre serveur communautaire pour un support en temps réel
- Email : Contactez-nous à support@dodopayments.com
- GitHub : Ouvrez un problème sur le répertoire