Urgent.News

What's breaking now, across hundreds of outlets.

Tech

How to check your Stripe webhook actually verifies signatures

Most apps that take money through Stripe find out about a payment from a webhook. A Lovable or Bolt app on Supabase usually has an Edge Function at something like /functions/v1/stripe-webhook ; a Cursor or v0 app on Next.js has a route handler at app/api/stripe/webhook/route.ts . When checkout.session.completed arrives, the handler marks the order paid, unlocks the plan or sends the download.…

To verify webhook signatures in a Stripe integration, follow these steps. First, locate the webhook handler in your codebase, searching for terms like stripe.webhooks, constructEvent, Stripe-Signature, and checkout.session.completed. If the event type is found but the required elements are missing, the handler lacks verification.

Next, confirm the handler reads and verifies the raw request body, as any manipulation will cause verification to fail. Ensure that a failed check stops the handler by catching verification errors and returning a 400 response. The signing secret should be stored in an environment variable, not hardcoded in the code, and it must be the correct one for your environment (test or live).

Send a forged event with an invalid signature to confirm that the handler returns a 400 response and does not modify the database. Verify the real signature by triggering a webhook event and ensuring a successful response. To make your endpoint idempotent, store the processed event.id in a database table with a unique constraint and skip any retries for previously processed events.

Finally, return a 2xx status code quickly to prevent Stripe from retrying the request. Avoid setting a zero timestamp tolerance and ignore any additional fields in the newer Stripe-Signature header. Check if the problem lies in the deploy if everything appears to be working correctly, but orders are not updating.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

More from Dev.to on urgent.news

Get the news by email. Yesterday's most-covered stories, every morning.

See today's edition · More options

More in Tech

More from Sunday, 6 December 2026 →