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

# Create Payment

> Creates a payment using the provided source.

`square.createPayment` creates a payment using the provided source.

## Example

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

export default automation("Create Square Payment", () => {
  onDashboardRun({ title: "Create Square Payment" })

  square.createPayment({
    sourceId: "ccof:GaJGNaZa8x4OgDJn4GB",
    idempotencyKey: "7b0f3ec5-086a-4871-8f13-3c81b3875218",
    amountMoney: {
      amount: BigInt("1000"),
      currency: "USD",
    },
    appFeeMoney: {
      amount: BigInt("10"),
      currency: "USD",
    },
    autocomplete: true,
    customerId: "W92WH6P11H4Z77CTET0RNTGFW8",
    locationId: "L88917AVBK2S5",
    referenceId: "123456",
    note: "Brief description",
  })
})
```

## Inputs

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

| Field                            | Type                            | Required | Default                                                                                                                                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| -------------------------------- | ------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sourceId`                       | `string`                        | Yes      | —                                                                                                                                      | The ID for the source of funds for this payment. This could be a payment token generated by the Web Payments SDK for any of its [supported methods](https://developer.squareup.com/docs/web-payments/overview#explore-payment-methods), including cards, bank transfers, Afterpay or Cash App Pay. If recording a payment that the seller received outside of Square, specify either `CASH` or `EXTERNAL`. For more information, see [Take Payments](https://developer.squareup.com/docs/payments-api/take-payments).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `idempotencyKey`                 | `string`                        | Yes      | —                                                                                                                                      | A unique string that identifies this `CreatePayment` request. Keys can be any valid string but must be unique for every `CreatePayment` request. Note: The number of allowed characters might be less than the stated maximum, if multi-byte characters are used. For more information, see [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `amountMoney`                    | `Square.Money`                  | No       | —                                                                                                                                      | The amount of money to accept for this payment, not including `tip_money`. The amount must be specified in the smallest denomination of the applicable currency (for example, US dollar amounts are specified in cents). For more information, see [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). The currency code must match the currency associated with the business that is accepting the payment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `tipMoney`                       | `Square.Money`                  | No       | —                                                                                                                                      | The amount designated as a tip, in addition to `amount_money`. The amount must be specified in the smallest denomination of the applicable currency (for example, US dollar amounts are specified in cents). For more information, see [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). Tips for external vendors such as a third party delivery courier must be recorded using Order.service\_charges. The currency code must match the currency associated with the business that is accepting the payment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `appFeeMoney`                    | `Square.Money`                  | No       | —                                                                                                                                      | The amount of money that the developer is taking as a fee for facilitating the payment on behalf of the seller. The amount cannot be more than 90% of the total amount of the payment. The amount must be specified in the smallest denomination of the applicable currency (for example, US dollar amounts are specified in cents). For more information, see [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). The fee currency code must match the currency associated with the seller that is accepting the payment. The application must be from a developer account in the same country and using the same currency code as the seller. For more information about the application fee scenario, see [Take Payments and Collect Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees). To set this field, `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required. For more information, see [Permissions](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees#permissions). |
| `appFeeAllocations`              | `unknown[]`                     | No       | —                                                                                                                                      | Details pertaining to recipients of the application fee. The sum of the amounts in the app\_fee\_allocations must equal the app\_fee\_money amount, if present. If populated, an allocation must be present for every party that expects to receive a portion of the application fee, including the application developer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `delayDuration`                  | `string`                        | No       | - Card-present payments: `PT36H` (36 hours) from the creation time. - Card-not-present payments: `P7D` (7 days) from the creation time | The duration of time after the payment's creation when Square automatically either completes or cancels the payment depending on the `delay_action` field value. For more information, see [Time threshold](https://developer.squareup.com/docs/payments-api/take-payments/card-payments/delayed-capture#time-threshold). This parameter should be specified as a time duration, in RFC 3339 format. Note: This feature is only supported for card payments. This parameter can only be set for a delayed capture payment (`autocomplete=false`). Default: - Card-present payments: `PT36H` (36 hours) from the creation time. - Card-not-present payments: `P7D` (7 days) from the creation time.                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `delayAction`                    | `string`                        | No       | CANCEL                                                                                                                                 | The action to be applied to the payment when the `delay_duration` has elapsed. The action must be CANCEL or COMPLETE. For more information, see [Time Threshold](https://developer.squareup.com/docs/payments-api/take-payments/card-payments/delayed-capture#time-threshold). Default: CANCEL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `autocomplete`                   | `boolean`                       | No       | true                                                                                                                                   | If set to `true`, this payment will be completed when possible. If set to `false`, this payment is held in an approved state until either explicitly completed (captured) or canceled (voided). For more information, see [Delayed capture](https://developer.squareup.com/docs/payments-api/take-payments/card-payments#delayed-capture-of-a-card-payment). Default: true                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `orderId`                        | `string`                        | No       | —                                                                                                                                      | Associates a previously created order with this payment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `customerId`                     | `string`                        | No       | —                                                                                                                                      | The Customer ID of the customer associated with the payment. This is required if the `source_id` refers to a card on file created using the Cards API.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `locationId`                     | `string`                        | No       | —                                                                                                                                      | The location ID to associate with the payment. If not specified, the [main location](https://developer.squareup.com/docs/locations-api#about-the-main-location) is used.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `teamMemberId`                   | `string`                        | No       | —                                                                                                                                      | An optional TeamMember ID to associate with this payment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `referenceId`                    | `string`                        | No       | —                                                                                                                                      | A user-defined ID to associate with the payment. You can use this field to associate the payment to an entity in an external system (for example, you might specify an order ID that is generated by a third-party shopping cart).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `verificationToken`              | `string`                        | No       | —                                                                                                                                      | An identifying token generated by [payments.verifyBuyer()](https://developer.squareup.com/reference/sdks/web/payments/objects/Payments#Payments.verifyBuyer). Verification tokens encapsulate customer device information and 3-D Secure challenge results to indicate that Square has verified the buyer identity. For more information, see [SCA Overview](https://developer.squareup.com/docs/sca-overview).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `acceptPartialAuthorization`     | `boolean`                       | No       | false                                                                                                                                  | If set to `true` and charging a Square Gift Card, a payment might be returned with `amount_money` equal to less than what was requested. For example, a request for $20 when charging a Square Gift Card with a balance of $5 results in an APPROVED payment of \$5. You might choose to prompt the buyer for an additional payment to cover the remainder or cancel the Gift Card payment. This field cannot be `true` when `autocomplete = true`. For more information, see [Partial amount with Square Gift Cards](https://developer.squareup.com/docs/payments-api/take-payments#partial-payment-gift-card). Default: false                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `buyerEmailAddress`              | `string`                        | No       | —                                                                                                                                      | The buyer's email address.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `buyerPhoneNumber`               | `string`                        | No       | —                                                                                                                                      | The buyer's phone number. Must follow the following format: 1. A leading + symbol (followed by a country code) 2. The phone number can contain spaces and the special characters `(` , `)` , `-` , and `.`. Alphabetical characters aren't allowed. 3. The phone number must contain between 9 and 16 digits.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `billingAddress`                 | `Square.Address`                | No       | —                                                                                                                                      | The buyer's billing address.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `shippingAddress`                | `Square.Address`                | No       | —                                                                                                                                      | The buyer's shipping address.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `note`                           | `string`                        | No       | —                                                                                                                                      | An optional note to be entered by the developer when creating a payment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `statementDescriptionIdentifier` | `string`                        | No       | —                                                                                                                                      | Optional additional payment information to include on the customer's card statement as part of the statement description. This can be, for example, an invoice number, ticket number, or short description that uniquely identifies the purchase. Note that the `statement_description_identifier` might get truncated on the statement description to fit the required information including the Square identifier (SQ \*) and name of the seller taking the payment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `cashDetails`                    | `Square.CashPaymentDetails`     | No       | —                                                                                                                                      | Additional details required when recording a cash payment (`source_id` is CASH).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `externalDetails`                | `Square.ExternalPaymentDetails` | No       | —                                                                                                                                      | Additional details required when recording an external payment (`source_id` is EXTERNAL).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `customerDetails`                | `Square.CustomerDetails`        | No       | —                                                                                                                                      | Details about the customer making the payment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `offlinePaymentDetails`          | `Square.OfflinePaymentDetails`  | No       | —                                                                                                                                      | An optional field for specifying the offline payment details. This is intended for internal first-party callers only.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

Use the official [CreatePayment reference](https://developer.squareup.com/reference/square/payments-api/create-payment) for provider field semantics and limits.

## Output

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