Checkout Handler
Integrate Dodo Payments checkout into your Hono 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:Route Handler Examples
All examples assume you are using the Hono App Router.
- Checkout Handler
- Customer Portal Handler
- Webhook Handler
Use this handler to integrate Dodo Payments checkout into your Hono app. Supports static (GET), dynamic (POST), and session (POST) 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.
Static Checkout (GET)
Static Checkout (GET)
Parámetros de consulta compatibles
string
requerido
Identificador del producto (p. ej.,
?productId=pdt_nZuwz45WAs64n3l07zpQR).integer
Cantidad del producto.
string
Nombre completo del cliente.
string
Nombre del cliente.
string
Apellido del cliente.
string
Dirección de correo electrónico del cliente.
string
País del cliente.
string
Línea de dirección del cliente.
string
Ciudad del cliente.
string
Estado o provincia del cliente.
string
Código postal del cliente.
boolean
Deshabilitar el campo de nombre completo.
boolean
Deshabilitar el campo de nombre.
boolean
Deshabilitar el campo de apellido.
boolean
Deshabilitar el campo de correo electrónico.
boolean
Deshabilitar el campo de país.
boolean
Deshabilitar el campo de línea de dirección.
boolean
Deshabilitar el campo de ciudad.
boolean
Deshabilitar el campo de estado.
boolean
Deshabilitar el campo de código postal.
string
Especificar la moneda del pago (p. ej.,
USD).boolean
Mostrar el selector de moneda.
number
Fija el importe cobrado en unidades principales de la moneda (p. ej.,
12.5 para 12,50 $). Solo para productos Pay What You Want; se ignora si es inferior al precio mínimo del producto.boolean
Mostrar los campos de descuento.
string
Cualquier parámetro de consulta que comience por
metadata_ se pasará como metadata.Response Format
Static checkout returns a JSON response with the checkout URL:Dynamic Checkout (POST)
Dynamic Checkout (POST)
- Send parameters as a JSON body in a POST request.
- Supports both one-time and recurring payments.
- For a complete list of supported POST body fields, refer to:
Response Format
Dynamic checkout returns a JSON response with the checkout URL:Checkout Sessions (POST)
Checkout Sessions (POST)
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 Hono application.Query Parameters
string
requerido
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.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.