What is going on
Your Stripe webhook handler fails to verify webhook signatures, rejecting legitimate webhook requests. Stripe events aren't processed, causing payment or subscription issues.
Webhook signature verification fails when the signing secret is incorrect, request body is modified, or verification code is wrong.
Error messages you might see
Common causes
- Using wrong signing secret (webhook endpoint secret vs API key)
- Request body modified before verification (e.g., parsed JSON and re-stringified)
- Signing secret not loaded from environment variables
- Missing 'stripe-signature' header in request
- Webhook endpoint secret not configured correctly in Stripe dashboard
How to fix it
Get signing secret: Stripe Dashboard > Webhooks > Your endpoint > Signing secret. Copy and set as env var: STRIPE_WEBHOOK_SECRET=whsec_...
Verify signature: Use Stripe SDK:const event = stripe.webhooks.constructEvent(body, sig, secret)
Pass raw request body (Buffer), not parsed JSON.
Correct endpoint setup: API route receives raw body. Configure Next.js to not parse JSON:export const config = { api: { bodyParser: false } }
Handle errors: If signature invalid, return 400. If valid but processing fails, return 200 (Stripe doesn't retry).
Getting help takes about a minute
No hiring, no back and forth. A real person looks at your app.
-
1
Describe it
Tell us what you need in plain words. You don't have to be technical or have an account to start.
-
2
Free 15-minute call
A verified developer calls you. Many tasks are sorted right there, and it costs nothing.
-
3
Pay after you approve
If there is more to do, you get one fixed price up front. You pay only once you are happy.
Real people, reviewed by hand
Developers who do this every day
Every developer is approved by our team before they can take a task. Describe yours and the first one who is free picks it up.
Get helpQuestions
What's the difference between API key and webhook secret?
API key for server-to-server calls. Webhook secret for verifying incoming Stripe requests. Never mix them up.
How do I test webhooks locally?
Use Stripe CLI: 'stripe listen --forward-to localhost:3000/api/webhooks/stripe' then 'stripe trigger payment_intent.succeeded'
What should I return from webhook handler?
200 OK if processed (even if error occurs). Stripe retries 400+. If processing fails, log error but still return 200.