# order_locked_for_refund

> The order is locked for refunds

- Status: 400 Bad Request
- Returned by: /api/public
- Operations: [refundOrder](https://developers.rivr.io/reference/api-public/refundOrder.md)
- Retry (`retryWhen`): `later`
- Did anything happen? (`outcome`): `unknown` (Unknown)
- Cancelling and refunding in /api/public
- Page in the portal: https://developers.rivr.io/errors/order_locked_for_refund
- Try it: `GET https://developers.rivr.io/errors/simulate/order_locked_for_refund` answers with the code's exact wire form; `?succeedAfter=N&attempt=K` gives a 200 once `attempt` passes `N`

## What it means

The order is locked against refunds, and nothing was refunded. Rivr sets the lock, automatically when the order is paid (if the clinic has turned on automatic refund locking) or when a payment arrives on the order's invoice, or by hand in Rivr's portal. The lock is checked before the order's status, so an order that has already been refunded or cancelled can get this answer too.

## What your system does

Fetch the order with `GET /api/public/orders/{orderId}` before you act: it may already be refunded or cancelled. Don't refund it any other way until you know whether a refund has already been made or is on its way. If it is to be refunded, unlock it in Rivr's portal, then send the request again.

## Is it worth retrying?

Only once the situation has changed, see above. Sending the same call straight away gets the same answer.

`retryWhen`: `later`. The same request can succeed, but only once something outside it has changed: another payment has finished, a permission has been given or Rivr has switched something on. Sending it again straight away gets the same answer. Follow the order or wait for the change.

## Did anything happen?

`outcome`: `unknown`. **Unknown.** The answer doesn't say whether what you asked for has happened, through this call or an earlier one. Read the state first.

This request refunded nothing. The lock is checked before the order's status, so the order may already have been refunded or cancelled earlier, or have a refund on its way at the payment provider.

Read the state (`resolveWith`):

- `refundOrder` → [`GET /api/public/orders/{orderId}`](https://developers.rivr.io/reference/api-public/getOrder.md): `status` 8 (Refunded): already refunded. 32 (Cancelled): cancelled. 2 (Pending): locked, nothing has been refunded. 4 (Completed): locked. Usually nothing has been refunded, but a refund may be on its way at the payment provider and doesn't show until it is confirmed (then it becomes 8).

## Example: /api/public

```http
HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "propertyName": "IsLockedToPreventRefund",
  "message": "The order is locked for refund. Unlock it to be able to perform a refund.",
  "errorCode": "order_locked_for_refund",
  "code": "order_locked_for_refund",
  "type": "https://developers.rivr.io/errors/order_locked_for_refund"
}
```

The `title`, `detail`, `message` and `error_description` texts are exactly as the API writes them today.
