Dodo Payments Integration

Automatically track payments and calculate commissions with Dodo Payments

Overview

Refgrow integrates with Dodo Payments to automatically track payments and calculate commissions for your affiliates.

  • Automatic tracking of one-time payments and subscriptions
  • Support for product-specific commission rates
  • Support for affiliate-specific commission overrides
  • Secure webhook implementation for real-time tracking
  • Works with Dodo Payments' subscription management system

Setting Up Dodo Payments Integration

Note: You'll need a Dodo Payments account to track payments. If you don't have one, sign up here.

Step 1: Configure Webhook

  1. Go to your project's "Integration" tab
  2. Select "Dodo Payments" as your tracking method
  3. Copy the provided webhook URL
  4. In your Dodo Payments dashboard, go to Settings → Webhooks
  5. Create a new webhook with the copied URL
  6. Enable these events: payment.completed, subscription.created, subscription.renewed, subscription.updated, payment.refunded, subscription.canceled
  7. Copy the webhook signing secret from Dodo Payments
  8. Paste the signing secret in Refgrow and click "Save Secret"

Step 2: Choose Your User Flow

Select the appropriate user conversion flow for your business:

  • Click → Signup → Purchase: Users create an account before purchasing
  • Click → Purchase: Users can purchase directly without signing up first
  • Both: Your platform supports both flows

Passing Referral Codes to Dodo Payments

Important: If you have a direct purchase flow (Click → Purchase), passing the referral code to Dodo Payments is essential for correct attribution.

For Dodo Payments

When creating a payment or subscription on your server, pass the referral code in the metadata:

// Example (Node.js Server-Side)
const refCode = req.cookies.refgrow_ref_code; // Get code from cookie

const payment = await dodo.payments.create({
  // ... other payment parameters
  metadata: {
    referral_code: refCode || null // Pass the code here
  }
});

For Dodo Payments Checkout

For checkout sessions, include the referral code in the metadata:

// Example (Node.js Server-Side)
const refCode = req.cookies.refgrow_ref_code; // Get code from cookie

const checkout = await dodo.checkout.create({
  // ... other checkout parameters
  metadata: {
    referral_code: refCode || null // Pass the code here
  }
});
Note: Refgrow will automatically process the referral code from the payment metadata when the webhook is received.

Commission Configuration

Default Commission Settings

Configure your default commission structure in your project settings:

  • Commission Type: Percentage or Fixed Amount
  • Commission Value: The percentage or fixed amount
  • Commission Duration: Lifetime, First Purchase, or Limited Period

Product-Specific Commissions

Override commission rates for specific products:

  1. Go to your project's "Integration" tab
  2. Scroll to "Product-Specific Commissions"
  3. Click "Add Product Commission"
  4. Select a Dodo Payments product and set its unique commission rate
Note: Product-specific rates take priority over your default commission settings.

Affiliate-Specific Overrides

Set custom commission rates for individual affiliates:

  1. Go to your "Affiliates" tab
  2. Find the affiliate you want to customize
  3. Click "Manage Override"
  4. Set a custom commission type and value
Priority: Affiliate-specific overrides take highest priority, followed by product-specific commissions, with default settings as the fallback.

How It Works

1. Referral Click

User clicks an affiliate link and the refgrow_ref_code cookie is set.

2. Dodo Payments

The referral code is passed to Dodo Payments, and the user completes payment.

3. Webhook Processing

Refgrow receives the webhook, attributes the payment, and calculates the commission.

Supported Webhook Events

Refgrow automatically listens for these webhook events:

  • payment.completed - When a one-time payment is completed
  • subscription.created - When a new subscription is created
  • subscription.renewed - When a subscription is renewed
  • subscription.updated - When a subscription is updated
  • payment.refunded - When a payment is refunded
  • subscription.canceled - When a subscription is canceled

Troubleshooting

  1. Verify your webhook signing secret is correctly set in your project settings
  2. Check that the webhook endpoint was created with the correct URL: https://refgrow.com/webhook/dodo/{your-project-id}
  3. Confirm all required events are enabled for the webhook
  4. Check your Dodo Payments dashboard for webhook delivery logs
  5. Ensure the webhook is active and not paused

  1. Ensure the referral code is being passed in the payment metadata
  2. Check that the affiliate with that referral code exists and is active
  3. Verify the referral code format matches exactly (case-sensitive)
  4. Check that the user hasn't been attributed to another affiliate already
  5. Review the webhook payload to confirm the referral code is present

  1. Check your default commission settings in project configuration
  2. Verify product-specific commission overrides if applicable
  3. Check affiliate-specific commission overrides
  4. Ensure the payment amount is greater than zero
  5. Review the webhook payload for correct currency and amount values

  1. Check that the same payment isn't being processed multiple times
  2. Verify webhook retry logic isn't causing duplicates
  3. Review your payment creation flow to prevent duplicate webhooks
  4. Check the conversion logs for duplicate payment IDs

API Reference

Webhook Endpoint

POST https://refgrow.com/webhook/dodo/{project-id}

Required Headers

Content-Type: application/json
dodo-signature: {hmac-sha256-signature}

Webhook Payload Example

{
  "type": "payment.completed",
  "data": {
    "payment": {
      "id": "pay_123456789",
      "amount": 2900,
      "currency": "USD",
      "discount_amount": 0,
      "tax_amount": 290
    },
    "customer": {
      "email": "customer@example.com"
    },
    "product": {
      "id": "prod_123456789"
    },
    "metadata": {
      "referral_code": "ABC123"
    },
    "discount": {
      "code": "SAVE10"
    }
  }
}

Best Practices

Security
  • Always verify webhook signatures
  • Use HTTPS for all webhook endpoints
  • Keep your webhook secrets secure
  • Monitor webhook delivery logs
Reliability
  • Implement webhook retry logic
  • Handle webhook failures gracefully
  • Monitor webhook delivery status
  • Test webhooks in development first

Need Help?

If you're experiencing issues with your Dodo Payments integration:

  • Review your webhook delivery logs in your Dodo Payments dashboard
  • Contact our support team with your project ID and specific error details

Something missing? Suggest a feature