Installation
Install the SDK using your package manager of choice:Quick Start
Initialize the client with your API key and start processing payments: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: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:billing yêu cầu tối thiểu mã quốc gia ISO gồm hai chữ cái. customer là một union của { customer_id } (để liên kết customer hiện có) hoặc { email, name? } (để tạo customer mới). product_price được biểu thị theo mệnh giá thấp nhất của currency.Thanh toán dựa trên mức sử dụng
Tiếp nhận sự kiện sử dụng
Theo dõi các event tùy chỉnh cho thanh toán dựa trên mức sử dụng:Các event phải có giá trị
event_id duy nhất để đảm bảo tính idempotency. Các ID trùng lặp trong cùng một request sẽ bị từ chối, còn các request tiếp theo có ID đã tồn tại sẽ bị bỏ qua.Truy xuất sự kiện sử dụng
Lấy thông tin chi tiết về các event sử dụng:Cấu hình proxy
Cấu hình các thiết lập proxy cho các runtime khác nhau:Node.js (sử dụng undici)
Bun
Deno
Logging
Kiểm soát mức độ chi tiết của log bằng environment variables hoặc các tùy chọn của client:'debug'- Hiển thị các debug message, info, warning và error'info'- Hiển thị các info message, warning và error'warn'- Hiển thị warning và error (mặc định)'error'- Chỉ hiển thị error'off'- Tắt toàn bộ logging
Migration từ Node.js SDK
Nếu bạn đang nâng cấp từ Node.js SDK cũ, TypeScript SDK cung cấp khả năng type safety và các tính năng được cải thiện:View Migration Guide
Tìm hiểu cách migration từ Node.js SDK sang TypeScript SDK
Tự động phân trang
Các phương thức list trong DodoPayments API được phân trang. Bạn có thể sử dụng cú phápfor await … of để lặp qua các item trên tất cả các page:
Yêu cầu
Các runtime sau được hỗ trợ:- Trình duyệt web (Chrome, Firefox, Safari, Edge và các trình duyệt khác phiên bản mới nhất)
- Node.js 20 LTS trở lên, với các phiên bản (non-EOL)
- Deno v1.28.0 trở lên
- Bun 1.0 trở lên
- Cloudflare Workers
- Vercel Edge Runtime
- Jest 28 trở lên với environment
"node" - Nitro v2.6 trở lên
Tài nguyên
GitHub Repository
Xem source code và đóng góp
API Reference
Tài liệu API đầy đủ
Discord Community
Nhận trợ giúp và kết nối với các developer
Report Issues
Báo cáo bug hoặc yêu cầu tính năng
Hỗ trợ
Cần trợ giúp với TypeScript SDK?- Discord: Tham gia community server của chúng tôi để nhận hỗ trợ theo thời gian thực
- Email: Liên hệ với chúng tôi qua support@dodopayments.com
- GitHub: Mở issue trên repository