# Test and troubleshoot Polar (https://talivia.com/docs/revenue-guides/polar/testing-and-troubleshooting)



Start with the [shared payment testing setup](https://talivia.com/docs/revenue-guides/testing-payment-providers), then use the Polar-specific connection and attribution checks below.

## Connection checklist [#connection-checklist]

In Polar, create an Organization Access Token for the correct organization with these permissions:

* Checkout Read;
* Orders Read;
* Organization Read;
* Products Read;
* Subscription Read;
* Webhook Write.

In **Website settings → Revenue → Polar**, paste the token, then select **Connect Polar**. Talivia detects the token's organization and whether it belongs to production or sandbox, validates every permission, creates the signed webhook, imports the previous 30 days of orders, and syncs subscription state.

You do not need to copy a webhook secret or create an OAuth application.

## End-to-end test [#end-to-end-test]

1. Create a separate Talivia website and connect a Polar Sandbox organization there.
2. Open checkout from a tracked browser session.
3. Complete an order with Polar's sandbox payment flow.
4. Confirm the payment appears in Talivia with provider **Polar**.
5. Open the payment and verify its session, source, entry page, and amount.
6. Create a refund in Polar and confirm the same payment's refunded amount is updated.

## Payment is unattributed [#payment-is-unattributed]

For Checkout API, inspect the created checkout and confirm `metadata.talivia_session_id` equals the value returned by `window.talivia.getSessionId()`.

For Checkout Links and Embedded Checkout, confirm the Polar success URL is a tracked page and contains:

```text
checkout_id={CHECKOUT_ID}
```

For subscriptions or custom flows, confirm Polar's customer `external_id` matches the `externalCustomerId` sent to `window.talivia.identify`.

## Connection fails [#connection-fails]

* **Organization not found:** confirm the token has Organization Read and was created as an Organization Access Token.
* **Permission error:** recreate or update the token with every permission in the checklist.
* **Webhook error:** confirm Webhook Write is enabled and reconnect; Talivia will repair or recreate its endpoint.
* **Production versus sandbox:** Talivia detects the environment from the token automatically. Keep
  sandbox and production in separate Talivia websites so their revenue is not mixed.
