Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How long does it take for a webhook to fire?

How long does it take for a webhook to fire?

provenq
Shopify Partner
22 0 3

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.

Replies 4 (4)

oscprofessional
Shopify Partner
16116 2409 3125

Hello 

 

<?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);
}

 

 

 

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: pallavi@oscprofessionals.com | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free
provenq
Shopify Partner
22 0 3

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?

Jason
Shopify Partner
11206 226 2314

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.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
ovidiucaramida
Shopify Partner
22 0 11

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.