Authentication
Authentication
On your Merchant dashboard account, you have the access ID and access Secret, each request made on behalf of your merchant account needs to be signed by the access secret.
// Some code
const CryptoJS = require("crypto-js");
const uuid = require('uuid');
// Set your secret key and data to be hashed
const accessId = "" // your access Id;
const accessSecret = "" // your access secret;
const requestId = uuid.v4();
const timeStamp = new Date().toISOString(); // timestamp of request
const url = "";
var payload = JSON.stringify({
timeStamp,
requestId,
accessId,
url
});
const hmac = CryptoJS.HmacSHA256(payload, accessSecret);
const hash = CryptoJS.enc.Base64.stringify(hmac);
// set the x-access-id, x-request-id, and x-timestamp as a header
const headers = {
"x-access-id": accessId,
"x-request-id": requestId,
"x-timestamp": timeStamp,
"authorization": hash
};
Last updated