November 17, 2026 · 10 min read · Thomas Osayi
Stripe payment went through but your app did not update? Fix the webhook
The common reasons Stripe webhooks fail in Next.js and AI-built apps, and how to make paid plans activate reliably.
This is one of the most common problems in apps people bring me. Checkout opens, the card is charged, Stripe shows the payment, and the user is still on the free plan. The customer has paid for something they did not get, and you find out when they email you.
The good news is that this failure has a short list of causes, and Stripe records enough detail to tell you which one you have. Work through the sections below in order and you will usually find it in under an hour.
How is a Stripe payment supposed to update your app?
Stripe tells your server about the payment by sending an event to a webhook endpoint, and your code updates the database when that event arrives.
The full sequence has four steps. Your app creates a Checkout Session and sends the customer to Stripe's hosted payment page. The customer pays. Stripe redirects them to your success URL. Separately, Stripe's servers send an HTTP POST to a URL on your server, the webhook endpoint, containing an event such as checkout.session.completed.
Your webhook handler then does three things: it verifies that the request really came from Stripe, works out which user the payment belongs to, and writes the new plan to your database.
The redirect and the webhook are independent. The redirect happens in the customer's browser and can fail if they close the tab or lose signal. The webhook travels from Stripe's servers to yours and does not depend on the browser at all. That is why the webhook is the one you trust. When the card is charged and nothing changes in the app, the redirect worked and the webhook did not.
What are the usual reasons the webhook fails?
There are six common causes, and the first three are configuration, not code.
- No webhook endpoint was ever created in the Stripe dashboard for production. It worked on your laptop because the Stripe CLI was forwarding events.
- The endpoint URL points at localhost, an old preview deployment, or a domain that redirects.
- The production server uses the test-mode signing secret, or the other way around.
- The route parses the JSON body before verification, so the signature check fails.
- The handler listens for the wrong event type, or the endpoint is not subscribed to the event the code expects.
- The code cannot match the event to a user because no customer or user ID was stored at checkout.
AI-built apps hit the first and third most often. The builder writes a correct handler and the app passes a local test, but nobody registers the production URL in Stripe or copies the new secret into the host's environment variables. The code is fine and the wiring was never done.
I run Stripe billing in SQWAD, my own SaaS, so this is a flow I maintain as well as one I debug for other people.

