I’m working on an app that handles refunds for unavailable inventory items through the Shopify API. When I make the refund request, everything seems to work fine and I get a proper response, but the refund doesn’t show up in the Shopify admin panel when I look at the order.
I have a collection of items to refund stored in items_to_refund
and I’m processing each one individually. Here’s what my implementation looks like:
refund_estimate = ShopifyAPI::Refund.calculate({
currency: "USD",
notify: false,
note: "Item unavailable",
shipping: {
"full_refund": false
},
refund_line_items: items_to_refund.map { |item|
{
line_item_id: item.id,
quantity: item.quantity,
restock_type: 'no_restock',
}
},
}, {
params: { order_id: order.id },
})
processed_refund = ShopifyAPI::Refund.new({
currency: "USD",
notify: false,
note: "Item unavailable",
shipping: {
"full_refund": false
},
refund_line_items: items_to_refund.map { |item|
{
line_item_id: item.id,
quantity: item.quantity,
restock_type: 'no_restock'
}
},
transactions: refund_estimate.transactions.map { |transaction|
{
kind: "refund",
gateway: transaction.gateway,
parent_id: transaction.parent_id,
amount: transaction.amount
}
},
}, {
params: { order_id: order.id }
})
The response I get back shows all the expected data with proper IDs and amounts, but when I check the actual order in Shopify, there’s no refund recorded. Am I missing a step to actually save the refund? Any help would be appreciated.