Revenue
Dodo Payments
Checkout sessions and payment links.
1. Add the webhook
In Dodo Payments, Developer, Webhooks, add this endpoint and subscribe to payment.succeeded and refund.succeeded:
Endpoint
https://earnedstats.com/api/webhooks/dodo/YOUR_SITE_ID2. Paste the signing secret
It starts with whsec_. Paste it in Settings, Revenue, Dodo Payments.
3. The visitor id
server.js
const session = await dodo.checkoutSessions.create({
product_cart: [{ product_id: 'pdt_xxx', quantity: 1 }],
return_url: 'https://example.com/thanks',
metadata: { es_visitor_id: body.es_visitor_id ?? '' },
});Payment links on your pages get the id added by the script when clicked.
Tip
Set the product's return URL to a page on your site. Dodo adds ?payment_id= to it, which links the payment to the exact visitor even when metadata does not come through.