Skip to main content

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:
Never commit your .env file or secrets to version control.

Route Handler Examples

All examples assume you are using the Hono App Router.
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.

Parâmetros de consulta compatíveis

string
obrigatório
Identificador do produto (por exemplo, ?productId=pdt_nZuwz45WAs64n3l07zpQR).
integer
Quantidade do produto.
string
Nome completo do cliente.
string
Nome do cliente.
string
Sobrenome do cliente.
string
Endereço de e-mail do cliente.
string
País do cliente.
string
Linha de endereço do cliente.
string
Cidade do cliente.
string
Estado/província do cliente.
string
Código postal do cliente.
boolean
Desativar o campo de nome completo.
boolean
Desativar o campo de nome.
boolean
Desativar o campo de sobrenome.
boolean
Desativar o campo de e-mail.
boolean
Desativar o campo de país.
boolean
Desativar o campo de linha de endereço.
boolean
Desativar o campo de cidade.
boolean
Desativar o campo de estado.
boolean
Desativar o campo de código postal.
string
Especificar a moeda do pagamento (por exemplo, USD).
boolean
Exibir o seletor de moeda.
number
Fixa o valor cobrado em unidades principais da moeda (por exemplo, 12.5 para US$ 12,50). Apenas para produtos Pay What You Want; ignorado se estiver abaixo do preço mínimo do produto.
boolean
Exibir os campos de desconto.
string
Qualquer parâmetro de consulta que comece com metadata_ será transmitido como 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 Hono application.

Query Parameters

string
obrigatório
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

Última modificação em 6 de agosto de 2026