HMAC Generation
This page aims to guide the implementation of the HMAC calculation for access to our APIs. HMAC is a new security layer to ensure correct caller identification.
Basically, this layer works by including an electronically generated signature in calls. Our APIs, upon receiving this call, will recalculate the same signature and match it with the signature sent.
#
RequirementsYou will need to have the following information, which is normally already used in calls without this authentication layer:
- API Key: Your identification as a customer. Your customer code, or Merchant ID.
- Secret Key: Your security key. In calls without this layer, it is sent as Merchant Key. In calls using HMAC, this information is never sent. It only participates in the calculation.
#
Adapting your callsThe examples below will behave in the same way as the examples mentioned on the pagemento page.
Considering a simple call as illustrated below:
Let's make the following changes to make it compatible with the new security layer.
- Step 1: Place the script below in your Postsman as a pre-req script:
- Step 2: Set the following header variables in your Postman:
Parameter | Description | Format | Mandatory |
---|---|---|---|
Content-Type | Must be sent with the value application/json . | = 15 AN | YES |
merchant_id | Store code in Carat. The production and certification codes will be different. | < 15 AN | YES |
merchant_key | Store authentication key in Carat. The production and certification keys will be different. | < 80 AN | YES |
Auth-Token-Type | Identification of the authentication type used in the call. In this case, HMAC | < 10 AN | YES |
Authorization | Result generated in the JavaScript routine of Step 1. In Postman, {Authorization} can be used to get the environment variable created by the Script | < 250 AN | |
Timestamp | Must contain the numeric representation of the date and time. In Postman, {time} can be used to get the environment variable created by the Script | < 15 N | YES |
Client-Request-Id | This field will contain a generated and unique number to be propagated throughout the life of the transaction. | < 100 N | YES |
api-key | This will contain your key for access via HMAC. This should be provided by Fiserv. | < 100 N | YES |
- Step 3: Execute the call:
After the changes, the new curl generated by Postman would look something like this:
The above example will behave just like the other calls on the payment page.