Prerequisites

Before you begin, make sure you have:

Boilerplate Setup

Clone our Next.js boilerplate to get started quickly:

git clone https://github.com/dodopayments/dodo-nextjs-minimal-boilerplate
cd dodo-nextjs-minimal-boilerplate
npm install

The boilerplate includes all necessary dependencies and basic setup for Dodo Payments integration.

Integration Options

Choose your integration path:

One-Time Payment Product Integration

Learn how to implement one-time payments in your application:

Key Steps

Subscription Payment Product Integration

Learn how to implement subscription payments:

Key Steps

Webhook Integration

Set up webhooks to handle asynchronous events:

import { verifyWebhookSignature } from '@dodopayments/node';

export default async function handler(req, res) {
  const signature = req.headers['dodo-signature'];
  const payload = req.body;
  
  try {
    verifyWebhookSignature({
      payload,
      signature,
      secret: process.env.WEBHOOK_SECRET
    });
    
    // Handle webhook event
    switch (payload.type) {
      case 'payment.succeeded':
        // Handle successful payment
        break;
      case 'subscription.created':
        // Handle new subscription
        break;
      // ... handle other events
    }
    
    res.status(200).json({ received: true });
  } catch (err) {
    res.status(400).json({ error: 'Invalid signature' });
  }
}

Testing

Before going live:

  1. Use test API keys
  2. Test with test card numbers
  3. Verify webhook handling
  4. Test error scenarios

Common Integration Issues

Next Steps

Need Help?