Webhook event "orders/create" not fired

John-Recrea
Tourist
7 0 5

Hi,

I'm having a hard time trying to fix an issue related to the event "orders/create" not reaching my server. I think creating orders directly in certain states prevents certain webhooks events/topics from firing. For example, as far as I know, if I create an order via API directly with the "paid" state, it won't trigger an "orders/paid" because there's no state transition. So we are wondering, what about the topic "orders/create" (the other one we're listening to)? Is there any situation where this event would not be fired when an order was created?

 

Best regards,

John

 

Replies 15 (15)

Keyurp
Excursionist
27 0 4

Hello @John-Recrea 

 

I request to you first check-in 'Setting>Notification>Webhook' in the Shopify admin and check any active webhook is there in this section. if activated then check the URL that you provided is the HTTPS.

Above, all the requirements is proper then please following the below link.

Ref:-https://shopify.dev/apps/webhooks/configuring#subscribe-to-a-webhook-topic

Thanks & Regards
Keyur Prajapati

John-Recrea
Tourist
7 0 5

Hi @Keyurp,

 

We're an app that use the API to manage webhooks on behalf of our users. I can confirm we can retrieve the webhooks via API and in fact regular orders created within Shopify send webhook notifications, however, one of our users is also using another app that is creating orders via API and only those orders don't create a webhook notification. We suspect they create the orders directly in the "paid" state, and thus, they won't trigger the "orders/paid" event, however the weird thing is that they also don't seem to trigger "orders/create". That's why we are wondering if there's any situation where that event is not triggered.

Best regards,

John

OliOnline
Excursionist
11 0 2

I'am having the same issue. After lots investigations, look like Webhook event "orders/create" being not fired happend when Shopify Admin is down. If the webhooks would fire fews minutes later it would be ok, but it's not the case, they are never fired. Some of my webhook were suposed to be fire on septembre 11-12 and still not receive them.

Same things for today.

Any change some Shopify DEV can confirm this issue ( I don't mind, just tel us ;))

John-Recrea
Tourist
7 0 5

Yeah, could any Shopfiy dev clarify this issue? At this point we're feeling like shooting in the dark trying to fix this issue. Support wasn't able/didn't want to respond my question via email and redirected me here.

HunkyBill
Shopify Expert
4845 60 547

You are probably being victimized by the third-party order creation, ie) and an external App is making the orders. While they are added to Shopify, it is not that they trigger webhooks as you already noticed for Orders/Paid. In order to get yourself ALL the orders you want, you might want to invest in a small routine to do bulk downloads every hour or something and cherry-pick the orders that show up that you did not get a webhook for. That solves that problem pretty quickly and easily.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
John-Recrea
Tourist
7 0 5

Even tho, we also listen to "orders/create", is there any situation where it's not triggered?

OliOnline
Excursionist
11 0 2

@HunkyBill, I do understand your approch and started to think of a similar solution..but...Is'nt it the goal of webhooks : keep the datas sync between two apps without having to bulk/cron/fecth the data on a regular basis ?

HunkyBill
Shopify Expert
4845 60 547

Let's do a little thought experiment. Imagine you are migrating from an old, crusty, Magento based shop to Shopify. You just imported 100,000 orders from your old system to Shopify for continuity. You used the API, and created those orders. Do you really expect Shopify to now fire off 100,000 webhooks for the sake of Apps?

The answer is no. Shopify is not going to trigger 100,000 webhooks for this. Imagine you made an error. And deleted those 100,000 orders due to that error. Now you fixed a line of code, and re-imported. Bingo, fire off another 100,000 webhooks?

For this reason, the goal of webhooks is limited to what Shopify deems to be created by Shopify. Not what you do with your store externally. YMMV.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
OliOnline
Excursionist
11 0 2

@HunkyBillthis example totally make sens, however, in my case ( and probably every one else on this topic ), it's not what's happening.

No other Apps are creating orders throught the API. Wehooks are randomly not fired, ONLY when Shopify's servers are having  problems OR when Shopify's support team confirmed to me that they had problems with some webhooks not firing.

In your example, huge amount of orders being created throught the API make sens not firing webhooks, but it won't make sens if it's an App creating "normal amount" of orders, it should fire them too ( well, it is my opinon )

John-Recrea
Tourist
7 0 5

@HunkyBill Well, in my case, yes, I would expect 100k webhooks to be fired. It would be counterintuitive otherwise. For example at which point would Shopify stop sending webhooks? With 100k orders created via API? At 10k? at 1k?

