Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hey :),
im trying to veryfiy webhooks in my nodejs app. but it just doesnt work, here is my code :
app.use(shopify.config.webhooks.path, async (req, res, next) => { if (!req.body) { return res.status(401).send("Couldn't verify incomming Webhook request!"); } const hmac = req.headers["x-shopify-hmac-sha256"]; const genHash = crypto .createHmac("sha256", process.env.SHOPIFY_API_SECRET) .update(JSON.stringify(req.body), "utf8", "hex") .digest("base64"); console.log(hmac); console.log(genHash); if (genHash !== hmac) { return res.status(401).send("Couldn't verify incomming Webhook request!"); } next(); });
Please help meee
Did you sorted it ?
The update() method should be used without the encoding ("utf8") and the output encoding ("hex").
Try that:
const genHash = crypto .createHmac("sha256", process.env.SHOPIFY_API_SECRET) .update(JSON.stringify(req.body)) .digest("base64");
This is incorrect because the update() method only takes one argument, which is the data you want to hash. The encoding is specified when calling the digest() method, as you did correctly with .digest("base64").
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025