How do you find the failure in the Stripe dashboard?
Open the webhook endpoint in the Stripe dashboard and read its recent deliveries; each failed attempt shows the HTTP status your server returned.
Webhooks live in the Developers area of the dashboard. Make sure you are looking at the right mode, live or test, because each has its own endpoints. If no endpoint is listed for your production domain, that is your answer: create one, subscribe it to the events you handle, and copy its signing secret.
If the endpoint exists, the status code on the failed deliveries narrows it down:
- 400 with a signature message: wrong signing secret, or the body was modified before verification
- 401 or 403: something in front of your route is blocking Stripe, usually auth middleware or deployment protection on a preview URL
- 404: the URL path does not match the route file
- 307 or 308: the URL redirects, for example from the bare domain to www. Stripe does not follow redirects, so register the final URL
- 500: your handler crashed; check your host's function logs for the stack trace
- Timed out: the handler takes too long before responding
If deliveries show 200 and the plan still does not change, the request is reaching your code and your code is deciding to do nothing. That points to the event type or the user lookup, covered below.
How do you verify the signature correctly in Next.js?
Read the request body as raw text, take the stripe-signature header, and pass both to Stripe's constructEvent function with the endpoint's signing secret.
Stripe signs the exact bytes it sends. If your code parses the body into JSON and turns it back into a string, the bytes change and the check fails with "No signatures found matching the expected signature for payload".
App Router
In a route handler such as app/api/webhooks/stripe/route.ts, do not call request.json(). Use these three lines instead:
const body = await request.text();
const signature = request.headers.get('stripe-signature');
const event = stripe.webhooks.constructEvent(body, signature, process.env.STRIPE_WEBHOOK_SECRET);
Wrap the last line in a try and catch, and return a 400 if it throws.
Pages Router
In pages/api, Next.js parses the body automatically. Turn that off for the webhook file by exporting a config object with api.bodyParser set to false, then read the raw buffer from the request stream.
The secret itself
The signing secret starts with whsec_ and is unique to each endpoint. The secret printed by the Stripe CLI during local testing is different from the one on your production endpoint, and test mode and live mode endpoints have different secrets again. Copy the right one into your host's environment variables, then redeploy. On Vercel, a changed environment variable only takes effect on the next deployment.
Also check that no middleware rewrites or protects the webhook path. An auth middleware that redirects logged-out visitors will redirect Stripe too.
How does the handler know which user paid?
It knows because you attach your own user ID to the Checkout Session when you create it, and read it back from the event.
Stripe has no idea who your users are. When you create the session, set client_reference_id to your user's ID, or put it in the metadata object. When checkout.session.completed arrives, the session in the event carries those values, along with the Stripe customer ID and, for subscriptions, the subscription ID.
Save all three on the user's record at that moment: plan, Stripe customer ID and subscription ID. Later events such as invoice.paid or customer.subscription.deleted do not include your client reference, so you find the user by the stored customer ID instead.
Three mistakes show up here. Matching by email fails when the customer types a different email at checkout than the one on their account. Session metadata is not copied onto the subscription unless you also set it under subscription_data. And creating a new Stripe customer for every checkout leaves you with several customer IDs for one user, so cancellations update the wrong record. Create the customer once and reuse it.
Which events should a subscription app handle?
Handle the first purchase, each renewal, failed payments, plan changes and cancellations, which is five events for most apps.
- checkout.session.completed: the first purchase; link the Stripe customer to your user and turn the plan on
- invoice.paid: a renewal went through; extend access
- invoice.payment_failed: a renewal failed; warn the user and decide when access stops
- customer.subscription.updated: the plan, quantity or cancellation setting changed
- customer.subscription.deleted: the subscription ended; move the user back to the free plan
Apps that only handle the first event look fine at launch and go wrong a month later, when a card fails or a customer cancels and keeps full access. The endpoint in the dashboard must be subscribed to each event your code handles. Selecting only the events you use also keeps noise out of the logs.
For one-time payments, checkout.session.completed is usually enough. If you accept delayed payment methods such as bank debits, check that payment_status is paid before granting access, and also handle checkout.session.async_payment_succeeded.
How do you test the whole flow before going live?
Test locally with the Stripe CLI, then test the deployed app in test mode with a test card, and only then switch keys.
Locally, run stripe listen with --forward-to pointed at your route, for example localhost:3000/api/webhooks/stripe. The CLI prints a signing secret for that session; put it in your local environment file. Then go through checkout in the browser with the test card 4242 4242 4242 4242, any future expiry date and any CVC. You can also fire events directly with stripe trigger checkout.session.completed, though triggered events carry sample data and will not match a real user.
On the deployed app, create a test-mode endpoint for your production URL and repeat the purchase. Then test the paths people skip:
- Close the tab on the payment page right after paying, before the redirect
- Cancel the subscription from the dashboard and confirm the app downgrades
- Pay twice with the same account and confirm you do not create two customers
When all of that passes, create the live-mode endpoint, copy its secret, switch the API keys to live, redeploy, and make one small real purchase yourself.
How do you make the webhook reliable over time?
Return a 200 quickly, make the handler safe to run twice, and log every event you could not process.
Stripe expects a successful response within a few seconds. If your handler sends emails or does other slow work before responding, the delivery can time out and count as failed even though your code ran. Do the database write, respond, and push slow work to a background job.
Stripe can deliver the same event more than once, and events can arrive out of order. Store each processed event ID and skip any you have seen. Write updates as "set the plan to pro", not "add one month", so a repeat changes nothing. When order matters, fetch the current subscription from Stripe's API instead of trusting the event's snapshot.
In live mode Stripe retries failed deliveries for up to three days, with longer gaps each time. A short outage on your side fixes itself, but an endpoint that fails for long enough gets disabled, and Stripe emails the account owner. Make sure that email address is one you read.
Should the success page unlock anything?
No. The success page should confirm the purchase to the customer and wait for the webhook to change the account.
It is tempting to mark the user as paid when they land on the success URL. Anyone can open that URL without paying, and real customers sometimes never reach it. A safe success page thanks the customer and shows their current plan from your database. If the webhook has not landed yet, show a short "activating your plan" state and re-check every couple of seconds.
If you want the page to react instantly, it can pass the session ID to your server, and the server can retrieve that session from Stripe and check its payment status. That is a secure addition. It does not replace the webhook, because renewals, failures and cancellations never pass through a success page.
When is it worth getting help?
Get help when customers are paying and not receiving what they bought, or when you have spent more than an afternoon on it.
A webhook fault is usually one specific thing, so it fits my Quick Fix package: from $60, about 2 days, with a write-up of what was wrong and what changed. If the billing code needs more, such as subscription handling, a customer portal or cleanup of duplicated customers, that is Fix Plus Features from $200. I need access to the repo, the host and the Stripe account, and I fix it in place instead of rewriting what works.
The bottom line
When the payment succeeds and the app does not update, look at the webhook. Read the delivery log in the Stripe dashboard, match the status code to the cause, and fix the endpoint URL, the signing secret, the raw body handling or the user lookup. Then handle renewals and cancellations, make the handler safe against duplicates, and test the full flow in test mode before real cards touch it.
Questions, answered in one line
Why does my Stripe webhook work locally but not in production?
Locally the Stripe CLI forwards events with its own signing secret; production needs a separate endpoint in the Stripe dashboard and its own secret in your host settings.
What does "No signatures found matching the expected signature" mean?
The webhook secret is wrong, or the request body was changed before verification; Stripe needs the raw body.
Should I unlock the plan on the success page instead?
No. The success page can be skipped or closed; the webhook is the reliable record that payment happened.
Which Stripe events should a subscription app listen for?
At minimum checkout.session.completed, invoice.paid, invoice.payment_failed, customer.subscription.updated and customer.subscription.deleted.
Does Stripe retry a failed webhook?
Yes. In live mode Stripe retries failed deliveries for up to three days with growing gaps between attempts, and you can resend any event by hand from the dashboard.
How much does it cost to have a developer fix a Stripe webhook?
Thomas Osayi fixes a single broken webhook from $60 in about 2 days, with a write-up of what was wrong and what changed.
Sources
- Receive Stripe events in your webhook endpoint Stripe Docs
- Using webhooks with subscriptions Stripe Docs
- Environment variables Vercel
Related articles
- Supabase auth redirect URL not working? Fix localhost, preview and production redirects
- Environment variables undefined on Vercel? Every cause and fix
- How to fix a CORS error on a Next.js API route
- Firestore "Missing or insufficient permissions": what triggers it and how to fix it
Fix, finish and launch your AI-built app
Built your app with Lovable, Bolt, v0, Replit or Cursor and got stuck? I fix the bugs, connect auth and payments, clean up the code and deploy it to production.
See the service