Polar is another hosted checkout provider supported by the repo. If you have
never worked with payments before, the key idea is simple: users pay on
Polar’s checkout page, then Polar tells your app what happened through a
webhook.
What You Are Setting Up
To make Polar work with this repo, you need:- products inside Polar
- checkout links that your users can click
- a webhook endpoint that Polar can call
- a way for the repo to know what each product means
Required Env Vars
Step 1: Create Products In Polar
Start by creating the products you want to sell in Polar. For a first setup, keep it simple:- one Enterprise product
- one Small credits product
anotherwrapper-enterprise or credits-small.
Step 2: Create Checkout Links
Once your products are ready, create the hosted checkout links in Polar. Then add them to.env.local, for example:
Step 3: Tell The Repo What Each Polar Product Means
You have two ways to do that.Option A: Put type In Metadata
If your Polar order or product metadata includes something like:
Option B: Use POLAR_PRODUCT_MAP
If you prefer to keep the mapping in env, use:
Step 4: Add The Webhook In Polar
In Polar, add this webhook endpoint:What Happens After A Successful Polar Payment
When Polar sends a successful webhook:- the repo verifies the webhook signature
- it reads the purchase type from metadata or
POLAR_PRODUCT_MAP - it stores the purchase in the
purchasestable - it tries to match the purchase to a user
- it updates credits or purchase state
Simple Example
Imagine you sell one credits pack in Polar. You might set:- the checkout button sends them to Polar
- Polar charges them
- Polar calls your webhook
- the repo recognizes
credits-small - the repo adds the correct number of credits
Verification Checklist
Your Polar setup is working if:- the app opens the Polar checkout page
- Polar shows a successful webhook delivery
- a row appears in
purchases - a credits purchase increases the user’s credits
- a plan purchase updates the user’s access state
Common Polar Mistakes
- creating the product but not saving the checkout URL in env
- configuring checkout but not configuring the webhook
- forgetting to map the Polar product to a valid purchase type
- changing env vars without restarting the app
- testing with the wrong domain in the webhook URL
Payments Overview
Go back to the shared payment fundamentals and repo-wide setup.

