Events Signature
Every notification we send to your endpoint is signed. We do this by including a header named "SmartFastPay-Signature"
in every event we send. This allows you to verify and ensure that the event was sent by SmartFastPay and not a third party.
The "SmartFastPay-Signature"
header contains a timestamp
and one or more signatures. The timestamp
is prefixed by t=
and each signature is prefixed by a schema. Schemas start with v
followed by an integer
. Currently there is only one signature schema which is v1
.
Exemplo do Header SmartFastPay-Signature:
Signatures are generated using a hashed message based authentication code (HMAC)
with SHA-256
. To prevent downgrade attacks, you must ignore all non-v1 schemas.
How to validate the signature
Step 1: Extract the Timestamp and Signature from the Header
Split the header using the character as a separator to get the list of elements. Once that's done, do another split using the =
character as a separator, to get the prefix and the value.
The value obtained from the t
prefix corresponds to the timestamp and the v1
corresponds to the signature. You can discard other values.
Step 2: Prepare the string to compare signatures
You must concatenate this information:
The timestamp (as
string
)The character
.
The JSON payload (request body, in
string
format)
Compute the HMAC
with the SHA256
hash function. Use the secret (see what your secret is by clicking here ).
Example in PHP:
Step 3: Compare signatures
Compare the signature sent by SmartFastPay in the Header with the signature you generated in Step 2.
Example in PHP: