Hiya,
Noticed a bit of a bug when refunding via the API..
If you perform a RefundOrder call (no returns) on a line, the totalRefundedSet.shopMoney.amount value always comes back as 0.0 even if you’ve successfully refunded i.e. 5.00.
This seems to be specifically when its a third-party payment gateway, i.e. Klarna / PayPal.
When the transaction goes from a “pending” state to successful, the amount then comes back successfully.
I feel that the totalRefundedSet value should come back at the same amount regardless of the transaction state?
As an example, here is my GraphQL call:
mutation RefundOrder($input: RefundInput!) {
refundCreate(input: $input) {
refund {
id
totalRefundedSet {
shopMoney {
amount
currencyCode
}
}
}
userErrors {
field
message
}
}
}
1 Like
Hey @ceri_waters,
Looking over our documentation for the totalRefundSet, this would be expected when the transaction is still pending.
This field specifically references the transactions:
The total amount across all transactions for the refund, in shop and presentment currencies.
You may need to poll the transaction status and then fetch the totalRefundSet once that clears. The benefit of this is that if you need to take action based on the refund you know it’s cleared before anything else happens.
If the above doesn’t help, can you share your use case for needing this immediately? I’ll pass that feedback on to our team to consider for future updates.
Hey @ceri_waters, Are you still experiencing this issue, or can I mark this as solved?
HI @KyleG-Shopify,
Thanks for checking in.
I feel like the documentation should be amended to make this a little bit more clear? Perhaps a note against the totalRefundSet specifically? I.e. this excludes pending transactions
Do you happen to know if an order update Webhook would be posted as/when the pending refund goes through (or doesn’t)?
Currently with this setup, there’s no way to easily confirm that:
- The refund request was created ok
- The refund amount matches the amount you requested
- If the refund does fail, the amount that was attempted to be refunded
Perhaps there needs to be an additional property? I.e. totalAmountSet? (Which has the amount of the refund regardless of the transaction status).
I just ran a test with a few different webhooks to confirm what happens with pending refunds and webhooks. You do receive webhook notifications as the refund progresses: initially when you call refundCreate, you’ll get orders/updated and refunds/create webhooks immediately. Then once the pending refund actually clears, you’ll receive tender_transactions/create and orders/updated webhooks again.
Your suggestion about adding a note like “excludes pending transactions” and potentially having a totalAmountSet field for requested amounts regardless of status are both valuable feedback that I’ll pass along to the team.
Hi @KyleG-Shopify thanks very much!