Issue Refunding A Cancelled Order Using Shopify REST API
I am trying to cancel and refund an order using this endpoint:
https://help.shopify.com/en/api/reference/orders/order#cancel
With the following payload:
{"refund": {
"shipping": {"full_refund": true},
"refund_line_items": [{
"quantity": 1,
"line_item_id": 2032498606169,
"price": "39.90",
"subtotal": "39.90",
"total_tax": "6.37",
"discounted_total_price": "39.90",
"total_cart_discount_amount": "0.00",
"location_id": null,
"restock_type": "no_restock",
"discounted_price": "39.90"
}],
"transactions": [{
"amount": "39.90",
"maximum_refundable": "39.90",
"kind": "refund",
"parent_id": 1147873263705,
"currency": "EUR",
"order_id": 922997620825,
"gateway": "amazon_payments"
}],
"notify": true
}}
The order has just this one article, so I am basically refunding the entirety of this order.
However, this REST API call returns success, but when I go check the order's page, I do see indeed that the order was cancelled, but there was no refund after all.
And the order status displays "Canceled", "Paid", "Unfulfilled". So I end up having to refund it manually.
Why is my REST call just cancelling this order, but not proceeding with the refunding?
Thanks!
Answer
You have the wrong reference. From your reference the cancel post should be:
POST /admin/api/2019-04/orders/#{order_id}/cancel.json {} // post an empty object -- not null
The Refund api at https://help.shopify.com/en/api/reference/orders/refund#create shows a slightly different POST body than what you supplied. You don't need any of the price info in your refund_line_item.
Have you verified the parent_id in the refund is a sale
or capture
transaction and that the gateway type matches.
Related Questions
- → Does anyone know how to solve IP canonicalization with shopify platform?
- → How can I add a featured image from a blog post to my homepage on shopify
- → Shopify - Get list of product from a specific collection
- → Shopify webhooks not wanted
- → Comparing two large files are taking over four hours
- → Need "add to cart" button price to update with correct amount depending on what checkbox is checked
- → How to append a variable inside another vaiable name in liquid html
- → GET /admin/webhooks.json returns an empty array
- → Javascript function not getting executed properly
- → How to give border to to current displaying border
- → Shopify background image
- → Dynamic Attribute Names in Shopify Cart
- → What after added shopify store into shipstation