Mocking Stripe's Webhooks Without Stripe

"Just mock the webhook" undersells what's actually involved once the sender is Stripe, Twilio, or GitHub, because all three sign their payloads, and a receiver that verifies signatures — which it should — will reject anything that isn't signed correctly. That's the part a generic webhook mock usually can't do, and it's worth understanding exactly why before deciding what a mock is actually useful for here.
How each of the three actually signs a request
- Stripe sends a
Stripe-Signatureheader shaped liket=1700000000,v1=<hex hmac>. The signed string is the timestamp and the raw request body joined with a literal dot ({timestamp}.{body}), hashed with HMAC-SHA256 using the endpoint's signing secret (thewhsec_...value from the dashboard), hex-encoded. The timestamp is checked against the current time too, specifically to reject replayed requests. - Twilio sends an
X-Twilio-Signatureheader: HMAC-SHA1 over the full request URL concatenated with every POST parameter sorted alphabetically (key immediately followed by value, no separator), keyed with the account's Auth Token, then base64-encoded. - GitHub sends an
X-Hub-Signature-256header shaped likesha256=<hex hmac>— HMAC-SHA256 over the raw payload bytes, keyed with whatever secret was configured for that webhook.
Three different algorithms, three different things get hashed, three different encodings. None of them can be produced by guessing — you need the actual secret, and in Stripe's and GitHub's case, the raw unparsed body, because re-serializing JSON before hashing it (even without changing a single value) produces a different hash than the original bytes did.
What this means for a mock
A mock that just returns a canned Stripe-shaped JSON payload will exercise your code's ability to parse a checkout.session.completed event and act on it — genuinely useful for testing business logic against unusual or hard-to-trigger event shapes. What it will not do is produce a header that passes your real signature verification, unless you hardcode a signature that was pre-computed for that exact, unchanging payload — which works until you want to vary anything in the body, at which point the hardcoded signature no longer matches and the mock request fails your own check.
This isn't a limitation specific to any one mocking tool; it's inherent to how these signatures work. A mock is not the sender's servers and doesn't hold the sender's signing secret (nor should it — that secret is yours, not a public credential a mocking tool could bake in even if it wanted to).
Where each approach actually fits
For testing signature verification itself — does your endpoint correctly reject a request when the signature is missing, wrong, or the timestamp is stale — the provider's own tooling is the right call: Stripe CLI's stripe trigger and stripe listen --forward-to sign requests correctly because they run with your real secret, and Twilio and GitHub have equivalent local-forwarding or replay tools for the same reason.
For everything else — testing what your handler does once a payload is accepted, reproducing an edge-case event shape a provider's sandbox won't reliably produce on demand, or building the receiving endpoint before you've even set up the provider account yet — a mock is the faster tool, and MockBase's stateful mocks and conditional matching on the body let a route return different event payloads depending on what's in the request, the same way a real event-driven integration would need to be tested against more than one shape. The two aren't competing solutions; they're answering different halves of "does my webhook handler actually work."
Xerat02
Building MockBase.
More from the blog

When Your Mock Lies to You: The Contract Drift Problem
Mocking a dependency is a productivity win right up until the mock quietly stops matching reality — at which point it's worse than not having one, because it gives you false confidence.

Yes, People Still Need to Mock SOAP APIs
SOAP didn't die, it just stopped being fashionable to admit you still integrate with it — and a REST-shaped mocking tool is the wrong tool for testing against one.