Payments and Billing (Stripe)
Monetize without fear.
Goal
Support subscriptions and one-time payments with Stripe.
Stripe modes
- Use test keys locally and live keys in production.
STRIPE_SECRET_KEYandNEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYare required.
One-time purchases vs subscriptions
- Subscriptions power recurring access.
- One-time payments work for repo access or fixed-price offers.
Pricing models supported
- Pricing page and checkout are wired to Stripe.
- You can add plans without reworking the flow.
Checkout flow
- Checkout lives in
workers/app/src/app/(admin)/checkout. - Stripe Elements handles payment collection.
- Promo code validation and total preview are built in.
Webhooks
- Webhooks are handled in
workers/app/src/app/api/stripe/webhooks. - Use the Stripe CLI locally:
npm run stripe-cli --workspace workers/app
Handling upgrades and downgrades
- The baseline supports plan changes; tailor the rules to your pricing.
Trials and demos
- Trials are optional and easy to add.
- Demo mode is supported for product walkthroughs.
Common Stripe errors
- Missing webhook secret.
- Incorrect product or price IDs.
Testing payments locally
- Use Stripe test cards and the CLI webhook forwarder.