All things Shopify and commerce
I am setting up Shopify webhooks for my app and I want to verify the webhooks. I am creating the webhooks using this API. I am verifying the webhooks in Node Js and this is the code that I am using to do it.
const verifyWebhook = async (req, res, next) => {
const hmac = req.get("X-Shopify-Hmac-Sha256");
const body = await getRawBody(req);
// Create hash based on body and key
const generatedHash = crypto
.createHmac("sha256", secretKey)
.update(body)
.digest("base64");
// Compare our hash to Shopify's hash
if (generatedHash !== hmac) {
return res.sendStatus(401);
}
req.body = JSON.parse(body);
next();
};
However, I am not so sure about the secret that I should use. I tried using the API secret available on the credentials tab for an app but it doesn't seem to work.
However, when I tried creating the webhooks from the store settings and used the secret available there then it works fine but I am not sure about the secret I should be using in case of webhooks created using the API. I have read the documentation and it mentions some shared secret but I am not able to figure out what it is.
Any help is highly appreciated and thanks in advance.
Hi, any luck with this?
I'm also having a similar issue. Here is my code.
```js
In Canada, payment processors, like those that provide payment processing services t...
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