What Stripe bugs do vibe-coded apps commonly ship?
Vibe-coded apps commonly ship Stripe bugs that work in a demo and fail with real money: access granted from a browser redirect, webhooks nobody verifies, test and live keys crossed, subscriptions that only know "active", and events processed twice. AI builders such as Lovable, Bolt and v0 write the happy path well. The edge cases are where they cut corners, because a prompt rarely mentions them.
These aren't exotic problems. They're the cases Stripe's own documentation warns about, which makes them easy to check. If you're working through a wider cleanup, our guide to rescuing a vibe-coded app puts billing in context, and the MVP design and development guide explains where payments fit in version one.
Bug pattern | What users see | The fix |
|---|---|---|
Access granted on the success redirect | People get paid features without paying, or pay and get nothing | Grant access from a verified webhook event |
Unverified webhooks | Usually nothing, until someone sends a fake event | Check the Stripe-Signature header on the raw body |
Test and live keys mixed | Payments that never arrive, or real charges in testing | Separate keys, endpoints and secrets per mode |
Only "active" handled | Canceled or failed-payment users keep access, or paying users lose it | Map every subscription status to an access rule |
Duplicate events processed | Double credits, double emails, double provisioning | Record event IDs and skip ones already handled |
Why is granting access on the checkout redirect a bug?
Granting access on the checkout redirect is a bug because the redirect proves only that a browser loaded a page, not that a payment succeeded. Anyone can open your success URL directly, and a real customer who closes the tab early never reaches it. Either way, your database ends up disagreeing with Stripe.
The fix is to treat the redirect as a thank-you screen and do the real work in a webhook handler. When Stripe sends checkout.session.completed, or the invoice and subscription events for recurring plans, your server checks the event, looks up the customer and updates their plan. The success page can show a short "confirming your payment" state until the server says the account is upgraded.
Our deeper guide to Stripe billing for SaaS covers the full model: Stripe owns payments and subscriptions, your database owns what each account is allowed to do.
How do you secure Stripe webhooks in an AI-built app?
You secure Stripe webhooks by verifying the signature on every request before acting on it. Stripe's webhook documentation says each event carries a Stripe-Signature header, and your handler should check it against the raw request body and the endpoint's signing secret, which starts with whsec_, using Stripe's official library.
AI-generated handlers get this wrong in two ways. Some skip verification entirely and trust any JSON that arrives. Others verify, but parse the body as JSON first, which changes it and makes every check fail, so someone "fixes" the error by removing the check. Stripe's docs are explicit that verification needs the unmodified raw body. In a Next.js route handler, that means reading the request as text before parsing it.
Two more rules from Stripe's docs: return a 2xx response quickly and do slow work afterwards, or the delivery times out; and remember that test and live modes use different signing secrets even for the same endpoint URL.
How do test and live Stripe keys get mixed up?
Test and live Stripe keys get mixed up when an app has one set of environment variables that someone edits by hand at launch. Stripe test keys start with sk_test_ and pk_test_, live keys with sk_live_ and pk_live_, and each mode has its own products, prices, customers and webhook endpoints. A price ID created in test mode doesn't exist in live mode.
- Secret keys stay on the server. Only the publishable key belongs in front-end code. If a secret key ever appeared in the browser bundle or the repository, rotate it.
- Separate environments, separate keys. Staging uses test keys and a test webhook secret; production uses live keys and the live secret.
- Recreate prices in live mode. Store price IDs in configuration per environment, not hard-coded in components.
- Check at startup. A small check that refuses to boot production with a test key catches the mistake before customers do.
Our Stripe integration page explains how we set this up when we build billing for clients.
Which subscription states do AI-built apps forget?
AI-built apps usually forget every subscription state except active. Stripe subscriptions can also be trialing, past_due, unpaid, canceled, incomplete, incomplete_expired or paused, and each needs a decision about what the user can do. Without one, a canceled customer keeps access forever, or a paying customer loses it during a retry.
Status | What it means | A sensible default |
|---|---|---|
trialing | In a free trial | Full access, show days left |
active | Paid and current | Full access |
past_due | A renewal payment failed and Stripe is retrying | Keep access, show a banner to update the card |
unpaid or canceled | Retries ended or the customer canceled | Downgrade to free or read-only |
incomplete | The first payment needs action or failed | No paid access until it completes |
Listen for customer.subscription.updated, customer.subscription.deleted and invoice.payment_failed, and store the status on your side. Then design the screens users meet in each state; our guide to in-app billing and upgrade UX covers the banners, limits and upgrade prompts.
How do duplicate webhook events and retries cause bugs?
Duplicate webhook events cause bugs because a handler that isn't idempotent runs the same side effect twice. Stripe's webhook documentation says an endpoint might occasionally receive the same event more than once, that events aren't guaranteed to arrive in order, and that in live mode Stripe retries failed deliveries for up to three days.
The fix has two parts. For incoming webhooks, record each processed event ID and skip any you've seen, and fetch the latest object from Stripe instead of assuming events arrive in sequence. For outgoing requests, send an idempotency key on POST requests so a retried call doesn't create a second charge or customer. Stripe's API reference says keys can be up to 255 characters and suggests random values such as V4 UUIDs.
Hypothetical example: how one missed duplicate turns into a support queue
For example, suppose an AI app sells credit packs. Its handler adds 500 credits whenever checkout.session.completed arrives, and it does slow work before responding. One delivery times out, so Stripe sends the event again, and the customer gets 1,000 credits.
Nothing crashed, so nobody noticed until finance compared Stripe's records with the credit balances. The fix is three small changes: respond with 2xx first, store the event ID in a processed-events table with a unique constraint, and only add credits inside the same database transaction that records the ID. This scenario is illustrative, not a real case.
How do you test the Stripe integration in a vibe-coded app before launch?
You test the Stripe integration in a vibe-coded app by running every billing path in a Stripe sandbox and replaying real webhook events against your local server with the Stripe CLI. Testing only a successful checkout isn't enough; the bugs live in the other paths.
Forward events locally
Run stripe listen with the Stripe CLI to forward sandbox events to your local webhook route, and use the signing secret it prints.
Trigger the edge cases
Use stripe trigger and Stripe's test cards to simulate failed payments, cards that need authentication and cancellations.
Replay an event
Resend the same event and confirm nothing happens the second time.
Open the success URL directly
Visit it without paying and confirm the account is not upgraded.
Check each status
Move a test subscription through trialing, past_due and canceled and confirm access changes the way your table says it should.
If the review turns up more than billing, our trial week is a low-risk way to start, and our MVP design service covers the larger rebuild.
