Payment webhook signature verification differs by gateway in 2026 - see how Stripe, PayPal and Adyen sign events, and the raw-body bug that breaks it.
By Babul Jack
Payment webhook signature verification is not one technique you learn once and reuse everywhere - Stripe, PayPal and Adyen each sign a different string, with a different algorithm, delivered in a different place, so a handler that "verifies the signature" for one gateway is usually blind to the others.
I've wired up all three in client fintech projects, and the bug that bites hardest isn't a missing check - it's a correct-looking check that silently verifies the wrong bytes.
Why a webhook endpoint needs a signature at all
A webhook endpoint is a public POST URL that flips an order to "paid" when a request lands on it. Nothing stops someone who finds that URL from sending a forged "payment succeeded" body unless the receiver checks who really sent it.
That's the whole point of a signature: the provider signs the message with a secret or private key, and your server checks that signature before it trusts a single field in the payload. Skip it, and your "payment confirmed" logic runs on unauthenticated input.
How Stripe signs webhooks
Stripe puts everything in one Stripe-Signature header shaped like t=1492774577,v1=5257a8.... The t is a Unix timestamp, and v1 is an HMAC-SHA256 computed over the string {timestamp}.{raw body} using your endpoint's whsec_ signing secret, according to Stripe's webhook signature documentation.
Stripe also sends a dummy v0 scheme on test events - its docs are explicit that only v1 is a live signature, so a handler that checks "is there a valid-looking scheme" instead of "is v1 correct" can be fooled.
To verify by hand:
Split the header into its t and v1 parts.
Build the signed string as t + . + the raw request body (not a re-serialized JSON object).
Compute HMAC-SHA256 of that string with your endpoint secret.
Compare the result to every v1 value using a constant-time comparison.
Reject the event if the timestamp is older than your tolerance window, to block replayed captures.
const sig = req.headers['stripe-signature'];
const event = stripe.webhooks.constructEvent(req.rawBody, sig, endpointSecret);
How PayPal signs webhooks
PayPal does not use a shared secret - it signs with its own private key and expects you to verify with its public certificate. The signed message is transmissionId|timeStamp|webhookId|crc32, built from the paypal-transmission-id and paypal-transmission-time headers, your configured webhook ID, and a decimal CRC32 checksum of the raw body, per PayPal's webhook integration guide.
The signature itself arrives in paypal-transmission-sig, computed with SHA256withRSA against the certificate named in paypal-cert-url. PayPal's docs warn, in bold, that you must use the original raw body for the CRC32 - parsing it into an object and re-stringifying it will produce a different checksum and a failed check.
PayPal also offers a second path: post the headers and event straight to its /v1/notifications/verify-webhook-signature endpoint and let PayPal return SUCCESS or FAILURE for you, described in the webhooks guide. It's simpler to wire up, but it costs an extra network round-trip on every webhook you receive.
How Adyen signs webhooks
Adyen's standard webhooks put the signature inside the JSON body instead of a header. Each NotificationRequestItem carries an additionalData.hmacSignature field, and Adyen's HMAC verification guide has you rebuild a colon-joined string from eight named fields - pspReference, originalReference, merchantAccountCode, merchantReference, value, currency, eventCode and success - with any missing field left as an empty string.
You convert your hex HMAC key (from the Customer Area) to binary, compute HMAC-SHA256 over that string, Base64-encode the result, and compare it to hmacSignature. A small number of non-standard Adyen webhooks sign the whole raw body instead and deliver the signature in an hmacSignature header - a different scheme hiding under a near-identical name.
Side-by-side comparison
Gateway
Where the signature lives
What gets signed
Algorithm
Stripe
Stripe-Signature header
{timestamp}.{raw body}
HMAC-SHA256, endpoint secret
PayPal
paypal-transmission-sig header
id|time|webhookId|crc32(raw body)
SHA256withRSA, PayPal certificate
Adyen (standard)
additionalData.hmacSignature in the body
8 colon-joined fields
HMAC-SHA256, hex key, Base64
Three gateways, three different answers to "what counts as the message" - which is exactly why copy-pasting one provider's verification code into another's handler fails quietly instead of loudly.
The bug that breaks every one of them: parsing the body first
In 2026 almost every framework parses incoming JSON automatically before your route handler ever sees it. That's convenient for every other endpoint and fatal for a webhook one, because all three schemes above need the exact bytes that left the server - re-serializing a parsed object almost never reproduces the original formatting, whitespace or key order.
What this looks like in practice
Express with a global app.use(express.json()) middleware hands your Stripe handler an already-parsed object, not the raw buffer.
A Next.js API route or framework that auto-parses request.json() loses the original bytes the same way.
PayPal's docs call this out directly for CRC32: parse-then-restringify gives a different checksum, so the signature check fails even though the webhook is genuine.
How to fix it
Register the webhook route before any body-parsing middleware, or exclude it explicitly.
Capture the raw body as a Buffer/string first, verify the signature against those exact bytes, and only then JSON.parse it for your own logic.
In Express, use express.raw({ type: 'application/json' }) scoped to just the webhook route.
Write an integration test that replays a captured real payload byte-for-byte - a hand-typed JSON fixture will pass your test and still fail in production.
Why the timestamp check matters as much as the hash
Stripe and PayPal both sign a timestamp alongside the body for a reason: without it, an attacker who captures one valid request can replay it forever, and the hash will still match because the bytes haven't changed.
Stripe's libraries reject events older than a configurable tolerance (five minutes by default) specifically to close that window. If you hand-roll verification, skipping the timestamp check leaves a valid, years-old "payment succeeded" event replayable on demand - the hash alone proves authenticity, not freshness.
A practical checklist before you ship a webhook handler
I run through the same list on every payment integration, regardless of which gateway is involved, because the failure modes repeat across clients:
The route that receives the webhook reads the raw body before any JSON-parsing middleware touches it.
Verification happens before any database write or order-status change - never after.
The comparison between the computed and received signature uses a constant-time function, not === or ==, to avoid timing side channels.
A timestamp or nonce check rejects old, replayed requests, where the gateway supports one.
Failed verifications are logged with enough detail to debug later, but the response body never leaks why the check failed.
Your signing secret or HMAC key lives in environment variables or a secret manager, never in source control.
You have at least one test that replays a captured, real webhook payload byte-for-byte, not a hand-typed fixture.
What a secure handler looks like end to end
app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), (req, res) => {
let event;
try {
event = stripe.webhooks.constructEvent(
req.body, // raw Buffer, untouched by JSON middleware
req.headers['stripe-signature'],
process.env.STRIPE_WEBHOOK_SECRET
);
} catch (err) {
return res.status(400).send(`Webhook signature verification failed: ${err.message}`);
}
// Only now is it safe to act on event.data.object
res.json({ received: true });
});
The same shape applies to PayPal and Adyen: verify first, against the raw bytes and the right scheme, and only trust the payload once that check passes. A single shared /webhooks route that tries to guess the provider from the body and dispatch generically is where I've seen most of these bugs creep in - one route per gateway, with its own raw-body middleware, is simpler to get right and easier to audit later.
Frequently asked questions
Do I need to verify webhook signatures if my endpoint is secret and hard to guess?
Yes. A webhook URL is not a secret - it appears in logs, browser dev tools during testing, and sometimes in error-tracking tools, and scanners regularly probe common webhook paths. Signature verification is the only check that actually proves the gateway sent the request.
Can I use the same verification code for Stripe, PayPal and Adyen?
No. Each gateway signs a different string with a different algorithm and key type, so you need one verification function per provider. A library built for Stripe will always report a PayPal webhook as invalid, correctly, because it's checking the wrong scheme.
What happens if I reject a valid webhook by mistake?
Most gateways retry failed webhook deliveries on a schedule - PayPal and Stripe both retry for multiple days - so a transient bug in your verification logic usually gets a second chance, but you should still alert on repeated signature failures rather than silently dropping them.
Is HMAC verification enough, or do I also need HTTPS?
You need both. HTTPS protects the data in transit from eavesdroppers; the signature proves the specific sender, independent of transport. A webhook endpoint served over plain HTTP, even with a perfect signature check, still exposes the payload to anyone on the network path.
If you're building or auditing a checkout flow and want this wired correctly across providers, that's the kind of work my web app development engagements cover end to end, from the raw-body middleware fix to the retry and alerting logic around it.
Stripe signs {timestamp}.{raw body} with HMAC-SHA256 in the Stripe-Signature header; only the v1 scheme is live.
PayPal signs transmissionId|timeStamp|webhookId|crc32(raw body) with RSA against a certificate it hosts at paypal-cert-url.
Adyen's standard webhooks embed an HMAC over eight colon-joined fields inside additionalData.hmacSignature, not in a header.
The most common failure in 2026 frameworks is body-parsing middleware consuming the raw bytes before your handler can verify them - fix the route order, not the crypto.
Timestamp checks matter as much as the hash itself; without one, a captured valid webhook can be replayed indefinitely.
You need a separate verification function per payment gateway - there is no universal "check the webhook signature" routine.