How can I correct HMAC validation error in my code?

Girish_Rajwani
Shopify Partner
82 3 8
const hmac_header = req.get('X-Shopify-Hmac-Sha256');
 
const map = Object.assign({}, req.query);
delete map['hmac'];
const message = querystring.stringify(map);

const genHash = crypto
.createHmac('sha256', process.env.SHOPIFY_API_SECRET)
.update(JSON.stringify(message))
.digest('hex');

if(genHash === hmac_header){
Valid
} else {
Invalid request
}
 
but i am getting invalid request error
 
I followed below youtube video 
 
 
in above video, they are comparing as 
if(genHash === hmac
 
but it should compare with hmac in the header send by Shopify, please correct me if i am wrong 
 
i tried above as well, and got below error
 
Received an error response (400 Bad Request) from Shopify:
If you report this error, please include this id:
 
Please help!
 
Thanks in advance 🙂 
*If my answer was helpful, then please click like and accept solution
*Looking for a solution to a problem in your store? Email me at: appsbygirish@gmail.com
*My Shopify Apps: https://apps.shopify.com/partners/girish-rajwani
Replies 0 (0)