← All guides

Stripe Not Working in Lovable or Bolt? Fix Production Payment Errors

LovableBoltSupabase

When Stripe breaks in an AI-built app, you see one of a few symptoms: the Buy button does nothing, the customer pays but their account stays on the free plan, or checkout worked with test cards and fails on the live site. Each symptom maps to a short list of causes, and Stripe records enough detail to tell them apart.

Use this guide as a checklist. Start by confirming how your platform connects to Stripe, since Lovable and Bolt set it up differently. Then locate the stage that fails and match the error code or HTTP status to its fix. If everything passed in testing and only production fails, jump to payments that work in test mode but fail in production.

First: how your app is wired to Stripe

Lovable

Lovable’s Stripe integration page lists two routes, and a project uses one or the other, never both together:

  • Built-in payments. Lovable sets up a Stripe or Paddle account for you and handles the keys, the webhooks and separate test and live environments. Lovable recommends this route for most projects, and its payments docs list a paid plan (Pro or higher) as a requirement.
  • Your own Stripe account. You paste a Stripe key into the Connect Stripe form that appears in the project chat (not into a chat message). It accepts restricted keys (rk_...) and secret keys (sk_...) and rejects publishable keys. Lovable stores it as a backend secret called STRIPE_SECRET_KEY, then writes edge functions that call Stripe with it. This route also works on the Free plan.

Two details of the own-account route matter when you debug:

  • Webhooks are off by default. Out of the box, the app asks Stripe directly for payment and subscription status. If you ask Lovable for webhooks, it writes the handler function, and you create the event destination under Developers → Webhooks in Stripe and hand the signing secret back to Lovable.
  • Subscriptions are matched by email. Lovable links a subscription to a user only when the user’s sign-in email is the same as the email on the Stripe customer. A customer who pays with one address and logs in with another looks unsubscribed.

Bolt

Bolt’s Stripe page requires a project with Bolt Database or Supabase, user authentication and edge functions, and states that the integration can’t run on Firebase. To connect it, click the project name at the top left, hover over Integrations, choose Stripe, then paste a secret key and import the products you want. Bolt then generates Supabase edge functions for creating checkout sessions, processing payment webhooks and managing subscriptions.

According to the same page, Bolt registers the webhook endpoint and verifies signatures for you, so there’s no endpoint to add by hand in Stripe. A Stripe setup you built yourself before can’t be converted to the built-in integration, though Bolt says it keeps working.

Why this matters: with Lovable built-in payments or Bolt’s integration, the platform owns the webhook setup, so its logs are the first stop. With webhooks you added yourself or a custom integration, the webhook steps below apply directly.

Step 1: find where it breaks

Every Stripe payment passes through three stages. Find the earliest one that fails:

  1. Checkout. Clicking Buy should open Stripe Checkout. If it doesn’t, the fault is in your app or in the function that creates the checkout session.
  2. Payment. The attempt should appear in the Stripe Dashboard under Payments. If nothing is there, the request never reached Stripe as a payment.
  3. Update. Your app should reflect the payment (plan upgraded, order marked paid). If Stripe has the payment and your app doesn’t, look at the webhook handler or the status check.

Start with these two logs:

  • Stripe’s API request logs. Stripe’s Workbench overview describes a Logs tab listing recent API requests and responses, plus an Errors tab grouping recent API errors. Lovable’s docs reach the same logs through Developers → Logs. The Logs tab doesn’t refresh live, so click Refresh logs after a new attempt.
  • Your function logs. On Lovable’s built-in backend, the function logs sit under More → Settings → Logs. On your own Supabase project, they’re in the Supabase dashboard under Edge Functions.

Step 2: checkout errors, by Stripe error code

When the checkout-session function fails, Stripe answers with an error code. These codes, with Stripe’s meaning paraphrased from its error codes reference, cover the key and ID mix-ups behind broken AI-built checkouts:

resource_missing

Stripe can’t find the ID you sent, or the ID belongs to a different kind of object. Check where each price, product and customer ID came from. Lovable’s docs point out that a price has one ID in test mode and another in live mode, and an ID copied from a second Stripe account fails the same way.

livemode_mismatch

Your key and the object you referenced sit in different modes. Stripe only lets test keys touch test objects and live keys touch live objects. See the production section.

secret_key_required

A publishable key (pk_...) was sent where the server needs a secret or restricted key. Check the Stripe secret stored in your backend.

Checkout doesn’t open at all

No API error, nothing happens. Lovable’s troubleshooting explains that checkout launches in a separate browser tab, which popup blockers can suppress. Permit popups on your app’s domain and retry, then check the browser console for errors from your own code.

CORS errors in the browser console

A CORS error when the app calls your checkout function means the function isn’t answering the browser’s preflight request with the right headers. Supabase’s CORS guide for Edge Functions covers handling preflight OPTIONS requests, either through its withSupabase wrapper or by adding the headers yourself.

Don’t “fix” this by calling Stripe from the browser with your secret key. Stripe’s API keys guide says publishable keys are the only Stripe keys that can safely leave your backend. Keep the Stripe call inside the function and fix its headers.

Step 3: webhook errors, by HTTP status

If you use webhooks, Stripe records each delivery attempt. Its webhook debugging guide shows where: in Workbench, pick the endpoint under Webhooks and open Event deliveries, where each event is marked Delivered, Pending or Failed with the HTTP status your server returned.

Stripe’s webhooks page says live-mode deliveries are retried with exponential back-off for up to three days, while sandbox events get three retries spread over a few hours.

401 from a Supabase Edge Function

Supabase’s function configuration docs explain that, by default, Edge Functions refuse any request whose Authorization header doesn’t carry a valid JWT. Stripe never sends a Supabase user token, so a webhook function left on the default fails with 401.

Fix: turn off JWT verification for the webhook function only, in supabase/config.toml. Use your function’s folder name in place of the placeholder:

[functions.your-webhook-function]
verify_jwt = false

Supabase cautions that this lets anyone call the function, which is why the function itself must check Stripe’s signature (next section). Supabase’s Stripe webhooks example follows this pattern. For other non-2xx responses from Supabase functions, see Edge Function returned a non-2xx status code.

400 with “Webhook signature verification failed”

This is the message Stripe’s guide shows for this failure:

Webhook signature verification failed. Err: No signatures found matching the expected signature for payload.

Stripe names a wrong endpoint secret as the top cause. Check:

  • The right whsec_ secret. An endpoint created in the Dashboard has a different secret from the one stripe listen prints in the CLI, and Stripe’s webhooks page adds that one endpoint used with both test and live keys gets a separate secret for each mode. Stripe suggests printing the secret your code reads and comparing it with the value behind Reveal secret, watching for stray whitespace.
  • The raw body. Verification needs the body exactly as Stripe sent it, byte for byte. Stripe warns that frameworks which parse, reorder or re-encode the body first will make the check fail. In a Supabase Edge Function, the official example reads the body with req.text() and verifies with constructEventAsync plus a Web Crypto provider, since Deno needs the async version.
  • The header. Confirm your code reads the Stripe-Signature header.

3xx: redirects

Stripe counts a redirect response to a webhook as a failed delivery. Point the endpoint at the final URL the redirect lands on, for example the https and www form your domain resolves to.

Other 4xx: 404, 403, 405

Stripe groups these as the server refusing the request or blocking access to the URL. For a 404, check the URL for typos and confirm the function is deployed to the project the URL points at.

5xx

Stripe’s guidance is to read your application’s logs to learn why it returned a 500. In the function logs, look for a missing secret, a database error or code that throws on an event type it doesn’t handle.

Payments work in test mode but fail in production

Stripe’s go-live checklist describes moving from a sandbox to live mode as mostly a key swap. “Mostly” covers the cases below: every Stripe object and secret has a separate live version, and production fails as soon as one of them is still the test one.

Live keys in the production backend

Stripe’s API keys guide gives each mode its own keys, and objects made in one mode can’t be reached from the other. Keys for a sandbox begin with pk_test_, sk_test_ or rk_test_; live keys start with pk_live_, sk_live_ or rk_live_. To get them, flip the toggle on the API keys page over to live mode. Copy a live secret key when you create it: Stripe reveals a new live key once, and you can reveal it again later only for keys Stripe generated for you.

ItemTestLive
Secret or restricted keysk_test_ / rk_test_sk_live_ / rk_live_
Publishable key (if used)pk_test_pk_live_
Products and price IDsSandbox IDsSeparate live IDs
Webhook endpointTest endpointA live endpoint you register
Webhook signing secretTest whsec_A different live whsec_
CustomersTest customersLive customers

Products and prices recreated in live mode

The go-live checklist warns that products, prices and coupons created in a sandbox can’t be used in live mode. Your code has to reference the live IDs. On Lovable with your own account, ask Lovable to change the price IDs in your code to their live versions. On Lovable built-in payments, publishing copies the catalog (products and prices) into the live environment, and Lovable’s docs advise managing products through Lovable rather than editing them in Stripe, to avoid mismatched IDs.

A live webhook endpoint with its own signing secret

A Stripe account holds test and live webhook endpoints separately, and the go-live checklist asks you to register the live ones and confirm they behave like the test ones. If your app uses webhooks you set up yourself:

  • Create the live endpoint in Stripe and point it at your production function URL.
  • Store the live endpoint’s whsec_ secret in the production backend. The test secret won’t verify live events.
  • Use an https URL. Stripe’s webhooks page says HTTPS is required in live mode.

On Lovable built-in payments, the live endpoints only appear once the live environment exists, and their URLs end in ?env=live, while test ones end in ?env=sandbox. Lovable’s docs advise against adding or deleting these endpoints by hand.

Secrets set where production reads them

Supabase’s secrets guide explains that local and production functions load secrets differently. Locally they read supabase/functions/.env; deployed functions read secrets set in the Dashboard under Edge Function Secrets or with supabase secrets set. A key that only exists in your local .env never reaches production. Supabase notes that deployed functions pick up a new secret straight away, without a redeploy.

On Lovable with your own Stripe account, change the key by asking Lovable to update it, then paste the live key into the form Lovable labels Update Stripe secret key. On the built-in backend the secret shows under More → Settings → Secrets, and Lovable says to update it through chat rather than there. With your own Supabase project, Lovable syncs STRIPE_SECRET_KEY to that project’s edge function secrets.

If your frontend also reads environment variables, our guide to env variables that are undefined after deploy covers build-time variables and redeploys.

An activated Stripe account

Stripe’s account setup page says you can test in a sandbox right after signing up, but a live-mode service needs your business verified and its activation requirements completed first.

On Lovable built-in payments, Lovable’s docs say live checkout won’t work until every go-live step in the Payments tab is done. For Stripe, that means claiming the account Lovable created, finishing Stripe’s onboarding checklist (which also connects live keys and webhooks through the Lovable app) and passing Lovable’s readiness check of your live site, which looks for a privacy policy, terms of service and the other policy pages it lists.

Platform notes

  • Lovable, own Stripe account: the project runs on a single key. With a live key in place, a purchase made from the preview charges real money, so test with a test key and switch only when you’re ready. Lovable’s go-live steps end with a real purchase on the published app.
  • Lovable built-in payments: the preview runs in test mode and accepts test cards only. The published app runs in live mode.
  • Bolt: Bolt’s Stripe page covers setup with test keys (sk_test_) and test cards, such as 4242424242424242 for a successful payment and 4000000000000002 for a decline. It doesn’t describe a separate go-live procedure, so check each row of the table above for your live deploy, and use Bolt’s logs and Stripe’s Event deliveries to confirm the live webhook works.

Read the live event trail

After a live test purchase, toggle the Stripe Dashboard to live mode and follow the payment: the API request in Workbench Logs, the payment under Payments, and the webhook under Event deliveries. The first place where the trail stops points back to one of the subsections above.

Step 4: secrets in the wrong place

Stripe treats only publishable keys as safe to expose, and makes you responsible for protecting every other key, restricted keys included (Stripe API keys).

