Card readers
The card reader of a till takes one payment at a time: its states, what moves it, what the API shows about it and the card fields of a payment.
On this page
Each till has one card reader, and it works on one payment at a time. Your software starts, retries and cancels a card payment; the customer presents the card at the reader, and the result arrives on the order.
The states of the reader
| Status | Meaning |
|---|---|
idle | No card payment is under way. The reader is free. |
waiting | The reader has the amount and waits for the customer to present the card. |
reading | The card is presented and being read. |
authorising | The card was read and the payment waits for its authorisation. |
approved | The payment is authorised and settles its amount on the order. |
declined | The payment was refused. It stays on the order and settles nothing. |
cancelled | The amount was taken back from the reader, while it waited or after a decline. |
What moves the reader
| Move | From | To | Caused by |
|---|---|---|---|
| Start | idle, approved, declined, cancelled | waiting | startCardPayment, which needs the network |
| The customer presents the card | waiting | reading | The customer, at the reader |
| Reading ends | reading | authorising | The reader |
| The answer | authorising | approved, declined | The authorisation |
| Retry | declined | waiting | retryCardPayment |
| Cancel | waiting, declined | cancelled | cancelCardPayment |
When the order is paid the reader returns to idle. After a part payment it stays approved until the next start. Retrying and cancelling are shown in Split a payment; the states of the order are in Order and payment states.
One payment at a time
While the reader waits, reads or authorises, a second payment cannot start: startCardPayment and takeCashPayment answer reader_busy, and so does closeBusinessDay. A reader that is reading or authorising cannot be cancelled, and its order cannot be voided: cancelCardPayment and voidOrder answer reader_busy too. To take cash instead of a card that has not been presented, cancel the card payment first.
What the API shows
Read the till for reader: its state, the orderId it works for, the amount it was started with and the attempt, the cards presented for this order so far, declined ones included. The order carries the result in payments, and a declined card also sends payment.declined; see Event catalogue.
curl
curl "$RDC_BASE_URL/pos/v1/tills/e57a3b65-d690-4e6c-8a6b-8f946c4e6610" \
-H "Authorization: Bearer $RDC_TOKEN" JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/pos/v1/tills/e57a3b65-d690-4e6c-8a6b-8f946c4e6610`, {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
},
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'GET',
f'{os.environ["RDC_BASE_URL"]}/pos/v1/tills/e57a3b65-d690-4e6c-8a6b-8f946c4e6610',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
)
result = response.json() PHP
<?php
$curl = curl_init(getenv('RDC_BASE_URL') . '/pos/v1/tills/e57a3b65-d690-4e6c-8a6b-8f946c4e6610');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/pos/v1/tills/e57a3b65-d690-4e6c-8a6b-8f946c4e6610");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"id": "e57a3b65-d690-4e6c-8a6b-8f946c4e6610",
"code": "till-1",
"name": "Till 1",
"cashier": "Cristina Lungu",
"businessDayId": "aaed5ba1-2a19-4c94-ac7f-119c9288a12c",
"currentOrderId": "9d8c072d-afa0-4272-97ab-4443d54d5b62",
"network": "online",
"queue": {
"count": 0,
"oldestAt": null,
"ageSeconds": 0
},
"reader": {
"state": "idle",
"orderId": null,
"amount": "0.00",
"attempt": 0
}
} Card fields of a payment
| Field of `card` | Meaning |
|---|---|
brand | The card brand. |
last4 | The last four digits of the card. |
entry | How the card was read: contactless or chip. |
authCode | The authorisation code of an approved payment, null for a declined one. |
declineReason | Why a card was declined, null for an approved payment. |
{
"declined": {
"brand": "mastercard",
"last4": "9204",
"entry": "contactless",
"authCode": null,
"declineReason": "insufficient_funds"
},
"approved": {
"brand": "visa",
"last4": "4417",
"entry": "contactless",
"authCode": "731818",
"declineReason": null
}
} Why a card is declined
| Value of `declineReason` | Meaning |
|---|---|
insufficient_funds | Insufficient funds |
card_declined | Card declined |
expired_card | Card expired |
When a request is refused
| Code | HTTP | What to do |
|---|---|---|
reader_busy | 422 | Wait for the payment to end, or cancel it while the reader waits for the card. |
no_declined_card | 422 | Start a card payment instead of retrying. |
no_card_payment | 422 | Read the till to see the state of its reader. |
network_lost | 422 | A card needs the network. Take cash, or repeat the request when the till reports online. |