Fixes · Data, email and payments
Razorpay webhook not verified: anyone can fake a payment
A Razorpay webhook that doesn't check the X-Razorpay-Signature header acts on any JSON posted to it, so someone can mark an order paid without paying.
What you see
Orders or subscriptions turn paid when nobody paid, or the webhook route accepts any request sent to it.
Why it happens
The webhook route reads the event and updates the database without first proving Razorpay sent it. Razorpay signs each event with the webhook secret you chose in its Dashboard, in the X-Razorpay-Signature header, and only that signature shows the event is real.
How to fix it
- Read the raw request body as text before parsing it: the signature is over the exact bytes Razorpay sent.
- Check it with
validateWebhookSignature(rawBody, signature, RAZORPAY_WEBHOOK_SECRET)from the razorpay package, or compare an HMAC-SHA256 of the raw body, keyed with the secret, to the header. Return 400 when it doesn't match. - Only then act on
payment.captured,order.paidand thesubscriptionevents, and make handling the same event twice harmless: Razorpay retries. - Keep the webhook secret in an environment variable, never in the code.
Or ask your AI tool to fix it
Paste this into Lovable, Bolt, v0, Replit or Cursor, and let it make the change.
Make the Razorpay webhook route read the raw request body, verify it against the X-Razorpay-Signature header with validateWebhookSignature and RAZORPAY_WEBHOOK_SECRET, return 400 when verification fails, and only then update the database. Handling the same event twice must not change anything.
Don't change what the app does.
Never put a secret key or password in the code: read it from an environment variable.
If a step has to be done outside the code, like revoking a key in a provider's dashboard, list it for me at the end instead of skipping it.How Launchpad helps
The launch check flags a Razorpay webhook that skips the signature. Launchpad sets your Razorpay keys and plan ids in every environment, tells you exactly which webhook to add in the Razorpay Dashboard (only partner accounts can create one through Razorpay's API), and keeps reminding you until RAZORPAY_WEBHOOK_SECRET is saved.
Check your app for this, freeStart free