Back to blog
April 28, 2026Tutorial

The Stripe billing flow that every Lovable app should steal

💳
The Lovestack team
11 min read

Stripe is straightforward. Wiring it into a Lovable app *correctly* — webhooks, portal, trials, plan changes — is where everyone slips. Here's the pattern that holds up.

The four moving parts

  • Products & prices — defined in Stripe, never hardcoded in your app. Read them by metadata key.
  • Checkout sessions — created server-side. Pass the user ID in client_reference_id so the webhook knows who paid.
  • Webhooks — your source of truth for subscription state. Don't trust the client redirect, ever.
  • Customer Portal — let users manage themselves. One Stripe link, zero billing UI to build.

The minimum schema

subscriptions(
id, user_id, stripe_subscription_id,
stripe_customer_id, price_id,
status, current_period_end,
cancel_at_period_end, created_at
)

Every webhook event updates this table. Every gate in your app reads from it. No duplication, no drift.

The prompt

“Add Stripe subscriptions with monthly and yearly plans. Use Stripe Checkout for purchase, Stripe Customer Portal for management. Create a subscriptions table that mirrors Stripe state and is updated by a webhook handler at /api/stripe/webhook. Gate the /app routes behind an active subscription.”