Mendlark / Guides

Stripe webhook not working in production: how to fix it

Payments go through in Stripe, but your Lovable, Bolt or Replit app never upgrades the account, never marks the order paid, or the webhook shows failures in the Stripe dashboard. It worked in test mode or not at all. Here's how to find out which part is broken and fix it.

1. Start in the Stripe dashboard

Go to Developers → Webhooks (in live mode, using the test/live toggle). Open your endpoint and look at recent deliveries. What you see tells you where to look:

  • No endpoint in live mode at all: test-mode webhooks don't carry over. You must add the endpoint again in live mode. See step 2.
  • No events listed: the endpoint isn't subscribed to the event you need (e.g. checkout.session.completed).
  • 400 errors: usually signature verification failing. See step 3.
  • 404 or 405: wrong URL, or a page route instead of an API route.
  • 500 errors or timeouts: your handler is crashing. Check your host's function logs.
  • 200 but nothing changes: the handler runs but doesn't update your database. See step 5.

2. Live mode needs its own endpoint and secret

Test mode and live mode are separate. In live mode, add the endpoint with your real production URL (e.g. https://yourapp.com/api/stripe-webhook, not a preview or localhost URL), select the events, and copy the new signing secret (whsec_…). Put it in your host's production environment variables and redeploy. Your live sk_live_… secret key must also be set there.

3. "No signatures found matching the expected signature"

Stripe signs the exact raw bytes of the request. If your framework parses the body as JSON first, the signature check fails. Read the raw body:

// Next.js App Router
export async function POST(req) {
  const body = await req.text();            // raw, not req.json()
  const sig = req.headers.get('stripe-signature');
  const event = stripe.webhooks.constructEvent(
    body, sig, process.env.STRIPE_WEBHOOK_SECRET
  );
  // ...
}

In Express, use express.raw({ type: 'application/json' }) on the webhook route only. The other common cause is using the test-mode or Stripe CLI whsec_ secret in production.

4. Supabase Edge Functions

If your webhook is a Supabase Edge Function, Stripe can't send a Supabase login token, so the function must allow calls without a JWT (deploy with --no-verify-jwt or set verify_jwt = false for that function). Then verify the Stripe signature yourself, using the async method in Deno: await stripe.webhooks.constructEventAsync(body, sig, secret). Without the signature check, anyone could call it and mark themselves as paid.

5. It returns 200 but the account doesn't upgrade

  • The handler can't find the user. Pass your user's ID into the Checkout Session (client_reference_id or metadata) when you create it, and read it back from the event.
  • RLS blocks the update. A webhook has no logged-in user, so an update with the anon key is silently filtered out. Server-side webhook code should use the service role key, kept only in server environment variables.
  • Wrong event. For subscriptions, also handle customer.subscription.updated and customer.subscription.deleted, or cancellations never take effect.

6. Don't unlock on the success page

If your app unlocks paid features when the user lands on the success URL, anyone can visit that URL without paying. The webhook should be the thing that grants access. More in Stripe success page unlocks paid features for free.

7. Handle repeats

Stripe retries deliveries and can send the same event more than once. Store each event.id and skip ones you've already processed, and return 200 quickly.

Quick checklist

  • Endpoint exists in live mode with the production URL
  • Live whsec_ and sk_live_ set in production, then redeployed
  • Raw body used for signature verification
  • User ID passed in the Checkout Session and used in the handler
  • Database update done server-side with the service role key
  • Duplicate events ignored

Still stuck?

Mendlark fixes this kind of problem for a fixed price: €49 for the first 5 builders (normally €79). We agree the problem first, test the fix and send it as a pull request. Fixed in 48 hours or you don't pay. Fix it for €49 or start with a free scan.

Not sure what else is wrong? Paste your app link into the free instant check and get a plain-English list of problems in seconds.