Skip to main content
While integrators should use the C API provided by libecodsdk, the JSON-RPC API is used by the EMV Core logs and is very useful during integration debugging.

Protocol Rules

Syntax Rules

All commands follow these formatting conventions:
  • All commands and events use the JSON-RPC 2.0 protocol with named parameters.
  • All commands and events require a response, except log() and ReaderMessageEvent(), which have no id.
  • Message format:
  • Use a different id for each command (e.g., a running counter) to aid synchronization.
  • An illegal command returns a "Not existing command" response from the EMV Core.

Send & Receive

Sending a message:
  1. Send the JSON-RPC message.
  2. Wait for the JSON-RPC response.
  3. Once data starts arriving, wait for a complete JSON (all parentheses closed), or a 1-second timeout.
Receiving a message (loop):
  1. Wait for incoming data.
  2. Once data starts arriving, wait for complete JSON, or a 1-second timeout.
  3. Parse and process the message as JSON-RPC.
  4. Send a JSON-RPC response (no response needed for ReaderMessageEvent; no response is sent for socket_data_received).

Payment Flow

A typical payment session follows this sequence:
  1. POS sends PreAuthorize.
  2. EMV Core responds (after card tap and authorization) with TransactionComplete.
  3. POS sends either ConfirmTransaction (product delivered) or VoidTransaction (otherwise).
  4. POS may send CancelTransaction at any time; TransactionComplete will return with status Cancelled.
Important notes:
  • Always close a PreAuthorize session with Confirm or Void/Cancel. An unclosed session will be reversed by the processor after some time, which may incur higher fees.
  • Once ConfirmTransaction has been acknowledged by the EMV Core, do not re-send it.
  • To force synchronous processing, set PAYMENT_SVC_SYNCHRONOUS=1.

Closed Loop (CLP) Flow

For pre-paid cards, EMV Core immediately returns the card UID to the host application via TransactionComplete without sending to the Nayax server.

Commands

PreAuthorize

Pre-authorize a card with the payment processor. The EMV Core waits for a card, reads it, processes it, then sends TransactionComplete. Example:
Parameters:

ConfirmTransaction

Confirms the pre-authorization so the payment can settle. Example:
Parameters:

VoidTransaction

Void a transaction in two cases:
  • Transaction was pre-authorized but not confirmed, to release reserved funds.
  • Transaction was completed but needs to be canceled (e.g., product not vended).
Example:
VoidTransaction does not return an event. Check voided transaction status in TMS by searching for Cancel and Cancel Declined statuses.

CancelTransaction

Cancels the last transaction started by PreAuthorize:
  • Card not yet presented: Stops the reader poll sequence. The display shows “Cancelling”; the host application must update the display.
  • Card already presented but not completed: Returns CannotCancel. TransactionComplete arrives after the online authorization result.
  • Transaction already completed: Returns NoTransaction.
  • For CannotCancel or NoTransaction, use VoidTransaction to undo a successful transaction.
  • If TransactionComplete returns Decline, no VoidTransaction is needed.
Example:

GetCardToken

Returns a card token without performing a payment transaction. Returns CardTokenReceived event.
  • For payment cards: returns a base64 card token.
  • For CLP (e.g., Mifare) cards: returns the card UID.
Example:
Notes:
  • Requires tag DFA155 added to the reader’s Clear results tag list.
  • CLP card UID is returned only when CLP_MIFARE_ENABLED=2.

GetStatus

Returns the current EMV Core status. Example:
Result values: {NotReady, Ready, PaymentTransaction, Update, NoReader, NoTerminalId}

ShowMessage

Shows a message on the OTI Saturn Reader display. Example:

GetVersion

Returns the version of components in the system. Example:

GetKioskID

Returns the Kiosk identification number. Example:

GetAttribute

Returns the value of an EMV Core configuration attribute. Example:

Events

TransactionComplete

Sent by the EMV Core when a transaction completes (success or failure). Contains all data needed for receipts and dispute resolution. Note: If no acknowledgment is received, the EMV Core resends up to 2 times (3 total). If still no answer, it assumes the message was received and does not cancel the transaction. Example (open loop):
Parameters: Authorization Details fields: Closed-loop card types:

CardTokenReceived

Sent when GetCardToken is completed. Example:

ReaderMessageEvent

Sent when the display message on the Saturn Reader changes. Use this to synchronize the kiosk application with reader state. Note: Requires the reader to be configured to send External Display message events (Tag DF 46 with index 04). This event does not require acknowledgment. Example:
Message Index:

Network Protocol

Socket API

socket_connect

Opens a TCP socket to a remote host.
Returns a positive socket ID on success, or a negative error number on failure.

socket_send

Sends data in binary form. Blocks until data is sent. hex_data is a hex-encoded string (2 ASCII characters per byte).

socket_recv

Receives data from a socket. Returns hex-encoded data.

socket_close

socket_data_received (event)

Sent by the host when data is available on an open socket. The device does not respond.

Network Management APIs

network_get_status

Returns "on" if network is available.

network_get_info

Returns network channel, operator, technology (3G/4G), signal strength, and BER.

resolve_host_name

DNS resolution: returns list of IP addresses and TTL.