Preserve the exact payload first
Most signature failures start before the HMAC check. Frameworks often parse JSON, normalize whitespace, or change encodings before application code sees the payload. Verification should run against the raw bytes or exact raw string the provider signed.
- Read the request body before parsing JSON.
- Confirm the header name and digest format for the provider.
- Check whether the provider signs a timestamped base string instead of only the body.
- Use a known test vector before changing production webhook code.
Check replay protection and the secret
A correct HMAC can still fail if the timestamp window is wrong, the endpoint secret was copied from another destination, or an account API key was used in place of a webhook signing secret.
- Compare the provider timestamp with the verifier clock.
- Use the endpoint-specific webhook secret, not a general API token.
- Log verification reasons carefully without exposing secrets or full payloads.
- Keep one safe fixture around for regression tests.
Turn the failure into named checks
A single false value is hard to act on. A better verifier returns named checks for signature match, timestamp tolerance, header discovery, and raw-body warnings so the next fix is visible.