Verify Shopify Webhook in NodeJS
Jimmy Rousseau
Author: Jimmy Rousseau | Published: 8/18/2023

Why Stand alone web hook?

So at work I started building an express based backend application in Typescript. As requirements came in, complexity grew. I had Shopify Management API integrated in a particular way, and just to be able to use the webhook feature, it included using another package, and initializing Shopify in a different way, requiring some rework of some currently working functionality.

The Solution

So the examples on Shopify docs for webhook implementation were only in Ruby and Python, perhaps some others but not NodeJS. Ruby and Python were the only one's I could really understand. From this, and a late night Googling patching together equivalent node APIs, but the solution was ultimately heavily borrowed from here

During Express initialization:

then the middleware would look something like this:

That's it! I was absolutely hitting a brick wall when it came to using the crypto module to do this myself, as I haven't used NodeJS crypto module but for basic decrypt and encryption tasks. Also My original solution was way off on how I would compare the two hashes. Luckily I was able to stand on the shoulders of the giants and wealth of knowledge in the tech community online.