• Example searches: “transaction”, “CreateOrder”, “/v2/locations”, “inventory”, “delete customer”

You are viewing an old version of the API
Create payment

POST /v2/payments

Charges a payment source, for example, a card represented by customer's card on file or a card nonce.

In addition to the payment source, the request must also include the amount to accept for the payment.

There are several optional parameters that you can include in the request. For example, tip money, whether to autocomplete the payment, or a reference ID to correlate this payment with another system.

The PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS OAuth permission is required to enable application fees.


Permissions
PAYMENTS_WRITE
Guide
Take Payments
Try in API Explorer
Name Description
source_id
string

Required

The ID for the source of funds for this payment. This can be a nonce generated by the Payment Form or a card on file made with the Customers API.

Min Length 1
idempotency_key
string

Required

A unique string that identifies this CreatePayment request. Keys can be any valid string but must be unique for every CreatePayment request.

Max: 45 characters

Note: The number of allowed characters might be less than the stated maximum, if multi-byte characters are used.

See Idempotency keys for more information.

Max Length 45 Min Length 1
amount_money
Money

Required

The amount of money to accept for this payment, not including tip_money.

Must be specified in the smallest denomination of the applicable currency. For example, US dollar amounts are specified in cents. See Working with monetary amounts for details.

The currency code must match the currency associated with the business that is accepting the payment.

tip_money
Money

Beta

The amount designated as a tip, in addition to amount_money

Must be specified in the smallest denomination of the applicable currency. For example, US dollar amounts are specified in cents. See Working with monetary amounts for details.

The currency code must match the currency associated with the business that is accepting the payment.

app_fee_money
Money

The amount of money the developer is taking as a fee for facilitating the payment on behalf of the seller.

Cannot be more than 90% of the total amount of the Payment.

Must be specified in the smallest denomination of the applicable currency. For example, US dollar amounts are specified in cents. See Working with monetary amounts for details.

The fee currency code must match the currency associated with the merchant 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 merchant.

For more information about the application fee scenario, see Collect Fees.

delay_duration
string

Beta

The duration of time after the payment's creation when Square automatically cancels the payment. This automatic cancellation applies only to payments that don't reach a terminal state (COMPLETED, CANCELED, or FAILED) before the delay_duration time period.

This parameter should be specified as a time duration, in RFC 3339 format, with a minimum value of 1 minute.

Notes: 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.

Example for 2 days, 12 hours, 30 minutes, and 15 seconds: P2DT12H30M15S

autocomplete
boolean

If set to true, this payment will be completed when possible. If set to false, this payment will be held in an approved state until either explicitly completed (captured) or canceled (voided). For more information, see Delayed Payments.

Default: true

order_id
string

Associate a previously created order with this payment

customer_id
string

The Customer ID of the customer associated with the payment. Required if the source_id refers to a card on file created using the Customers API.

location_id
string

The location ID to associate with the payment. If not specified, the default location is used.

reference_id
string

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.

Limit 40 characters.

Max Length 40
verification_token
string

An identifying token generated by SqPaymentForm.verifyBuyer(). Verification tokens encapsulate customer device information and 3-D Secure challenge results to indicate that Square has verified the buyer identity.

See the SCA Overview.

accept_partial_authorization
boolean

Beta

If set to true and charging a Square Gift Card, a payment may be returned with amount_money equal to less than what was requested. Example, a request for $20 when charging a Square Gift Card with balance of $5 wil result in an APPROVED payment of $5. You may choose to prompt the buyer for an additional payment to cover the remainder, or cancel the gift card payment. Cannot be true when autocomplete = true.

For more information, see Partial amount with Square gift cards.

Default: false

buyer_email_address
string

The buyer's e-mail address

Max Length 255
billing_address
Address

The buyer's billing address.

shipping_address
Address

The buyer's shipping address.

note
string

An optional note to be entered by the developer when creating a payment

Limit 500 characters.

Max Length 500
statement_description_identifier
string

Beta

Optional additional payment information to include on the customer's card statement as part of 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 may get truncated on the statement description to fit the required information including the Square identifier (SQ *) and name of the merchant taking the payment.

Max Length 20

Response Fields

