Shopify refund amount wrong when refund in pending state (Admin REST API)
Solution:
I think I have figured out what is going on, but I cannot find any official documentation of this phenomena, only a few other reports from site owners such as this one (https://community.shopify.com/c/shopify-apis-and-sdks/multiple-order-adjustments-of-type-refund-discrepancy/td-p/881261).
When a refund is logged, there is an associated physical funds transfer to the customer. In the REST API data, the funds transfer is called the "transaction". Shopify may delay the execution of this transaction, and in this case the transaction has a status of "pending" and when complete changes to "success".
If the transaction starts with a pending status, Shopify adds a "discrepancy" adjustment to make the net value of the refund zero (I think the reason is to indicate that no physical refund has happened yet, maybe for reporting purposes). Later when the transaction is complete, another adjustment is added to reverse the first, i.e. making the net value of the refund correct.
So, to get the correct net value of the refund, find any transactions inside the refund with status="pending", then filter out adjustments (with kind="refund_discrepancy") that have the same value.
Source
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.