Solved

How to get all daily refunds via API

gg7
Visitor
1 0 1

Hello there,

 

I'm wondering if it's possible to get a daily list of all refunds for the day without having to query through each past order as specified here: https://help.shopify.com/en/api/reference/orders/refund

It seems quite inefficient to have to go through each order to find all refunds.

 

Thanks!

Accepted Solution (1)

Visely-Team
Shopify Partner
1843 210 488

This is an accepted solution.

You can use Orders API - https://help.shopify.com/en/api/reference/orders/order#index-2020-01 - with financial_status=refunded query param as well as updated_at_min and updated_at_max

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog

View solution in original post

Replies 12 (12)

Visely-Team
Shopify Partner
1843 210 488

This is an accepted solution.

You can use Orders API - https://help.shopify.com/en/api/reference/orders/order#index-2020-01 - with financial_status=refunded query param as well as updated_at_min and updated_at_max

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
Sling
Shopify Partner
5 0 1

Hey Shopify Team!

I'm trying to get refunds for some orders in the way you proposed, I'm not entirely successful with it though.

So today we have Feb 25th 2021. We have a client who had some Order created on Nov 18th 2020. Then, this order was refunded on Jan 11th 2021. When I'm trying to fetch refunds like 

`/orders.json?limit=250&status=any&fields=id&since_id=1&financial_status=refunded&updated_at_min=2021-01-01`

I'm not getting this order in the response. Does this relates to https://community.shopify.com/c/API-Announcements/ACTION-REQUIRED-Apps-require-Shopify-approval-to-r... Is this expected behaviour?

 

Thanks, Pawel

hamma11
Tourist
4 0 1

facing similar issue. were you able to solve it? thanks

 

jenkinsbilly
Visitor
1 0 0

Hi there, this does not solve the problem when pulling historical data.

 

If a purchase is made on day 1 and refunded on day 2, a confirmation email is sent on day 3. The orders 'updated_at' endpoint will not get the refund on the correct date, as a new 'updated_at' value is added on day 3.

 

The only real fix i see, is to use the proposed solution and then filter each day to find the discrepancies. Then manually search the orders in the platform and append the required fields to your dataset. I hope there is another way?

zamartz
Shopify Partner
1 0 3

agreed with other posts here - this only works if the order and refund are on the same day.
In cases where i want to see what was purchased and refunded on the same day this wont work.

you can almost get away with looking at the "update_date" but if any other update is made on that order other than the return (like a comment or tag added) this also wont work.

"refund" API needs the ability to call all refunds like "orders" api.

markmaurerrr
Shopify Partner
5 0 7

Your approach is not working, don't know how this can be the accepted solution. Also i really can't believe that such a simple thing is such a nightmare in the shopify api. Refunds have to have its own endpoint, everything else is a huge mess of unneccessary data processing!

ShopifyDevSup
Shopify Staff
1322 217 457

Hello all - thanks for getting in touch. I just wanted to reach out to mention that while this behaviour is currently expected (that in order to query refunds, you have to first pull them through their respective orders) - I do understand the need for a more efficient way to query refunds in general. Enabling this would streamline processes and make the development experience a bit better - you all raise really great points here. 

I can't guarantee anything on my end here - but I partly also wanted to reach out to update you all that I will be passing your feedback along to our product team. As mentioned, I'm unable to confirm what the next steps on this would be or if the feature would be considered, but I can guarantee that our developers will take a look at your feedback here for potential future consideration. 

Thanks again for reaching out here - these are definitely valuable concerns, so I'm happy to bring them up to our team. 

Al | Shopify Developer Support 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

markmaurerrr
Shopify Partner
5 0 7

I really appreciate your answer but i want to add an example to discuss with your developers to demonstrate how mind-boggling this is.

This month there was a refund for an order that is already 4 years old. Could be any reason. Refunds can be made for any order. Now it's the end of the month and I need to find out which refunds were done this month to export the outgoing payments (refunds) to the accounting software.

The store has ~50.000 orders every month, since 4 years, so we're talking about 2.4 million orders in that time period, with a refund rate of 30% we're at 720.000 refunds. And there are WAY bigger stores with WAY more orders existing out there.

Technically to find out (100% accurate) if any order was refunded this month I'd have to fetch all 720.000 orders (refunded oder partially_refunded), which already takes hours and then loop trough all of them and check if any order has a refund with "processedAt" date from this month. This is not doable so the only approach is to build a huge complex setup with another external database where refunds are stored to be fetched more effectively, triggered by refunds/create webhook. Correct me if i'm wrong and you have a more effective solution for that really common task.


But... This could be a simple call to your refunds api with a date range query. Voilà refunds from this month received within seconds.  This is how we developers are used to work with apis.

Honestly, this is an absolute nightmare. People came up with this problem multiple times now and i just can't believe that after such a long time there is still no solution for that.

Please get this fixed!


kishan_gohel
Shopify Partner
11 0 6

Hi,

Your solution has some cracks that can probably mess up the refund functionality. Like here, you suggest using webhook to get refund data. But, what if the webhook fails for some reason? Here, I am not using any database table to store any details regarding the refund. So, Is there any robust solution?

However, you already said that you are using a database to maintain refund logs or something.  This works for you, but not an efficient way to deal with refunds.

Hey Shopify team, 
Please figure out this issue ASAP.

Mantas3
Shopify Partner
4 0 0

Are there any updates to this?

kishan_gohel
Shopify Partner
11 0 6

HI Shopify team,

We are eagerly waiting for your response related to retrieving refunds directly via the API endpoint.
Please pay attention to this issue as many many developers facing.

kishan_gohel
Shopify Partner
11 0 6

This solution does not work anymore now. Why this solution has been accepted even many many developers are still facing it?
I request Shopify team, please add a robust and accurate solution for this.

https://[store-name].myshopify.com/admin/api/2022-04/orders.json?financial_status=refunded

This is not returning any of the refunds. Has anyone tried this solution and is it still working or not?