A webhook endpoint is a public URL that changes orders. Anyone who finds it can send it a request that says "invoice paid", so the only thing standing between a forged request and a shipped order is the signature check. This post builds that check in PHP and in Node.js, step by step, and runs it against a valid request, a forged one and a replayed one.
The examples use the Stablevoy header format, X-Stablevoy-Signature: t=<unix seconds>,v1=<hex> . Many payment providers sign webhooks the same way and differ only in the header name and the encoding, so the code carries over with small changes.
How a signed delivery works
The sender and your server share one secret. The sender never sends it: it uses the secret to compute an HMAC of the request and puts the result in a header. Your server computes the same HMAC from what it received. If the two match, the request came from someone who knows the secret and nobody changed it on the way.
One delivery.…