Fintoc-Signature header. This header allows you to verify that every event received was in fact sent by Fintoc and not by a third party.
Fintoc generates a secret that is shown only once at the moment of registration of a Webhook Endpoint. This secret is necessary to validate the Fintoc signature of every event.
Verify that the events are being sent by Fintoc
Each event sent by Fintoc includes theFintoc-Signature header. The header structure is the same for every event. It contains a timestamp denoted by the t key and a signature denote by the v1 key. Here is an example of a Fintoc-Signature header:
Validate the signature using our SDK
If you’re using Python or Node, the easiest way to verify webhook signatures is with our Python SDK or Node SDK .Python
Node
Validating the signature using your code
If you want to write your own implementation or use a different programming language, follow these steps:Extracting the timestamp and the header signature
Split theFintoc-Signature header into an array by the , character. Then, split each element of the generated array by the = character to obtain a key-value pair. Finally, get the corresponding values for each key.
Re-building the signed message
The message that Fintoc signed before sending the webhook corresponds to the timestamp concatenated to a. character and the the raw body of the request. Let’s re-build that same message using the timestamp that we just untangled from the Fintoc-Signature header and the raw body of the request.
message should have would be the following:
Generating the signature
Now that you have the message that needs to be signed, let’s do just that, using the SHA-256 hash function and the secret generated when creating the webhook endpoint.Comparing the signatures
Finally, let’s compare the signature that we untangled from theFintoc-Signature header to the one that we just obtained following the guide’s steps. If both signatures match, then you can assume that the event was in fact sent by Fintoc.