409
payments.refund_cancel_not_allowedpaymentsRule R18Rule R24This refund can no longer be canceled
Two rules share this code. A refund can be canceled only while its status is requested — once approved or rejected, the decision stands — and only by the principal who requested it or someone holding refund.approve.
Why the API refuses
WHEN CancelRefund is executed, THE SYSTEM SHALL reject it unless the refund status is requested.
WHEN CancelRefund is executed by a principal who is neither the refund's requested_by nor a holder of refund.approve, THE SYSTEM SHALL reject it.
What to do
Read the refund's status and requested_by. If it is past requested, there is nothing to cancel; if it succeeded and should not have, that is a new payment to the customer, not a cancelation. If the status is requested and you still got this error, the caller is neither the requester nor an approver — use a key or session that is.