Payments

Drop-in pricing page with checkout, subscription management and webhook-synced state — powered by Dodo Payments and Zod. Configure your plans and ship.

@dodopayments/nextjsdodopayments@prisma/client@prisma/adapter-pgpgdotenvzustandzodprisma@types/pg
shadcn/uibuttonbadgeskeletoncardauto-installed by CLI

Preview

Add these to your .env before installing

The CLI checks for these at install time — missing values mean the database step gets skipped, and the feature won't work until it's added.

  • DATABASE_URLrequired

    PostgreSQL connection string.

    e.g. postgresql://user:pass@localhost:5432/mydb
  • DODO_PAYMENTS_API_KEYrequired

    Dodo API key. Get it from your Dodo dashboard →

  • DODO_PAYMENTS_WEBHOOK_KEYrequired

    Webhook signing secret. Set up your webhook →

  • DODO_PAYMENTS_RETURN_URLrequired

    Post-checkout redirect URL.

    e.g. http://localhost:3000/checkout/success
  • DODO_PAYMENTS_ENVIRONMENTrequired

    test_mode or live_mode.

    e.g. test_mode

Install via CLI

npx feature101@latest add payments

PostInstall Guides

  1. 01Visit /pricing to see the checkout flow, pricing page, and webhook handler in action
  2. 02Fill in your product IDs in features/payments/payment.config.ts
  3. 03Register your products & webhook in the Dodo dashboard pointing to POST /api/webhook/dodo-payments

Data Flow

client

What the user clicks and types.

zustand

Updates the screen instantly, before the server replies.

server

Validates and saves the change securely.

prisma

Your data, permanently written to the database.

Files23
app/api/checkout/route.ts
import { Checkout } from "@dodopayments/nextjs";

// This route handler exists for direct and external integrations
// (e.g. mobile clients, third-party tools, or future use cases that
// can't use server actions). The payments primitive itself calls the
// Dodo SDK directly via createCheckoutSessionAction — this file is
// not in that path.
export const POST = Checkout({
  bearerToken: process.env.DODO_PAYMENTS_API_KEY!,
  returnUrl: process.env.DODO_PAYMENTS_RETURN_URL,
  environment: process.env.DODO_PAYMENTS_ENVIRONMENT as
    | "live_mode"
    | "test_mode"
    | undefined,
  type: "session",
});