Stripe Setup (Billing)
NextGenKit includes Stripe subscriptions, customer portal, and webhook-driven sync out of the box.
1. Create Stripe Products
- Go to Stripe Dashboard → Products
- Create two products: Pro and Business
- For each product, create two prices: Monthly and Annual
- Copy the Price IDs to your
.env.local
2. Configure Customer Portal
- Go to Settings → Billing → Customer Portal
- Enable subscription cancellation and plan switching
- Save the configuration
3. Set Up Webhooks
- Go to Developers → Webhooks
- Add endpoint:
https://your-domain.com/api/webhooks/stripe - Subscribe to events:
checkout.session.completedcustomer.subscription.updatedcustomer.subscription.deletedinvoice.payment_failed
- Copy the Signing Secret to
STRIPE_WEBHOOK_SECRET
4. Local Webhook Testing
# Install Stripe CLI, then:
pnpm stripe:listen
# This forwards events to localhost:3000/api/webhooks/stripe
Plan Gating
Use requirePlan() from lib/billing/gate.ts to restrict features by plan:
import { requirePlan } from "@/lib/billing/gate"
// In a server action or route handler:
await requirePlan("pro") // throws if user is on free plan