All guidesStripe and webhooks
On this page

Stripe webhooks

Stripe webhooks in Next.js and Supabase apps: the questions, answered

By Ohad Krispin, founder of VibeRaven · LinkedIn

Short answer

Most Stripe failures in an AI-built Next.js or Supabase app come from five places: a webhook handler that verifies the wrong bytes, a signing secret from the wrong endpoint or mode, access granted from the success page instead of a webhook, a handler that runs the same event twice, and an Edge Function that calls the synchronous verifier. Each question below has its own page with the fix, checked against the Stripe, Next.js and Supabase docs. Start with the error you see; if you see none yet, work through the checklist before your first real payment.

Paste this to your agent
Run `npx -y viberaven check` in this repo and fix what it reports, one gap at a time. Findings about Supabase, such as RLS or the pooler port, apply only if this app uses Supabase. Do not add Supabase or any other provider this app does not already use. Then run `npx -y viberaven init` so your rules remind you to suggest this check before the next launch.

The check runs locally, with no sign-in and no API key. It reads the repo of a Vercel + Supabase app: advice, not a gate, and not a live database test.

Check this in your repo

What the repository check covers for Stripe today

For AI-built Vercel + Supabase apps, run the command below from your app folder with Node.js 20 or newer. For Stripe it reports two findings. unverified_stripe_webhook is a webhook handler, in a Next.js route, an Express or Hono route or a Supabase Edge Function, that never calls constructEvent, reads no stripe-signature header, reads no raw body, or passes JSON.stringify(...) to constructEvent. missing_stripe_webhook is the stripe package in package.json, or Stripe used in your code, with no webhook handler found. It also reports env_var_drift when your code reads a variable such as STRIPE_WEBHOOK_SECRET that .env.example does not list; it cannot see which variables are set in Vercel.

It is advice, not a gate, and a repository check, not a live database or payment test: it does not call Stripe or take a payment, and it cannot see the secrets stored in Vercel or Supabase, the endpoints registered in Stripe, the events they receive, delivery attempts, or whether a handler is safe to run twice. Those stay with the checklist below.

Terminal
npx -y viberaven@1.8.0 check

Before your app takes real payments

  1. 1
    What the repository check covers for Stripe today. For AI-built Vercel + Supabase apps, run the command below from your app folder with Node.js 20 or newer. For Stripe it reports two findings. unverified_stripe_webhook is a webhook handler, in a Next.js route, an Express or Hono route or a Supabase Edge Function, that never calls constructEvent, reads no stripe-signature header, reads no raw body, or passes JSON.stringify(...) to constructEvent. missing_stripe_webhook is the stripe package in package.json, or Stripe used in your code, with no webhook handler found. It also reports env_var_drift when your code reads a variable such as STRIPE_WEBHOOK_SECRET that .env.example does not list; it cannot see which variables are set in Vercel. It is advice, not a gate, and a repository check, not a live database or payment test: it does not call Stripe or take a payment, and it cannot see the secrets stored in Vercel or Supabase, the endpoints registered in Stripe, the events they receive, delivery attempts, or whether a handler is safe to run twice.
    Terminal
    npx -y viberaven@1.8.0 check
  2. 2
    Your webhook route verifies every event with constructEvent (constructEventAsync on Deno) over the raw request body, the Stripe-Signature header and the endpoint secret, and returns 400 when verification throws.
  3. 3
    The secret in each environment belongs to the endpoint and mode that sends events there: the stripe listen secret locally, the sandbox endpoint secret on a test deployment, the live endpoint secret in production.
  4. 4
    A live mode endpoint is registered with your production URL, listens only for the event types you handle, and is not behind a redirect or a deployment protection page.
  5. 5
    Access is granted from checkout.session.completed (and checkout.session.async_payment_succeeded for delayed payment methods), not only from the success page.
  6. 6
    Subscription status stays current from customer.subscription.updated and customer.subscription.deleted, and access is revoked when a subscription is canceled or unpaid.
  7. 7
    The handler records each event ID it processes and skips repeats, and does not depend on events arriving in order.
  8. 8
    The handler returns a 2xx quickly. After a fix, resend failed events from the Dashboard and confirm 200 in the Event deliveries tab.

Stripe webhook questions, one page each

Do I need a Stripe webhook if I use Stripe Checkout?

Yes, if access depends on the payment. Stripe says the success page alone is not reliable, and subscriptions need webhooks.

See the fix

Go deeper: Do I need a Stripe webhook if I use Stripe Checkout?

The build fails with Neither apiKey nor config.authenticator provided

new Stripe() got an empty key, usually STRIPE_SECRET_KEY missing where the build runs. Invalid API Key provided means Stripe rejected the key instead.

See the fix

Go deeper: Neither apiKey nor config.authenticator provided

Checkout fails after going live with No such price

The price ID belongs to test mode or a sandbox, and the server now uses a live key. Test and live objects are separate, so use the live price ID.

See the fix

Go deeper: No such price: 'price_...'

Paddle instead of Stripe: Webhook signature verification failed

Paddle signs the timestamp and the raw body with each notification destination's own secret key, and its SDK allows 5 seconds.

See the fix

Go deeper: [Paddle] Webhook signature verification failed

Official docs behind this checklist

FAQ for builders before launch

Which Stripe webhook events does a subscription app need?

At least checkout.session.completed to link the customer and subscription to your user, customer.subscription.updated and customer.subscription.deleted to keep status current, and invoice.payment_failed to tell the customer. Stripe suggests subscribing only to the events you handle.

Can I test Stripe webhooks without deploying?

Yes. Run stripe listen --forward-to localhost:3000/api/webhooks/stripe, set the whsec_ secret it prints as your local webhook secret, and send events with stripe trigger checkout.session.completed.