Polar is a payment platform built specifically for developers selling to developers. It offers GitHub integration, simple pricing, and a developer-friendly experience.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/revokslab/shipfree/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- A Polar account (sign up here)
- Your ShipFree application running locally or deployed
- (Optional) A GitHub repository for integration
Setup Instructions
Step 1: Get Your API Keys
- Log in to Polar
- Navigate to Settings → API
- Create a new Access Token
- Copy the access token (starts with
polar_) - Note your Organization ID
Step 2: Create Products
Polar uses a product-based pricing model.- Go to Products in your Polar dashboard
- Click Create Product
- For each plan (Starter, Pro, Enterprise):
- Set the product name
- Set the description
- Configure pricing:
- Price: Amount in USD
- Billing interval: Monthly or Yearly
- Recurring: Yes for subscriptions
- Set the product visibility
- Save and copy the Product ID
Step 3: Configure Environment Variables
Add these variables to your.env file:
Polar currently focuses on monthly billing. If you need yearly billing, create separate products for annual plans.
Step 4: Set Up Webhooks
Polar sends webhooks to notify your application about subscription and payment events.For Local Development
Use a tool like ngrok to expose your local server:-
Install ngrok:
-
Start your development server:
-
In another terminal, start ngrok:
-
Copy the HTTPS forwarding URL (e.g.,
https://abc123.ngrok.io) - In Polar dashboard, go to Settings → Webhooks
-
Add webhook endpoint:
- URL:
https://abc123.ngrok.io/api/webhooks/payments - Events: Select all subscription and payment events
- URL:
-
Save the webhook secret to your
.env
For Production
- Go to Settings → Webhooks in Polar dashboard
- Click Add Endpoint
-
Set the endpoint URL:
https://yourdomain.com/api/webhooks/payments -
Select events to listen for:
subscription.createdsubscription.updatedsubscription.canceledorder.paidcustomer.createdcustomer.updated
- Click Create
- Copy the Webhook Secret and add it to your production environment variables
Testing in Development
Sandbox Mode
Polar provides a sandbox environment for testing. SetPOLAR_ENVIRONMENT=sandbox in your .env.
Test Checkout Flow
-
Start your development server and ngrok:
- Configure webhook URL in Polar dashboard with your ngrok URL
- Navigate to your pricing page
- Click on a plan to create a checkout session
- Complete the checkout in sandbox mode
- Verify webhook events are received in your application logs
Testing Subscriptions
Polar provides test mode for subscriptions:Polar Implementation Details
The Polar adapter is implemented insrc/lib/payments/providers/polar.ts.
Key Features
Checkout Sessions
Creates Polar checkout sessions with:- Product-based pricing
- Customer metadata (userId, plan)
- Trial periods (if configured)
- Custom success URLs
Customer Management
Polar creates customers automatically during checkout. The adapter handles:- Customer creation during checkout flow
- Linking customers to user records
- Storing customer metadata
Unlike Stripe, Polar doesn’t require explicit customer creation before checkout. Customers are created automatically when they complete a purchase.
Subscription Handling
The adapter provides:- Subscription retrieval by ID
- Status mapping to unified status format
- Support for cancellation at period end
Webhook Processing
The adapter processes these Polar webhook events:customer.created,customer.updatedsubscription.created,subscription.updated,subscription.canceledorder.paid
Customer Portal
Polar provides a customer portal for managing subscriptions:Polar’s customer portal is different from Stripe’s. It’s hosted at
polar.sh/customer/{customerId} and provides basic subscription management.GitHub Integration
One of Polar’s unique features is GitHub integration. You can:- Link products to GitHub repositories
- Grant repository access based on subscription
- Use GitHub Sponsors integration
- Display products on your GitHub README
- Go to Settings → GitHub in Polar dashboard
- Connect your GitHub account
- Link repositories to products
- Configure access permissions
Going Live
Pre-Launch Checklist
- Set
POLAR_ENVIRONMENT=production - Update
POLAR_ACCESS_TOKENwith production token - Create live products in Polar dashboard
- Update environment variables with live product IDs
- Configure production webhook endpoint
- Set up webhook secret for production
- Test complete checkout flow
- Verify GitHub integration (if applicable)
Security Best Practices
- Protect access tokens: Keep
POLAR_ACCESS_TOKENserver-side only - Validate webhooks: Always verify webhook signatures
- Use HTTPS: Polar requires HTTPS for production webhooks
- Handle errors: Don’t expose API errors to users
- Monitor webhooks: Check webhook logs regularly
Troubleshooting
Webhook Not Received
- Verify ngrok is running (for local dev)
- Check webhook endpoint is accessible (test with curl)
- Review webhook logs in Polar dashboard
- Ensure
POLAR_WEBHOOK_SECRETmatches dashboard - Check application logs for errors
Checkout Session Fails
- Verify
POLAR_ACCESS_TOKENis set correctly - Check that product IDs exist in Polar dashboard
- Ensure products are active and published
- Review error logs for specific error messages
- Check network tab in browser dev tools
Subscription Not Found
- Ensure subscription was created successfully
- Verify subscription ID format
- Check that webhook was processed
- Review database for subscription records
GitHub Integration Issues
- Verify GitHub account is connected in Polar
- Check repository access permissions
- Ensure product is linked to correct repository
- Review GitHub app installation logs
Polar vs Other Providers
When to Choose Polar
✅ Choose Polar if you:- Are selling developer tools or APIs
- Want GitHub integration
- Prefer a developer-first experience
- Are building open-source monetization
- Want simpler setup than Stripe
- Need extensive payment methods (credit cards, wallets, etc.)
- Require advanced billing features (metered usage, complex pricing)
- Need a merchant of record
- Want maximum payment customization
Feature Comparison
| Feature | Polar | Stripe | Lemon Squeezy |
|---|---|---|---|
| GitHub Integration | ✅ | ❌ | ❌ |
| Developer Focus | ✅ | ⚠️ | ⚠️ |
| Setup Complexity | Low | High | Medium |
| Fees | Competitive | 2.9% + $0.30 | 5% + processing |
| Payment Methods | Basic | Extensive | Good |
| Customer Portal | Basic | Advanced | Good |
| Tax Handling | Manual | Manual | Automatic (MoR) |
Additional Resources
Support
For Polar-specific issues: For ShipFree integration issues:- Check the source code in
src/lib/payments/providers/polar.ts - Review webhook handling in
src/app/api/webhooks/payments/route.ts