X-PaySway-Signature header.
By replicating this same process with your secret, you can confirm that the webhook request is authentic and has not been tampered with.
Obtain your secret
When you create a webhook subscription, the response includes a
secret field that is base64-encoded. You must decode this string before using it to generate an HMAC signature.Extract the timestamp and signature
PaySway includes an Parse the header to extract the
X-PaySway-Signature header in each webhook request. This header contains two key-value pairs separated by commas:t: The UNIX timestamp of when the message was signedv1: The actual signature in hexadecimal format
Signature header
t and v1 values. Ignore any other values that may appear in the header.Reconstruct the signing payload
PaySway signs the combination of the timestamp and raw request body, separated by a period
Generate the expected signature
Use your webhook secret to compute the HMAC-SHA256 hash of the signing payload. Convert the resulting hash to a hexadecimal string for comparison.
Verify the signature and timestamp
Compare your
expectedSignature with the v1 value from the X-PaySway-Signature header:- If they match: The request is authentic and was signed by PaySway using the correct secret
- If they don’t match: Reject the request as potentially malicious or corrupted
t to implement replay attack protection by setting a maximum acceptable age for requests (e.g., 5 minutes).