Skip to main content
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

POST /subscriptions (metode subscriptions.create pada SDK) sudah deprecated. Metode ini masih berfungsi untuk integrasi yang sudah ada, tetapi integrasi baru sebaiknya membuat subscription melalui Checkout Session.
Billing memerlukan setidaknya kode ISO dua huruf Country. Gunakan AttachExistingCustomer untuk mengaitkan customer yang sudah ada, atau NewCustomer untuk membuat customer baru. ProductPrice menggunakan denominasi mata uang terkecil.

Penanganan Error

SDK melempar exception tertentu berdasarkan status code HTTP. Semua error 4xx mewarisi DodoPayments4xxException. Jenis exception lainnya:
  • DodoPaymentsIOException: error jaringan I/O
  • DodoPaymentsInvalidDataException: Kegagalan dalam menafsirkan data yang telah di-parse
  • DodoPaymentsException: Class dasar untuk semua exception

Pagination

Auto-Pagination

Iterasikan semua hasil di seluruh halaman menggunakan metode Paginate, yang mengembalikan sebuah IAsyncEnumerable:

Manual Pagination

Integrasi ASP.NET Core

Daftarkan client di container DI Anda:
Program.cs
appsettings.json
Untuk development, gunakan user secrets alih-alih menyimpan key di appsettings.json:

Resources

NuGet Package

Lihat package di NuGet Gallery

GitHub Repository

Lihat source code dan berkontribusi

API Reference

Dokumentasi API lengkap

Discord Community

Dapatkan bantuan dan terhubung dengan developer

Dukungan

Butuh bantuan dengan C# SDK?
Terakhir diubah pada 17 Agustus 2026