I am integrating INSTAMOJO payment gateway in my application. I am using MAC verification on webhooks response from INSTAMOJO site. Available tutorial is only for Php and Python. But I'm implementing it using NodeJs (ExpressJs). I have attached my code below. So the problem is expected HashCode and calculated HashCode are not the same, kindly look into my code and INSTAMOJO documentation.
func(req, res){
body= req.body
{mac}=body
delete body.mac
const instaCredentials= {key:***********, secret:*********, webhooks:********}
const bodyKeys= Object.keys(body).map(key => key);
const sortedKeys = bodyKeys.sort()
const values = sortedKeys.map(key => {
const value = body[key];
return value.toLowerCase();
});
let message = values.join('|');
const secret = instaCredentials.webhooks
let calculatedMac= cryptoJs.HmacSHA1(message, secret)
calculatedMac = expectedMac.toString();
console.log(mac,calculatedMac)
}