- We are having trouble in verification of hmac for web hooks . Its working for some webhook request but not for all. I do not understand what wrong ?
code snippet we are using to verify webhook request
var isValidRequestForWebhook = function(hmac , req){
var message = JSON.stringify(req.body);
message = message.split(‘/’).join(‘\/’);
message = message.split(‘&’).join(‘\u0026’);
var calculatedHmac = crypto.createHmac(‘SHA256’, app_secret).update(message.toString(‘utf8’)).digest(‘base64’);
return (hmac == calculatedHmac);
}