Check the webhook signatures
Overview
Wooshpay signature header
Wooshpay-Signature
header included in each signed event contains a timestamp and signature.t=
, and each signature is prefixed by v1
.Wooshpay-Signature:t=1492774577,v1=6fdfb9c357542b8ee07277f5fca2c6f728bae2dce9be2f91412f4de922c1bae4
Webhook secret key
whsec_
webhook.secret
in webhook object.Verifying signatures
Step 1: Extract the timestamp and signatures from the header
,
character as the separator, to get a list of elements. Then split each element, using the =
character as the separator, to get a prefix and value pair.t
corresponds to the timestamp, and v1
corresponds to the signature. You can discard all other elements.t=1687845304,v1=6fdfb9c357542b8ee07277f5fca2c6f728bae2dce9be2f91412f4de922c1bae4
Step 2: Prepare the signed_payload
string
signed_payload
string is created by concatenating:.
1687845304
+.
+JSON payload
1687845304.{
"id": "evt_1NNUrjL6kclEVx6Mb1x5dKJ3",
"object": "event",
"api_version": "2022-11-15",
"created": 1687845303,
"data": {
"object": {
"id": "prod_O9oUVgsSaordCT",
"object": "product",
"active": true,
"livemode": true,
"name": "test",
"type": "service",
"livemode": true,
"pending_webhooks": 1,
"type": "product.created"
}
Step 3: Determine the expected signature
webhook.secret
in webhook objectsigned_payload
string as the message which you already prepared in step 2.
Step 4: Compare the signatures
Modified at 2023-06-27 10:10:06