How do you implement "verifying webhooks" in Coldfusion?

Palas
New Member
1 0 0

This link contains examples in other languages but not Coldfusion.

 

https://shopify.dev/tutorials/manage-webhooks#verify-webhook

 

 

0 Likes
garyrgilbert
Excursionist
34 3 6

Hi There, 

 

If you are talking about webhooks created in the admin and not through the API its a matter generating an HMAC containing the message body you get from shopify in the reqest body and comparing that to the header x-shopify-hmac-sha256

example:

 

<cfset shopifyWebhooksecret = [add your secret here]>
<cfset httpRequestData= getHttpRequestData()>
<cfset httpContent = httpRequestData.content>
<cfset shopifyHmac = httpRequestData.headers["X-Shopify-Hmac-SHA256"]>
<cfset calculated_hmac = HMAC(httpContent, shopifyWebhooksecret ,"HMACSHA256")>
<cfset isValid = calculated_hmac EQ shopifyHmac>

 

 

if you are talking about verifying webhooks you added through the webhook api.. I'm trying to find an answer myself still

 

Cheers,

 

Gary

0 Likes