Discussing APIs and development related to customers, discounts, and order management.
My app helps with returns management. In certain instances, we need to restock returned items without creating a true refund. We flow through the `POST /admin/api/2021-07/orders/{order_id}/refunds/calculate.json` endpoint, get a transaction, and then set the amount to zero for all line items before invoking `POST /admin/api/2021-07/orders/{order_id}/refunds.json` such that we are restocking with a zero dollar refund. To my knowledge, this is the only way to restock via the API.
We have now encountered a customer using a payment gateway that has disabled refund support. In the /admin UI, the "Refund" button does not appear. Instead, a "Restock" button appears. When I attempt to use the `refunds/calculate.json` API, though, I get back zero transactions. How can I restock this items via the API?
Solved! Go to the solution
This is an accepted solution.
Hey @mistahenry,
The refund endpoint in your instance doesn't need to specify an actual transaction. You can make the refund request to the REST endpoint without specifying a transaction (skipping the calculate step) and simply set all your line item amounts to zero as you do in your other example. Doing this will mean that inventory is returned but no transaction amount is refunded on the order in Shopify. I believe this works for your example where the merchant has disabled refunds for the associated payment gateway on the order.
Regards,
John
John C | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me 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
This is an accepted solution.
Hey @mistahenry,
The refund endpoint in your instance doesn't need to specify an actual transaction. You can make the refund request to the REST endpoint without specifying a transaction (skipping the calculate step) and simply set all your line item amounts to zero as you do in your other example. Doing this will mean that inventory is returned but no transaction amount is refunded on the order in Shopify. I believe this works for your example where the merchant has disabled refunds for the associated payment gateway on the order.
Regards,
John
John C | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me 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
@_JCC_ This worked like a charm for restocking these gateways that don't support refund, thank you so much!
On a related note, I tried the same approach for a true refund, in which the actual refund is done externally but my app attempts to make the books right. More technically, I bypassed the `/calculate` endpoint, and sent back a refund like:
{
"refund": {
"currency": "MYR",
"notify": false,
"refund_line_items": [
{
"line_item_id": 123456,
"quantity": 1,
"restock_type": "return",
"amount": 59,
"location_id": 554324231
}
]
}
}
@_JCC_ here's another thread of people asking essentially my same question (albeit in the context of external refunds when the gateway provider may support refunds):
https://community.shopify.com/c/shopify-apis-and-sdks/create-a-return-without-a-refund-via-api/m-p/1...