Subscriptions for AI Coders | SheCodes
Advanced 8 min read

Subscriptions for AI Coders

How to charge people every month, without learning to code.

In this chapter

  • What a subscription really is, explained like you're five
  • How to set up Free, Pro, and Team plans
  • How to give people a free trial
  • How to let people upgrade, downgrade, or cancel without emailing you

What a subscription actually is

Think of Netflix. You hand over your card once, and every month a little bit of money disappears from your account until you say stop. That's a subscription.

To do this in your own app, you don't build the payment part yourself (that's illegal-levels-of-scary). Instead, you use Stripe. Stripe is like a trusted friend who handles the money. Your app just asks Stripe "is this person paying?" and Stripe says yes or no.

What happens when someone subscribes

Here's the whole story from the customer's point of view:

  1. 1
    They click the "Subscribe" button on your pricing page
  2. 2
    Your app sends them to a safe Stripe page to type their card details
  3. 3
    Stripe takes their money (your app never sees the card, safer for everyone)
  4. 4
    Stripe whispers to your app: "hey, this person just paid"
  5. 5
    Your app writes down: "yep, they're a Pro member now"
  6. 6
    Stripe sends them back to your app, and they can use the paid features

You don't build any of this by hand. Your AI tool wires it up when you ask it to.

Designing your plans

Most apps offer three plans. It's the sweet spot: enough choice to feel personal, not so much that people freeze up.

Live example
Free
$0
Enough to hook them. Limited features: just a taste of the good stuff.
Pro
$19/mo
The one most people pick. Highlight it with a "Most popular" badge.
Team
$49/mo
For bigger customers. More seats, more features, priority support.

Let Stripe handle the checkout

Don't build a payment form. Stripe already made a beautiful one called Stripe Checkout. When your customer clicks "Subscribe", you send them to Stripe's page, they type their card, Stripe sends them back. Done.

This is safer too: the card never touches your app, so you have way fewer security rules to worry about.

ADD STRIPE CHECKOUT

“Add Stripe Checkout to my app for subscriptions. On my pricing page, each plan's "Subscribe" button should send the visitor to Stripe's hosted checkout page for that plan. After they pay, bring them back to a /success page. Keep my Stripe keys in the safe place for secrets, and walk me through where to find each plan's price ID in the Stripe dashboard step by step.”