Make sure no sk_ or rk_ key is:

  • in a frontend environment variable such as VITE_... or NEXT_PUBLIC_..., which ends up in the browser bundle
  • hard-coded in a component or committed to the repo
  • pasted into an AI chat. Lovable’s docs say to enter the key only in the secure form, never as a chat message.

If a secret key was exposed, rotate it in Stripe and update the backend secret. Our guide on what to do when you’ve leaked an API key walks through the first steps, and the vibe-coded app security checklist covers secrets more broadly.

Step 5: the account doesn’t update after paying

If Stripe shows the payment but your app doesn’t:

  • On Lovable without webhooks: the app checks with Stripe whenever a user signs in and opens it. Confirm the user’s login email is the one on the Stripe customer, and that the check function isn’t erroring in the logs.
  • With webhooks: check Event deliveries (Step 3). If deliveries succeed, confirm the handler listens for the events you need, for example checkout.session.completed or customer.subscription.updated, and that it updates the correct user.
  • If plan status lives in a Supabase table: confirm the row was written, then confirm the signed-in user is allowed to read it. Our guide to Supabase RLS policies explains how read and write rules work.
  • Don’t trust the success page alone. Landing on a thank-you page isn’t proof of payment. If that page is the only thing that unlocks access, a closed tab breaks it and a typed-in URL skips it.

Go-live checklist

  • Every row of the test vs live table is switched to live.
  • The Stripe account is verified and activated for live payments.
  • No secret or restricted key is exposed (Step 4).
  • The webhook function (if used) passes the Step 3 checks with its live secret.
  • Event deliveries show 200 for a real purchase.
  • Repeated events don’t grant anything twice. Stripe’s webhooks page warns that an endpoint can receive one event more than once, and suggests recording processed event IDs.
  • Access is granted by the server-side check or the webhook, not the success page.
  • The customer portal is activated in Stripe, if your app uses it. Lovable’s docs note it won’t run inside the preview panel.
  • One real purchase has been completed on the published app, end to end.

For the rest of the launch review, see our AI-built app production readiness checklist.

If payments still misbehave, a vetted senior engineer can review and fix the flow. Fixed price, agreed upfront. See /fix/lovable, /fix/bolt or /fix/supabase.

FAQ

Why does Stripe work in preview but fail on my live domain?

On Lovable built-in payments, the preview runs in test mode and the published app runs in live mode, and live checkout stays off until the go-live steps in the Payments tab are complete. With your own Stripe account or a custom setup, check that the published app has live keys, live price IDs and a live webhook endpoint with its own signing secret.

Where do I see why a payment failed?

Open the payment in the Stripe Dashboard under Payments. Stripe’s declines guide says the payment details show the failure type and the decline information from the card issuer, and the API exposes the same data in the charge’s outcome. For errors before a payment exists, such as a bad key or price ID, check the Logs and Errors tabs in Workbench.

Why does my Stripe webhook return 401 in Supabase?

Edge Functions expect a JWT by default and Stripe doesn’t send one. Set verify_jwt = false for the webhook function only, and verify Stripe’s signature in the function instead.

Payments work in test mode but not live. What changed?

One piece is still on its test version: the key, a price ID, the webhook endpoint or its signing secret. Stripe returns resource_missing or livemode_mismatch when modes are mixed. An account that hasn’t completed activation also can’t take live payments.

Do I need to redeploy after changing a Stripe secret in Supabase?

No. Supabase says deployed Edge Functions read a newly set secret immediately. You do need to set it in production (Dashboard or supabase secrets set), not just in your local .env file.

Can I use Stripe test cards on my live site?

No. Lovable’s troubleshooting says to use Stripe’s test card with a test key and real cards only with a live key. On Lovable built-in payments, the published app runs in live mode, so test cards belong in the preview.

Comments

Add a comment

Generated for you. Click to type your own.

Required. Never shown on the page. Privacy policy.

Basic markdown: **bold**, *italic*, `code`, lists, quotes, and fenced code blocks. HTML shows as plain text.

Your draft stays on this device until you post.