Billing
Billing & Stripe
Stripe subscription integration, plans, checkout, and webhooks.
Overview
NextBento includes Stripe for subscription billing with:
- Three plans: Standard, Pro, Ultra
- Monthly and annual billing — 20% discount on annual
- 7-day free trial — No credit card required
- Webhook handling — Subscription lifecycle events
Plans & Pricing
From lib/config/constants.ts:
| Plan | Monthly | Annual (20% off) | Request Limits | Team Members |
|---|---|---|---|---|
| Standard | $29 | ~$279 | 10,000 | 5 |
| Pro | $99 | ~$950 | 100,000 | 10 |
| Ultra | $299 | ~$2,870 | 1,000,000 | 25 |
Customize in constants.ts and create matching Stripe products/prices.
Trial
TRIAL_CONFIG = { durationDays: 7 }
New users get 7 days before payment is required. lib/subscriptions/trial.ts provides isTrialActive().
Checkout Flow
- User clicks "Upgrade" or "Get Started" →
/api/checkoutwithpriceIdanduserId - API creates Stripe Checkout session
- User redirected to Stripe hosted checkout
- On success: redirect to success URL; Stripe sends webhook
- Webhook handler updates
subscriptionstable
Webhook Events
/api/webhooks/stripe handles:
| Event | Action |
|---|---|
checkout.session.completed | Create/update subscription record |
customer.subscription.updated | Update subscription status, plan |
customer.subscription.deleted | Mark subscription canceled |
invoice.paid | Record payment |
invoice.payment_failed | Notify user, optionally restrict access |
Customer Portal
/api/billing/portal creates a Stripe Customer Portal session. Users can:
- Update payment method
- View invoices
- Cancel subscription
Configure the portal in Stripe Dashboard → Settings → Billing → Customer portal.
Key Files
| File | Description |
|---|---|
app/api/checkout/route.ts | Create checkout session |
app/api/webhooks/stripe/route.ts | Handle Stripe webhooks |
app/api/billing/portal/route.ts | Customer portal redirect |
app/api/subscription/current/route.ts | Get current subscription |
lib/subscriptions/ensure-subscription.ts | Ensure user has subscription record |
lib/subscriptions/trial.ts | Trial logic |
lib/stripe/server.ts | Stripe server client |
app/(dashboard)/settings/billing/page.tsx | Billing settings UI |
Next Steps
- Stripe Setup — Configure Stripe
- Environment Variables — Price IDs