Deploy DodoPayments webhooks to Netlify Functions.
- 🔒 Webhook verification - Secure signature checking using DodoPayments library
- 🔄 Idempotency - Prevents duplicate processing with webhook IDs
- 📊 Event logging - Complete audit trail in database
⚠️ Error handling - Logged failures with retry support
Note: This implementation demonstrates handling three core subscription events (
subscription.active,subscription.cancelled,subscription.renewed) with minimal fields. You can easily extend it to support additional event types and fields based on your requirements.
npm install -g netlify-clinetlify loginThis will open your browser to authenticate with your Netlify account.
You'll need a PostgreSQL database. We recommend Neon for serverless PostgreSQL.
Create the tables:
- Sign up for Neon
- Create a new project
- Open the SQL Editor
- Copy and paste the contents of
schema.sql - Run the query
Get your connection string:
- Go to your Neon project → Connection string
- Copy the connection string
npm installnetlify env:set DATABASE_URL "your-neon-connection-string"
netlify env:set DODO_PAYMENTS_API_KEY "your-api-key"Note: We'll set
DODO_PAYMENTS_WEBHOOK_KEYafter deployment once you have your webhook URL.
netlify initnpm run deployYour webhook URL is:
https://[your-project].netlify.app/.netlify/functions/webhook
- Go to DodoPayments Dashboard → Developer → Webhooks
- Create a new webhook endpoint
- Configure your webhook URL as the endpoint
- Enable these subscription events:
subscription.activesubscription.cancelledsubscription.renewed
- Copy the Signing Secret
netlify env:set DODO_PAYMENTS_WEBHOOK_KEY "your-webhook-signing-key"
npm run deploynpm run devYour webhook will be available at http://localhost:8888/.netlify/functions/webhook
| Variable | Required | Description |
|---|---|---|
DATABASE_URL |
Yes | Neon PostgreSQL connection string |
DODO_PAYMENTS_API_KEY |
Yes | API key for DodoPayments client |
DODO_PAYMENTS_WEBHOOK_KEY |
Yes | Webhook signing key for verification |
After deployment, your webhook URL will be at:
https://[your-site-name].netlify.app/.netlify/functions/webhook
Configure this URL in your DodoPayments dashboard.
This implementation uses the dodopayments library for secure webhook signature verification.
Features:
- ✅ HMAC-SHA256 signature verification
- ✅ Automatic timestamp validation (5-minute tolerance)
- ✅ Replay attack prevention
- ✅ Constant-time comparison
Important: Always set both DODO_PAYMENTS_API_KEY and DODO_PAYMENTS_WEBHOOK_KEY in production.