The webhook object
The following fields are returned byGET /v1/webhooks and GET /v1/webhooks/{id}.
Available events
Subscribe to any combination of the events below when you register a webhook.When a hosted payment method update link completes, CharityStack emits
subscription.payment_method_updated and also emits subscription.updated for backward compatibility. The dedicated payment method event includes a safe summary and excludes provider identifiers.Registering a webhook
CallPOST /v1/webhooks with a destination URL and the list of events you want to receive.
Verifying webhook signatures
Every webhook delivery includes three headers that you should use to authenticate the request before processing the payload.
CharityStack signs each payload by combining the timestamp and raw request body, then computing an HMAC-SHA256 digest using your webhook secret. To verify a request:
1
Extract the headers
Read
X-Webhook-Signature, X-Webhook-Timestamp, and X-Webhook-ID from the incoming request.2
Construct the signed string
Concatenate the timestamp and the raw request body with a
. separator:3
Compute the expected signature
Compute an HMAC-SHA256 of the signed string using your webhook secret as the key, then hex-encode the result.
4
Compare signatures
Compare your computed digest to the value in
X-Webhook-Signature (after stripping the sha256= prefix). Use a constant-time comparison to prevent timing attacks. Reject the request if they do not match.5
Check the timestamp
Optionally reject requests where
X-Webhook-Timestamp is older than a few minutes to protect against replay attacks.API endpoint
Create a webhook
Register a new webhook endpoint and subscribe to one or more event types.