Vai al contenuto principale
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 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 da DodoPayments4xxException. Altri tipi di eccezioni:
  • DodoPaymentsIOException: Errori di rete I/O
  • DodoPaymentsInvalidDataException: Impossibilità di interpretare i dati analizzati
  • DodoPaymentsException: Classe base per tutte le eccezioni

Paginazione

Auto-Paginazione

Itera attraverso tutti i risultati su tutte le pagine usando il metodo Paginate, che restituisce un IAsyncEnumerable:

Paginazione Manuale

Integrazione con ASP.NET Core

Registrare il client nel tuo contenitore DI:
Program.cs
appsettings.json
Per lo sviluppo, usa segreti utente invece di memorizzare le chiavi in 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#?
Ultima modifica il 28 maggio 2026