Issue with Refunds and Sales Totals Using Shopify REST API

Hi,

I’m using the Shopify REST API to generate reports that integrate with other sales channels. Specifically, I’m using the /admin/api/2024-10/orders.json endpoint to fetch orders filtered by date in order to calculate daily sales totals. Most of the time, this works fine.

However, there are specific cases causing issues. For example, on July 20, the API returns an order with the status refunded, and it includes its respective refunds. The problem is that the refund dates are July 23, so the discounts shouldn’t be applied until that date (as reflected in the “Sales over time” report).

When I change the filter to July 23 and perform the respective calculations, the total sales amount for that day ends up being higher than what the Shopify report shows. This happens because there’s nothing in the API response to reflect the refund of the order created on July 20.

This issue is recurring. One of the key purposes of using the REST API is to allow businesses to access their data and generate specific reports, in my case, to declare the company’s net income by date. For example, if Shopify processes a payout on July 24, how can I explain that the sales report for July 23 shows more money than Shopify actually disbursed?

I’ve seen similar cases discussed before, but I haven’t found a solution or clarification from Shopify. It’s frustrating that Shopify seems to require querying orders from the beginning of time to reconcile each payout manually and then apply refunds where necessary. This is incredibly inefficient.

It would be much simpler if, in addition to the endpoint for filtering orders by date range, Shopify provided an endpoint to retrieve a list of refunds along with their associated orders, also filterable by date range. This would optimize requests on both our side and Shopify’s.

I apologize if a solution already exists and I simply haven’t found it. I’ve opened two support chats, but no one has been able to clarify whether this issue has been resolved. If anyone has already found a solution, I’d greatly appreciate it if you could share it.

Here’s the reference number for the ticket I opened (52523693), in case a Shopify developer wants to review my specific case.

Thank you in advance!

Just a heads up, REST is being deprecated so you might struggle getting support. Have you looked at moving over to GraphQL?

Hello,

As you are experiencing, the order REST resource will give you a snapshot of the order at its current state in time. It sounds like what you are looking for is the state of the order at some previous time to be able to calculate the sales for that previous day. I think there are two options for this:

  1. Reconstruct the data by adding refunded amounts from future days. For your example, the order retrieved will include the refunded amounts from the refund on the 23rd, and you could inspect the refunds on the order to add these values back onto the sales for the previous day, the 20th.
  2. If you migrate to GraphQL we expose the SaleAgreements connection on the Order. These agreements have dates they happened at, as well as all the associated Sale records. Using this you can pull out precisely which sales happened on which day with no refund inference required.
1 Like