Dodo Payments
Connect Dodo Payments with an API key and attribute payments and subscriptions.
Connecting Dodo Payments imports your payments, refunds and subscriptions into Trakily and keeps them in sync. Trakily only reads data; it never creates charges or changes anything in your Dodo Payments account. Read Revenue attribution first if you haven't.
1. Create a api key
- 1
Dodo Payments → Developer → API keys → Add API key
- 2
Paste it here (test and live keys are both detected)
Direct link: app.dodopayments.com/developer/api-keys
2. Connect it in Trakily
- 1
Open your site's Settings → Revenue (owners only) and click Connect next to Dodo Payments.
- 2
Paste the api key, then click Connect Dodo Payments. Trakily checks the key.
- 3
The first sync imports your full history in the background. After that, Trakily pulls changes every 15 minutes, and webhooks deliver new payments within seconds.
Keys are encrypted at rest and only used to read payments. Test-mode and live keys both work; a test key only sees test data.
3. Webhook for real-time updates
Dodo Payments webhooks are added by hand. They are optional: without one, new payments still arrive with the next sync (every 15 minutes).
In the Dodo Payments dashboard, open the webhook settings under Developer, add an endpoint with the URL below, subscribe to the events listed, and copy the signing secret.
https://trakily.com/api/webhooks/dodo/pls_…
Events to send:
payment.succeededrefund.succeededsubscription.activesubscription.renewedsubscription.updatedsubscription.plan_changedsubscription.past_duesubscription.on_holdsubscription.pausedsubscription.cancelledsubscription.expiredPaste the endpoint's signing secret into the Webhook card in Settings and click Save (you can also add it while connecting). Every webhook is verified with that secret; requests that don't match are rejected.
4. Pass the visitor id at checkout
Read the ids from Trakily's cookies on your server and pass them as metadata when you create the checkout session. Trakily reads metadata.trakily_visitor_id and metadata.trakily_session_id.
// Read Trakily's ids on your server (Next.js example)
import { cookies } from "next/headers";
const jar = await cookies();
const visitorId = decodeURIComponent(jar.get("_trakily_vid")?.value ?? "").split("|")[0];
const sessionId = jar.get("_trakily_sid")?.value ?? "";
await dodo.checkoutSessions.create({
product_cart: [{ product_id: "<product id>", quantity: 1 }],
metadata: { trakily_visitor_id: visitorId, trakily_session_id: sessionId },
});The keys are always trakily_visitor_id and trakily_session_id. The visitor id is the first part of the _trakily_vid cookie (before the first |); the session id is the _trakily_sid cookie. If the session id is missing, Trakily uses the visitor's latest session before the payment.
Success page detection
When Dodo returns the buyer to your site, the return URL carries payment_id=pay_… for one-time payments or subscription_id=sub_… with a status for subscriptions. The script reports either one from your thank-you page.
Troubleshooting
- “Dodo Payments rejected this API key.” The key is invalid, revoked, or can't read payments. Create a new one.
- Payments arrive but show as unattributed. Pass the visitor id at checkout (step 4). Payments that can't be matched yet are retried every hour for 90 days, so a later identify call can still link them.
- Nothing new since connecting. Click Sync now on the provider card. If the card says Needs attention, the error message tells you what the provider returned (for example a revoked key).