Skip to content

Payment webhook signature verifier

Runs in your browser

A signature mismatch is almost never a problem with the hashing. It is the string being hashed — a re-serialised body, a missing pipe, an amount that arrived as 1499 and got compared as 1499.00. This shows you that string, which is the one thing no provider’s documentation prints.

Everything happens in this page. Your secret is never sent anywhere.

Inputs

Algorithm
hmac-sha256 → hex
Header
X-Razorpay-Signature

Paste the body exactly as received, byte for byte. Re-serialising parsed JSON is the most common cause of a mismatch: JSON.stringify can reorder keys and will turn 170.00 into 170.

Set when you created the webhook in the dashboard. Not your API key secret.

The string being signed

This is where the bug almost always is. Pipes are highlighted so you can count them.

Fill in the fields to see the string.

Signature

What these inputs should produce

—

Paste it to compare. Case is ignored for hex.

The formulas, as each provider documents them

Transcribed from each provider’s own page, including the pipes. Four providers, four different schemes: two keyed HMACs with different output encodings, one plain salted digest, and one that does not sign the payload at all.

Signature formula, algorithm and header for four Indian payment gateways
ProviderWhat is signedFormulaHeaderSource
RazorpayWebhook payloadhex( HMAC-SHA256( raw_request_body, webhook_secret ) )X-Razorpay-SignatureValidate and Test Webhooks (opens in a new tab)
CashfreeWebhook payloadbase64( HMAC-SHA256( x-webhook-timestamp + raw_request_body, secret_key ) )x-webhook-signatureWebhook Signature Verification (opens in a new tab)
PayUPayment response (reverse hash)sha512( SALT|status||||||udf5|udf4|udf3|udf2|udf1|email|firstname|productinfo|amount|txnid|key )hash (POST field, not a header)Generate Hash (opens in a new tab)
PhonePeCallback Authorization headersha256( username:password )AuthorizationWebhook Handling (opens in a new tab)

Why it is not matching

Per provider, the things that actually break. These come from reading the documentation against itself, so several of them are places where a provider’s own pages disagree.

Razorpay

hmac-sha256 → hex

  • The key is the webhook secret you set when creating the webhook, not your API key secret. These are different values and swapping them is the second most common cause of a mismatch.
  • Razorpay's own Node example calls the helper with JSON.stringify(body), which re-serialises the payload and contradicts their raw-body rule on the same page. Pass the original bytes.
  • Compare in constant time. A plain === leaks timing information about the expected signature.
  • After rotating a webhook secret, retries of older events are still signed with the old secret. Accept both for the retry window.

Cashfree

hmac-sha256 → base64

  • The timestamp is concatenated in front of the body with no separator and no space. It comes from the x-webhook-timestamp header on the same request.
  • The result is base64, not hex. Razorpay is hex. Mixing the two up produces a value of the wrong length, which is the quickest way to spot it.
  • Standard gateway webhooks are signed with your PG secret key; partner-level webhooks use the partner API key instead.
  • Cashfree recommends rejecting anything whose timestamp is more than 5 minutes old, but does not enforce it. That replay check is yours to write — a valid signature on a replayed request is still a valid signature.
  • Cashfree's merchant-onboarding webhook page documents a different header (x-cashfree-signature) and a sorted-keys scheme. If you are verifying onboarding events rather than payment events, confirm which applies.

PayU

sha512 → hex

  • PayU's documentation contradicts itself on delimiter count: the prose says 15, the sample code produces 16. This tool follows the sample code, because that is the version merchants actually ship.
  • This is a plain SHA-512 of a salted string, not an HMAC. The salt sits at the front of the string rather than being used as a key.
  • The response hash reverses the request field order and adds status at the front. Reusing the request formula is the usual mistake.
  • If PayU sends additional_charges, that value is prepended to the whole string followed by a pipe. Omit it and the hash will not match on exactly those transactions that carry a charge.
  • Verify txnid and amount against your own record as well as the hash. A valid hash on the wrong amount is still the wrong amount.
  • PayU documents this for the browser redirect response. Their webhooks page is published but empty, and nothing in their documentation states that server-to-server webhooks are signed the same way, so do not assume it.

PhonePe

sha256 → hex

  • The username and password are the pair you configured for the callback URL in the PhonePe Business dashboard, not your API credentials.
  • This hashes only the credentials. It does not cover the request body, so it authenticates the caller but proves nothing about the payload. Validate the payment with a status call before acting on it.
  • PhonePe's docs call this Basic Authentication on some pages, which it is not — the header carries a bare SHA-256 digest, with no Basic prefix and no base64.
  • Other PhonePe products sign with x-phonepe-checksum-signature instead. Check the page for the product you integrated.

Where the numbers come from

Each formula above links to the provider’s own page. Where their pages contradict each other we say so rather than picking the version that makes a tidier table — the methodology explains why that rule exists.

Part of OnlinePayment.in. Found a mistake? Tell us and we will fix it.