Applies to: Terminal API
Learn how to take an one-off payment with the Terminal API, Square Terminal, and a POS application.
This guide assumes that you obtained a device code, signed in to one or more Square Terminals (depending on the seller's number of Square Terminals in the fleet), and paired the Square Terminal with a POS application. If not, these steps are covered in the Terminal API Quickstart
For more information about how the POS client pairs with the Square Terminal, see POS Application Pairing with Square Terminal.
To take a payment with a paired Square Terminal
- Request a Square Terminal checkout for payment from the buyer.
- Complete the checkout.
- Verify a payment.
- Search for Terminal checkout requests.
- Cancel a checkout request, when applicable.
- To add payment and checkout features in a Terminal checkout request
payment and checkout features in a Terminal checkout request , the Square Terminal software must be on the latest version and your application should use the latest Square API release version. To view the Square Terminal version and verify that your version supports a given checkout feature or device option:- On the Square Terminal, swipe left, and then tap Settings.
- Tap Hardware, tap General, and then tap About Terminal.
- Under Terminal, view the OS Version.
- Applications must have the following OAuth permissions:
PAYMENTS_WRITE
to process payments andPAYMENTS_READ
to retrieve payments. - You cannot take cash payments with the Terminal API.
- Application fees require calling
CreateTerminalCheckout
with an OAuth token and thePAYMENTS_WRITE_ADDITIONAL_RECIPIENTS
permission, in addition to the existing required OAuth permissions. For more information, see TerminalTerminal . - Using CancelTerminalCheckout
CancelTerminalCheckout to cancel an e-money payment after getting an error on the Square Terminal is currently not supported. To cancel an e-money payment, the buyer needs to manually cancel the payment on the Square Terminal.
The following procedure describes the checkout process.
Your POS application must specify the total amount to be paid by the buyer (including any sales tax or other fees) when requesting a checkout. Optionally, your POS application can require the Square Terminal to prompt the buyer to add a tip amount, show a receipt screen, or show a signature screen.
Note
A Square Terminal accepts Apple Pay, Google Pay, Square gift cards, and prepaid debit cards. However, for US-based sellers, if the balance of a gift card or prepaid card isn't sufficient to pay for a transaction, the seller can delay the capture of the initial payment and request additional transactions to cover the remaining balance.
To take a payment from a buyer, the Square Terminal needs to have the total purchase amount and currency. For example, a Square Terminal can be told to accept $100 (USD). To process this request:
- The POS application makes a request to Square using the Terminal API to send the payment request to a paired Square Terminal, identified by the device ID.
- The payment checkout process starts, which involves enabling the POS client to send a request to checkout a buyer, accept the payment, and complete the checkout.
Important
In a production environment, you must use the
device_id
returned from the Devices APIDevices API . In the checkout request body fordevice_id
, you can also enter the Square Terminal's serial number, which is located on the back of the Square Terminal. You cannot use a device code generated from the Square Dashboard; however, you can view the device ID in the Square Dashboard after the Devices API has generated it.If the
collect_signature
option is set totrue
in the CreateTerminalCheckoutCreateTerminalCheckout endpoint underdevice_options
, the payment flow requests the buyer's signature for the payment.
When the status of a Terminal checkout object is updated, webhook notifications are sent to the endpoint that is registered for a POS application. To get the notifications, be sure that your Square application is updated in the Developer Console. The webhook notifications are as follows:
terminal.checkout.created
terminal.checkout.updated
When a Terminal checkout object is created, canceled, or completed, a full copy of the object is sent to your application at your webhook URL. The object provides status
and payment_ids
fields.
When the checkout completes, a PaymentCOMPLETED
, CANCELED
, or FAILED
. A completed payment is normally for the full amount of the purchase but must be verified against the amount expected by your POS application. A completed payment for the full purchase amount means that the checkout is complete and the POS payment window can be closed.
When a checkout is completed, it has one or more payment_ids
listed on it. These are confirmations about how much money was actually collected, if any.
Important
A COMPLETED
checkout might not have collected the exact total you requested (for example, when a tip is added to the payment). You should always check the Payment
object to determine the actual amount collected.
Get a completed checkout to find its payment_ids
, as shown in the following example:
Get terminal checkout
The following is returned:
{
"checkout": {
"id": "xv4gh2KBCmlqO",
"amount_money": {
"amount": 100,
"currency": "USD"
},
...snip...
"status": "COMPLETED",
"payment_ids": [
"{PAYMENT_ID}"
],
}
}
Search for existing Terminal checkout requests filtered by the:
- Device ID.
- Time and date range that the Terminal checkout was requested.
- Terminal checkout status.
Search results are sorted and paginated and allow for a custom page size. Search for existing requests if you need to verify completed Terminal checkouts and if you need to complete pending checkout requests.
The following example requests an additional page of completed Terminal checkout requests sent to the Square Terminal with ID R5WNWB5BKNG9R
, created on or after noon UTC/GMT, and started on 03-20-2020. Results are limited to 10 Terminal checkouts per result page.
To learn more about how to work with cursors, see Pagination
Search terminal checkouts
A Terminal checkout request can be canceled from the POS application while the status of the checkout is PENDING
or IN_PROGRESS
. To cancel a Terminal checkout, POST a request to the CancelTerminalCheckoutPENDING
Terminal checkout causes the Terminal checkout to be CANCELED
. IN_PROGRESS
Terminal checkouts transition to CANCEL_REQUESTED
and, if the buyer hasn't yet completed the transaction, transition to CANCELED
.
If the transaction is already complete, the checkout request becomes COMPLETED
. In this case, the seller cannot trigger a refund for the Payment
In this example, the seller cancels a PENDING
Terminal request from the POS application:
Cancel terminal checkout
If the request is successful, the response provides the Terminal checkout object in its new state.
{
"checkout": {
"id": "{CHECKOUT_ID}",
"amount_money": {
"amount": 100,
"currency": "USD"
},
"device_options": {
"device_id": "432532423`",
"tip_settings": {
"allow_tipping": false
},
"skip_receipt_screen": true
},
"status": "CANCELED",
"created_at": "2020-04-06T21:37:08.516Z",
"updated_at": "2020-04-06T21:37:08.516Z",
"app_id": "sq0ids-o38CJ3JfIrKJ_xn10mRhFg"
}
}
Using CancelTerminalCheckoutIN_PROGRESS
or PENDING
status when this error occurs.
The Terminal API server sets a Terminal checkout to CANCELED
if a checkout isn't completed prior to the created_at
time.
A Terminal might be completing a payment at the threshold of the timeout. When this happens, the Terminal API server might set the CANCELED
state on the checkout while the Terminal device is completing it. In this case, the checkout might become CANCELED
prior to becoming COMPLETED
. If you subscribe to Terminal API webhooks, any confusion can be avoided because you're receiving updates with each state change.