Skip to main content

Checkout Handler

Integrate Dodo Payments checkout into your Express app.

Customer Portal

Allow customers to manage subscriptions and details.

Webhooks

Receive and process Dodo Payments webhook events.

Installation

1

Install the package

Run the following command in your project root:
2

Set up environment variables

Create a .env file in your project root:
Never commit your .env file or secrets to version control.

Route Handler Examples

Use this handler to integrate Dodo Payments checkout into your Express app. Supports static (GET), dynamic (POST), and session (POST) payment flows.

Checkout Route Handler

Dodo Payments supports three types of payment flows for integrating payments into your website, this adaptor supports all types of payment flows.
  • Static Payment Links: Instantly shareable URLs for quick, no-code payment collection.
  • Dynamic Payment Links: Programmatically generate payment links with custom details using the API or SDKs.
  • Checkout Sessions: Create secure, customizable checkout experiences with pre-configured product carts and customer details.

Các tham số truy vấn được hỗ trợ

string
bắt buộc
Mã định danh sản phẩm (ví dụ: ?productId=pdt_nZuwz45WAs64n3l07zpQR).
integer
Số lượng sản phẩm.
string
Họ và tên đầy đủ của khách hàng.
string
Tên của khách hàng.
string
Họ của khách hàng.
string
Địa chỉ email của khách hàng.
string
Quốc gia của khách hàng.
string
Dòng địa chỉ của khách hàng.
string
Thành phố của khách hàng.
string
Tiểu bang/tỉnh của khách hàng.
string
Mã ZIP/mã bưu chính của khách hàng.
boolean
Tắt trường họ và tên.
boolean
Tắt trường tên.
boolean
Tắt trường họ.
boolean
Tắt trường email.
boolean
Tắt trường quốc gia.
boolean
Tắt trường dòng địa chỉ.
boolean
Tắt trường thành phố.
boolean
Tắt trường tiểu bang.
boolean
Tắt trường mã ZIP.
string
Chỉ định đơn vị tiền tệ thanh toán (ví dụ: USD).
boolean
Hiển thị bộ chọn đơn vị tiền tệ.
number
Cố định số tiền được tính, theo đơn vị tiền tệ chính (ví dụ: 12.5 cho $12.50). Chỉ áp dụng cho các sản phẩm Pay What You Want và sẽ bị bỏ qua nếu thấp hơn giá tối thiểu của sản phẩm.
boolean
Hiển thị các trường giảm giá.
string
Mọi tham số truy vấn bắt đầu bằng metadata_ sẽ được truyền dưới dạng metadata.
If productId is missing, the handler returns a 400 response. Invalid query parameters also result in a 400 response.

Response Format

Static checkout returns a JSON response with the checkout URL:

Response Format

Dynamic checkout returns a JSON response with the checkout URL:
Checkout sessions provide a more secure, hosted checkout experience that handles the complete payment flow for both one-time purchases and subscriptions with full customization control.Refer to Checkout Sessions Integration Guide for more details and a complete list of supported fields.

Response Format

Checkout sessions return a JSON response with the checkout URL:

Customer Portal Route Handler

The Customer Portal Route Handler enables you to seamlessly integrate the Dodo Payments customer portal into your Express application.

Query Parameters

string
bắt buộc
The customer ID for the portal session (e.g., ?customer_id=cus_123).
boolean
If set to true, sends an email to the customer with the portal link.
Returns 400 if customer_id is missing.

Webhook Route Handler

  • Method: Only POST requests are supported. Other methods return 405.
  • Signature Verification: Verifies the webhook signature using webhookKey. Returns 401 if verification fails.
  • Payload Validation: Validated with Zod. Returns 400 for invalid payloads.
  • Error Handling:
    • 401: Invalid signature
    • 400: Invalid payload
    • 500: Internal error during verification
  • Event Routing: Calls the appropriate event handler based on the payload type.

Supported Webhook Event Handlers


Prompt for LLM

Lần sửa đổi cuối 6 tháng 8, 2026