Polar
View as MarkdownConnect Polar with an organization access token or Connect with Polar, set up the webhook, and pass the visitor id in checkout metadata.
On this page
Reveata imports Polar orders, refunds and subscriptions, and receives new ones through a Polar webhook. There are two ways to connect.
Option 1: Connect with Polar
Shown on the Polar card when it is available.
- Open your website's Settings → Payments, choose Polar under Pick your payment provider, then Connect with Polar.
- Polar asks you to approve access. Pick only the organization this website sells through: an approval that covers several organizations is refused, so Reveata never mixes two businesses.
- You come straight back to Reveata. The webhook is created for you, and the import starts.
Reveata asks Polar for read access to your organization, orders, subscriptions and refunds, plus webhook management so it can add and remove its own endpoint. Access renews itself; Disconnect removes the endpoint and revokes the approval in Polar.
Option 2: an organization access token
- In Polar, open your organization's Settings and create an Organization Access Token (it starts with
polar_oat_). Give it read access to orders, subscriptions and refunds. Add the webhooks:write scope if you want Reveata to create the webhook itself. - In Reveata, choose Polar, paste the token into Organization access token and select Connect Polar (or Use an API key instead if the card offers Connect with Polar first).
- With webhooks:write, the endpoint is created for you. Without it, add it by hand: in Polar, open Settings → Webhooks, add an endpoint with the URL Reveata shows on the card, choose the Raw format, select the events below, and paste the endpoint's secret into the card (Save secret). You can also paste the secret in Webhook secret while connecting.
order.paid
order.updated
order.refunded
refund.created
refund.updated
subscription.created
subscription.updated
subscription.active
subscription.canceled
subscription.uncanceled
subscription.revoked
subscription.past_dueA token that can see several organizations is refused: use an organization token, which covers exactly one.
What counts
- Paid orders are revenue, without tax. Subscription cycles after the first are renewals and keep the first payment's source.
- Refunds are booked as negative revenue on the day they happen, with the order's source.
- Subscriptions feed MRR, churn, upgrades and downgrades.
- Polar is the merchant of record, so chargebacks are handled by Polar and are not taken out of your revenue.
On connect, Reveata imports the last 12 months; the card shows the progress.
Pass the visitor id
Add the ids to the checkout metadata when your server creates the checkout. Polar copies checkout metadata onto the order and the subscription, where Reveata reads it:
// browser: send the ids with the request that creates the checkout
await fetch('/api/checkout', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ productId, ...window.reveata.metadata() }),
});// server (Node.js, @polar-sh/sdk)
const checkout = await polar.checkouts.create({
products: [body.productId],
successUrl: 'https://example.com/thanks',
metadata: {
reveata_visitor_id: body.reveata_visitor_id,
reveata_session_id: body.reveata_session_id,
},
});Reveata looks for reveata_visitor_id, reveata_session_id and reveata_user_id in the order's metadata, its custom field data and the customer's metadata. Your server can also read the ids from the _dt_v and _dt_s cookies: see Stripe Checkout for parsers in several languages.
Checkout links you share without creating a checkout on your server carry no metadata. Those orders are matched by the buyer's email for visitors you identify.
Check it works
- Open your site in a private window from a link ending in
?ref=test. - Buy your cheapest product, and refund it afterwards if you like: the refund is booked against the same source. A free order is not a payment, so it does not show up.
- The order appears under Revenue with the source
test. Last delivery on the Polar card shows the webhook arrived; if it says None received yet, check the endpoint's format is Raw.
A webhook delivered twice is processed once, and each order is stored once under its Polar id. See Why payments are never counted twice.