Billing
Lemon Squeezy
Lemon Squeezy integration for checkout and subscription management.
Setup
- Create a Lemon Squeezy account at lemonsqueezy.com
- Create a store and products
- Set environment variables:
LEMONSQUEEZY_API_KEY=""
LEMONSQUEEZY_STORE_ID=""
LEMONSQUEEZY_WEBHOOK_SECRET=""- Copy variant IDs to
config/billing.config.ts
Lemon Squeezy uses the REST API directly — no SDK dependency required.
API routes
| Route | Method | Purpose |
|---|---|---|
/api/lemonsqueezy/checkout | POST | Create a checkout session |
/api/lemonsqueezy/webhook | POST | Handle webhook events |
Webhook setup
- In the Lemon Squeezy dashboard, go to Settings > Webhooks
- Add a webhook URL:
https://yourdomain.com/api/lemonsqueezy/webhook - Set a signing secret and copy it to
LEMONSQUEEZY_WEBHOOK_SECRET - Subscribe to events:
order_created,order_refunded,subscription_created,subscription_updated,subscription_cancelled,subscription_payment_success,subscription_payment_failed
For local development, use a tunneling service like ngrok or Cloudflare Tunnel to expose your local server.
Service functions
Helper functions are available in lib/services/lemonsqueezy-service.ts for creating checkout sessions and verifying webhook signatures.