Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
I've been testing webhooks on our development store, and I registered for the carts/create and checkouts/create topics. When I went to our development store, I clicked to add a product to the cart, then clicked to checkout. I checked the logs for our webhook, and saw no logging (it hadn't been called). I thought it wasn't working since I saw no logging. however, the next day, I saw the log events had fired a day later. I believe it was roughly 12 hours or so later after actually clicked to add to the cart and checking out.
I've tried a couple more times, and that seems to be the case. Does anyone know how long it is supposed to take for an event to trigger a call to your registered endpoint? That is, if a person clicks to checkout, and you've registered a webhook to receive that event, is it supposed to be fired within seconds of someone clicking to checkout, or is it customary for it to take hours? Or is this just a development store quirk?
Just FYI: I know the webhook logs immediately when invoked, because when I call it in Postman, it logs right away.
Hello provenq ,
Web-hooks are immediately triggered when event is fired and as its not working in yours then you should check the below given points:-
1) The server on which the request is send should be SSL certified with A grade.
2) We have to verify the request. You can use this code to verify it:-
<?php
define('SHOPIFY_APP_SECRET', '#########################');
function verify_webhook($data, $hmac_header)
{
$calculated_hmac = base64_encode(hash_hmac('sha256', $data, SHOPIFY_APP_SECRET, true));
return hash_equals($hmac_header, $calculated_hmac);
}
Want to modify or custom changes on store hire us.
If helpful then please Like and Accept Solution.
Email: pallavi@oscprofessionals.com
Thanks for the response. I will take a look at those steps and verify. We have an Amazon cert, so I assume that is good. But I do not believe we are checking the HMAC. Though, why would the HMAC not be valid for an actual shopify call?
It is possible for a webhook to be delayed so the comment above about them firing instantly is incorrect. That said, I would not expect the delay you're seeing.
In my case, the app/uninstall webhook is triggered after more than 2 minutes after the app is uninstalled from the shopify store.
Because of this, my app fails app review every time because the app doesn't know when to reset the session and this will lead to failure when trying to reinstall.