# payment_pending

> A payment is under way

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

## What it means

The order has a payment this endpoint can't stop, and the request changed nothing: a disbursement from Medical Finance, a payment reference (KID or OCR) that can still receive funds or, on cancel, a payment still being processed that `POST /api/public/orders/{orderId}/refund` can reverse. `message` says which. The same code also comes for an order that is already refunded or cancelled but carries a Medical Finance or bank reference payment.

## What your system does

Fetch the order with `GET /api/public/orders/{orderId}` before you act: it may already be refunded. Don't send the same call again. Follow the order or the callback, and refund it once it is paid if the money is to be returned.

## Is it worth retrying?

No, not without changing the call.

`retryWhen`: `never`. Don't send it again. The answer is final for this request: read the current state, the order for example, and act on that.

## 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.

The request wrote nothing; the payment in progress was started earlier. A retried refund of a Medical Finance order that Rivr has opened for refunds through the API can get this answer although the refund has already been made.

Read the state (`resolveWith`):

- `cancelOrder` → [`GET /api/public/orders/{orderId}`](https://developers.rivr.io/reference/api-public/getOrder.md): `status` 2 (Pending) or 1 (Created): the payment is in progress and nothing was done. 8 (Refunded): the order is already refunded.
- `refundOrder` → [`GET /api/public/orders/{orderId}`](https://developers.rivr.io/reference/api-public/getOrder.md): `status` 8 (Refunded): already refunded. 2 (Pending) or 1 (Created): the disbursement or bank reference is in progress and nothing was refunded.

## Example: /api/public

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

{
  "propertyName": "Status",
  "message": "A payment for the order has been accepted and is still being processed, so the order can no longer be cancelled. Use POST /api/public/orders/{orderId}/refund to reverse it.",
  "errorCode": "payment_pending",
  "code": "payment_pending",
  "type": "https://developers.rivr.io/errors/payment_pending"
}
```

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