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 memerlukan minimal kode ISO dua huruf Country. Gunakan AttachExistingCustomer untuk melampirkan pelanggan yang ada, atau NewCustomer untuk membuatnya. ProductPrice berada dalam denominasi mata uang terendah.Penanganan Error
SDK menghasilkan pengecualian spesifik berdasarkan kode status HTTP. Semua error 4xx mewarisi dariDodoPayments4xxException.
| Status | Pengecualian |
|---|---|
| 400 | DodoPaymentsBadRequestException |
| 401 | DodoPaymentsUnauthorizedException |
| 403 | DodoPaymentsForbiddenException |
| 404 | DodoPaymentsNotFoundException |
| 422 | DodoPaymentsUnprocessableEntityException |
| 429 | DodoPaymentsRateLimitException |
| 5xx | DodoPayments5xxException |
| lainnya | DodoPaymentsUnexpectedStatusCodeException |
DodoPaymentsIOException: Error jaringan I/ODodoPaymentsInvalidDataException: Kegagalan dalam menafsirkan data yang diuraiDodoPaymentsException: Kelas dasar untuk semua pengecualian
Pagination
Auto-Pagination
Iterasi melalui semua hasil di semua halaman menggunakan metodePaginate, yang mengembalikan IAsyncEnumerable:
Pagination Manual
Integrasi ASP.NET Core
Daftarkan klien di container DI Anda:Program.cs
appsettings.json
Sumber Daya
NuGet Package
Lihat paket di Galeri NuGet
GitHub Repository
Lihat kode sumber dan berkontribusi
API Reference
Dokumentasi API lengkap
Discord Community
Dapatkan bantuan dan terhubung dengan pengembang
Dukungan
Perlu bantuan dengan SDK C#?- Discord: Bergabunglah dengan server komunitas kami untuk dukungan real-time
- Email: Hubungi kami di support@dodopayments.com
- GitHub: Buka masalah di repositori