> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Pay Order

> Pay for an [order](entity:Order) using one or more approved [payments](entity:Payment) or settle an order with a total of `0`.

`square.payOrder` pay for an [order](entity:Order) using one or more approved [payments](entity:Payment) or settle an order with a total of `0`.

## Example

```ts automations/square-pay-order.automation.ts theme={null}
import { automation, onDashboardRun } from "automate.ax"
import { square } from "automate.ax/square"

export default automation("Pay Square Order", () => {
  onDashboardRun({ title: "Pay Square Order" })

  square.payOrder({
    orderId: "order_id",
    idempotencyKey: "c043a359-7ad9-4136-82a9-c3f1d66dcbff",
    paymentIds: ["EnZdNAlWCmfh6Mt5FMNST1o7taB", "0LRiVlbXVwe8ozu4KbZxd12mvaB"],
  })
})
```

## Inputs

Every input accepts a compatible signal. It requires `ORDERS_WRITE` and `PAYMENTS_WRITE`.

| Field            | Type               | Required | Default | Description                                                                                                                                                                                                                                                                                                                                                                          |
| ---------------- | ------------------ | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `orderId`        | `string`           | Yes      | —       | The ID of the order being paid.                                                                                                                                                                                                                                                                                                                                                      |
| `idempotencyKey` | `string`           | Yes      | —       | A value you specify that uniquely identifies this request among requests you have sent. If you are unsure whether a particular payment request was completed successfully, you can reattempt it with the same idempotency key without worrying about duplicate payments. For more information, see [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency). |
| `orderVersion`   | `number \| null`   | No       | —       | The version of the order being paid. If not supplied, the latest version will be paid.                                                                                                                                                                                                                                                                                               |
| `paymentIds`     | `string[] \| null` | No       | —       | The IDs of the payments to collect. The payment total must match the order total.                                                                                                                                                                                                                                                                                                    |

Use the official [PayOrder reference](https://developer.squareup.com/reference/square/orders-api/pay-order) for provider field semantics and limits.

## Output

Returns the official `Square.PayOrderResponse` response as a codec-safe object. Square integer money amounts remain `bigint` values.
