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

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