Subscriptions & proration
Run tiered subscriptions with 0% ExaSpark platform fee — including mid-cycle upgrades, proration rules, self-serve cancellations, and failed-payment recovery.
How recurring billing and 0% ExaSpark fees work
Every recurring app built on ExaSpark connects directly to your own Stripe account. ExaSpark charges a 0% platform fee on every monthly renewal, annual upgrade, and seat expansion — standard Stripe card processing fees still apply, and settled revenue transfers straight from Stripe to your bank.
Stripe owns payment methods, invoices, and renewal timers. Your ExaSpark Cloud database stores a clean subscriptions projection updated strictly via cryptographically signed Stripe webhooks.
Checking that local table on every server request keeps feature gating fast and never stalls on external billing API calls.
Designing multi-tier and seat-based pricing
Choose a pricing model aligned with customer value, and map every Stripe Price ID explicitly to an internal plan code on your backend.
| Pattern | Best fit for | Mechanics | Example |
|---|---|---|---|
| Flat tiers | Solo SaaS tools, member portals | Fixed monthly/annual fee unlocking quotas | Free ($0), Starter ($19/mo), Pro ($49/mo) |
| Annual toggle | Stronger cash flow and retention | Annual price offers ~2 months free | $19/month or $180/year |
| Seat billing | B2B client portals, agencies | Per-seat price multiplied by workspace quantity | $12/seat/month (min 3 seats) |
Never infer a user's tier from raw dollar strings or browser parameters. Keep one authoritative server-side lookup map from Stripe price_id to plan limits:
{
"price_live_starter_mo": { "plan": "starter", "interval": "month", "max_projects": 10, "csv_export": false },
"price_live_starter_yr": { "plan": "starter", "interval": "year", "max_projects": 10, "csv_export": false },
"price_live_pro_mo": { "plan": "pro", "interval": "month", "max_projects": 100, "csv_export": true },
"price_live_pro_yr": { "plan": "pro", "interval": "year", "max_projects": 100, "csv_export": true }
}Keep Test and Live Price IDs separate via environment settings so Preview always runs against Stripe Test mode. See Preview vs Live isolation.
Upgrades, downgrades, and how proration works
Subscribers upgrade mid-cycle the moment they hit a quota. Proration calculates unused credit from the old plan against remaining time on the new plan.
If a $19/month Starter subscriber upgrades to $49/month Pro halfway through a 30-day cycle:
- Unused Starter credit:
-$9.50(15 days left) - Remaining Pro cost:
+$24.50(15 days left) - Net charge:
$15.00for the current cycle, then$49.00on next renewal.
| `proration_behavior` | How Stripe bills | Recommended use |
|---|---|---|
| `always_invoice` | Charges net proration immediately | Upgrades — clears payment before instant unlock |
| `create_prorations` | Batches credits/debits onto next invoice | Seat edits — avoids tiny repeated charges |
| `none` (period end) | Switches at current_period_end with no mid-cycle refund | Downgrades — lets users finish paid time |
Handling downgrades without deleting user data
Never delete a subscriber's projects or records when they downgrade. If a Pro user with 18 projects drops to Starter (limit 10), keep all 18 readable, show a calm limit notice (18 / 10), and block creating a new project until they archive down or upgrade.
Switching between monthly and annual cycles
When a monthly subscriber switches to an annual plan inside the Customer Portal, Stripe starts a new 12-month cycle immediately, credits their unused monthly days toward the annual invoice, and sends customer.subscription.updated with the annual price_id and updated current_period_end.
Always allow seamless monthly-to-annual upgrades while scheduling annual-to-monthly downgrades for current_period_end. That policy prevents unexpected partial annual refunds and keeps cash flow predictable while honoring every day already paid.
Self-serve billing with the Stripe Customer Portal
Manual card swaps, invoice requests, and cancellation emails waste founder time and trigger avoidable disputes. Route a single Manage billing button straight to Stripe's hosted Customer Portal.
Configure Portal rules in Stripe
Enable card updates, invoice downloads, allowed plan switches, and cancel-at-period-end in Stripe → Billing → Customer portal.
Block duplicate subscriptions
Before creating a new Checkout Session, check
subscriptions. Route already-active subscribers to the Customer Portal instead.Build an authenticated portal route
Look up
users.stripe_customer_idfrom the server session and return a short-lived portal session pointing back to/settings/billing.Sync changes via webhooks
Update
plan_code,status,current_period_end, andcancel_at_period_endwhenevercustomer.subscription.updatedorcustomer.subscription.deletedarrives.Verify every flow in Preview
Upgrade, downgrade, cancel, and reactivate in Stripe Test mode while confirming Cloud table state.
Recovering failed renewals (dunning and grace periods)
Even loyal subscribers hit failed renewals from expired cards or bank fraud filters. Handling past_due calmly preserves recurring revenue.
Keeping access calm during Smart Retries
Enable Stripe Smart Retries so Stripe automatically retries failed renewals over several days. When invoice.payment_failed arrives, set status = 'past_due' instead of locking users out immediately.
Show a slim account banner ("Renewal failed — update your card to keep Pro active") linking to the Customer Portal, and send one branded alert via Transactional email flows.
- Retry succeeds:
invoice.paidflipsstatusback toactiveand clears the banner. - Retries exhaust:
customer.subscription.deletedcleanly downgrades the account tocanceled.
Cancel at period end vs immediate cancellation
When a subscriber cancels in the Customer Portal, Stripe sets cancel_at_period_end = true while keeping status = 'active' through current_period_end. Display the exact end date and keep Pro unlocked until customer.subscription.deleted fires.
Build multi-tier Stripe subscriptions: Free ($0, 3 projects), Starter ($19/mo or $180/yr, 10 projects), and Pro ($49/mo or $480/yr, unlimited projects and CSV exports). Map Stripe `price_id` values server-side, route active subscribers to Stripe Customer Portal instead of creating duplicate Checkouts, and handle `checkout.session.completed`, `invoice.paid`, `invoice.payment_failed`, `customer.subscription.updated`, and `customer.subscription.deleted` idempotently. Keep `past_due` access open with a slim update-card banner, display the exact end date when `cancel_at_period_end` is true, and keep existing projects readable on downgrade while blocking new creation above the lower limit.
Troubleshooting subscription and proration edge cases
| Symptom | Most likely root cause | Reliable fix |
|---|---|---|
| Portal upgrade stayed locked | Webhook missed customer.subscription.updated or price_id map | Map all monthly/annual price_id values and update plan_code on update |
| User billed on two active plans | Upgrade button launched fresh Checkout instead of Portal | Check active subscriptions server-side and redirect to Customer Portal |
| Lost access right after cancel | UI treated cancel_at_period_end as immediate revoke | Grant access while status IN ('trialing', 'active'); revoke on canceled |
| Seat edits fired tiny charges | Quantity updates used always_invoice on every seat add | Use create_prorations so seat deltas batch onto the next invoice |
| Live checkout hit `No such price` | Test mode price_... IDs left in Live config | Create Live products/prices in Stripe Live Dashboard and update Live IDs |