Issue Refunding A Cancelled Order Using Shopify REST API

I am trying to cancel and refund an order using this endpoint:

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.

enter image description here

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?




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 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.