verify shopify webhook integrity - Node /Express Js

New Member
6 0 0

Hi Team,

I am working on verifying the integrity of shopify webhook and the digest generated is not similar to received headers Following

function verifyShopifyHook(req) {
    var digest = crypto.createHmac('SHA256', SECRET)
            .update(new Buffer(req.body, 'utf8'))
    return digest === req.headers['X-Shopify-Hmac-Sha256'];

I was getting error - Unhandled promise rejection (rejection id: 2): TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object

So I changed to

   var msg = JSON.stringify(req.body);
   var digest = crypto.createHmac('sha256', APP_SHARED_SECRET)

digest generated is different then x-shopify-hmac-sha256

Any one has same issue ? or any idea how to resolve this