You are viewing an old version of the API
Pay order

Beta

Pay for an order using one or more approved payments, or settle an order with a total of 0

The total of the payment_ids listed in the request must be equal to the order total. Orders with a total amount of 0 can be marked as paid by specifying an empty array of payment_ids in the request.

To be used with PayOrder, a payment must:

  • Reference the order by specifying the order_id when creating the payment. Any approved payments that reference the same order_id not specified in the payment_ids will be canceled.
  • Be approved with delayed capture. Using a delayed capture payment with PayOrder will complete the approved payment.

Learn how to pay for orders with a single payment using the Payments API.

Required permissions PAYMENTS_WRITE ORDERS_WRITE

Path Parameters

Name Description
order_id
string

Required

The ID of the order being paid.

Request Body

Name Description
idempotency_key
string

Required

A value you specify that uniquely identifies this request among requests you've sent. If you're unsure whether a particular payment request was completed successfully, you can reattempt it with the same idempotency key without worrying about duplicate payments.

See Idempotency for more information.

Max Length 192 Min Length 1
order_version
integer

The version of the order being paid. If not supplied, the latest version will be paid.

payment_ids
string [ ]

Response Fields

Name Description
errors
Error [ ]

Any errors that occurred during the request.

order
Order

The paid, updated order.

Examples

You are viewing an old version of the API
POST /v2/orders/{order_id}/pay
cURL
  • cURL
  • Ruby
  • Python
curl https://connect.squareup.com/v2/orders/{order_id}/pay \
  -X POST \
  -H 'Square-Version: 2019-11-20' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -d '{
    "idempotency_key": "c043a359-7ad9-4136-82a9-c3f1d66dcbff",
    "payment_ids": [
      "EnZdNAlWCmfh6Mt5FMNST1o7taB",
      "0LRiVlbXVwe8ozu4KbZxd12mvaB"
    ]
  }'
Response JSON
{
  "order": {
    "id": "lgwOlEityYPJtcuvKTVKT1pA986YY",
    "location_id": "P3CCK6HSNDAS7",
    "line_items": [
      {
        "uid": "QW6kofLHJK7JEKMjlSVP5C",
        "quantity": "1",
        "name": "Item 1",
        "base_price_money": {
          "amount": 500,
          "currency": "USD"
        },
        "gross_sales_money": {
          "amount": 500,
          "currency": "USD"
        },
        "total_tax_money": {
          "amount": 0,
          "currency": "USD"
        },
        "total_discount_money": {
          "amount": 0,
          "currency": "USD"
        },
        "total_money": {
          "amount": 500,
          "currency": "USD"
        }
      },
      {
        "uid": "zhw8MNfRGdFQMI2WE1UBJD",
        "quantity": "2",
        "name": "Item 2",
        "base_price_money": {
          "amount": 750,
          "currency": "USD"
        },
        "gross_sales_money": {
          "amount": 1500,
          "currency": "USD"
        },
        "total_tax_money": {
          "amount": 0,
          "currency": "USD"
        },
        "total_discount_money": {
          "amount": 0,
          "currency": "USD"
        },
        "total_money": {
          "amount": 1500,
          "currency": "USD"
        }
      }
    ],
    "created_at": "2019-08-06T02:47:35.693Z",
    "updated_at": "2019-08-06T02:47:37.140Z",
    "version": 4,
    "total_tax_money": {
      "amount": 0,
      "currency": "USD"
    },
    "total_discount_money": {
      "amount": 0,
      "currency": "USD"
    },
    "total_money": {
      "amount": 2000,
      "currency": "USD"
    },
    "closed_at": "2019-08-06T02:47:37.140Z",
    "tenders": [
      {
        "id": "EnZdNAlWCmfh6Mt5FMNST1o7taB",
        "location_id": "P3CCK6HSNDAS7",
        "transaction_id": "lgwOlEityYPJtcuvKTVKT1pA986YY",
        "created_at": "2019-08-06T02:47:36.293Z",
        "amount_money": {
          "amount": 1000,
          "currency": "USD"
        },
        "type": "CARD",
        "card_details": {
          "status": "CAPTURED",
          "card": {
            "card_brand": "VISA",
            "last_4": "1111",
            "exp_month": 2,
            "exp_year": 2022,
            "fingerprint": "sq-1-n_BL15KP87ClDa4-h2nXOI0fp5VnxNH6hfhzqhptTfAgxgLuGFcg6jIPngDz4IkkTQ"
          },
          "entry_method": "KEYED"
        },
        "payment_id": "EnZdNAlWCmfh6Mt5FMNST1o7taB"
      },
      {
        "id": "0LRiVlbXVwe8ozu4KbZxd12mvaB",
        "location_id": "P3CCK6HSNDAS7",
        "transaction_id": "lgwOlEityYPJtcuvKTVKT1pA986YY",
        "created_at": "2019-08-06T02:47:36.809Z",
        "amount_money": {
          "amount": 1000,
          "currency": "USD"
        },
        "type": "CARD",
        "card_details": {
          "status": "CAPTURED",
          "card": {
            "card_brand": "VISA",
            "last_4": "1111",
            "exp_month": 2,
            "exp_year": 2022,
            "fingerprint": "sq-1-n_BL15KP87ClDa4-h2nXOI0fp5VnxNH6hfhzqhptTfAgxgLuGFcg6jIPngDz4IkkTQ"
          },
          "entry_method": "KEYED"
        },
        "payment_id": "0LRiVlbXVwe8ozu4KbZxd12mvaB"
      }
    ],
    "total_service_charge_money": {
      "amount": 0,
      "currency": "USD"
    },
    "net_amounts": {
      "total_money": {
        "amount": 2000,
        "currency": "USD"
      },
      "tax_money": {
        "amount": 0,
        "currency": "USD"
      },
      "discount_money": {
        "amount": 0,
        "currency": "USD"
      },
      "tip_money": {
        "amount": 0,
        "currency": "USD"
      },
      "service_charge_money": {
        "amount": 0,
        "currency": "USD"
      }
    },
    "source": {
      "name": "Source Name"
    },
    "state": "COMPLETED"
  }
}

Share Feedback

Thanks for visiting the Square API documentation. What's on your mind?