How to get all orders of a single payout

Highlighted
Tourist
9 0 1

Hi there,

I'm fighting with Shopify's API to retrieve what is easily accessible via the web browser, but cannot get the data I need via the API. I want to write a python script that generates a monthly payout reports. For that it should collect all payouts within a certain month, let's say last month. And for every single payout, I need the ORDERS that are part of it and which FORM the payout amount of that day (ID, #xyzy-Name, anything to work with).

However, according to the documentation (https://shopify.dev/docs/admin-api/rest/reference/shopify_payments) it is possible to get a list of payouts with the "/shopify_payments/payouts.json" endpoint and additional information for a single payout with "/payouts/{payout_id}.json". But that .json does NOT list the most important detail in my opinion: the order IDs that belong to that payout! I have no idea why, but isn't it THE most important thing together with the amount?

Maybe I am doing something wrong here, but what I would need is something like this:

1. Collect a list of payouts in a certain month -> Easy, I have done that
2. Go through that list an collect per payout all orders (ID, name, whatever unique attribute) and its amount -> Seems to be impossible

So my question is: How do I get for a specific Payout-ID "blablabla" a .json with all order-ids that form the payout? Any help is really appreciated! I think this should be possible as I can get the information manually by clicking on the payout in the Shopify backend. But copy&paste into Excel is not the preferred workaround to be honest :-(

0 Likes
Highlighted
Shopify Partner
234 14 49

Depending on the depth of data you are looking for, couldn't you iterate through the Order endpoint and pull the payment data that way?

0 Likes
Highlighted
Tourist
9 0 1

Hmm, that would be absolutely OK for me. But I would need an endpoint per order that gives me the ID of the corresponding single payout. I cannot figure out any suitable order endpoint though :-(

0 Likes
Highlighted
Shopify Partner
234 14 49

I must be missing your goal. Are you looking to sum up payment types that have been used? For examples, yesterday there were three orders totaling $300 on Visa, two orders totaling $100 on Mastercard, five orders totaling $700 on PayPal, etc. If that's what you are looking for then all you'd need to do would be to query the Order endpoint, iterating through each order and totaling up its respective payment type with dollar amount. Is this what you're looking to do?

0 Likes
Highlighted
Tourist
9 0 1

Hmm, not exactly to be honest. What I need is per payout all orders that are associated with that payout, to be precise the #-numbers of the orders OR the unique order ID. The problem with your suggestion is that payouts are not aggregate all orders of a single day, but sometimes (regularly) one payout has orders from various days. This especially happens over weekends or bank holidays. For example:

  • On a payout on a Thursday, all orders from a Tuesday  are summarised and paid out. That is easy.
  • But a payout on a Monday or Tuesday has orders from the previous Friday, Saturday and Sunday! And with bank holiday midweek, this gives no routine that could be put in a ´n automatic script. That seems to be impossible via API endpoints.

However, if I log into Shopify and click on settings and open up the list of payouts, I can click on every single payout and see all orders with the #-number that are associated with this certain payout and account for the overall payout amount. So this information is available in the backend GUI - so it must be easily accessible per API. However, the endpoint one would assume is not available.

By the way, if you wonder why I need that information: It is because our tax law in Germany requires to associate every inbound money to a bank account with a customer bill. However, the individual bills have the individual order amount whereas the Shopify payouts are aggregated amounts of various orders and the corresponding inbound money is the aggregated sum. And that disaggregation of the sum into individual orders (=bills) is what is needed. And currently it is only possible by manually clicking through every payout per month, copy&paste the #-number per payout to Excel and generate the report. Which is really annoying the more orders you get.

I really wonder how other companies deal with this. Is everyone doing it manually? Or not at all? Well, good luck with your finance authorities then ;-)

Best regards,
JB

0 Likes
Highlighted
Shopify Partner
234 14 49

Oh I see what you are getting at now. Sorry for my being behind the curve :) In our region of the US, we don't have such a requirement so I've never encountered the need. I'd imagine that what you need might be doable, but involving querying multiple API endpoints and cross-referencing them. If this isn't doable then hopefully there are third party apps available from Shopify partners. Especially seeing that if this is prevalent for a lot of Shopify customers in your part of the world! If there aren't apps available maybe you can market your own solution you come up with :) 

0 Likes
Highlighted
Shopify Partner
234 14 49

Just came across this --> https://shopify.dev/docs/admin-api/rest/reference/shopify_payments/transaction?api[version]=2020-07. Wouldn't this help bridge the gap? It does list the order ID's associated with the transactions, right?

0 Likes