> ## Documentation Index
> Fetch the complete documentation index at: https://docs.payglue.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Polar

> Connect Polar as a payment provider in PayGlue.

Polar is the first fully supported payment provider in PayGlue.

## Prerequisites

* A Polar account at [polar.sh](https://polar.sh)
* At least one product created in Polar

## Steps

<Steps>
  <Step title="Add Polar as provider in PayGlue">
    In your PayGlue dashboard, go to **Connection > Polar** and follow the steps.

    <Frame>
      <img src="https://mintcdn.com/payglue/7AYLLS7Kc1n_BHYT/images/payglue-polar.png?fit=max&auto=format&n=7AYLLS7Kc1n_BHYT&q=85&s=9f690f0a0bbed6eb61b394c92b4390a8" alt="Payglue Polar" width="1242" height="967" data-path="images/payglue-polar.png" />
    </Frame>

    <Card title="Onboarding Steps" type="info">
      On the right side, you see important steps to set up your connection to run properly.
    </Card>
  </Step>

  <Step title="Create a Webhook Endpoint in Polar">
    In Polar, go to **Settings > Webhooks > Add Endpoint** and create a new Webhook. Paste the webhook URL from your PayGlue connection page, set **Format** to **Raw**, set expiration to **Never**, and select the required events.

    <Frame>
      <img src="https://mintcdn.com/payglue/7AYLLS7Kc1n_BHYT/images/polar-webhook.png?fit=max&auto=format&n=7AYLLS7Kc1n_BHYT&q=85&s=fee704636b1a90c31557fef0235f0150" alt="Polar Webhook" width="1242" height="967" data-path="images/polar-webhook.png" />
    </Frame>

    <Warning>
      The format has to be **Raw**. The signature Polar sends is calculated over the exact bytes of the payload, so any other format reshapes it on the way and the signature no longer matches. Every delivery then fails verification, and the error looks like a wrong webhook secret rather than a wrong format.
    </Warning>

    <Card title="Events to select" type="info">
      `order.created`, `subscription.active`, `subscription.canceled` and `subscription.revoked`.

      Both `subscription.canceled` and `subscription.revoked` remove the membership, and they are different moments: `canceled` fires when the customer clicks cancel, `revoked` when access should actually end. Enable both so the behaviour follows Polar.
    </Card>
  </Step>

  <Step title="Copy your Webhook Secret">
    After saving the endpoint, you get a webhook secret from polar. We need this secret to communicate safely with Polar to add new member to your ghost blog.

    <Frame>
      <img src="https://mintcdn.com/payglue/7AYLLS7Kc1n_BHYT/images/polar-webhook-secret.png?fit=max&auto=format&n=7AYLLS7Kc1n_BHYT&q=85&s=e18c246ffb01ae7ed6a389edcecc8d8a" alt="Polar Webhook Secret" width="1198" height="923" data-path="images/polar-webhook-secret.png" />
    </Frame>
  </Step>

  <Step title="Optional: Create an API Token in Polar">
    In Polar, go to **Settings > Preferences > Developers** and create a new API token. Set expiration to **Never** and enable the required scopes.

    <Frame>
      <img src="https://mintcdn.com/payglue/7AYLLS7Kc1n_BHYT/images/polar-developer-api-2.png?fit=max&auto=format&n=7AYLLS7Kc1n_BHYT&q=85&s=2ddc1ab722095d637c9dd534a271fa6b" alt="Polar Developer Api" width="1242" height="967" data-path="images/polar-developer-api-2.png" />
    </Frame>

    <Tip>
      This step is optional, but it grants some nice features. Our product auto-fetch. If you decide to add a developer key from Polar to PayGlue, we can automatically fetch all products; no manual copy and paste with product\_IDs is needed anymore.
    </Tip>
  </Step>

  <Step title="Add your webhook secret & (optional) API Token">
    In your PayGlue dashboard, go to **Connection > Polar** and paste your secret & token.

    <Frame>
      <img src="https://mintcdn.com/payglue/7AYLLS7Kc1n_BHYT/images/payglue-polar-connected.png?fit=max&auto=format&n=7AYLLS7Kc1n_BHYT&q=85&s=913bea88e0cd51ec06f5860ec2ea40a6" alt="Payglue Polar Connected" width="1242" height="967" data-path="images/payglue-polar-connected.png" />
    </Frame>
  </Step>

  <Step title="Run a health check">
    When everything works as expected, you get a green status indicator for Connection Established.
  </Step>

  <Step title="Create a test and see if auto-fetch works">
    In your PayGlue dashboard, go to **Installation > Button**. Choose Polar and link to a product to auto-fetch your products.

    <Frame>
      <img src="https://mintcdn.com/payglue/7AYLLS7Kc1n_BHYT/images/payglue-polar-autofetch.png?fit=max&auto=format&n=7AYLLS7Kc1n_BHYT&q=85&s=402aaea60fce2051621f414f1fad7e02" alt="Payglue Polar Autofetch" width="1242" height="967" data-path="images/payglue-polar-autofetch.png" />
    </Frame>
  </Step>
</Steps>
