Connect
- In Polar, create an organization access token under Settings → Developers, with the
webhooks:writeandorders:readscopes. Production and sandbox tokens both work. - Paste it (
polar_oat_…) into Setup → Payments → Polar.
DataPenny creates the webhook and never stores the token.
By hand
Add an endpoint under Settings → Webhooks with the format set to Raw, pointing at https://YOUR-DATAPENNY-URL/api/webhooks/polar/YOUR_SITE_ID. Subscribe to order.paid and order.refunded, then paste the signing secret (whsec_…) under Connect by hand.
Checkouts
Checkout links (buy.polar.sh/…) are tagged by the script. It sets reference_id, unless you’ve set your own.
Checkout sessions you create with the API need the visitor id in metadata:
metadata: { datapenny_visitor_id: visitorId }
A success URL with ?checkout_id={CHECKOUT_ID} is used as a fallback.
Import past sales
The import needs a token with the orders:read scope, so the one from above works. It’s used while the import runs and isn’t stored.