Skip to main content

Checkout Handler

Integrate Dodo Payments checkout into your Fastify 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 Fastify App Router.
Use this handler to integrate Dodo Payments checkout into your Fastify 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.

Paramètres de requête pris en charge

string
requis
Identifiant du produit (par ex., ?productId=pdt_nZuwz45WAs64n3l07zpQR).
integer
Quantité du produit.
string
Nom complet du client.
string
Prénom du client.
string
Nom de famille du client.
string
Adresse e-mail du client.
string
Pays du client.
string
Ligne d’adresse du client.
string
Ville du client.
string
État ou province du client.
string
Code postal du client.
boolean
Désactiver le champ du nom complet.
boolean
Désactiver le champ du prénom.
boolean
Désactiver le champ du nom de famille.
boolean
Désactiver le champ de l’adresse e-mail.
boolean
Désactiver le champ du pays.
boolean
Désactiver le champ de la ligne d’adresse.
boolean
Désactiver le champ de la ville.
boolean
Désactiver le champ de l’État.
boolean
Désactiver le champ du code postal.
string
Spécifier la devise du paiement (par ex., USD).
boolean
Afficher le sélecteur de devise.
number
Fixe le montant facturé, exprimé dans les unités principales de la devise (par ex., 12.5 pour 12,50 $). Uniquement pour les produits Pay What You Want, et ignoré si le montant est inférieur au prix minimum du produit.
boolean
Afficher les champs de remise.
string
Tout paramètre de requête commençant par metadata_ sera transmis en tant que 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 experiences that handle 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 Fastify application.

Query Parameters

string
requis
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

Dernière modification le 6 août 2026