Indie Kit DocsIndie Kit Docs

Dodo Payments Integration

Learn how to set up Dodo Payments in your Indie Kit application

Dodo Payments Integration 💳

Let's set up Dodo Payments for your Indie Kit application! 🚀

Initial Setup ⚡

  1. Create a Dodo Payments account

  2. Set up your business details

  3. Add required legal documents:

    • Privacy Policy
    • Terms of Service
  4. Add these environment variables to your .env file:

    # Dodo Payments Configuration
     DODO_PAYMENTS_API_KEY=xxx... # From Dodo Payments API keys
     DODO_PAYMENTS_WEBHOOK_SECRET=whsec_xxx... # From Dodo Payments webhook settings
     DODO_PAYMENTS_API_URL="https://live.dodopayments.com" # Or test.dodopayments.com for testing
    

    🔒 Security Note: Never commit these keys to your repository. In production, add them securely to your hosting platform's environment variables.

    💡 Testing vs Production: Make sure to use the correct API URL for your environment.

Product Configuration 🛍️

In your Dodo Payments Dashboard:

  1. Create Products with pricing:
    • Monthly subscriptions
    • Yearly subscriptions
    • One-time payments
  2. Customer Portal:
    • Already enabled by default

Webhook Setup 🔌

  1. Add your webhook endpoint in Dodo Payments Dashboard:

    https://your-domain.com/api/webhooks/dodo
  2. Enable these webhook events:

  • 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
  • license_key.created
  • customer.created

💡 Important: All these events are required for proper subscription management. They handle:

  • Customer creation and management
  • Subscription lifecycle (creation, updates, deletion)
  • Invoice payments
  1. For local testing, use ngrok:
    # Forward webhooks to your local server
    ngrok http 3000

Plan Mapping 🗺️

  1. Go to your super admin dashboard: /super-admin/plans
  2. For each plan, add the corresponding Dodo Payments Price IDs:
    • monthlyDodoPriceId
    • yearlyDodoPriceId
    • onetimeDodoPriceId

💡 Tip: Find Price IDs in Dodo Payments Dashboard under Products → Select Product

Adding Subscribe Buttons 🔘

Use the getSubscribeUrl helper to create subscription links:

import getSubscribeUrl, { PlanType, PlanProvider } from '@/lib/plans/getSubscribeUrl'
 
function PricingCard({ plan }) {
  // Monthly subscription with 7-day trial
  const monthlyUrl = getSubscribeUrl({
    codename: plan.codename,
    type: PlanType.MONTHLY,
    provider: PlanProvider.DODO,
    trialPeriodDays: 7
  })
 
  // Yearly subscription with 14-day trial
  const yearlyUrl = getSubscribeUrl({
    codename: plan.codename,
    type: PlanType.YEARLY,
    provider: PlanProvider.DODO,
    trialPeriodDays: 14
  })
 
  // One-time payment
  const onetimeUrl = getSubscribeUrl({
    codename: plan.codename,
    type: PlanType.ONETIME,
    provider: PlanProvider.DODO
  })
 
  return (
    <div className="pricing-card">
      <h2>{plan.name}</h2>
      <div className="buttons">
        {plan.hasMonthlyPricing && (
          <Link href={monthlyUrl}>
            <Button>Subscribe Monthly</Button>
          </Link>
        )}
        {plan.hasYearlyPricing && (
          <Link href={yearlyUrl}>
            <Button>Subscribe Yearly</Button>
          </Link>
        )}
        {plan.hasOnetimePricing && (
          <Link href={onetimeUrl}>
            <Button>Buy Lifetime</Button>
          </Link>
        )}
      </div>
    </div>
  )
}

Features Available 🎯

  • 🔄 Automatic plan upgrades/downgrades
  • 💳 Dodo Payments-managed billing
  • 🏪 Customer portal for subscription management
  • ⚡ Webhook handling
  • 🔍 Payment tracking
  • 📊 Usage monitoring

Best Practices 💡

  1. Testing

    • Use ngrok for local webhook testing
    • Test all subscription flows
    • Verify upgrade/downgrade paths
  2. Production

    • Add all required legal documents
    • Configure proper webhook security
    • Monitor webhook events
    • Set up alerts for failed payments
  3. Customer Experience

    • Clear pricing information
    • Smooth upgrade flow
    • Easy access to billing portal
    • Clear trial period information

Now your Indie Kit application is ready to accept payments and manage subscriptions through Dodo Payments! 🎉

On this page