HunkyBill
Shopify Expert
4845 60 547

Take it up with Shopify. I am simply trying to focus in on the real issue, and that is one of "why" this person is missing certain webhooks. While it is easy enough to just blame Shopify for missing a few, in which case there is no need for a discussion, it also came up that the webhooks themselves are not well understood with respect to Shopify platform operations. As someone that has had Apps live and processing webhooks by the millions, it is not as if I am not also subject to the issue.

My information here is that you are NOT going to get webhooks for everything, no matter how hard you wish it were true. You can expect them all you want, but your little ding-dong bell, I got a webhook! is not going to ring in certain cases, so it is best to learn that and code for it. Why shoot the messenger. Takes more energy than solving the problem!

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
John-Recrea
Tourist
7 0 5

@HunkyBill I didn't mean to blame you for anything (sorry if it sounded that way) but I think that complacency is not something we should settle for. If something is broken on Shopify, or something doesn't work how it's supposed to work, I will make an effort to fix it where it should be fixed.

 

EDIT: In fact, I wrote a email to the Shopify support first, but they didn't want to answer me via email with the excuse that this question was interesting for the community so they redirected me here to ask in order to have a public answer. I really wasn't expecting a user response but an official response from a Shopify dev.

HunkyBill
Shopify Expert
4845 60 547

They do that to me too. I laugh as I understand that the chances of my question being answered here are slim to none. With few exceptions, when you find a true problem with Shopify, you are on your own! When you find a problem you think is Shopify, but in reality is just you, you will not often get much of a response, save for the few times someone points out the obvious.

I still don't understand why people think Webhooks should just always be fired. Even though it seems logical that they should, there are cases where in fact they should not, but not for obvious reasons!

A little story for you. Imagine you get a webhook wherein you have an order. So your code processes it, but crashes. You examine your logs and it crashed due to not having a Customer. You blink. You shake your fist. An order cannot exist without a customer! What is the point of an order without a Customer! So you write in these here forums employing BOLD fonts and capital letters. This is an outrage! Crickets chirp. Your destiny is not to get an answer.

So you eventually learn that at that moment in time, orders were created and fired off as Webhooks orders/create, without a Customer. Because it turns out, Customers are processed in a separate part of Shopify, and the latency between that process and the Webhook was such that the Webhook fired off prematurely! So when you did your due diligence and used the API to download the order, it had a Customer!

So now you are faced with blanketing your code with Exception clauses where you may not get what is expected in your payload.

Do you see how this slippery slope of expectation leads to less than stellar outcomes? Shopify has decided to change that, so that Webhooks now fire only AFTER the parts are all processed, so we rarely if ever now get an Order with no customer, but we can still get orders without a Shipping Address, at least on random days that seems to be the case.

In other words, don't rely on thinking you know how it works or think it has to work the way you think it should because that will just give you a headache. You have to be flexible. And adapt. Reality is not logical, nor does it always flow the same way through the pipes. Such is the nature of computing and debugging issues.

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
OliOnline
Excursionist
11 0 2

Shopify Webooks definitions here : https://shopify.dev/apps/webhooks

TLDR :

  • Webhooks are a useful tool for apps that want to stay in sync with Shopify or execute code after a specific event occurs in a shop.
  • When an event for a given topic occurs, the webhook subscription sends a relevant payload to the destination. ( not talking about "sometimes it dose'nt sent..)

  • [...] Whenever an order on the shop is created, the webhook subscription sends a webhook with an order payload to the registered endpoint.

  • Data about orders can change often. Instead of continuously polling for changes to orders, you can receive a webhook when a specific event occurs.

 

At the end of this article, they say : Your app shouldn't rely solely on receiving data from Shopify webhooks. Because webhook delivery isn't always guaranteed, you should implement reconciliation jobs to periodically fetch data from Shopify.

WOW, what a confusing docs....

 

kunalwf
Shopify Partner
28 0 4

Thanks - that's helpful. It turns out Shopify webhooks are definitely not reliable, and can sow chaos in your data if you rely on them to be.  You need to implement reconciliation jobs. It's good to know I'm not imagining this, but that they say so too, as even in their own Webhook examining interface for Partners, I could see no webhooks listed at all at certain timespans.  It looks like the Webhook system on Shopify has occassional downtime and there's no catchup process they use to fix their errors, you're just SOL at those times without a reconciliation process