Add Payments with Lemon Squeezy
Integrate Lemon Squeezy into your Next.js app to accept payments, manage subscriptions, and handle licensing. A simpler alternative to Stripe with built-in tax handling.
Why Lemon Squeezy
Lemon Squeezy acts as the merchant of record, meaning they handle VAT, sales tax, and compliance automatically. This makes it ideal for solo developers and small teams who want to sell software without dealing with tax complexity. Unlike Stripe, you don't need separate tax software or an accountant to go global. It supports one-time payments, subscriptions, and software licenses out of the box.
Setting Up Your Lemon Squeezy Account
Create an account at lemonsqueezy.com and set up your store with your business details. Create a product — either a one-time purchase or a subscription plan — and note the variant ID from the product URL. Generate an API key from your dashboard settings and store it as LEMONSQUEEZY_API_KEY in your environment variables. Add your webhook signing secret as LEMONSQUEEZY_WEBHOOK_SECRET for secure event handling.
Creating Checkout Sessions
Install the official SDK with `npm install @lemonsqueezy/lemonsqueezy.js`. Create an API route that calls `createCheckout` with your store ID, variant ID, and customer details. Pass a `checkoutOptions` object to pre-fill the customer's email and set redirect URLs for success and cancellation. Return the checkout URL to the client and redirect the user to complete payment on Lemon Squeezy's hosted checkout.
Handling Webhooks
Lemon Squeezy sends webhook events for order completions, subscription changes, and payment failures. Create a POST endpoint at `/api/webhooks/lemonsqueezy` that verifies the signature using the raw request body and your signing secret. Parse the event type and handle `order_created` to provision access and `subscription_cancelled` to revoke it. Store order and subscription data in your database tied to the user's account.
Managing Subscriptions
Use the Lemon Squeezy API to retrieve a customer's active subscriptions and display their plan status in your app. Implement a customer portal link using `getSubscription` and `updateSubscription` so users can manage billing without contacting support. Store the `lemon_squeezy_customer_id` on your user record to look up subscription status quickly. Poll the API or rely on webhooks to keep your local subscription state in sync.
Testing and Going Live
Enable test mode in your Lemon Squeezy dashboard and use the provided test card numbers to simulate purchases. Verify your webhook handler receives and processes events correctly before switching to live mode. Ensure your success and cancel redirect URLs work end-to-end with a real user flow. Once confirmed, switch your API keys to production and remove any test mode flags from your code.
Need help with this?
Our team handles add features for AI-built apps every day. Get a fixed quote within 24 hours.
Start with a self-serve audit
Get a professional review of your app at a fixed price.
Security Scan
Black-box review of your public-facing app. No code access needed.
- OWASP Top 10 checks
- SSL/TLS analysis
- Security headers
- Expert review within 24h
Code Audit
In-depth review of your source code for security, quality, and best practices.
- Security vulnerabilities
- Code quality review
- Dependency audit
- AI pattern analysis
Complete Bundle
Both scans in one package with cross-referenced findings.
- Everything in both products
- Cross-referenced findings
- Unified action plan
100% credited toward any paid service. Start with an audit, then let us fix what we find.
Related guides
How to Add Stripe Payments to Your AI-Built App
Step-by-step guide to adding Stripe payments to your vibe coded app.
Production Readiness Checklist for AI-Built Apps
The complete checklist before launching any AI-generated app.
How to Add Authentication to Your AI-Built App
Add secure user login to your vibe coded app.
Related technologies
Need help with your app?
Tell us about your project. We'll respond within 24 hours with a clear plan and fixed quote.