Langsung ke konten utama
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.

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:
Always store your API keys securely using environment variables, user secrets, or Azure Key Vault. Never hardcode them in your source code or commit them to version control.

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

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 using WithOptions:

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 dari DodoPayments4xxException. Jenis pengecualian lainnya:
  • DodoPaymentsIOException: Error jaringan I/O
  • DodoPaymentsInvalidDataException: Kegagalan dalam menafsirkan data yang diurai
  • DodoPaymentsException: Kelas dasar untuk semua pengecualian

Pagination

Auto-Pagination

Iterasi melalui semua hasil di semua halaman menggunakan metode Paginate, yang mengembalikan IAsyncEnumerable:

Pagination Manual

Integrasi ASP.NET Core

Daftarkan klien di container DI Anda:
Program.cs
appsettings.json
Untuk pengembangan, gunakan rahasia pengguna daripada menyimpan kunci di 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#?
Terakhir diubah pada 28 Mei 2026