Skip to main content

Checkout Sessions

Create a secure, hosted checkout for one-time payments and subscriptions.

Payment Links

Share a URL to collect payments without code.

Webhooks

Listen for payment events and fulfill orders.

API Reference

Full endpoint documentation and live testing.

Prerequisites

Before you start, you need:
  • A Dodo Payments account.
  • At least one product. Create it under Products in the dashboard. A subscription product with a non-zero price must meet the subscription minimum for the currency the customer pays in: $1.00 for USD. Currencies other than USD, EUR, and GBP must also be worth at least $1.00. A $0 subscription is also supported.
  • An API key. Create it under Developer → API Keys and store it in the DODO_PAYMENTS_API_KEY environment variable. Create the key in test mode while you build: the examples on this page use test mode, and a test mode key works only against test mode. See Authentication.
  • The SDK for your language. The Node.js SDK requires Node.js 20 or later, the Python SDK requires Python 3.9 or later, and the Go SDK requires Go 1.22 or later. The cURL examples need no SDK.
The webhook example also uses the standardwebhooks package. Install it with npm install standardwebhooks.

Choose an Integration Path

Overlay and inline checkout run in a web page only. In a native mobile app, create the checkout session on your server and open its checkout_url with a mobile checkout SDK. To have a coding agent build this integration for you, install the Agent Plugin.

Checkout Sessions

Create a secure, hosted checkout experience. You create a session on your server, then redirect the customer to the returned checkout_url.
Each checkout_url works once and expires after 24 hours, or after 15 minutes when you pass confirm: true. With confirm: true, you must also provide every required field. Create a new session for each customer and each payment attempt.

Create a Checkout Session

Redirect to Checkout

After creating a session, redirect the customer to the checkout_url:
For advanced customization, see the full Checkout Sessions guide and the API Reference.

Handle Errors

When a request fails, the API returns an HTTP status code and a JSON body with a code and a message. Branch your error handling on code, not on message. For every code, its cause, and how to resolve it, see Error Codes. A failed payment is reported separately: the payment’s status is failed, its error_code gives the reason, and you receive a payment.failed webhook. To decide whether to retry, see Handle Payment Failures. A payment link is a URL that opens checkout for a product, so you can collect payments without writing code. Query parameters pre-fill customer details and control the checkout form. When a customer opens the link, checkout stores the parameters in a session and shortens the URL to a session parameter, so a page refresh keeps them. A static payment link is a URL you create once and share multiple times. The base URL is:
Add query parameters to customize the checkout:
integer
default:"1"
Number of items to purchase.
string
required
Payment links use redirect_url. The Checkout Sessions API uses return_url for the same purpose.URL to redirect to after payment. Dodo Payments appends the payment details as query parameters, for example https://example.com/?payment_id=pay_ts2ySpzg07phGeBZqePbH&status=succeeded&email=customer%40example.com. If the product issues license keys, a license_key parameter is also appended, with multiple keys separated by commas.
string
Specifies the payment currency. Defaults to the billing country’s currency.
boolean
default:"true"
Show or hide the currency selector.
boolean
default:"true"
Show or hide the discounts section. Set to false to prevent customers from entering coupon codes.
number
Fixes the amount charged, in major currency units, for example 12.5 for $12.50. Works with Pay What You Want products only, and is ignored if it’s below the product’s minimum price.
paymentAmount uses major currency units (12.5 is $12.50). The Checkout Sessions API field product_cart[].amount uses the smallest currency unit (1250 is $12.50). See Dynamic Pricing.
string
Custom metadata fields, for example metadata_orderId=123.

Pre-fill Customer Information

Add customer fields as query parameters to streamline checkout:
string
Customer’s full name (ignored if firstName or lastName is provided).
string
Customer’s first name.
string
Customer’s last name.
string
Customer’s email address.
string
Customer’s country (ISO 3166-1 alpha-2 code).
string
Street address.
string
City.
string
State or province.
string
Postal or ZIP code.

Disable Form Fields

To prevent customers from changing pre-filled information, disable a field by providing its value and setting the corresponding disable... flag to true:
Disabling fields prevents accidental changes and ensures data consistency.
The POST /payments and POST /subscriptions endpoints are deprecated. Use Checkout Sessions instead for new integrations.
For existing integrations using dynamic payment links, pass payment_link: true to Create One-Time Payment or Create Subscription to create a link. The examples below create a one-time payment link. For subscriptions, see the Subscription Integration Guide.

Webhooks

Webhooks tell your server when a payment succeeds or fails, so you can fulfill the order.

Create a Webhook Endpoint

Go to Developer → Webhooks in the dashboard and add your endpoint URL. Copy the endpoint’s signing secret into the DODO_PAYMENTS_WEBHOOK_KEY environment variable. Here’s an example using Next.js:
app/api/webhooks/dodo/route.ts
Our webhook implementation follows the Standard Webhooks specification.

Events to Listen For

At minimum, listen for these events in a one-time payment flow:
Always fulfill on payment.succeeded from the webhook, not on the browser redirect. The redirect can be missed if the customer closes the tab, whereas the webhook is retried until acknowledged.
If you sell products with license keys, also handle license_key.created. For the complete list of events, including subscription, entitlement, credit, recovery, and dunning events, see the Webhook Event Guide. For a complete Next.js and TypeScript example, see the demo repository and its live deployment.

Currency and Billing Address

To charge in a specific currency, pass billing_currency and billing_address.country when you create the checkout session. If you omit them, Adaptive Currency picks the currency and country from the customer’s IP address, which may not be the currency you intend to charge. Pay What You Want amounts are in the product’s base currency, which must be USD, GBP, or EUR. To collect a fixed amount in another currency, use Adaptive Currency, which converts your base price at live exchange rates, or Localized Pricing, which sets a fixed price per currency. Localized Pricing doesn’t work with Pay What You Want.

One-Click Repeat Purchase

To charge a returning customer with a saved payment method, pass its payment_method_id with confirm: true. payment_method_id is accepted only when confirm is true, and you must also pass the existing customer’s customer_id. Because confirm is true, you must also pass a complete billing_address, or only country and zipcode when minimal_address is true. The session charges the saved payment method directly, so it returns no checkout_url. Use webhooks to learn whether the payment succeeded.

Checkout Sessions

Full guide with advanced customization options.

Overlay Checkout

Embed checkout as a modal overlay on your page.

Inline Checkout

Embed checkout directly in your page layout.

Subscription Integration

Set up recurring billing.

Webhook Event Guide

Complete list of all webhook events.

API Reference

Checkout Sessions API documentation.
Last modified on September 30, 2026