Skip to main content
To ensure webhook events received at your endpoint are actually sent by CreptaPay and have not been tampered with, you must verify the signature sent in the request headers. CreptaPay includes an X-CreptaPay-Signature header in every webhook request. The signature is generated using a SHA-256 HMAC of the event’s data payload with your merchant Secret API Key (sk_...).

Verification steps

  1. Retrieve the X-CreptaPay-Signature header from the incoming request.
  2. Extract the data object from the request body.
  3. Generate a SHA-256 HMAC of the stringified data object using your secret API key as the key.
  4. Compare your generated signature with the signature retrieved from the header.
You must perform a constant-time comparison to prevent timing attacks.

Code examples

Here is how to verify webhook signatures in different languages:

Node.js (Express)

Python (Flask)

PHP

Java (Spring Boot)