HTTP_X_SHOPIFY_HMAC_SHA256 error in Laravel

Barry1
Shopify Expert
11 0 1

I ma trying to set up an api that works off a webhook. I have set up the webhook in shopify and then in the laravel controller I have added the php code as per the shopify doc s

https://help.shopify.com/api/getting-started/webhooks#verify-webhook

 

Problem is I keep getting an error: 

(1/1) ErrorException

Undefined index: HTTP_X_SHOPIFY_HMAC_SHA256

Any help greatly appreciated

Replies 4 (4)
Alex
Shopify Staff
Shopify Staff
1561 81 321

Hey Barry,

On an absolutely basic level I can't replicate this behaviour. With some logging set up for a standard webhook posts route, I'm finding the index just fine in webhook request header arrays:

Route::post('/webhooks', function()
{
  Log::info($_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256']);
});

If I had to guess, maybe the shift in context from route to controller is where the values of $_SERVER are being lost?

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Barry1
Shopify Expert
11 0 1

I Managed to get this working by having the verification in a controller and routing to the controller, but it had to be in the construct, wouldnt work in the index method

javedali
New Member
1 0 0

How did you solve this? I am also facing the same problem. I am trying to recieve data from a webhook in Laravel. When I fire it to a route in Laravel and add the verify code into the route nothing happens. I also checked this: https://community.shopify.com/c/Shopify-APIs-SDKs/Shopify-webhooks-and-Laravel-routes/m-p/378017

This didn't work for me. Can you just tell me how did you included the PHP code in the controller and what modification you made in the routes?

VincentSAV
New Member
6 0 0

@javedali Hey my friend how are you ?

Have you fix this problem ? if so, how did you do it?
I am facing the same problem...

Thank you my friend