verify_webhook checks a delivery’s sv-signature header and returns the parsed event. For the event catalog, payloads and how to set up an endpoint, see the Webhooks documentation.
Prerequisites
- A webhook endpoint in SolvaPay Console, and its signing secret (
whsec_...) inSOLVAPAY_WEBHOOK_SECRET.
Add a receiver route
bytes or str. The signature covers the raw bytes, so a body you parsed and serialized again fails the check. In FastAPI, read it with await request.body() too.
The event is a plain dict parsed from the JSON body.
How the signature is checked
Thesv-signature header looks like t=1767225600,v1=5f3c.... verify_webhook computes an HMAC-SHA256 over "{t}.{raw body}" with your signing secret and compares it to v1 in constant time. A timestamp more than 300 seconds from now, in either direction, is rejected. Pass now= (a datetime) to check against another time, for example in tests.
Error codes
verify_webhook raises SolvaPayError with one of these codes, also in WEBHOOK_ERROR_CODES:
Answer a failed check with a
4xx, so the delivery shows as failed in SolvaPay Console.
Next steps
- The TypeScript equivalent is webhook handling.