Polar.sh Payment Integration
Overview
Polar.sh is a Merchant of Record (MoR) platform that handles payment processing, tax collection, and billing. This skill covers the full integration flow: product synchronization, checkout sessions, webhook handling, database schema, and sandbox testing.
Architecture
Products DB → Sync Service → Polar API (Products/Variants/Prices)
↓
Client → Checkout Session → Polar Hosted Flow → Order Created
↓
Polar → Webhook → Application → Update Payment Status → Fulfillment
Quick Reference
Environment Variables
POLAR_ACCESS_TOKEN — Server-side API token (format: polar_oat_*)
POLAR_WEBHOOK_SECRET — Webhook signature verification
NEXT_PUBLIC_POLAR_SANDBOX — Toggle sandbox/production (true or omitted)
Core Flows
- Sync products to Polar before checkout — each product+variant+currency becomes a Polar product
- Create checkout session with line items and metadata — Polar handles the hosted payment UI
- Handle webhooks for order lifecycle events (
order.paid, checkout.expired, etc.)
- Verify signatures using Standard Webhooks spec —
@polar-sh/nextjs handles this automatically
Supported Countries
Polar supports 50+ countries including US, EU, UK, Canada, Australia, Brazil, Mexico, Colombia, Peru, Chile, and others. See Payment Flow for MoR model details.
References
- Payment Flow — Product sync, checkout, multi-currency, error handling, MoR model, localization
- Webhooks & Schema — Webhook events, DB schema, repository patterns, signature verification
- API Reference — Polar REST API essentials (auth, products, checkout, orders)
- Sandbox & Setup — Sandbox environment, API keys, webhook configuration
- Code Examples — Sync, checkout, webhook, cancel, raw API calls
1---2name: 010113-polar-integration3description: Polar.sh payment integration — product sync, checkout, webhooks, multi-currency, MoR model, sandbox testing, and API reference.4license: MIT5---67# Polar.sh Payment Integration89## Overview1011Polar.sh is a Merchant of Record (MoR) platform that handles payment processing, tax collection, and billing. This skill covers the full integration flow: product synchronization, checkout sessions, webhook handling, database schema, and sandbox testing.1213## Architecture1415```16Products DB → Sync Service → Polar API (Products/Variants/Prices)17 ↓18Client → Checkout Session → Polar Hosted Flow → Order Created19 ↓20Polar → Webhook → Application → Update Payment Status → Fulfillment21```2223## Quick Reference2425### Environment Variables26- `POLAR_ACCESS_TOKEN` — Server-side API token (format: `polar_oat_*`)27- `POLAR_WEBHOOK_SECRET` — Webhook signature verification28- `NEXT_PUBLIC_POLAR_SANDBOX` — Toggle sandbox/production (`true` or omitted)2930### Core Flows311. **Sync products** to Polar before checkout — each product+variant+currency becomes a Polar product322. **Create checkout session** with line items and metadata — Polar handles the hosted payment UI333. **Handle webhooks** for order lifecycle events (`order.paid`, `checkout.expired`, etc.)344. **Verify signatures** using Standard Webhooks spec — `@polar-sh/nextjs` handles this automatically3536### Supported Countries37Polar supports 50+ countries including US, EU, UK, Canada, Australia, Brazil, Mexico, Colombia, Peru, Chile, and others. See [Payment Flow](references/payment-flow.md) for MoR model details.3839## References4041- [Payment Flow](references/payment-flow.md) — Product sync, checkout, multi-currency, error handling, MoR model, localization42- [Webhooks & Schema](references/webhooks-schema.md) — Webhook events, DB schema, repository patterns, signature verification43- [API Reference](references/api-reference.md) — Polar REST API essentials (auth, products, checkout, orders)44- [Sandbox & Setup](references/sandbox-setup.md) — Sandbox environment, API keys, webhook configuration45- [Code Examples](references/code-examples.md) — Sync, checkout, webhook, cancel, raw API calls