This tutorial demonstrates integrating Dodo Payments into a Next.js app using the Node.js SDK for One-Time and Subscription Products. It utilizes the Dodo Next.js Minimal Boilerplate and covers essential steps to get started efficiently.
git clone https://github.com/dodopayments/dodo-nextjs-minimal-boilerplate cd dodo-nextjs-minimal-boilerplate npm install
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' }); } }
Was this page helpful?