Accept payments and subscriptions with Polar and Encore. Polar handles monetization as your Merchant of Record. Encore handles infrastructure.
- Polar SDK initialized with an Encore secret
- Checkout endpoint that creates Polar checkout sessions
- Webhook handler that validates signatures and processes subscription events
- Frontend at
/with a checkout form
You'll need a Polar account. For development, use the sandbox dashboard:
- Create a product. Go to Products and create a product. Copy the product ID, you'll paste it in the checkout form.
- Create an access token. Go to Settings > Developers > Personal Access Tokens.
- Create a webhook (optional). Go to Settings > Webhooks. Point it to your API URL followed by
/webhook/polar. For local dev, use ngrok or similar to expose your local server.
-
Install Encore if you haven't already:
curl -L https://encore.dev/install.sh | bash -
Create a new app from this example:
encore app create --example=ts/polar
-
Set your Polar access token:
encore secret set --type local PolarAccessToken
-
Run the app:
encore run
-
Open http://localhost:4000 to create a test checkout. Paste your product ID and enter a test email.