All posts
Product design

Stripe in Vibe-Coded Apps: The Payment Bugs AI Builders Ship

The Stripe integration bugs vibe-coded apps ship: unverified webhooks, redirect-based access, mixed test and live keys, missing subscription states, and fixes.

By Mehdi Hassan8 min read

The short answer

A Stripe integration in a vibe-coded app usually breaks in five places: access granted on the checkout redirect instead of a webhook, webhooks that skip signature checks, test and live keys mixed up, subscription states beyond "active" ignored, and duplicate events processed twice. Each has a documented fix in Stripe's docs, and you can test all five before launch.

Key takeaways

  • Never grant access from the checkout success page. Grant it when a verified webhook says the payment happened.
  • Verify every webhook signature against the raw request body, with the signing secret for that mode.
  • Keep test and live keys, webhook endpoints and secrets fully separate, and keep secret keys off the client.
  • Handle past_due, canceled, trialing and incomplete subscriptions, not just active ones.
  • Store processed event IDs so a repeated webhook can't grant credits or send emails twice.

Part of MVP Design and Development: The Founder's Guide to Building Version One

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.

  1. 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.

  2. Trigger the edge cases

    Use stripe trigger and Stripe's test cards to simulate failed payments, cards that need authentication and cancellations.

  3. Replay an event

    Resend the same event and confirm nothing happens the second time.

  4. Open the success URL directly

    Visit it without paying and confirm the account is not upgraded.

  5. 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.

Frequently asked questions

Does Lovable or Bolt set up Stripe webhooks correctly?
AI builders can generate Stripe code, including webhook handlers, but what they produce depends on the prompt and the tool's current templates. Treat the output as a draft. Check that the handler verifies signatures on the raw body, grants access only from webhook events, handles every subscription status and skips duplicate events. Check the builder's current docs for its recommended setup.
Can I use Stripe Payment Links instead of a custom integration?
Yes, for simple one-off payments or early validation. Payment Links need no checkout code, but if your app must turn on paid features after payment, you still need a webhook handler that updates the user's account. Once you have subscriptions, trials or usage limits, a Checkout integration with verified webhooks and a local record of each account's plan is easier to keep correct.
Should I use Stripe's customer portal?
For most early products, yes. Stripe's hosted customer portal lets customers update cards, view invoices and cancel without you building those screens, which removes a lot of AI-generated code that's easy to get wrong. Your app still has to listen for the resulting subscription events and update access, so the webhook handling covered here applies either way.
How do I know if my webhook endpoint is failing?
Stripe's dashboard shows each endpoint's event deliveries with their status and the HTTP response your server returned. Check it regularly at launch, and send your own error tracking alerts when the handler throws. A failing endpoint often looks fine from the app because checkout still works; the damage shows up later as wrong plan states.
What's the difference between Stripe test mode and a sandbox?
Both let you run payments with test keys and test cards without moving real money. Stripe's docs now describe sandboxes as isolated test environments within your account, alongside the older test mode. Whichever you use, the rules here hold: separate keys and webhook secrets from live mode, and recreate products and prices before launch. Check Stripe's current docs for the setup.

· CEO & Design Director

Copywriter, designer and developer, and founder of Designify Studio. Over five years, 60+ projects across 14+ industries, for startups that have raised $300M+.

Not sure yet? Try a week together.

One week of design and development, so you can see how we work before you commit. $1,000, fixed.

Schedule Call