Documentation

Guides and references

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:

PlanMonthlyAnnual (20% off)Request LimitsTeam Members
Standard$29~$27910,0005
Pro$99~$950100,00010
Ultra$299~$2,8701,000,00025

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

  1. User clicks "Upgrade" or "Get Started" → /api/checkout with priceId and userId
  2. API creates Stripe Checkout session
  3. User redirected to Stripe hosted checkout
  4. On success: redirect to success URL; Stripe sends webhook
  5. Webhook handler updates subscriptions table
Stripe Checkout

Webhook Events

/api/webhooks/stripe handles:

EventAction
checkout.session.completedCreate/update subscription record
customer.subscription.updatedUpdate subscription status, plan
customer.subscription.deletedMark subscription canceled
invoice.paidRecord payment
invoice.payment_failedNotify 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.

Stripe Customer Portal

Key Files

FileDescription
app/api/checkout/route.tsCreate checkout session
app/api/webhooks/stripe/route.tsHandle Stripe webhooks
app/api/billing/portal/route.tsCustomer portal redirect
app/api/subscription/current/route.tsGet current subscription
lib/subscriptions/ensure-subscription.tsEnsure user has subscription record
lib/subscriptions/trial.tsTrial logic
lib/stripe/server.tsStripe server client
app/(dashboard)/settings/billing/page.tsxBilling settings UI

Next Steps