# markSalesOrderPaid mutation


`markSalesOrderPaid` is a GraphQL mutation of the Chameleoon MAX API. Send it as `POST https://max-api.chameleoon.sk/api/v1/graphql` with your API key, see [Chameleoon MAX](/chameleoon-max).

Marks the order as paid in full. Call it when the customer has paid in the external source.

MAX records one settled payment for the amount still owed, in the order's payment method. If a
user changed the order in MAX since it was placed, the MAX total applies.

#### Permissions

Requires the `order.write` and `order.read` permissions.

#### Repeated calls

A repeat changes nothing and returns `changed: false`. The same happens when the payment
`reference` is already settled on this order.

#### Errors

- `CONFLICT` when the order is cancelled, merged or a draft.
- `CONFLICT` when a pending or authorised payment is recorded on the order.
- `CONFLICT` when the `reference` is on this order with another status, such as a failed or
  voided payment or a refund. A user in MAX resolves these cases.
- `CONFLICT` when the `reference` belongs to another order. Send the correct reference.
- `NOT_FOUND` when the order does not exist or your API key cannot see it.

> An error whose path runs below this field does not mean the call failed: the payment was
> recorded, so do not retry. See [`Mutation`](/chameleoon-max/mutations).

## Arguments

- `ref`: [`SalesOrderRefInput!`](/chameleoon-max/type/sales-order-ref-input) · required
- `paid`: [`SalesOrderPaidInput`](/chameleoon-max/type/sales-order-paid-input)

## Returns

[`SalesOrderChangeResult!`](/chameleoon-max/type/sales-order-change-result)

## Example

**Mutation**

```graphql
mutation markSalesOrderPaid($ref: SalesOrderRefInput!) {
  markSalesOrderPaid(ref: $ref) {
    salesOrder {
      id
      number
      status
      legalEntityId
      source
      externalId
    }
    changed
  }
}
```

**Variables**

```json
{
  "ref": {
    "id": "00000000-0000-4000-8000-000000000001"
  }
}
```

**Response**

```json
{
  "data": {
    "markSalesOrderPaid": {
      "salesOrder": {
        "id": "00000000-0000-4000-8000-000000000001",
        "number": "example",
        "status": "DRAFT",
        "legalEntityId": "00000000-0000-4000-8000-000000000001",
        "source": "example",
        "externalId": "example"
      },
      "changed": true
    }
  }
}
```

Values are illustrative: replace IDs and codes with your own before you send the call.
