Hoppa till huvudinnehåll

Checkout API Route

Integrate Dodo Payments checkout into your Nuxt app using a server route.

Customer Portal API Route

Allow customers to manage subscriptions and details via a Nuxt server route.

Webhooks API Route

Receive and process Dodo Payments webhook events securely in Nuxt.

Overview

This guide explains how to integrate Dodo Payments into your Nuxt application using the official Nuxt module. You’ll learn how to set up checkout, customer portal, and webhook API routes, and how to securely manage environment variables.

Installation

1

Install the Nuxt module

Run the following command in your project root:
2

Register the module in nuxt.config.ts

Add @dodopayments/nuxt to your modules array and configure it:
nuxt.config.ts
Never commit your .env file or secrets to version control.

API Route Handler Examples

All Dodo Payments integrations in Nuxt are handled via server routes in the server/routes/api/ directory.
Use this handler to integrate Dodo Payments checkout into your Nuxt app. Supports static (GET), dynamic (POST), and session (POST) payment flows.
If productId is missing or invalid, the handler returns a 400 response.

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

productId
string
obligatorisk
Product identifier (e.g., ?productId=pdt_nZuwz45WAs64n3l07zpQR).
quantity
integer
Quantity of the product.
fullName
string
Customer’s full name.
firstName
string
Customer’s first name.
lastName
string
Customer’s last name.
email
string
Customer’s email address.
country
string
Customer’s country.
addressLine
string
Customer’s address line.
city
string
Customer’s city.
state
string
Customer’s state/province.
zipCode
string
Customer’s zip/postal code.
disableFullName
boolean
Disable full name field.
disableFirstName
boolean
Disable first name field.
disableLastName
boolean
Disable last name field.
disableEmail
boolean
Disable email field.
disableCountry
boolean
Disable country field.
disableAddressLine
boolean
Disable address line field.
disableCity
boolean
Disable city field.
disableState
boolean
Disable state field.
disableZipCode
boolean
Disable zip code field.
paymentCurrency
string
Specify the payment currency (e.g., USD).
showCurrencySelector
boolean
Show currency selector.
paymentAmount
integer
Specify the payment amount (e.g., 1000 for $10.00).
showDiscounts
boolean
Show discount fields.
metadata_*
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:

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 Nuxt application.

Query Parameters

customer_id
string
obligatorisk
The customer ID for the portal session (e.g., ?customer_id=cus_123).
send_email
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

Senast ändrad 22 maj 2026