الانتقال إلى المحتوى الرئيسي
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

كود_نهاية_PLACEHOLDER_78c679659965a0d5

Manage Customers

Handle Subscriptions

Error Handling

The SDK throws specific exceptions based on the HTTP status code. All 4xx errors inherit from DodoPayments4xxException. Other exception types:
  • DodoPaymentsIOException: I/O networking errors
  • DodoPaymentsInvalidDataException: Failure to interpret parsed data
  • DodoPaymentsException: Base class for all exceptions

Pagination

Auto-Pagination

Iterate through all results across all pages using the Paginate method, which returns an IAsyncEnumerable:

Manual Pagination

ASP.NET Core Integration

Register the client in your DI container:
Program.cs
appsettings.json
For development, use user secrets instead of storing keys in appsettings.json:

Resources

NuGet Package

View package on NuGet Gallery

GitHub Repository

View source code and contribute

API Reference

Complete API documentation

Discord Community

Get help and connect with developers

Support

Need help with the C# SDK?
آخر تعديل في ٢٨ مايو ٢٠٢٦