Skip to main content
The TypeScript SDK provides convenient server-side access to the Dodo Payments REST API for TypeScript and JavaScript applications. It features comprehensive type definitions, error handling, retries, timeouts, and auto-pagination for seamless payment processing.

Installation

Install the SDK using your package manager of choice:

Quick Start

Initialize the client with your API key and start processing payments:
Always store your API keys securely using environment variables. Never commit them to version control or expose them in client-side code.

Core Features

TypeScript First

Full TypeScript support with comprehensive type definitions for all API endpoints

Auto-Pagination

Automatic pagination for list responses makes working with large datasets effortless

Error Handling

Built-in error types with detailed messages for different failure scenarios

Smart Retries

Configurable automatic retries with exponential backoff for transient errors

Configuration

Environment Variables

Set environment variables for secure configuration:
.env

Timeout Configuration

Configure request timeouts globally or per-request:

Retry Configuration

Configure automatic retry behavior:
The SDK automatically retries requests that fail due to network errors or server issues (5xx responses) with exponential backoff.

Common Operations

Create a Checkout Session

Generate a checkout session for collecting payment information:

Manage Customers

Create and retrieve customer information:

Handle Subscriptions

Create and manage recurring subscriptions:
POST /subscriptions(SDKのsubscriptions.createメソッド)は非推奨です。既存のインテグレーションでは引き続き動作しますが、新しいインテグレーションではCheckout Sessionを通じてサブスクリプションを作成してください。
billingには、少なくとも2文字のISO国コードが必要です。customerは、既存の顧客を紐付ける{ customer_id }、または新しい顧客を作成する{ email, name? }のいずれかです。product_priceは、通貨の最小単位で指定します。

使用量ベースのBilling

使用量イベントの取り込み

使用量ベースのBilling用にカスタムイベントを追跡します:
イベントには、冪等性を確保するために一意のevent_id値を設定する必要があります。同一リクエスト内で重複するIDは拒否され、既存のIDを含む後続のリクエストは無視されます。

使用量イベントの取得

使用量イベントの詳細情報を取得します:

Proxyの設定

さまざまなランタイム向けにProxy設定を構成します:

Node.js(undiciを使用)

Bun

Deno

ロギング

環境変数またはクライアントオプションを使用して、ログの詳細度を制御します:
利用可能なログレベル:
  • 'debug' - デバッグメッセージ、情報、警告、エラーを表示
  • 'info' - 情報、警告、エラーを表示
  • 'warn' - 警告とエラーを表示(デフォルト)
  • 'error' - エラーのみを表示
  • 'off' - すべてのロギングを無効化
デバッグレベルでは、ヘッダーとボディを含むすべてのHTTPリクエストとレスポンスがログに記録されます。一部の認証ヘッダーはマスキングされますが、ボディ内の機密データは表示される可能性があります。

Node.js SDKからの移行

従来のNode.js SDKからアップグレードする場合、TypeScript SDKでは型安全性と機能が向上しています:

View Migration Guide

Node.js SDKからTypeScript SDKへの移行方法

自動ページネーション

DodoPayments APIのListメソッドはページネーションに対応しています。for await … of構文を使用すると、すべてのページにわたって項目を反復処理できます:
また、一度に1ページずつリクエストすることもできます:

要件

以下のランタイムがサポートされています:
  • Webブラウザー(最新のChrome、Firefox、Safari、Edgeなど)
  • Node.js 20 LTS以降の(non-EOL)バージョン
  • Deno v1.28.0以降
  • Bun 1.0以降
  • Cloudflare Workers
  • Vercel Edge Runtime
  • "node"環境でのJest 28以降
  • Nitro v2.6以降
TypeScript >= 4.9がサポートされています。

リソース

GitHub Repository

ソースコードを確認して貢献する

API Reference

APIドキュメントをすべて確認する

Discord Community

ヘルプを受け、開発者とつながる

Report Issues

バグを報告する、または機能をリクエストする

サポート

TypeScript SDKについてサポートが必要ですか?

コントリビューション

コントリビューションを歓迎します!開始するには、コントリビューションガイドラインを確認してください。
最終更新日 2026年8月17日