Metrivo
Docs/Dodo Payments

Dodo Payments billing setup

Use this guide for Metrivo app subscription billing. Customer payment attribution webhooks still use the per-integration URL generated inside Data Connections.

Secrets stay server-side

Do not prefix Dodo API keys or webhook secrets with NEXT_PUBLIC. The browser only receives hosted checkout or portal URLs returned by Metrivo server routes.

Dashboard setup

  1. 1. In Dodo Payments, create subscription products for Starter, Growth, and Business monthly/yearly intervals.
  2. 2. Copy each product ID used by checkout and map it to the six Metrivo env vars below.
  3. 3. Go to Developer > Webhooks, add a webhook, and enter this endpoint:
https://metrivo.co/api/webhooks/dodo/billing

Select only the subscription events Metrivo handles: subscription.active, subscription.updated, subscription.renewed, subscription.plan_changed, subscription.on_hold, subscription.paused, subscription.cancelled, subscription.failed, subscription.expired, payment.cancelled, payment.failed. Copy the webhook signing secret from the Dodo webhook details page into DODO_WEBHOOK_SECRET.

Vercel environment variables

DODO_API_KEY
DODO_WEBHOOK_SECRET
DODO_PRICE_STARTER_MONTHLY
DODO_PRICE_STARTER_YEARLY
DODO_PRICE_GROWTH_MONTHLY
DODO_PRICE_GROWTH_YEARLY
DODO_PRICE_BUSINESS_MONTHLY
DODO_PRICE_BUSINESS_YEARLY
NEXT_PUBLIC_APP_URL

Optional: set DODO_ENVIRONMENT=test for Dodo test mode and DODO_CUSTOMER_PORTAL_RETURN_URL to override the portal back button.

Plan mapping

starterStarter monthly$9/monthDODO_PRICE_STARTER_MONTHLY
starterStarter yearly$90/yearDODO_PRICE_STARTER_YEARLY
growthGrowth monthly$14/monthDODO_PRICE_GROWTH_MONTHLY
growthGrowth yearly$140/yearDODO_PRICE_GROWTH_YEARLY
businessBusiness monthly$19/monthDODO_PRICE_BUSINESS_MONTHLY
businessBusiness yearly$190/yearDODO_PRICE_BUSINESS_YEARLY

Enterprise/custom is coming soon and does not create checkout sessions.

Test mode verification

  1. 1. Set Dodo test API keys and test product IDs in Vercel, then redeploy.
  2. 2. Open Metrivo billing settings, choose Starter, Growth, or Business, and complete Dodo checkout.
  3. 3. In Dodo Developer > Webhooks > Testing, send a subscription.active test event.
  4. 4. In Supabase, inspect the subscriptions row for the workspace. Confirm plan, status, dodo_customer_id, dodo_subscription_id, current_period_end, and last_webhook_event_id updated.
  5. 5. Use the Manage subscription button in Metrivo billing settings to open the Dodo customer portal and test cancellation or payment method updates.

Customer payment attribution

This page covers Metrivo subscription billing. If a customer wants to connect their own Dodo checkout for revenue attribution, use Data Connections to create a Dodo integration and copy its per-integration webhook URL.

For high-confidence attribution, pass the Metrivo checkout metadata through your Dodo checkout or payment metadata. Metrivo reads metrivo_visitor_id and metrivo_session_id from signed Dodo webhooks and leaves the payment unattributed if the evidence is missing.

// Client: capture this before opening checkout
const metadata = window.Metrivo.getAttributionMetadata()

// Server: include the object in your Dodo checkout/payment metadata
await createDodoCheckout({
  product_id: "prod_123",
  customer: { email: "customer@example.com" },
  metadata: {
    ...metadata,
    plan: "growth"
  }
})