Name Description
errors
Error [ ]

Information on errors encountered during the request.

payment
Payment

The newly created payment.

Examples

You are viewing an old version of the API
POST /v2/payments
cURL
  • cURL
  • Ruby
  • Python
  • C#
  • Java
  • PHP
curl https://connect.squareup.com/v2/payments \
  -X POST \
  -H 'Square-Version: 2020-09-23' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "idempotency_key": "4935a656-a929-4792-b97c-8848be85c27c",
    "amount_money": {
      "amount": 200,
      "currency": "USD"
    },
    "source_id": "ccof:uIbfJXhXETSP197M3GB",
    "autocomplete": true,
    "customer_id": "VDKXEEKPJN48QDG3BGGFAK05P8",
    "location_id": "XK3DBG77NJBFX",
    "reference_id": "123456",
    "note": "Brief description",
    "app_fee_money": {
      "amount": 10,
      "currency": "USD"
    }
  }'
Response JSON
{
  "payment": {
    "id": "GQTFp1ZlXdpoW4o6eGiZhbjosiDFf",
    "created_at": "2019-07-10T13:23:49.154Z",
    "updated_at": "2019-07-10T13:23:49.446Z",
    "amount_money": {
      "amount": 200,
      "currency": "USD"
    },
    "app_fee_money": {
      "amount": 10,
      "currency": "USD"
    },
    "total_money": {
      "amount": 200,
      "currency": "USD"
    },
    "status": "COMPLETED",
    "source_type": "CARD",
    "card_details": {
      "status": "CAPTURED",
      "card": {
        "card_brand": "VISA",
        "last_4": "1111",
        "exp_month": 7,
        "exp_year": 2026,
        "fingerprint": "sq-1-TpmjbNBMFdibiIjpQI5LiRgNUBC7u1689i0TgHjnlyHEWYB7tnn-K4QbW4ttvtaqXw",
        "card_type": "DEBIT",
        "prepaid_type": "PREPAID",
        "bin": "411111"
      },
      "entry_method": "ON_FILE",
      "cvv_status": "CVV_ACCEPTED",
      "avs_status": "AVS_ACCEPTED",
      "auth_result_code": "nsAyY2",
      "statement_description": "SQ *MY MERCHANT"
    },
    "location_id": "XTI0H92143A39",
    "order_id": "m2Hr8Hk8A3CTyQQ1k4ynExg92tO3",
    "reference_id": "123456",
    "note": "Brief description",
    "customer_id": "RDX9Z4XTIZR7MRZJUXNY9HUK6I",
    "receipt_number": "GQTF",
    "receipt_url": "https://squareup.com/receipt/preview/GQTFp1ZlXdpoW4o6eGiZhbjosiDFf"
  }
}

Error Descriptions

400 Bad request ADDRESS_VERIFICATION_FAILURE

The card issuer declined the request because the postal code is invalid.

>
400 Bad request CARDHOLDER_INSUFFICIENT_PERMISSIONS

The card issuer has declined the transaction due to restrictions on where the card can be used. For example, a gift card is limited to a single merchant.

>
400 Bad request CARD_EXPIRED

The card issuer declined the request because the card is expired.

>
400 Bad request CARD_NOT_SUPPORTED

The card is not supported either in the geographic region or by the MCC merchant category code

>
400 Bad request CARD_TOKEN_EXPIRED

The provided card token (nonce) has expired.

>
400 Bad request CARD_TOKEN_USED

The provided card token (nonce) was already used to process payment.

>
400 Bad request CVV_FAILURE

The card issuer declined the request because the CVV value is invalid.

>
400 Bad request EXPIRATION_FAILURE

The card expiration date is either invalid or indicates that the card is expired.

>
400 Bad request GENERIC_DECLINE

An unexpected error occurred.

>
400 Bad request GIFT_CARD_AVAILABLE_AMOUNT

