# Update a prepared payment.

> Changes the amount or currency of a payment prepared with `deferred: true`, while its checkout is still open: the buyer changed country, applied a discount, picked a delivery. One prepared payment serves the whole checkout, and the mounted Components keep their session. The new amount is checked as `POST /payments` checks it: the currency's limits, and the payment's `accept`, which must still leave a way to pay. `expires` gives the payment a new expiry, counted from now: the payment keeps it once activated. A payment that was not prepared answers `404`. A prepared payment that was activated, cancelled or has expired answers `409`. Requires the secret key.

`PATCH https://api.wajub.com/payments/{id}`

## Path parameters

- `id` (string, required): The prepared payment `id`.

## Body (application/json)

- `amount` (number, required): The new amount, in the major unit of the currency.
- `currency` (string, required): ISO 4217 currency code.
- `expires` (object, nullable): When the payment ends on its own if nobody pays it. Absent, the expiry does not change.
  - `expires.in` (integer, nullable): The new expiry in minutes from now (5–43200), as `POST /payments` takes it.

## Responses

- `200`: Payment updated
- `404`: Not a prepared payment
- `406`: Publishable key
- `409`: Activated, cancelled or expired
- `422`: Unprocessable Content

## Example response (200)

```json
{
  "code": 200,
  "status": "OK",
  "message": "Payment updated",
  "transaction": {
    "id": "trx_CSUGajfv9xh0XQ5wu2lx",
    "amount": 12500,
    "currency": "XAF",
    "status": "pending"
  }
}
```
