v0 integration

Stripe Webhook Signature Verification Failing

Your v0-generated Next.js application receives Stripe webhook events but fails to verify their signatures, returning 400 errors or throwing 'Webhook signature verification failed' exceptions. Payments are processed by Stripe but your application never confirms them, leaving orders in a pending state and customers confused.

Stripe signs every webhook event with a signature derived from the raw request body and your webhook signing secret. If the body is modified in any way before verification (such as being parsed as JSON), or if the signing secret is incorrect, verification fails. This is a critical security feature that prevents attackers from sending fake webhook events to your application.

This is one of the most common Stripe integration issues because Next.js API routes automatically parse the request body as JSON, which modifies the raw body that Stripe's verification expects.

Error Messages You Might See

Stripe webhook signature verification failed No signatures found matching the expected signature for payload Webhook Error: Unexpected token in JSON at position 0 stripe.webhooks.constructEvent is not a function 400 Bad Request on /api/webhook
Stripe webhook signature verification failedNo signatures found matching the expected signature for payloadWebhook Error: Unexpected token in JSON at position 0stripe.webhooks.constructEvent is not a function400 Bad Request on /api/webhook

Common Causes

  • Body pre-parsed by Next.js — Next.js API routes parse JSON body automatically, but Stripe verification requires the raw body bytes
  • Wrong webhook secret — using the API secret key (sk_...) instead of the webhook signing secret (whsec_...)
  • Local vs production secret mismatch — Stripe CLI uses a different signing secret than the dashboard webhook endpoint
  • App Router body handling — Next.js App Router route handlers consume the body stream, making it unavailable for Stripe verification
  • Middleware modifying request — authentication or logging middleware reading the request body before the webhook handler

How to Fix It

  1. Disable body parsing — for Pages Router: export const config = { api: { bodyParser: false } }
  2. Read raw body in App Router — use const body = await request.text() to get the raw body string before any JSON parsing
  3. Use correct signing secret — get the webhook signing secret (whsec_...) from Stripe Dashboard > Webhooks > your endpoint > Signing secret
  4. Verify with Stripe SDK — use stripe.webhooks.constructEvent(body, sig, webhookSecret) with the raw body string
  5. Test with Stripe CLI — run stripe listen --forward-to localhost:3000/api/webhook and use the provided signing secret for local testing
  6. Return 200 quickly — process webhook asynchronously and return 200 immediately to avoid Stripe retry storms

Real developers can help you.

Dor Yaloz Dor Yaloz SW engineer with 6+ years of experience, I worked with React/Node/Python did projects with React+Capacitor.js for ios Supabase expert David Olverson David Olverson Solo dev shipping production apps with AI-assisted development. I specialize in rescuing broken Lovable/Bolt/Cursor builds and taking them to production. 10+ apps shipped including SaaS CRMs, gaming platforms, real estate tools, and Discord bots. Stack: Next.js 16, TypeScript, Tailwind CSS, FastAPI, PostgreSQL, Prisma. I use Claude Code with 50+ custom skills for rapid delivery. Average turnaround: 2-4 weeks from broken prototype to production. MFox MFox Full-stack professional senior engineer (15+years). Extensive experience in software development, qa, and IP networking. Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system. Tejas Chokhawala Tejas Chokhawala Full-stack engineer with 5 years experience building production web apps using React, Next.js and TypeScript. Focused on performance, clean architecture and shipping fast. Experienced with Supabase/Postgres backends, Stripe billing, and building AI-assisted developer tools. Pratik Pratik SWE with 15+ years of experience building and maintaining web apps and extensive BE infrastructure Stanislav Prigodich Stanislav Prigodich 15+ years building iOS and web apps at startups and enterprise companies. I want to use that experience to help builders ship real products - when something breaks, I'm here to fix it. Vlad Temian Vlad Temian 15+ years shipping production infrastructure for startups. Former CTO at qed.builders (acquired by The Sandbox). Cursor ambassador and agentic tooling builder. I've scaled systems, automated deployments, and built observability tools for AI coding workflows. I specialize in taking vibe-coded apps from broken prototype to production-ready: fixing Supabase auth/RLS, Stripe integrations, deployment pipelines, and cleaning up AI-generated spaghetti. I build tools in this space (agentprobe, claudebin, micode) and understand both sides: how AI generates code and why it breaks. https://blog.vtemian.com/ Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code — but connecting product vision, technical execution, and business impact.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

Why does webhook verification fail even with the correct secret?

Most likely the request body was parsed as JSON before verification. Stripe needs the raw body bytes. Disable body parsing with config = { api: { bodyParser: false } }.

Where do I find my webhook signing secret?

Go to Stripe Dashboard > Developers > Webhooks > click your endpoint > Signing secret. It starts with whsec_. Do not use your API key (sk_...).

How do I test webhooks locally?

Install Stripe CLI, run 'stripe listen --forward-to localhost:3000/api/webhook', and use the signing secret it outputs (whsec_...) for local testing.

Related v0 Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help