Create payment
Creates a payment using the provided source.
You can use this endpoint
to charge a card (credit/debit card or
Square gift card) or record a payment that the seller received outside of Square
(cash payment from a buyer or a payment that an external entity
processed on behalf of the seller).
The endpoint creates a
Payment
object and returns it in the response.
Name | Description |
---|---|
source_
Required
|
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, 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. |
idempotency_
Required
|
A unique string that identifies this Note: The number of allowed characters might be less than the stated maximum, if multi-byte characters are used. For more information, see Idempotency. |
amount_
Required
|
The amount of money to accept for this payment, not including 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. The currency code must match the currency associated with the business that is accepting the payment. |
tip_
|
The amount designated as a tip, in addition to 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. The currency code must match the currency associated with the business that is accepting the payment. |
app_
|
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. 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. To set this field, |
delay_
|
The duration of time after the payment's creation when Square automatically
either completes or cancels the payment depending on the 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 ( Default:
Example for 2 days, 12 hours, 30 minutes, and 15 seconds: P2DT12H30M15S |
delay_
|
The action to be applied to the payment when the Default: CANCEL |
autocomplete
|
If set to Default: true |
order_
|
Associates a previously created order with this payment. |
customer_
|
The Customer ID of the customer associated with the payment. This is required if the |
location_
|
The location ID to associate with the payment. If not specified, the main location is used. |
team_
|
An optional TeamMember ID to associate with this payment. |
reference_
|
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). |
verification_
|
An identifying token generated by 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. |
accept_
|
If set to For more information, see Partial amount with Square Gift Cards. Default: false |
buyer_
|
The buyer's email address. |
billing_
|
The buyer's billing address. |
shipping_
|
The buyer's shipping address. |
note
|
An optional note to be entered by the developer when creating a payment. |
statement_
|
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 |
cash_
|
Additional details required when recording a cash payment ( |
external_
|
Additional details required when recording an external payment ( |
Response Fields
Name | Description |
---|---|
errors
|
Information about errors encountered during the request. |
payment
|
The newly created payment. |
Examples
- cURL
- Ruby
- Python
- C#
- Java
- PHP
- Node.js
curl https://connect.squareup.com/v2/payments \
-X POST \
-H 'Square-Version: 2023-03-15' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"idempotency_key": "7b0f3ec5-086a-4871-8f13-3c81b3875218",
"amount_money": {
"amount": 1000,
"currency": "USD"
},
"source_id": "ccof:GaJGNaZa8x4OgDJn4GB",
"autocomplete": true,
"customer_id": "W92WH6P11H4Z77CTET0RNTGFW8",
"location_id": "L88917AVBK2S5",
"reference_id": "123456",
"note": "Brief description",
"app_fee_money": {
"amount": 10,
"currency": "USD"
}
}'
{
"payment": {
"id": "R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY",
"created_at": "2021-10-13T21:14:29.577Z",
"updated_at": "2021-10-13T21:14:30.504Z",
"amount_money": {
"amount": 1000,
"currency": "USD"
},
"app_fee_money": {
"amount": 10,
"currency": "USD"
},
"status": "COMPLETED",
"delay_duration": "PT168H",
"source_type": "CARD",
"card_details": {
"status": "CAPTURED",
"card": {
"card_brand": "VISA",
"last_4": "1111",
"exp_month": 11,
"exp_year": 2022,
"fingerprint": "sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ",
"card_type": "DEBIT",
"prepaid_type": "NOT_PREPAID",
"bin": "411111"
},
"entry_method": "ON_FILE",
"cvv_status": "CVV_ACCEPTED",
"avs_status": "AVS_ACCEPTED",
"auth_result_code": "vNEn2f",
"statement_description": "SQ *EXAMPLE TEST GOSQ.C",
"card_payment_timeline": {
"authorized_at": "2021-10-13T21:14:29.732Z",
"captured_at": "2021-10-13T21:14:30.504Z"
}
},
"location_id": "L88917AVBK2S5",
"order_id": "pRsjRTgFWATl7so6DxdKBJa7ssbZY",
"reference_id": "123456",
"risk_evaluation": {
"created_at": "2021-10-13T21:14:30.423Z",
"risk_level": "NORMAL"
},
"note": "Brief Description",
"customer_id": "W92WH6P11H4Z77CTET0RNTGFW8",
"total_money": {
"amount": 1000,
"currency": "USD"
},
"approved_money": {
"amount": 1000,
"currency": "USD"
},
"receipt_number": "R2B3",
"receipt_url": "https://squareup.com/receipt/preview/EXAMPLE_RECEIPT_ID",
"delay_action": "CANCEL",
"delayed_until": "2021-10-20T21:14:29.577Z",
"application_details": {
"square_product": "ECOMMERCE_API",
"application_id": "sq0ids-TcgftTEtKxJTRF1lCFJ9TA"
},
"version_token": "TPtNEOBOa6Qq6E3C3IjckSVOM6b3hMbfhjvTxHBQUsB6o"
}
}
Error Descriptions
400 Bad request |
ADDRESS_ The card issuer declined the request because the postal code is invalid. |
> |
400 Bad request |
CARDHOLDER_ 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_ The card issuer declined the request because the card is expired. |
> |
400 Bad request |
CARD_ The card is not supported either in the geographic region or by the merchant category code (MCC). |
> |
400 Bad request |
CARD_ The provided card token (nonce) has expired. |
> |
400 Bad request |
CARD_ The provided card token (nonce) was already used to process the payment or refund. |
> |
400 Bad request |
CVV_ The card issuer declined the request because the CVV value is invalid. |
> |
400 Bad request |
EXPIRATION_ The card expiration date is either invalid or indicates that the card is expired. |
> |
400 Bad request |
GENERIC_ Square received a decline without any additional information. If the payment information seems correct, the buyer can contact their issuer to ask for more information. |
> |
400 Bad request |
GIFT_ When a Gift Card is a payment source, you can allow taking a partial payment
by adding the |
> |
400 Bad request |
INSUFFICIENT_ The funding source has insufficient funds to cover the payment. |
> |
400 Bad request |
INSUFFICIENT_ 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_ The issuer was not able to locate the account on record. |
> |
400 Bad request |
INVALID_ The credit card cannot be validated based on the provided details. |
> |
400 Bad request |
INVALID_ Generic error - the provided card data is invalid. |
> |
400 Bad request |
INVALID_ The provided email address is invalid. |
> |
400 Bad request |
INVALID_ The expiration date for the payment card is invalid. For example, it indicates a date in the past. |
> |
400 Bad request |
INVALID_ The app_fee_money on a payment is too high. |
> |
400 Bad request |
INVALID_ 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_ The card issuer declined the request because the PIN is invalid. |
> |
400 Bad request |
INVALID_ The postal code is incorrectly formatted. |
> |
400 Bad request |
MANUALLY_ The card must be swiped, tapped, or dipped. Payments attempted by manually entering the card number are declined. |
> |
400 Bad request |
PAN_ The specified card number is invalid. For example, it is of incorrect length or is incorrectly formatted. |
> |
400 Bad request |
PAYMENT_ The payment was declined because there was a payment amount mismatch. The money amount Square was expecting does not match the amount provided. |
> |
400 Bad request |
PAYMENT_ Square declined the request because the payment amount exceeded the processing limit for this merchant. |
> |
400 Bad request |
TRANSACTION_ 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_ The card issuer declined the request because the issuer requires voice authorization from the cardholder. The seller should ask the customer to contact the card issuing bank to authorize the payment. |
> |
402 Payment required |
ALLOWABLE_ 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_ The card expiration date is either missing or incorrectly formatted. |
> |
402 Payment required |
CARD_ The payment card was declined with a request for additional verification. |
> |
402 Payment required |
CHIP_ The card issuer requires that the card be read using a chip reader. |
> |
403 Forbidden |
CARD_ The location provided in the API call is not enabled for credit card processing. |
> |
503 Service unavailable |
TEMPORARY_ A temporary internal error occurred. You can safely retry your call using the same idempotency key. |
> |
{
"errors": [
{
"code": "ADDRESS_VERIFICATION_FAILURE",
"category": "PAYMENT_METHOD_ERROR"
}
]
}