Describe the bug
In the order detail page, Refund & Cancel (RefundOrderDialog, use-refund-order.ts handleSubmit) calls cancelOrder first and refundOrder second. When the refund is then refused or fails, the order items are already cancelled, so the order ends up cancelled but not refunded.
This happens for any refund failure after the cancellation, for example:
refundOrderreturns an error result (e.g.RefundAmountError,RefundStateTransitionError), or throws (e.g. a plugin interceptor rejecting the input);- the payment provider declines the refund:
PaymentMethodHandler.createRefundreturnsstate: 'Failed', andrefundOrderreturns aRefundin theFailedstate, which the dialog treats as success ("Refund processed successfully").
Also, the "No payment or destination was selected" check runs after cancelOrder.
To Reproduce
- Use a payment method whose handler's
createRefundreturns{ state: 'Failed' }(or anything that makesrefundOrderfail), and place an order with it so its payment is Settled. - Open the order in the dashboard, choose Refund & Cancel, select the line with "cancel" checked, pick a reason and submit.