Skip to content
FlowPatrol

Blog

Checkout works in preview but fails live? Check your environment variables

Your AI tool wires up payments. You click through checkout in preview with a test card and it works. You ship, a real customer tries to pay, and nothing happens.

In apps built with Lovable, Bolt, v0, Replit or Cursor, this is usually not a code bug. It's environment variables: the keys and secrets your app reads at runtime, which live in your hosting settings, not in your code.

Why it happens

  • Preview and production have separate settings. A key you added for preview isn't automatically there in production.
  • Test and live keys get mixed. A live publishable key paired with a test secret key (or the other way round) makes every payment fail.
  • Webhook secrets change per environment. Your production webhook endpoint has its own signing secret. If the app still has the test one, payments go through but the order never gets marked paid.
  • An AI edit renames a variable. The code now reads PAYMENT_SECRET while your host still has STRIPE_SECRET_KEY, so the value is empty.

The ten-minute check

  1. Open your host's environment settings and list every variable your payment code reads. Confirm each one exists in production, not just preview.
  2. Make sure all payment keys in production come from the same live account and mode.
  3. Copy the production webhook signing secret from your payment provider and compare it with the one in your host.
  4. Redeploy after changing variables. Most hosts only pick up new values on the next deploy.
  5. Do one real low-value purchase on the live domain, then refund it. Check that the order and the paid status actually appear in your app.

Still failing? Paste the error from your host's logs into your AI tool with the variable names your code expects.

Don't wait for a customer to tell you

FlowPatrol checks your sign-up, login and checkout flows on a schedule and emails you a ready-to-paste fix prompt as soon as one breaks. Try a free scan of your app.

All posts