When using a gift card as a payment source in a CreatePayment request, you can allow taking partial payment by adding the accept_partial_authorization parameter in the request. If the gift card does not have sufficient balance to pay the entire amount_money specified in the request, the request will succeed (an APPROVED payment for the remaining balance will be returned). For more information, see Partial amount with Square gift cards.\r\n\r\n However, taking such a partial payment does not work if your request also includes tip_money, app_fee_money, or both. Square declines such payment and returns this error.\r\n* The error details provide the amount that was available on the gift card at the time of the request. The amount is a string representation in the smallest denomination of the applicable currency. For example, in USD the amount is specified in cents.\r\n* The error code appears in an array along with the INSUFFICIENT_FUNDS error.\r\n\r\nThe following is an example set of errors:\r\n\r\n{\r\n \"errors\": [\r\n {\r\n \"code\": \"INSUFFICIENT_FUNDS\",\r\n \"detail\": \"Gift card does not have sufficient balance for requested amount and tip.\",\r\n \"category\": \"PAYMENT_METHOD_ERROR\"\r\n },\r\n {\r\n \"code\": \"GIFT_CARD_AVAILABLE_AMOUNT\",\r\n \"detail\": \"4494\",\r\n \"category\": \"PAYMENT_METHOD_ERROR\"\r\n }\r\n ]\r\n}\r\n\r\n\r\n In addition to the errors, it shows the gift card balance at 44.94 USD. You can review this amount and submit a new CreatePayment request with tip_money and amount_money that fit within the available balance.

>
400 Bad request INSUFFICIENT_FUNDS

The funding source has insufficient funds to cover the payment.

>
400 Bad request INSUFFICIENT_PERMISSIONS

The Square account does not have the permissions to accept this payment. For example, Square may limit which merchants are allowed to receive gift card payments.

>
400 Bad request INVALID_ACCOUNT

The card issuer was not able to locate account on record.

>
400 Bad request INVALID_CARD_DATA

Generic error - the provided card data is invalid.

>
400 Bad request INVALID_EMAIL_ADDRESS

The provided email address is invalid.

>
400 Bad request INVALID_EXPIRATION

The expiration date for the payment card is invalid. For example, it indicates a date in the past.

>
400 Bad request INVALID_FEES

The appfeemoney on a payment is too high.

>
400 Bad request INVALID_LOCATION

The Square account cannot take payments in the specified region. A Square account can take payments only from the region where the account was created.

>
400 Bad request INVALID_PIN

The card issuer declined the request because the PIN is invalid.

>
400 Bad request INVALID_POSTAL_CODE

The postal code is incorrectly formatted.

>
400 Bad request MANUALLY_ENTERED_PAYMENT_NOT_SUPPORTED

The card must be swiped, tapped, or dipped. Payments attempted by manually entering the card number are declined.

>
400 Bad request PAN_FAILURE

The specified card number is invalid. For example, it is of incorrect length or is incorrectly formatted.

>
400 Bad request PAYMENT_LIMIT_EXCEEDED

Square declined the request because the payment amount exceeded the processing limit for this merchant.

>
400 Bad request TRANSACTION_LIMIT

The card issuer has determined the payment amount is either too high or too low. The API returns the error code mostly for credit cards (for example, the card reached the credit limit). However, sometimes the issuer bank can indicate the error for debit or prepaid cards (for example, card has insufficient funds).

>
400 Bad request VOICE_FAILURE

The card issuer declined the request because the issuer requires voice authorization from the cardholder.

>
402 Payment required ALLOWABLE_PIN_TRIES_EXCEEDED

402 Request failed - the card has exhausted its available pin entry retries set by the card issuer. Resolving the error typically requires the card holder to contact the card issuer.

>
402 Payment required BAD_EXPIRATION

402 Request failed - the card expiration date is either missing or incorrectly formatted.

>
402 Payment required CHIP_INSERTION_REQUIRED

402 Request failed - the card issuer requires that the card be read using a chip reader.

>
403 Forbidden CARD_PROCESSING_NOT_ENABLED

403 Forbidden - the location provided in the API call is not enabled for credit card processing.

>
503 Service unavailable TEMPORARY_ERROR

A temporary internal error occurred. You can safely retry your call using the same idempotency key.

>
400 Bad request
{
  "errors": [
    {
      "code": "ADDRESS_VERIFICATION_FAILURE",
      "category": "PAYMENT_METHOD_ERROR"
    }
  ]
}

Share Feedback

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