TCP
Overview
This document describes the TCP transport protocol for communication with the payment device. The device listens on port 9000
and uses the link layer protocol for message framing. JSON-RPC requests, responses, and control messages are transported over this channel.
Message Types
The TCP transport supports the following message types:
MessageType | Value (Hex) | Requires API Key? | Description |
---|---|---|---|
Request | 0x01 |
Yes | JSON-RPC request with authentication. |
Response | 0x02 |
No | JSON-RPC response from the device. |
Event | 0x03 |
No | JSON-RPC notification. |
KeepAlive | 0x04 |
No | Periodic keep-alive signal. |
ACK | 0x05 |
No | Acknowledgment of a KeepAlive. |
Error | 0x06 |
No | Indicates a link-layer error. |
For details about message frame structures and payloads, refer to the Link Layer Protocol Documentation.
Authentication
All API methods must be authenticated. Each request (MessageType 0x01
) must include a 4-byte API key in the message body (refer to the Link Layer Protocol for details). The API key is obtained through a pairing process.
- If the API key is invalid or missing, the device responds with an
Error
frame with code0x05
(NOT_AUTHENTICATED
). - For the methods that process the pairing (
pair
andauthenticate
) the API Key must be filled with zeros).
Communication Workflow
- Establish Connection:
- Connect to the payment device on port 9000 over TCP.
- Send Requests:
- Construct a valid
Request
frame (refer to the link layer for structure) and send it to the device. Ensure the API key is included. - Receive Responses:
- Parse incoming
Response
,Event
, orError
frames using the link-layer structure. - KeepAlive:
- Send periodic
KeepAlive
messages (MessageType 0x04
) to maintain the connection. - Expect an
ACK
(MessageType 0x05
) in response.
Error Handling
When an error occurs, the device responds with an Error
frame (MessageType 0x06
). The 1-byte error code in the body indicates the type of issue. For error codes and their meanings, (refer to the Link Layer Protocol Documentation).
Cached Responses
When enabled in the device settings screen, responses that fail to deliver (e.g., due to client disconnection) are cached. These responses are retried upon the next connection from the same client is established.