Best method to cancel order after refund

I am implementing a method to allow for a customer to cancel an order after the order has already been paid for. I currently am refunding the customer when they request the cancellation. Now I am looking for a way to update the order.state to be set to “CANCELED” after I refund the payments attached to this order.

This is the error response I receive:
{"errors": [{"code": "BAD_REQUEST","detail": "Orders cannot be canceled after payments have been processed.","field": "order.state","category": "INVALID_REQUEST_ERROR"}]}

How can I set the order.state after the refund to “CANCELED”?

Unfortunately, you can’t. You will be unable to cancel it once an order has a payment attached to it; and if it was already marked as COMPLETED you can’t edit the order at all unfortunately. However, if you do do a refund, a new Order object will be created, and will reference the original order as a source_order_id.

So the original order will be left with a state of “OPEN” indefinitely? How will my client’s POS system or online dashboard understand that this order should not be worked on anymore? Also, what are the advantages of creating a new order based on the original order? It seems to make things more complicated.

Is there a guide explaining how to properly handle “cancelling” an order? I was not able to find one on

Technically, yes. But, you can cancel the fulfillment that is within the order, and that would make it be removed from the POS/Dashboard. It’s easier/possible to cancel orders without payments, to be clear.

Another alternative solution would be to use CreatePayment with autocomplete=false which is not a “processed payment”. You would have up to 7 days before it auto-voids, but before then you could mark the fulfillment and order as canceled. Otherwise, call CompletePayment to actually capture the payment.

1 Like

Is there any benefit to having the order have a state of “CANCELED”? My current setup has it simply refunding the payment(s) for an order and then setting the fulfillment state to “CANCELED” which leaves the order having a state of “OPEN”.