Skip to content

Polar guide

Refenue reads orders from your Polar organization to credit partners. You connect it once per mode with an organization access token: a token from the Polar sandbox for test mode, and from your production organization for live mode.

Create the access token

  1. In Polar, open your organization's Settings, find Developers, and click New token. For test mode, do this on sandbox.polar.sh.
  2. Name it "Refenue" and give it one scope:
ScopeWhy
webhooks:writeSo Refenue can add its own webhook endpoint
  1. Create the token and paste it in Developers → Polar in the Refenue dashboard.

Refenue stores the token encrypted and adds a webhook endpoint to your Polar organization. Each order and subscription arrives in full in the webhook, so Refenue doesn't need to read anything else from your account. If the token has expired, webhooks keep arriving; you only need a working token to disconnect or replace it.

What Refenue does with each event

Polar eventWhat happens
order.paidRecords one sale per order and creates the commission. A $0 order links the customer without a sale
order.refundedReduces the commission in step with the refund
subscription.created, .updated, .active, .canceled, .uncanceled, .revokedTracks the subscription's status. A referred trial is attributed before its first order

Every delivery is stored by its webhook-id before it's processed, and a sale is unique per order, so a webhook Polar sends twice never creates two sales. Developers → Billing events shows the latest events and what Refenue did with each.

Pass the referral to checkout

When you create a checkout from your server, put the referral in its metadata. Polar copies checkout metadata to the order and the subscription:

const checkout = await polar.checkouts.create({
  // ...your existing options
  metadata: { refenue_referral: referral ?? "" },
});

Send window.refenue.referral from the browser with the checkout request. Using a Checkout Link instead? Append ?reference_id=<referral> to it.

How an order is matched to a partner

The first rule that matches wins:

  1. The Polar customer is already linked to a partner, from an earlier order.
  2. A referral id in the order's metadata (refenue_referral or reference_id), or in the Polar customer's metadata (refenue_referral).
  3. The customer's email equals the email of a lead from refenue.signup().
  4. The customer's external id equals the externalId you passed to refenue.signup(). This works well with Polar's external_customer_id.

Once a customer is linked, every renewal follows the same partner for as long as the commission rule lasts. Only a team member can move a customer to another partner.

Amounts and currencies

Commissions are calculated on the order's net_amount: after discounts, before tax, in the order's currency.

Refunds and disputes

  • Full refund before the commission is paid: the commission is reversed.
  • Partial refund, or any refund after it was paid: a negative adjustment comes off the partner's next payout.
  • Disputes: Polar doesn't send dispute webhooks. A dispute Polar settles with a refund arrives as order.refunded.

Product rules

Commission rules for specific products take Polar product ids (UUIDs). Copy one from the product's menu in Polar.

Test mode

Connect a token from the Polar sandbox while the dashboard is in test mode. Test orders in the sandbox then create test commissions, and nothing touches live data or your plan's usage.

Disconnecting

Disconnect in Developers → Polar removes Refenue's webhook endpoint from your Polar organization and deletes the stored token.