Adding Stripe to an AI-built app: webhooks and billing done right
Almost every AI-built app I review has a Stripe checkout that works. You click the button, pay with a test card, and land on a success page. It looks done.
It usually isn’t. Here’s what real billing needs, and what AI builders tend to leave out.
The success page is not proof of payment
The most common mistake: the app gives a user access because they reached the “payment successful” page. But anyone can visit that page. And a real payment can succeed even if the user closes the tab before they get there.
The source of truth is Stripe itself. Stripe tells your server what happened by sending webhooks, messages like “this checkout was completed” or “this subscription was canceled.” Your app should grant and remove access based on those, not on which page someone visited.
Webhooks need to be verified
A webhook is just a request to your server. If your app doesn’t check that it really came from Stripe, anyone could send a fake “payment succeeded” message. Stripe signs every webhook, and your server should verify that signature before believing it.
Your server should also cope with the same webhook arriving twice, because Stripe will retry when it isn’t sure you got it.
Payments fail, and subscriptions change
The happy path is one payment that works. Real billing is everything else:
- Failed renewals. Cards expire and payments get declined. What happens to the user’s access, and do they get a chance to fix it?
- Upgrades and downgrades. What does the user get, and when?
- Cancellations. Does access end immediately, or at the end of the period they paid for?
- Refunds and disputes. Does your app know when money has gone back?
Each one is a webhook your app needs to handle. If it doesn’t, your records drift away from Stripe’s, and you end up with users who have access they didn’t pay for, or paying users who are locked out.
Credits and usage need a ledger
AI products often sell credits, usage limits or packs on top of a subscription. That needs a ledger: a record of every purchase and every use, so you can always answer “how much does this customer have left, and why?” A single number that gets changed in place will eventually be wrong, and you won’t be able to tell why.
Keys belong on the server
Stripe gives you a publishable key, which is fine in the browser, and a secret key, which must never be. Prices and amounts should also be decided on the server. If the browser tells your server how much to charge, someone can change it.
Test like it’s live
Before you take real money, use Stripe’s test cards to try declined payments, expired cards and cards that need extra verification, and check that your app does the right thing each time. Then switch to live keys deliberately, with live webhooks set up, and make one small real purchase yourself.
A quick check
In your Stripe dashboard, look at your webhook endpoint and its recent deliveries. If there’s no endpoint, or deliveries are failing, your billing isn’t finished.
Payments are one of the first things we check in every vibe coding rescue, because mistakes there cost real money.
