Skip to main content

Checkout Handler

Integrate Dodo Payments checkout with static, dynamic, and session flows.

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

All examples assume you are using the Next.js App Router.
Use this handler to integrate Dodo Payments checkout into your Next.js app. Supports static (GET), dynamic (POST), and checkout 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.

Supported Query Parameters

string
requerido
Product identifier (e.g., ?productId=pdt_nZuwz45WAs64n3l07zpQR).
integer
Quantity of the product.
string
Customer’s full name.
string
Customer’s first name.
string
Customer’s last name.
string
Customer’s email address.
string
Customer’s country.
string
Customer’s address line.
string
Customer’s city.
string
Customer’s state/province.
string
Customer’s zip/postal code.
boolean
Disable full name field.
boolean
Disable first name field.
boolean
Disable last name field.
boolean
Disable email field.
boolean
Disable country field.
boolean
Disable address line field.
boolean
Disable city field.
boolean
Disable state field.
boolean
Disable zip code field.
string
Specify the payment currency (e.g., USD).
boolean
Show currency selector.
number
Fixes the amount charged, in major currency units (e.g., 12.5 for $12.50). Pay What You Want products only, and ignored if below the product’s minimum price.
boolean
Show discount fields.
string
Any query parameter starting with metadata_ will be passed as 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:
Dynamic Checkout actúa como proxy para los endpoints obsoletos INLINE_CODE_PLACEHOLDER_387c606e6218254f8_END e POST /subscriptions. Sigue funcionando para las integraciones existentes, pero las nuevas integraciones deben usar Checkout Sessions a continuación.

Formato de respuesta

Dynamic Checkout devuelve una respuesta JSON con la URL de checkout:
Checkout Sessions proporciona una experiencia de checkout alojada y más segura que gestiona todo el flujo de pago, tanto para compras únicas como para suscripciones, con control total de personalización.Consulta la guía de integración de Checkout Sessions para obtener más detalles y una lista completa de los campos compatibles.

Formato de respuesta

Checkout Sessions devuelve una respuesta JSON con la URL de checkout:

Controlador de rutas de Customer Portal

El controlador de rutas de Customer Portal te permite integrar sin problemas el portal de clientes de Dodo Payments en tu aplicación de Next.js.

Parámetros de consulta

string
requerido
El ID del cliente para la sesión del portal (p. ej., ?customer_id=cus_123).
boolean
Si se establece en true, envía un correo electrónico al cliente con el enlace al portal.
Devuelve 400 si falta customer_id.

Controlador de rutas de Webhook

  • Método: Solo se admiten solicitudes POST. Los demás métodos devuelven 405.
  • Verificación de firma: Verifica la firma del webhook mediante webhookKey. Devuelve 401 si la verificación falla.
  • Validación del payload: Se valida con Zod. Devuelve 400 si el payload no es válido.
  • Gestión de errores:
    • 401: Firma no válida
    • 400: Payload no válido
    • 500: Error interno durante la verificación
  • Enrutamiento de eventos: Llama al controlador de eventos adecuado según el tipo de payload.

Controladores de eventos de Webhook compatibles


Prompt para LLM

Última modificación el 21 de agosto de 2026