Guide
Stripe test mode to live: the switch-over checklist for Lovable, Bolt and Cursor apps
Short answer: switching Stripe from test mode to live is "mostly a matter of swapping your API keys", in Stripe's own words.¹ The catch is the word mostly. Test (sandbox) and live are separate worlds: each has its own keys, and products, prices, coupons and webhook endpoints made in a sandbox don't exist in live mode.¹ ² So you swap the keys, recreate the products and prices, register a live webhook endpoint with its own signing secret, then check the deployed site really changed.
Why apps get stuck in test mode
AI app builders usually wire Stripe up with test keys, which is the right way to build. The problems start when you launch:
- The publishable key (
pk_test_…) is baked into the front end at build time, so changing it in one place isn't enough. You have to redeploy. - Price IDs in your code point at sandbox prices. Live mode can't use them, because a sandbox product "can't be part of a live mode payment".²
- The webhook was only ever registered in the sandbox, so live payments go through but your app never hears about them.¹
- The signing secret (
whsec_…) in your server settings is the sandbox one, so every live webhook fails signature checks.³
The result is the worst kind of bug: everything looks fine to you, but real customers either can't pay or pay and get nothing.
How to tell which mode your live site is in
Stripe keys say their mode in the prefix:²
| Key | Sandbox (test) | Live | Safe in the browser? |
|---|---|---|---|
| Publishable | pk_test_… |
pk_live_… |
Yes |
| Restricted | rk_test_… |
rk_live_… |
No, server only |
| Secret | sk_test_… |
sk_live_… |
No, server only |
Open your live site (not the preview), view the page source or the JavaScript files, and search for pk_test_. If it's there, real cards won't work. If you find any sk_ or rk_ key in the browser at all, test or live, treat it as leaked: roll it in the Stripe Dashboard straight away.²
The switch-over checklist
1. Finish activating your Stripe account
Live mode needs your business and payout details filled in. Do this first, because it can take a while to review and you can't take real payments until it's done.
2. Recreate products and prices in live mode
Sandbox products, prices, plans and coupons aren't usable in live mode.¹ Recreate them in live mode. Stripe suggests keeping the same IDs where you can so your code keeps working.¹ If your app stores price_… IDs in code or in a database table, update them to the live IDs. If you used Stripe Payment Links, create new links in live mode too, because the sandbox ones only take test cards.
3. Swap the keys, in the right places
- Publishable key (
pk_live_…): goes in your front-end environment variable (oftenVITE_STRIPE_PUBLISHABLE_KEYorNEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY, depending on your stack). Then redeploy, because front-end env vars are read at build time. - Secret key: goes only in server-side secrets, e.g. Supabase Edge Function secrets or your host's environment variables. Never in front-end code. Stripe now recommends a restricted key (
rk_live_…) with only the permissions your app needs, rather than the all-powerful secret key.² - Check your code doesn't contain any keys at all, and rotate any key that has ended up in a chat, a screenshot or a repo.¹ ²
4. Register the live webhook endpoint
Your account can have separate test and live webhook endpoints, so add the endpoint again in live mode and subscribe it to the same events (for example checkout.session.completed).¹ Register the final URL. Stripe treats a redirect (http to https, or root to www) as a failed delivery.³
5. Use the live signing secret
Each endpoint has its own signing secret, and webhook secrets are separate from API keys.² Copy the live endpoint's whsec_… into your server secrets. A sandbox or Stripe CLI secret in production is the classic cause of "No signatures found matching the expected signature".³ Our Stripe webhooks with Supabase guide covers the full setup.
6. Make the webhook handler production-proof
Stripe's go-live checklist asks that your live endpoint handles delayed events, duplicate events, and events arriving in any order.¹ In practice: store each event.id and skip ones you've seen, and don't assume invoice.paid arrives after customer.subscription.created.
7. Test one real payment, then refund it
Make one low-value live payment with a real card, confirm your app unlocked whatever it should, check the webhook delivery shows 2xx in the Dashboard, then refund it. Stripe also suggests getting someone who isn't a developer to try it.¹
Quick checklist
- [ ] Stripe account activated for live payments
- [ ] Products, prices and coupons recreated in live mode; code uses live
price_…IDs - [ ]
pk_live_…in the front end, site redeployed - [ ] No
pk_test_on the live site; nosk_orrk_key anywhere in the browser - [ ] Secret or restricted live key only in server-side secrets
- [ ] Live webhook endpoint registered at the final URL, same events as test
- [ ] Live
whsec_…signing secret in server secrets - [ ] Duplicate and out-of-order events handled
- [ ] One real low-value payment tested end to end, then refunded
FAQ
Is switching Stripe to live mode just changing the keys? Mostly, but not only. Stripe says it's "mostly a matter of swapping your API keys", but sandbox products, prices, coupons and webhook endpoints don't carry over, so you also recreate those in live mode and use the live webhook signing secret.¹ ²
How do I know if my live site is still in Stripe test mode?
Search the live site's page source and JavaScript for pk_test_. Live publishable keys start with pk_live_.² The free Quick Check flags a Stripe test key on your live site automatically.
Why do payments work but my app doesn't update after going live?
Usually the webhook was only registered in the sandbox, or the server still has the sandbox signing secret. Add a live endpoint and use its own whsec_… secret.¹ ³
Is it safe to have my Stripe publishable key in front-end code?
Yes. Publishable keys are designed for the browser. Secret (sk_) and restricted (rk_) keys are not, and should only live on your server.²
Not sure yours switched over? The free Quick Check looks for Stripe test keys and leaked secret keys on your live site in about a minute. The $49 Launch Check goes further, including whether your webhook accepts unsigned events (with your permission), and tells you what to fix in plain English with copy-paste prompts for Lovable, Bolt or Cursor. We never ask for your keys or account access.
Sources
- Stripe docs, Go-live checklist: https://docs.stripe.com/get-started/checklist/go-live
- Stripe docs, API keys (sandbox vs live, key prefixes, restricted keys, webhook signing secrets): https://docs.stripe.com/keys
- Stripe docs, Receive Stripe events in your webhook endpoint: https://docs.stripe.com/webhooks