Cant cancel and refund a COD order: Shopify Admin REST API

Topic summary

Issue: Unable to cancel and refund Cash on Delivery (COD) orders via Shopify Admin REST API with the same outcome as the Shopify dashboard.

  • Current flow: Use refunds/calculate to build a refund object, then POST to orders/{id}/cancel with reason and email. Works for paid orders.
  • Problem on COD: refunds/calculate returns an empty transactions array (no payment transaction exists for COD), preventing a refund payload from being created.
  • Discrepancy: Canceling a COD order via API without a refund leaves the order amount visible, while canceling the same in the Shopify admin dashboard sets the order total to 0.
  • Implication: There appears to be an internal mechanism the dashboard uses to zero out canceled COD orders that isn’t exposed through the public API.
  • Evidence/Debug: X-Request-ID provided (3764232d-79a2-4975-9b2c-a64fbdf3a7a3).

Status: No workaround or official method identified; request for a solution remains open.

Summarized with AI on January 21. AI used: gpt-5.

If I want to cancel and refund an order, i first would hit the calculate endpoint

POST https://{{store-name}}/admin/api/{{api-version}}/orders/5322564469010/refunds/calculate.json

and then we dump its response to the “refund” object in this endpoint

POST https://{{store-name}}/admin/api/{{api-version}}/orders/5322570367250/cancel.json?reason=customer&email=true

Now this works great for paid orders, but for COD order, the transactions array from the calculate endpoint is empty!

My X-Request-ID is 3764232d-79a2-4975-9b2c-a64fbdf3a7a3

I know there is no “transaction” done for a COD order, but if i cancel the order without refund, then the order amount shows up in the order vs if i cancel a cod order directly using the shopify dashboard, the order amount is set to 0.

So there is definitely some internal API to mark the value of a cancelled cod order as zero, i guess its not just exposed yet.

Could anyone find a way? Still stuck on this