All posts
June 9, 2026 · Snapdock

How Do I Add Subscriptions and Recurring Billing?

You built something with Claude, ChatGPT, Bolt, or Lovable and you want users to pay monthly or annually rather than once. A subscription model. Recurring…

You built something with Claude, ChatGPT, Bolt, or Lovable and you want users to pay monthly or annually rather than once. A subscription model. Recurring billing that charges automatically every month without requiring users to pay again manually. In an earlier post we covered one-time payments with Stripe. Subscriptions use the same platform but with a different setup. Here is exactly how to build recurring billing into your app.

How Stripe Handles Subscriptions

Stripe’s subscription system has three components you need to understand:

Products are what you are selling. “Pro Plan”, “Business Plan”, “Monthly Access”. A product describes the thing.

Prices are how much the product costs and how often. $29 per month. $290 per year. A product can have multiple prices (monthly and annual billing).

Subscriptions are what a customer has. When a user subscribes, Stripe creates a subscription object that links the customer to the price and handles recurring billing automatically on the billing cycle.

Setting Up Products and Prices in Stripe

Before writing any code, set up your subscription in the Stripe dashboard:

  1. Go to your Stripe dashboard at dashboard.stripe.com
  2. Click Products in the left sidebar
  3. Click Add Product
  4. Give it a name (e.g. “Pro Plan”) and optionally a description
  5. Under Pricing, select Recurring
  6. Set the price and billing period (monthly or annually)
  7. Save the product

Stripe gives each price a Price ID that looks like price_1234567890. Copy this. You will need it in your code.

How to Implement Subscriptions in Your App

The flow for subscription billing is:

  1. User chooses a plan and clicks Subscribe
  2. Your app creates a Stripe Checkout Session with your Price ID
  3. User is redirected to Stripe’s hosted checkout page
  4. User enters payment details and subscribes
  5. Stripe redirects the user back to your app
  6. Stripe sends a webhook to your app confirming the subscription is active
  7. Your app updates the user’s account to reflect their subscription status

Ask your AI: “I want to add monthly subscription billing to my app using Stripe. The Price ID for my Pro Plan is [your price ID]. Can you write the code to create a Stripe Checkout Session for subscriptions, handle the webhook that confirms successful subscription, and update my database to mark the user as a paid subscriber?”

Managing Subscriptions After Sign-Up

Once a user is subscribed, they will eventually want to cancel, upgrade, downgrade, or update their payment method. Stripe provides a customer portal that handles all of this without you building any UI.

Ask your AI: “Can you add a button in my app that opens the Stripe customer portal where users can manage their subscription, update their payment method, or cancel?”

The customer portal is a hosted page Stripe provides. You just link to it with the user’s customer ID. Everything else is handled by Stripe.

Handling Subscription Webhooks

Subscriptions require more webhook handling than one-time payments because things change over time: renewals succeed, payments fail, subscriptions cancel.

The key webhook events to handle:

customer.subscription.created (subscription started, grant access)

invoice.payment_succeeded (recurring payment succeeded, continue access)

invoice.payment_failed (payment failed, notify user and potentially restrict access)

customer.subscription.deleted (subscription cancelled, remove access)

Ask your AI: “Can you add webhook handlers for the main Stripe subscription events? I need to grant access when a subscription is created or renewed, and remove access when a payment fails or subscription is cancelled.”

Testing Subscriptions

In Stripe’s test mode, use the card 4242 4242 4242 4242 to subscribe successfully. Use 4000 0000 0000 0341 to simulate a card that fails after the first charge, letting you test payment failure handling.

The One Thing to Remember

Stripe subscriptions need three things set up: a Product with a recurring Price in your Stripe dashboard, code that creates a Checkout Session with that Price ID, and webhook handlers for subscription created, payment succeeded, payment failed, and subscription cancelled. The Stripe customer portal handles plan changes and cancellations without you building any management UI.


Want your subscription app running reliably in production? → Snapdock

New here? These might help: How do I add payments to my app? → What is a webhook? How apps talk to each other without you being involved. →