Cancelling a shipping line makes it impossible to refund the shipping cost directly

First we call:

  • orderEditBegin
  • orderEditSetQuantity
  • orderEditRemoveShippingLine
  • orderEditCommit

Then when I try to call refundCreate with a shipping amount, it errors:

{
  "data": {
    "refundCreate": {
      "refund": null,
      "userErrors": [
        {
          "field": [
            "shipping"
          ],
          "message": "Shipping must have amount less than or equal to remaining shipping"
        },
        {
          "field": null,
          "message": "either refund line items or refund duties or transactions or refund methods must be present"
        }
      ]
    }
  }
}

While this makes sense because I removed the shipping line, it now has 4.95 that isn’t refunded. What’s the proper flow here?

Hey @Lynn-srs - thanks for reaching out

In this flow, you’r right that once orderEditRemoveShippingLine is committed, there isn’t any remaining shipping amount left for refundCreate.shipping to allocate against. The 4.95 is still an amount that needs to be returned because the order edit reduced the order total, but it isn’t treated as remaining refundable shipping anymore, so shipping: { amount: "4.95" } hits that validation.

The two paths I’d suggest testing are:

  1. If you need this recorded specifically as a shipping refund, create the refund while the shipping line/amount still exists. The shipping amount should be included in the refund transaction total as well as the shipping field.

  2. If the shipping line has already been removed, try settling the outstanding amount with a refund transaction/refund method for 4.95, but omit the shipping filed. In that case you’re refunding the order edit balance rather than allocating the refund to shipping.

If that second path still errors, could you share the API version, a redacted refundCreate input, and the x-request-id from the response? I can take a closer look from there. Hope this helps!

For the time being I’ve implemented path 2 and that works.