Billing & Stripe
Stripe powers subscription billing from the dashboard Billing page.
- Create products and prices in the Stripe Dashboard
- Add keys to
.env:
STRIPE_SECRET_KEY=sk_test_...STRIPE_WEBHOOK_SECRET=whsec_...NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...STRIPE_STARTER_PRICE_ID=price_...STRIPE_PRO_PRICE_ID=price_...Checkout
Section titled “Checkout”Server actions on /app/billing create Stripe Checkout sessions. Successful checkouts are synced to the subscription table via webhooks.
Webhooks
Section titled “Webhooks”Point Stripe to:
http://localhost:3000/app/api/webhooks/stripeUse the Stripe CLI for local testing:
stripe listen --forward-to localhost:3000/app/api/webhooks/stripeCustomer portal
Section titled “Customer portal”Users with an active subscription can open the Stripe Customer Portal from the billing page to manage payment methods and cancel plans.