Products vs Prices (it's two things, not one)

One thing that trips everyone up: in Stripe, every plan you sell is actually two things stacked together.

Product

The thing being sold. "Pro Plan", "Team Plan". One product per tier.

Price

A specific amount + how often. One product can have multiple prices: monthly, yearly, USD, EUR.

You create both in the Stripe Dashboard once, then tell your AI tool to use the "price IDs" (they look like price_1AbCd...). Each plan's Subscribe button needs to know its own price ID.

Remembering who's a paying customer

Your app needs a little list (a database table) that tracks who's on which plan. Every time someone loads your app, it checks the list and decides whether to show them the paid features.

You don't fill it out by hand. Stripe sends a webhook (see the Webhooks chapter) every time something changes, and your app updates the table automatically. The bare-minimum columns:

subscriptions table

  • user_id your user
  • stripe_customer_id Stripe's ID for this customer (cus_...)
  • stripe_subscription_id Stripe's ID for this subscription (sub_...)
  • price_id which plan they're on
  • status active / trialing / past_due / canceled / incomplete
  • current_period_end when their paid time runs out
  • cancel_at_period_end true if they cancelled but still have access

The status column is the one your app actually checks. active and trialing = let them in. past_due = card failed, give them a grace period. canceled = revoke access.

SAVE SUBSCRIPTION STATUS

“Create a subscriptions table in my database with columns for user_id, stripe_customer_id, stripe_subscription_id, price_id, status, current_period_end, and cancel_at_period_end. Whenever Stripe sends a webhook for customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, invoice.payment_succeeded, or invoice.payment_failed, upsert the matching row. Then give me a helper isPro(user) that returns true if status is active or trialing.”

Upgrades, downgrades, and cancellations

People will want to switch plans or cancel. You don't have to build screens for any of this: Stripe has a ready-made page called the Customer Portal. You add one button to your app; Stripe does the rest.

Upgrade Switching to a pricier plan. Stripe charges the difference on the spot and gives them access right away.
Downgrade Switching to a cheaper plan. Usually kicks in at the end of the month they already paid for, so they keep the fancier plan until then.
Cancel They keep access until the end of the time they already paid for. After that, Stripe tells your app to quietly take the paid features away.
Changed their mind If they cancelled but the month isn't over yet, they can un-cancel with one click. Happens a lot.
ADD THE CUSTOMER PORTAL

“On my billing settings page, add a "Manage my subscription" button. When someone clicks it, send them to Stripe's Customer Portal where they can see their invoices, update their card, switch plans, or cancel. When they're done, Stripe should bring them back to my billing settings page.”

Things that will confuse you at first

Someone paid but my app still treats them as free

Stripe's little "hey, they paid" messages aren't reaching your app. Ask your AI tool to check the webhook setup (there's a whole chapter on this). In Stripe's dashboard, go to Developers → Webhooks to see if messages are being delivered.

My test card keeps getting declined

You're probably in "live mode" instead of "test mode." Stripe has two worlds: one for real money, one for pretend. The card number 4242 4242 4242 4242 only works in test mode.

A customer is stuck as "past_due"

Their card was declined (expired, no funds, etc). Stripe will keep trying for a few weeks. Show them a friendly banner: "Your last payment didn't go through. Please update your card."

Someone cancelled but they can still log in

That's actually correct! They paid for the month, so they keep access until that month is up. Show them a message like "Your subscription ends on March 30."

Real World Example: Turning your free app into a paid one

You built a free app and people are using it. Time to make some money. You want Free, Pro, and Team plans, a 14-day free trial on Pro, and a way for people to manage their subscription without emailing you. With the right prompt, your AI tool can set this all up in about an hour.

Build this with AI

“Add Stripe subscriptions to my app. Set up three plans: Free ($0), Pro ($19/month with a 14-day free trial), and Team ($49/month, no trial). Create the plans in Stripe test mode for me and tell me exactly which buttons to click. Build a pricing page with all three plans side by side, hook up the Subscribe buttons to Stripe Checkout, remember who's on which plan in my database, and add a "Manage subscription" button on the settings page that goes to Stripe's Customer Portal. Finally, make my paid features only show up for Pro and Team members.”

Prompt This

ADD A FREE TRIAL

“Give my Pro plan a 14-day free trial. When someone subscribes, don't charge them for the first 14 days. Send them a friendly email on day 12 reminding them the trial is almost up. They can cancel anytime during the trial and won't be charged.”

ADD ANNUAL PRICING

“Add a yearly option to my Pro and Team plans. Yearly should cost about 10 times the monthly price, so customers effectively get 2 months free. Add a little toggle on my pricing page so visitors can flip between Monthly and Yearly, and show how much they save.”

ADD REFERRAL DISCOUNTS

“Build a simple referral system: when an existing customer sends a friend who signs up, give the referrer 20% off their next bill. Keep it simple, since Stripe has a built-in coupon feature you can use.”

Frequently Asked Questions

Why are subscriptions harder than one-time payments?

Because they happen over and over again. The payment service has to remember the customer, try the card every month, give people a free trial, let them switch plans, and stop charging when they cancel. The good news: Stripe does all of that for you. You just plug it in.

What's a webhook and do I really need one?

A webhook is a little message Stripe sends your app to say 'hey, something just happened: a customer paid, a card was declined, someone cancelled.' Yes, you need them, otherwise your app won't know who is actually a paying customer. Your AI tool will wire them up for you (see the Webhooks chapter for the friendly explanation).

Do I need a database for subscriptions?

Yes. Your app needs a little list that says 'this person is on the Pro plan, this other person is on Free.' Without it, your app can't tell who should see paid features. Your AI tool will create the list for you, so you don't have to build anything by hand.

What's a free trial?

A window of time where someone can use your paid plan without being charged. 7 or 14 days is normal. Stripe tracks the clock and charges the card automatically when the trial ends, unless the person cancels first.