Re: Laravel Verifying Webhook

Laravel Verifying Webhook

ostamustafa
Visitor
2 0 0

hello,

I'm trying to verify the webhook sent from shopify over to my laravel project and i followed the documentation from this link https://shopify.dev/tutorials/manage-webhooks#verify-webhook and I'm still unable to verify the webhook, if any more information is needed i will be happy to provide

Replies 3 (3)

mikedasilva
Shopify Staff (Retired)
61 7 13

Hi @ostamustafa 

 

We can try and help out but we'll need more information. Can you provide some errors and/or logs? With that, we can then try and point you in the right direction.

Cheers,

Mike

 

To learn more visit the Shopify Help Center or the Community Blog.

ostamustafa
Visitor
2 0 0

I am receiving the webhook to my project and when i try to verify the webhook by checking the hmac header it will give me that the verification process i followed is producing an non-equal hmac hash

private function verifyWebhook(string $data, string $hmacHeader, string $appSecret)
{
    $calculatedHmac = base64_encode(hash_hmac('sha256', $data, $appSecret, true));
    return hash_equals($hmacHeader, $calculatedHmac);
}

I'm getting the $data via

file_get_contents('php://input')

 and the $appSecret from the shopify dashboard which beings with shpss_

and the $hmacHeader via 

$request->header('X-Shopify-Hmac-Sha256')

 

Am I doing anything wrong?

giudax
Visitor
2 0 0

I have the same problem, but in my case works only "CreateUser" Webhook.

For all the other Webhook I have the same problem as you.