Dodo Payments Integration
Set up Dodo Payments for your Indie Kit application - API, webhooks, and plan mapping.
Dodo Payments Integration
Set up Dodo Payments for your Indie Kit application.
Initial Setup
- Create a Dodo Payments account
- Set up your business details
- Add required legal documents:
- Privacy Policy
- Terms of Service
- Add these environment variables to
.env(template) and set real values in.env.local:
# Dodo Payments
DODO_PAYMENTS_API_URL="https://test.dodopayments.com"
DODO_PAYMENTS_API_KEY=""
DODO_PAYMENTS_WEBHOOK_SECRET=""For production use https://live.dodopayments.com and your live API key.
Security Note
Never commit API key or webhook secret to your repository. Keep them in .env.local and in your hosting platform's environment variables.
Testing vs Production
Use test.dodopayments.com for testing and live.dodopayments.com for production.
Webhook Setup
-
In Dodo Payments Dashboard, add your webhook endpoint:
https://your-domain.com/api/webhooks/dodo -
For local testing, expose your app with ngrok and use that URL:
ngrok http 3000Then set the webhook URL to
https://your-ngrok-url.ngrok.io/api/webhooks/dodo. -
Enable these webhook events in the dashboard:
- payment.succeeded, payment.failed, payment.processing, payment.cancelled
- refund.succeeded, refund.failed
- dispute.opened, dispute.expired, dispute.accepted, dispute.cancelled, dispute.challenged, dispute.won, dispute.lost
- subscription.created, subscription.active, subscription.on_hold, subscription.renewed, subscription.paused, subscription.cancelled, subscription.failed, subscription.expired
- license_key.created
- customer.created
Important
The kit's webhook handler at /api/webhooks/dodo implements all of these. In production, set DODO_PAYMENTS_WEBHOOK_SECRET so requests are verified.
Plan Mapping
- In Dodo Dashboard, create products (monthly, yearly, one-time) and copy each Product ID.
- Go to super admin:
/super-admin/plans. - For each plan, set:
monthlyDodoProductId– Dodo product ID for monthlyyearlyDodoProductId– Dodo product ID for yearlyonetimeDodoProductId– Dodo product ID for one-time
Product IDs are in Dodo Dashboard under Products → select product.
Subscribe Buttons
Use the getSubscribeUrl helper to build checkout links:
import getSubscribeUrl, { PlanType, PlanProvider } from '@/lib/plans/getSubscribeUrl'
const monthlyUrl = getSubscribeUrl({
codename: plan.codename,
type: PlanType.MONTHLY,
provider: PlanProvider.DODO,
trialPeriodDays: 7
})
const yearlyUrl = getSubscribeUrl({
codename: plan.codename,
type: PlanType.YEARLY,
provider: PlanProvider.DODO,
trialPeriodDays: 14
})
const onetimeUrl = getSubscribeUrl({
codename: plan.codename,
type: PlanType.ONETIME,
provider: PlanProvider.DODO
})Credits Product (Optional)
If you sell credits via Dodo, create a product in Dodo and set in .env.local:
DODO_CREDITS_PRODUCT_ID="your_credits_product_id"Features
- Automatic plan upgrades/downgrades via webhooks
- Dodo-managed billing and customer portal
- Payment and subscription tracking
- Credit purchases with metadata
Best Practices
- Testing: Use ngrok for local webhook tests; verify subscription and one-time flows.
- Production: Set
DODO_PAYMENTS_WEBHOOK_SECRET, use live API URL and key, monitor webhook logs. - Customer experience: Show clear pricing and trial info; link to billing portal for subscription management.
Your Indie Kit app is ready to accept payments and manage subscriptions with Dodo Payments.