Shopify webhook requests arrive but fail X-Shopify-Hmac-Sha256 signature validation.
Examples for common stacks. Adapt them to your provider contract and framework.
const crypto = require('crypto');
app.post('/webhooks/shopify', express.raw({ type: 'application/json' }), (req, res) => {
const receivedHmac = req.headers['x-shopify-hmac-sha256'];
if (!receivedHmac) return res.status(400).send('Missing HMAC header');
// Shopify uses base64 — NOT hex (unlike GitHub/Razorpay)
const computedHmac = crypto
.createHmac('sha256', process.env.SHOPIFY_APP_SECRET)
.update(req.body) // raw Buffer from express.raw()
.digest('base64');
const received = Buffer.from(receivedHmac, 'utf8');
const computed = Buffer.from(computedHmac, 'utf8');
if (received.length !== computed.length || !crypto.timingSafeEqual(received, computed)) {
return res.status(401).send('HMAC validation failed');
}
const payload = JSON.parse(req.body);
const topic = req.headers['x-shopify-topic'];
console.log('Shopify topic:', topic, 'shop:', req.headers['x-shopify-shop-domain']);
res.status(200).json({ received: true });
});Capture raw body → compute HMAC → base64 encode → compare → return 200.
Works with webhooks and other async event systems (including AI callbacks). Instead of guessing, inspecting the exact payload and headers can help debug faster.
Try the free webhook testerWas this page helpful?
Your feedback helps us improve the docs.