Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon MWS API: Some orders are missing when we download orders

I have implemented a system to download an Amazon seller's orders. The system works like this:

  • we start off wanting to download orders from 12:00pm - 2:00pm, so I tell Amazon (via their Java client): "give me all orders from 12:02 to 2:00 (the two minute time difference is to accommodate pending orders as described by Amazon in their API).
  • We fully download these orders: if there are more than a hundred we use the next token, and once we have them all we use the listOrderItems operation on each order to get the line items.

Some of these orders are pending and, if so, we store them in our database and check them next time to see if they are ready for download. Our next job would run for the next two hour interval, asking for all orders from 2:00 to 3:58.

This operation was working fine, but our customers started to report missing orders on their end. Apparently every now and then an order will slip through the proverbial cracks and we are not sure why. To try to fix this we set up a 30 minute overlap so that each time we downloaded orders we looked 30 minutes in the past. In addition to the penalty of downloading redundant orders we have to check the database to see if the order has already been processed so it slows things down quite a bit.

And to rub salt in the wound, it still has not fixed the problem! It doesn't happen as often, but a 0-4 orders show up missing on an average day.

like image 722
IcedDante Avatar asked Oct 20 '22 14:10

IcedDante


1 Answers

Getting orders via ListOrders seems to have a number of pitfalls.

The following is a response from MWS support staff,

Please note that an order is only populated in the ListOrders data when it has cleared some internal checks (mostly for fraudulent orders). This means that there will be a delay between when the order is created, and when it shows up in API queries (or in SellerCentral, for that matter). This delay is usually a few minutes, occasionally half an hour, and very rarely multiple hours.

And some orders can move from pending status to unshipped status very soon. The order id --- is been in pending status only for 7 seconds and all the requests you have made are before the time this order is actually available for API to populate in ListOrders. And even the order --- is in pending status for 17 seconds and you made the requests before that. Once you receive the email notification they are no longer in pending status.

Since you are selecting orders by their creation date, you may easily miss orders that were created, but haven't passed pending state.

In my experience, a reliable way to get all orders is to call GetReportList, asking for all _GET_ORDERS_DATA_ reports which haven't been acknowledged yet - then acknowledge the ones you've stored in your system. The "Acknowledged" flag in the Amazon system keeps the two systems in sync. The beauty of this solution is that you don't have to worry about time stamps.

like image 174
Hazzit Avatar answered Oct 22 '22 09:10

Hazzit