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 richiede almeno il codice ISO a due lettere Country. Usa AttachExistingCustomer per collegare un cliente esistente o NewCustomer per crearne uno. ProductPrice è nella denominazione più bassa della valuta.Gestione degli Errori
L’SDK lancia eccezioni specifiche in base al codice di stato HTTP. Tutti gli errori 4xx ereditano daDodoPayments4xxException.
| Stato | Eccezione |
|---|---|
| 400 | DodoPaymentsBadRequestException |
| 401 | DodoPaymentsUnauthorizedException |
| 403 | DodoPaymentsForbiddenException |
| 404 | DodoPaymentsNotFoundException |
| 422 | DodoPaymentsUnprocessableEntityException |
| 429 | DodoPaymentsRateLimitException |
| 5xx | DodoPayments5xxException |
| altri | DodoPaymentsUnexpectedStatusCodeException |
DodoPaymentsIOException: Errori di rete I/ODodoPaymentsInvalidDataException: Impossibilità di interpretare i dati analizzatiDodoPaymentsException: Classe base per tutte le eccezioni
Paginazione
Auto-Paginazione
Itera attraverso tutti i risultati su tutte le pagine usando il metodoPaginate, che restituisce un IAsyncEnumerable:
Paginazione Manuale
Integrazione con ASP.NET Core
Registrare il client nel tuo contenitore DI:Program.cs
appsettings.json
Risorse
NuGet Package
Visualizza pacchetto su NuGet Gallery
GitHub Repository
Visualizza codice sorgente e contribuisci
API Reference
Documentazione completa API
Discord Community
Ottieni aiuto e connettiti con gli sviluppatori
Supporto
Hai bisogno di aiuto con l’SDK C#?- Discord: Unisciti al nostro server della community per supporto in tempo reale
- Email: Contattaci a support@dodopayments.com
- GitHub: Apri una segnalazione sul repository