# Polar

> Connect Polar to atrby so each paid order is matched to the visit that brought it, with checkout metadata and refunds.

Canonical: https://atrby.site/docs/integrations/polar
Last updated: 2026-10-21

Attribute every Polar payment to the visit that brought it.

## Connect

1. In Polar, open Settings → Webhooks → Add endpoint and copy its **secret**.
2. In atrby, open Revenue → Payment processors → Connect, choose Polar and paste the secret.
3. atrby shows your webhook URL. It looks like `https://app.atrby.site/api/webhooks/polar/…`. Add it in Polar and send these events: `order.paid`, `order.refunded`.

The connection shows as active once the first webhook arrives. Webhooks with a wrong signature are rejected.

## Pass the visit ids

Where they go: Checkout `metadata`, which Polar copies to the order. Read them in the browser with `atrby.ids()` and send them to your server with the checkout request.

*Browser*

```js
const ids = window.atrby?.ids(); // { atrby_sid, atrby_site }
```

*Server · Polar checkout*

```js
await polar.checkouts.create({
  products: [productId],
  metadata: { ...ids, atrby_uid: user.id },
});
```

`atrby_uid` is your user id, from [identify](https://atrby.site/docs/identify). It's optional, but it credits payments made long after the first visit.

## What gets recorded

- Each payment once, however often Polar retries the webhook.
- Full and partial refunds are subtracted from the source of the original order.

## Related
- [Stripe](https://atrby.site/docs/integrations/stripe)
- [Lemon Squeezy](https://atrby.site/docs/integrations/lemon-squeezy)
- [Payment API](https://atrby.site/docs/payment-api)
