Stripe works in test mode but not live: fix for Lovable and Bolt apps
By Arif Khan, AIVolve LLC · Updated November 20, 2026
"My Stripe payments work perfectly in test mode, but on my live app the customer pays and nothing happens. What's wrong?"
Short answer: test mode and live mode in Stripe are two separate worlds, and almost everything has to be set up twice. When it works in test but not live, it's usually one of these: (1) your live Stripe account isn't fully activated yet; (2) your published app still uses test keys or test price IDs; (3) there's no live webhook endpoint, or it points at your preview, localhost or an address that redirects; (4) your app checks the webhook with the test signing secret (whsec_...), but every endpoint, in each mode, has its own secret; or (5) on Supabase, the webhook function still requires a login token, so Stripe gets a 401. While you're in there, check one more thing: paid access should only unlock from a verified Stripe event or a server-side check with Stripe, never just because someone reached your "payment successful" page. Otherwise anyone can fake a payment.
You don't need to be a developer for most of this. You'll click through the Stripe dashboard, and you can paste the prompts below into your AI tool.
First: which payment setup does your app use?
The fix depends on who manages the Stripe connection. Check this first, because the advice is different.
- Lovable built-in payments. Lovable created the Stripe account for you, and there's a Payments tab under the More menu with a test/live toggle. Lovable manages the keys, webhooks and test and live environments. Skip to If you use Lovable built-in payments.
- Lovable with your own Stripe account. You pasted a Stripe key into Lovable's Connect Stripe form. By default this setup doesn't use webhooks at all: your app asks Stripe directly whether someone has paid or has an active subscription. If you later asked Lovable to add webhooks, you set up the endpoint and its signing secret yourself in Stripe.
- Bolt's Stripe integration. Bolt's docs say it creates the checkout and webhook functions (Supabase Edge Functions), registers the webhook and verifies signatures for you, and they describe the setup with a test key. They don't describe the switch to live, so check the live side with the steps below.
- Custom code (Cursor, Claude Code, Replit, or code your AI tool wrote by hand): everything below applies.
The 2-minute check
Open your Stripe dashboard and switch from the sandbox (test) to live mode using the account picker.
- Is the account activated? If Stripe is still asking you to verify your business, live payments can't work yet. Finish that first (Step 1).
- Is there a live webhook? Open Workbench → Webhooks. If your app uses webhooks and the list is empty in live mode, that's your problem. The endpoints you made in test mode don't receive live events (Step 3).
- Is it delivering? Click the live endpoint and open Event deliveries. The status code tells you what's wrong:
What you see What it usually means Go to No live endpoint at all Webhooks were only set up in test mode Step 3 400Signature check failed: wrong whsec_secret, or the body was changed before checkingSteps 4 and 6 401or403The URL blocks callers without a login, often JWT verification on a Supabase function Step 6 404The URL is wrong, or points at an old preview Step 5 302or other3xxThe URL redirects, for example the bare domain to www. Stripe treats a redirect as a failureStep 5 500Your handler crashed. Read its logs Step 6 Timed out Your handler does slow work before replying Step 8 All 200, but the user still isn't unlockedThe events arrive but your code ignores them, or they're the wrong events Step 7 - Is your app even talking to live Stripe? In live mode, open Developers → Logs and click your app's Buy button on the published site. If no new request shows up in live mode, the app is still using a test key (Step 2).
Stripe test mode vs live mode: what is actually different
Stripe calls its testing environment a sandbox. Many people still say "test mode" or "test account", and Stripe's docs still mention a legacy "test mode sandbox", so you may see either name. In a sandbox you can charge test cards and create test products and prices, and the payments aren't processed by card networks, so no real money moves. To take real payments, Stripe's docs say to set up your Stripe account, exit the sandbox with the account picker, and use your live API keys.
- API keys. Test keys start with
pk_test_,rk_test_andsk_test_. Live keys start withpk_live_,rk_live_andsk_live_. Your published app needs the live ones, stored as environment variables or secrets, not in your code. - Products and prices. A sandbox is isolated from live mode, so a product, price or customer you made there doesn't exist in live mode. Create them again in live mode and use the new live price IDs.
- Webhooks. Webhook signing secrets are separate from API keys. You find each one in the Webhooks section of the Dashboard, under that endpoint, and a live endpoint has its own.
Step 1: Finish activating your live Stripe account
Stripe lets you test right away, but to use a service in live mode you have to verify your business and complete its activation requirements. Until then, live payments won't work no matter how good your code is.
- Your own Stripe account: open the Stripe dashboard and finish the business verification it asks for.
- Lovable built-in payments: open the Payments tab and follow the go-live checklist. With Stripe, that means claiming the Stripe account Lovable created, completing Stripe's onboarding, and passing Lovable's readiness check (privacy policy, terms of service, refund policy and real site content). Lovable's docs are clear that live checkout won't work until all go-live steps are done.
Step 2: Use live keys and live prices in production
Stripe test keys start with sk_test_, rk_test_ and pk_test_. Live keys start with sk_live_, rk_live_ and pk_live_. Each mode has its own keys, and objects from one mode can't be used in the other: a test price can't be part of a live payment. To check that no secret key is sitting in your project files, run our free leaked-keys checker.
So your published app needs all three of these switched:
- The secret (or restricted) key on the server is
sk_live_...orrk_live_.... It belongs in your backend's secrets, never in browser code. - The publishable key in the browser, if your app uses one, is
pk_live_.... - The price IDs are the live ones. Price IDs differ between test and live mode, so recreate the products in live mode and point your app at the new IDs.
Where to change the key:
- Lovable with your own Stripe account: ask Lovable to update your Stripe key, and paste the live key into the Update Stripe secret key form. Never paste a key into the chat as a message. Then ask Lovable to switch your app to the live price IDs. Note that this setup uses one key at a time, so once you switch to a live key, payments made from the preview are real too.
- Supabase Edge Functions: set it in your project's Edge Function secrets, for example
supabase secrets set STRIPE_SECRET_KEY=sk_live_.... Supabase says functions read a new secret immediately, with no redeploy. - Bolt: Bolt's docs describe adding the key through the Stripe settings in your project, starting with a test key. Their docs don't cover the switch to live, so check that the live key and live products are in place before launch, then use the 2-minute check above.
- Other hosts (Netlify, Vercel and so on): set the live keys in the production environment variables, not just preview or development.
Lovable with your own Stripe, subscriptions only: Lovable matches subscriptions to users by email address. If someone pays with a different email from the one they signed in with, the app won't see their subscription.
Step 3: Create a separate live webhook endpoint
If your app uses webhooks, this is the most common cause. Stripe's go-live checklist says your account can have both test and live webhook endpoints, and you must define live endpoints and confirm they work exactly like your test one.
In Stripe live mode, go to Workbench → Webhooks → Create an event destination and:
- Choose Your account.
- Choose the same payload format as your test endpoint. Stripe now asks you to choose Thin or Snapshot. If your code reads the whole event, for example
event.data.object, it was written for Snapshot events. Picking Thin for the live endpoint will break that code. - Select the same events as your test endpoint (see Step 7).
- Enter your production webhook URL (see Step 5).
Lovable with your own Stripe account: Lovable's docs say the same thing in short form: create an event destination pointing at the webhook function's URL, select the events, and store the signing secret when Lovable asks for it.
Step 4: Use the live endpoint's own signing secret (whsec_)
Every webhook endpoint has its own signing secret, starting with whsec_. Stripe's docs spell it out: Stripe generates a unique secret for each endpoint, and if you use the same endpoint URL for test and live, the secret is different for each one. The secret printed by stripe listen when you test with the Stripe CLI is different again.
So when you add the live endpoint:
- Open it in Workbench → Webhooks and click Reveal secret.
- Put that live
whsec_...value in your production secrets, in place of the test one (on Supabase, for example,supabase secrets set STRIPE_WEBHOOK_SECRET=whsec_..., using whatever name your function reads).
If the secret is wrong, every delivery fails with 400 and Stripe's error "No signatures found matching the expected signature for payload." Stripe says the most common cause of this error is using the wrong endpoint secret.
Step 5: Point the webhook at your live app (not the preview or localhost)
Stripe can only deliver to a public HTTPS address. A webhook that worked in testing often points at something Stripe can't reach in production:
localhost. That only worked because the Stripe CLI was forwarding events to your computer.- An old preview or staging address.
- An address that redirects, for example
yourapp.comredirecting towww.yourapp.com. Stripe counts any redirect (3xx) as a failed delivery. Use the final address.
What the right URL looks like:
- Supabase Edge Function (Lovable with your own Stripe, Bolt, most AI-built apps):
https://<project-ref>.supabase.co/functions/v1/<function-name>. It's the same for preview and production, which is why the problem in these apps is usually the secret or JWT setting rather than the URL. - A route inside your app (Next.js, Netlify or Vercel functions and so on): your real production domain plus the route, for example
https://yourapp.com/api/stripe/webhook.
Step 6: On Supabase, check the raw body and turn off JWT verification for the webhook function
If your webhook runs as a Supabase Edge Function, three details trip up AI-generated code.
1. Turn off JWT verification for this one function. By default, Edge Functions require a valid user token (JWT) in the request. Stripe doesn't have one, so every delivery is rejected with 401. Supabase's own docs use the Stripe webhook as the example of a function that needs this off. In supabase/config.toml:
[functions.stripe-webhook]
verify_jwt = false
(Use your function's real name.) If you deploy with the Supabase CLI, supabase functions deploy stripe-webhook --no-verify-jwt does the same. Only turn this off for the webhook. Your other functions should keep it on, and the Stripe signature check (next point) becomes the lock on this one.
2. Read the raw body. Stripe signs the exact bytes it sends. If the code reads the body as JSON first (await req.json()) and then turns it back into text, the signature check fails. Read it as text with await req.text().
3. Use the async check. Supabase Edge Functions run on Deno, which uses the Web Crypto API. There, Stripe's constructEvent() throws the error "SubtleCryptoProvider cannot be used in a synchronous context. Use `await constructEventAsync(...)` instead of `constructEvent(...)`." Supabase's official example does it like this:
import Stripe from 'npm:stripe'
const stripe = new Stripe(Deno.env.get('STRIPE_API_KEY') as string)
// Needed to use the Web Crypto API in Deno
const cryptoProvider = Stripe.createSubtleCryptoProvider()
// Inside your request handler:
const signature = req.headers.get('Stripe-Signature')
const body = await req.text() // raw body, not req.json()
let event
try {
event = await stripe.webhooks.constructEventAsync(
body,
signature!,
Deno.env.get('STRIPE_WEBHOOK_SIGNING_SECRET')!,
undefined,
cryptoProvider
)
} catch (err) {
return new Response(err.message, { status: 400 })
}
(Your function may name the secrets differently, such as STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET. What matters is that the names match the secrets you set.)
To have your AI tool check all of this, paste:
"Review the Stripe webhook function. Confirm that: (1) it reads the raw body with
await req.text()before verifying, and never verifies a parsed or re-stringified body; (2) it verifies withawait stripe.webhooks.constructEventAsync(body, signature, webhookSecret, undefined, Stripe.createSubtleCryptoProvider())and returns 400 if verification fails; (3) JWT verification is disabled for this function only (verify_jwt = falsein supabase/config.toml); (4) the signing secret comes from an environment secret, not code; (5) it returns a 2xx response quickly. Show me the changes before applying them."
Not on Supabase? The same raw-body rule applies everywhere. With Express, for example, Stripe notes that the webhook route has to come before app.use(express.json()), or the body is parsed before your check runs.
Step 7: Subscribe to the events your app actually uses
A live endpoint only receives the events you select. If test mode used one list and live mode another, the live app quietly misses things. The usual set:
- One-time payments with Checkout:
checkout.session.completed. If you accept payment methods that confirm later, such as bank debits, alsocheckout.session.async_payment_succeeded(andcheckout.session.async_payment_failedif you want to tell the customer). - Subscriptions:
invoice.paid(Stripe says you can grant access when it arrives and the subscription's status isactive),customer.subscription.updated(plan changes and renewals),customer.subscription.deleted(the subscription ended) andinvoice.payment_failed(a renewal didn't go through).
Stripe recommends listening only for the events your app needs, not "all events."
Step 8: Unlock access only from a verified source (the "fake payment" check)
This is the security half of the problem, and AI-built apps get it wrong a lot. Two patterns let people get paid features for free:
1. Unlocking on the success page. After checkout, Stripe sends the buyer to your success_url, for example /payment-success. If your app unlocks the paid plan just because that page loaded, anyone can type the address and skip paying. Stripe also warns that you can't rely on that page for fulfillment, because a customer can pay and then lose their connection before it loads.
The right pattern, according to Stripe:
- The webhook is the source of truth. It's required to make sure every payment is fulfilled.
- The success page can also trigger fulfillment for speed, but only if your server takes the Checkout Session ID, retrieves the session from Stripe and checks that its
payment_statusshows it's paid. Never trust a value the browser sends.
2. A webhook that doesn't check the signature. Your webhook URL is public. If it accepts any request without verifying the Stripe-Signature header, anyone can send a fake "payment succeeded" event to it. Stripe's docs say this directly: without verification, an attacker could send fake events to trigger fulfillment, grant account access or change records.
Test it in 30 seconds (on a test or staging copy if you can): send your webhook a request with no Stripe signature.
curl -i -X POST "https://<project-ref>.supabase.co/functions/v1/<function-name>" \
-H "Content-Type: application/json" \
-d '{"type":"checkout.session.completed"}'
400with a signature error, and nothing changes in your app: good, the check works.200, or a user gets unlocked: your webhook trusts anyone. Fix it now with Step 6.401: JWT verification is still on, so Stripe's real events are being blocked too. Turn it off for this function (Step 6), then run the test again to check the signature verification itself.
Retries and duplicates. Stripe sometimes sends the same event more than once, and doesn't guarantee the order. In live mode it retries failed deliveries for up to three days (in a sandbox, only three times over a few hours, which is one reason live behaves differently). So your handler should:
- record the event IDs it has processed and skip repeats, so nobody is unlocked or emailed twice;
- not depend on events arriving in a particular order;
- reply with a
2xxquickly, before slow work like sending emails. When you use asuccess_urland listen forcheckout.session.completed, Stripe Checkout waits up to 10 seconds for your webhook to respond before redirecting the customer.
To fix missed events after the endpoint was broken, open the event in Stripe and click Resend (the Dashboard allows this for up to 15 days after the event).
If you use Lovable built-in payments
Lovable manages the keys, webhooks and both environments for you, so most of the steps above are done for you. The things that do go wrong:
- Live checkout doesn't work at all: the go-live checklist in the Payments tab isn't finished (Step 1).
- People pay, but features never unlock: someone deleted or disabled a Lovable-registered webhook endpoint in the Stripe dashboard. Lovable registers two endpoints per environment (your app's endpoint, ending in
?env=sandboxor?env=live, and Lovable's monitoring endpoint), and both must stay. Lovable's docs warn that deleting your app's endpoint means purchases still succeed but subscriptions never activate. - "Invalid webhook signature": check that the webhook handler still exists in your app and that no extra endpoint you created points at the same URL. If every delivery in one environment still fails, ask Lovable to rotate the webhook secret for that environment, then publish again.
- Products look wrong in live: Lovable syncs products and prices from test to live when you publish. It recommends managing products through Lovable rather than editing them in the Stripe dashboard, to avoid ID mismatches. Discount codes don't sync. Create those in live separately.
How to confirm it's fixed
- In Stripe live mode, check that the webhook endpoint exists, points at your production URL and has the same events and payload format as your test endpoint.
- Run the unsigned-request test from Step 8 and get a
400. - Make a real, small purchase on your published app with a real card. You can refund it afterwards in the Stripe dashboard.
- In Event deliveries, the new events show
200. - The buyer's account is unlocked, and refreshing or signing out and back in keeps it unlocked.
- Type your success page's address directly in a private window while signed in as a non-paying test user. Nothing should unlock.
- For subscriptions, cancel the test subscription in Stripe and check that access ends when it should (at the end of the paid period, if that's how your app works).
FAQ
Why do Stripe payments work in test mode but not in live mode?+
Because test and live mode are separate in Stripe: each has its own API keys, products and prices, and webhook endpoints, and every endpoint has its own signing secret. A live app needs live keys, live price IDs, an activated Stripe account and, if it uses webhooks, a live webhook endpoint with its own whsec_ secret.
Do I need a separate Stripe webhook for live mode?+
Yes. Endpoints you create in test mode don't receive live events. Create the endpoint again in live mode with your production URL, the same events and the same payload format, then copy its new signing secret into your production secrets.
What does "No signatures found matching the expected signature for payload" mean?+
Stripe couldn't verify the webhook. The most common cause is the wrong signing secret, such as the test or Stripe CLI secret on a live endpoint. The other is code that changes the request body before checking it. Use the live endpoint's own whsec_ secret and verify the raw body.
Why does my Supabase Edge Function return 401 to Stripe?+
Edge Functions require a user login token by default, and Stripe doesn't send one. Turn off JWT verification for the webhook function only, with verify_jwt = false in supabase/config.toml or --no-verify-jwt when deploying, and rely on Stripe's signature check instead.
Is it safe to unlock paid features on the payment success page?+
No. Anyone can open that page without paying, and a real buyer might never reach it. Unlock access from a verified Stripe webhook, or have your server retrieve the Checkout Session from Stripe and check that it's paid. Never trust the browser alone.
What is a Stripe test account, and how is it different from live?+
Stripe's testing environment is a sandbox, often called a test account or test mode. You can charge test cards there and no real money moves. To accept real payments you exit the sandbox with the account picker and use your live API keys and, if you use webhooks, a live webhook endpoint with its own signing secret.
Still stuck?
If you've checked all eight steps and payments still don't unlock, the cause is usually something specific to how your app was generated. Our free App X-ray takes about 2 minutes and needs no code or passwords: you paste a prompt into your AI builder, send us the report, and get a plain-English verdict on what works, what only looks done and your biggest risk. An AIVolve developer reviews every X-ray within 1 business day. Get a free X-ray → Prefer to see the options first? See pricing.
Related: Lovable + Supabase login loop: the real fix · Supabase RLS for AI-built apps: the 10-minute check · Make cron jobs and webhook endpoints fail closed · Is my Replit app ready for real users? 8 checks
Written by Arif Khan, AIVolve LLC. VibeCoderSOS isn't affiliated with Stripe, Lovable, Bolt or Supabase. Settings names, error messages and code were checked against their documentation on October 26, 2026, and may change.
Need help?
Start with a free X-ray: 2 minutes, no code or passwords. You'll get a plain-English verdict on what works, what only looks done, and your biggest risk.
Get a free X-ray →