eBay GetOrders : how to distinguish combined orders from original transactions
Asked Answered
L

3

7

My eBay integration just broke after months of working properly and I'm not sure if its a bug or not on their end.

My buyer made 2 transactions of two different items and then combined them to save shipping. All this happened in a matter of a few minutes.

This had the following result :

  • New sales record created (which incidentally doesn't show up in seller manager)
  • New OrderId created for the combined order. Contains the two transactions (as expected). This OrderId was assigned to the original 2 orders and the combined one (not expected!)
  • Three orders returned in call to GetOrders. All have the same OrderId value
  • The CreatedTime on each OrderType returned is different for each with the most recent order having the latest time (as expected).

What I'm trying to figure out is how I'm supposed to know not to ship all 3 orders. If my code hadn't been trying to put these orders into a dictionary then I wouldn't even have known there were duplicate OrderId values being returned.

I'm hoping there's a property somewhere that indicates the order record was combined into another order - but I can't find it.

Am I supposed to look at the time of the order and pick the most recent one? Or is there a way to exclude transactions that have been subsequently combined from the search results.

Latimer answered 30/8, 2012 at 5:55 Comment(7)
wierd - I put a bounty on this and it got 3 upvotes but no answerLatimer
Have you got any updates to this problem?Marikomaril
@SH no - I ended up just looking at the time and picking the latest :-/ I only ever had this once in months. I'm not sure exactly what my buyer did that triggered this behavior. I assume you seeing something similar? [added my code as an answer]Latimer
I've just got the same error and I'm wondering how to deal with it! Should't an ID be unique ? to me it's another ebay weirdness :(Obreption
Simon_Weaver and @mCasamento, did you ever end up finding a more robust solution, or are you still stuck with "pick the latest"?Ventail
Also, when you had this problem, did all of the orders show up in status "completed"?Ventail
it looks like they solved this problem in late january, from this date on didn't get errors anymoreObreption
L
1

This is my C# code to check for dupes of this nature and return only the latest order. There's a lot of assertion checking in here but it hasn't crashed yet - then again I don't know if the codepath where o.Count() != 1 has ever been hit yet.

        // raw orders coming back from eBay
        var orderArrayRaw = getTransactions.ApiResponse.OrderArray.ToArray();

        // processed list to remove dupes
        var orderArray = orderArrayRaw.ToArray().GroupBy(x => x.OrderID).Select(o =>
        {
            // single unique order
            if (o.Count() == 1)
            {
                return o.Single();
            }
            else
            {
                // get most recent
                var mostRecent = o.OrderByDescending(x => x.CreatedTime).First();

                // get all the transaction IDs in the non-most-recent
                var allTransactions = o.Except(new[] { mostRecent }).SelectMany(x => x.TransactionArray.ToArray().Select(t => t.TransactionID)).OrderBy(x => x).ToArray();

                var combinedTransactions = mostRecent.TransactionArray.ToArray().Select(x => x.TransactionID).OrderBy(x => x).ToArray();

                if (allTransactions.SequenceEqual(combinedTransactions))
                {
                    // ok!
                    return mostRecent;
                }
                else
                {
                    var dupes = orderArrayRaw.ToArray().GroupBy(x => x.OrderID).Where(x => x.Count() > 1);
                    var dupeIds = dupes.Select(x => x.Key).ToArray();

                    throw new ApplicationException("The following orders were returned more than once in the response " + string.Join(", ", dupeIds));
                }
            }


        }).ToArray();
Latimer answered 21/9, 2012 at 4:28 Comment(0)
A
1

It doesn't guarantee that the latest order is the one with the combined order nodes. In my experience, it happened that the later order is only a suppose line item of the previous order. We reported countless times to ebay support on this and they only say that they'll fix it soon.

My solution for now is compare with the order's PayPal transaction using the GetTransactionDetails API. I assumed the PayPal transaction should have the combined order records. What I did is, I created a map of ebay line items ({ItemID:Quantity}) and created a map of paypal transaction line items ({Number:Quantity}) then compared the two with the paypal transaction map as the reference. If an ebay order node doesn't match with the paypal transaction, then ignore it and proceed to next order node until the one with the combined order is met. Sometimes, the one with combined order records comes first of the order nodes of the GetOrdersResponse, so just ignore the next ones when detected. Hope I helped.

Alterant answered 31/3, 2015 at 1:40 Comment(0)
L
1

Looks like eBay orders are created when a buyer commits to buy for example winning the auction. So when they are about to make the payment they can combine these orders together and it would create another order with the transactions. I am having the same issues as well, just thinking what if we pass the order status only to retrieve the complete orders?

A good presentation by eBay about the API https://youtu.be/n4UDGrO6H_g?t=1111

Lelandleler answered 21/8, 2021 at 9:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.