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.

Matthew Butler Matthew Butler Systems Development Engineer @ Amazon Web Services Milan Surelia Milan Surelia Milan Surelia is a Mobile App Developer with 5+ years of experience crafting scalable, cross-platform apps at 7Span and Meticha. At 7Span, he engineers feature-rich Flutter apps with smooth performance and modern UI. As the Co-Founder of Meticha, he builds open-source tools and developer-focused products that solve real-world problems. Expertise: 💡 Developing cross-platform apps using Flutter, Dart, and Jetpack Compose for Android, iOS, and Web. 🖋️ Sharing insights through technical writing, blogging, and open-source contributions. 🤝 Collaborating closely with designers, PMs, and developers to build seamless mobile experiences. Notable Achievements: 🎯 Revamped the Vepaar app into Vepaar Store & CRM with a 2x performance boost and smoother UX. 🚀 Launched Compose101 — a Jetpack Compose starter kit to speed up Android development. 🌟 Open source contributions on Github & StackOverflow for Flutter & Dart 🎖️ Worked on improving app performance and user experience with smart solutions. Milan is always happy to connect, work on new ideas, and explore the latest in technology. Jared Hasson Jared Hasson Full time lead founding dev at a cyber security saas startup, with 10 yoe and a bachelor's in CS. Building & debugging software products is what I've spent my time on for forever hanson1014 hanson1014 Full-stack developer experienced in fixing and deploying AI-generated apps from Lovable, Bolt.new, Cursor, and Replit. I specialize in debugging Supabase integration issues (auth flows, RLS policies, database connections), fixing broken deployments, resolving routing/blank screen problems, and cleaning up messy React/Vite codebases. I also build production apps with the Claude API and have shipped a Mac desktop dev tool (Nexterm from scratch. Based in Hong Kong, fast turnaround. Victor Denisov Victor Denisov Developer Jacek Rozanski Jacek Rozanski Senior PHP/Symfony developer and DevOps engineer with 20+ years of professional experience, running opcode.pl (web development agency, est. 2004). Day job: I'm the sole backend developer at merketing company where I own and maintain 11 PHP/Symfony microservices on AWS (ECS Fargate, RDS, S3, CloudFront), handle the full CI/CD pipeline (Bitbucket Pipelines, Docker), and manage monitoring with Sentry and CloudWatch. These services handle high request volumes in production every month. What I bring to AI-built apps: - I audit and fix security issues (OWASP methodology), performance bottlenecks, and architectural problems in codebases generated by Cursor, Claude Code, Lovable, Bolt, and v0 - I refactor AI-generated prototypes into production-grade applications with proper error handling, testing, and clean architecture (SOLID, DDD, hexagonal architecture) - I set up the infrastructure AI tools don't touch: AWS hosting, CI/CD pipelines, automated deployments, database optimization, monitoring, and alerting - I integrate external services: payment providers, email systems, partner APIs, SSO/auth Tech stack: PHP 8.x, Symfony, React, Next.js, PostgreSQL, MySQL, Docker, AWS (ECS, RDS, S3, SQS/SNS, CloudFront), Terraform, Supabase. I also use AI tools daily (Claude Code, Cursor) in my own workflow, so I understand both the strengths and the gaps in AI-generated code. Based in Poland (CET timezone). Available for async work and calls during EU/US business hours. 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 Franck Plazanet Franck Plazanet I am a Strategic Engineering Leader with over 8 years of experience building high-availability enterprise systems and scaling high-performing technical teams. My focus is on bridging the gap between complex technology and business growth. Core Expertise: 🚀 Leadership: Managing and coaching teams of 15+ engineers, fostering a culture of accountability and continuous improvement. 🏗️ Architecture: Enterprise Core Systems, Multi-system Integration (ERP/API/ETL), and Core Database Structure. ☁️ Cloud & Scale: AWS Expert; architected systems handling 10B+ monthly requests and managing 100k+ SKUs. 📈 Business Impact: Aligning tech strategy with P&L goals to drive $70k+ in monthly recurring revenue. I thrive on "out-of-the-box" thinking to solve complex technical bottlenecks and am always looking for ways to use automation to improve business productivity. AUXLE AUXLE I am a Full Stack Developer experienced in building Websites, Web apps and Cross Platform Mobile Apps for Startups and Companies. PawelPloszaj PawelPloszaj I'm fronted developer with 10+ years of experience with big projects. I have small backend background too

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