BillingJune 11, 202612 min read

Deep SaaS billing tutorial

Stripe Subscription Setup Guide

Stripe subscriptions are more than a checkout button. A SaaS billing system needs products, recurring prices, checkout sessions, webhook handling, customer records, access rules, and a tested customer portal path.

Billing model

Start with products, prices, and access rules.

Before writing code, decide what customers buy and what access each plan unlocks. Stripe products and recurring prices should map to simple application rules.

Create one product for the SaaS or one product per major offering.

Create recurring monthly and annual prices for each tier you plan to sell.

Store Stripe price IDs in environment variables.

Map each price ID to a plan name and access level in your app.

Implementation

Build the subscription flow in order.

Most billing bugs come from skipping lifecycle steps. Implement checkout, return states, webhook persistence, access rules, and customer portal as one connected flow.

Step 1

Create checkout sessions

Use the selected price ID, authenticated user, success URL, cancel URL, and metadata that lets you connect checkout back to the app account.

Step 2

Listen for checkout completion

Use webhook events to connect the Stripe customer and subscription to your user after payment succeeds.

Step 3

Persist subscription state

Store customer ID, subscription ID, plan, status, current period dates, and cancellation state if your app needs them.

Step 4

Gate paid features

Use the mirrored subscription state to decide whether the user can access paid routes, limits, or team features.

Step 5

Open the customer portal

Let customers update payment methods, view invoices, manage subscriptions, or cancel without support tickets.

Step 6

Test every lifecycle path

Test success, cancel, upgrade, downgrade, renewal, failed payment, cancellation, and webhook retry behavior before launch.

Webhook events

Handle asynchronous changes carefully.

A customer can change billing state outside your app. Webhooks keep the application current when invoices, subscriptions, and checkout sessions change.

Area
Common trap
Better path
checkout.session.completed
Confirms checkout finished.
Attach customer and subscription IDs to the app user.
customer.subscription.updated
Plan, status, trial, renewal, or cancellation changed.
Update access and billing state in your database.
customer.subscription.deleted
Subscription ended.
Remove paid access or downgrade the account.
invoice.payment_failed
Renewal payment failed.
Trigger grace-period logic, email, or access policy.

Nexora shortcut

Use a billing-ready starter kit when speed matters.

Nexora includes Stripe-oriented billing surfaces, pricing-page structure, checkout patterns, webhook route structure, and customer portal flow so you can spend less time wiring billing basics.

Pricing to checkout

Connect visible tiers to Stripe price IDs and send users into the correct subscription flow.

Checkout to dashboard

Return users to a product surface where subscription state can unlock the next action.

Portal to retention

Give customers a self-service path to manage billing while your app keeps plan state in sync.

FAQ

Answers for founders comparing the next step.

How do I set up Stripe subscriptions for SaaS?

Create products and recurring prices in Stripe, create checkout sessions from your app, listen for subscription webhooks, store subscription state, gate paid features, and enable the customer portal.

Which Stripe webhooks should a SaaS handle?

Common SaaS webhooks include checkout.session.completed, customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, invoice.paid, and invoice.payment_failed.

Should my app trust checkout redirects or webhooks?

Use redirects for user experience, but use webhooks to persist billing state because subscription and invoice events can happen asynchronously.

Continue from research into useful tools.

Use the free calculators, generators, and planning tools next, then move into product use cases when the idea has sharper shape.