payment_not_refundable
HTTP 422, type invalid_request_error.
This payment is in a state that cannot be refunded.
Why it happened
Only captured money can be returned: a payment whose status is succeeded, partially_captured or partially_refunded. The message names the payment's money state, a finer internal word. Read the payment's status with GET /payments/{id}; the steps below use those status values.
How to fix it
If the status is authorized, the money was never taken: release the authorization with POST /payments/{id}/voids, not a refund. If it is refunded, it is already fully refunded. If it is voided, declined, failed, expired or canceled, the payment is final and no money was taken, so there is nothing to refund. If the status is created, requires_payment, authenticating or processing, the payment has not finished yet and can still become authorized or succeeded: read it again with GET /payments/{id} until its status changes, then act on the new status.
Retrying: do not retry the same request while the status is one of those above. If a payment that had not finished becomes succeeded, send the refund as a new request with a new Idempotency-Key: this refusal happened after the key was claimed.
Related codes
refund_exceeds_captured-- a refund larger than what is leftpayment_not_voidable