my-appengineer Courses

How Stripe subscriptions work

Subscriptions with StripeLesson20 min11 / 20

A SaaS lives on recurring revenue. Before you wire payments into Bookwise, you need a clear picture of how subscriptions work at Stripe: which objects exist, which states a subscription moves through, and which events your app must listen to. Get this model right and the code is straightforward. Get it wrong and you will give away access or lock out paying customers.

Where Stripe fits on my-app.engineer

When you plan a build, the blueprint row Payments offers None · Stripe · Mollie. If you picked Stripe for Bookwise, the builder knows your app takes payments through Stripe. You still need your own Stripe account: the money goes to you, and Stripe's terms are between you and Stripe.

The platform also has Till, a separate tool for Stripe accounts, products, payments and bookkeeping "over an API your agent can use to add checkout to any app", with operations such as payment links, a ledger summary and a VAT position. An app connects to Till under Apps → App hub → the app's card → Integrations, which gives the app a venture key. Each venture uses its own Stripe account, whose keys a person adds. Till can create recurring prices (monthly or yearly) and payment links on them, and its webhook books checkout and invoice payments, but it has no "create subscription" operation. In this module you work with Stripe directly, which is the standard path for subscriptions.

Open Till

How it works in your country

Stripe is available in many but not all countries, and the payment methods your customers expect differ: cards everywhere, SEPA Direct Debit and iDEAL in the Netherlands, BLIK and Przelewy24 in Poland, Bacs Direct Debit in the UK. Check Stripe's list of supported countries and payment methods for your business before you build. Mollie is the blueprint's alternative if it suits your market better.

The objects you need to know

Stripe's documentation page "How subscriptions work"
Stripe docs: How subscriptions work

Stripe's How subscriptions work page is the reference. The objects that matter for Bookwise:

ObjectWhat it isBookwise example
ProductWhat you sell"Bookwise"
PriceHow much, how often, in which currency€29 per month; €290 per year
CustomerThe paying party at StripeOne per salon
SubscriptionA customer on a price, renewing automaticallySalon "Studio Lina" on €29/month
InvoiceA bill Stripe creates each periodInvoice for March
Payment methodCard, direct debit, etc. stored for renewalsThe salon's card

One salon equals one Stripe customer. Store the Stripe ids (stripe_customer_id, stripe_subscription_id) on your subscriptions table, as in the data model from module 1. Never store card numbers yourself; Stripe holds them.

The subscription lifecycle

A subscription moves through a predictable set of statuses. The ones you will meet:

StatusMeaningWhat Bookwise does
trialingIn the free trialFull access, show "x days left"
activePaid and runningFull access
incompleteFirst payment needs action or failedNo access yet; show "complete your payment"
incomplete_expiredFirst payment never completedNo access
past_dueA renewal payment failed; Stripe retriesAccess with a banner, for a grace period you choose
unpaid / canceledRetries exhausted or the subscription endedRead-only or no access, data kept for a set period
pausedPaused (for example a trial ending without a payment method, if configured)No access, offer to add a payment method

Check the full and current list in Stripe's docs; the important idea is that your app decides access from the status, and the status comes from Stripe.

Three building blocks that save you weeks

  1. Stripe Checkout: a payment page hosted by Stripe. Your app creates a Checkout Session for a price and redirects the salon owner there. Stripe handles card entry, strong customer authentication (3-D Secure) and local payment methods.
  2. Customer portal: a page hosted by Stripe where customers update their card, download invoices, switch plans and cancel. You configure it in the Stripe dashboard; your app only creates a portal session and redirects.
  3. Webhooks: Stripe sends events to an endpoint in your app when something happens: a checkout completed, an invoice was paid, a payment failed, a subscription changed. This is how your app learns the truth.
Background

With Checkout and the customer portal, you never build a card form and you do not handle card data. That keeps you out of the heaviest security obligations (PCI DSS scope stays minimal) and is the right choice for an MVP.

The events Bookwise listens to

EventWhenWhat the app does
checkout.session.completedOwner finished CheckoutLink the Stripe customer and subscription to the salon
customer.subscription.created / updatedStatus, plan or period changedStore status, price and current_period_end
customer.subscription.deletedSubscription endedMark as canceled, start your data retention clock
invoice.paidA period was paidOptional: record it, send a thank-you
invoice.payment_failedA renewal failedShow a banner, email the owner to update the card
customer.subscription.trial_will_endA few days before the trial endsRemind the owner to add a payment method

Trials and failed payments

For Bookwise the founder chooses a 14-day trial without a card: a salon can try the booking page with real clients before paying. The alternative, a trial that requires a card up front, gets fewer sign-ups but more conversions. The course Subscriptions: onboarding, retention and SaaS metrics compares both.

Failed renewal payments are normal: cards expire, limits are reached. Stripe can retry automatically and send reminder emails; you configure this in the Stripe dashboard under your billing settings (Stripe calls retrying failed payments "dunning" and offers Smart Retries). Decide your grace period: Bookwise keeps the booking page running for 7 days in past_due, because cutting off a salon's bookings on a Saturday creates angry clients for them.

Test mode first

Stripe has a test mode with separate keys and test card numbers (for example 4242 4242 4242 4242 with any future date and any CVC succeeds; Stripe's docs list cards that fail or require authentication). Build and test everything in test mode. You switch to live keys only in the launch module.

Watch out

Stripe gives you a publishable key (can be in the browser) and a secret key (server only). The secret key can move money and read customer data. It never goes into frontend code, a git repository, a screenshot or a chat with anyone, including Claude. Put it in your app's server-side settings or secrets. You set your app's secrets under Apps → App hub → the app's card → Integrations: it finds the environment variable names your app reads, validates the value and connects it; the value is stored in Vault, injected into the app, and the app is restarted.

Let Claude explain your own setup

Ask Claude
I am building [product name], a SaaS for [customers], with Stripe subscriptions: [plans and prices], a [14]-day trial [with/without] card, and a grace period of [7] days when a renewal fails. Explain, as a table, which Stripe subscription statuses my app will see, what access the customer should have in each, and which webhook events move a subscription into that status. Then list the three mistakes founders most often make with subscription webhooks. Refer to Stripe's official docs; do not guess field names you are unsure of.

Bookwise

Bookwise has one product with two prices: €29 per month and €290 per year (two months free). Trials are 14 days without a card. The founder sketched the status table above on paper before writing a single request to the builder, and decided on the grace period with three salon owners from the interviews.

Your task

Create a Stripe account (if you do not have one), stay in test mode, create your product and prices, and write your own status table: for every status, what access your customers get. You will implement it in the next lesson.

This course is general information, not personal legal, tax or financial advice. Rules, amounts and dates change: check the official source for your country before you act.