Skip to content

Test environment

Four programs that put a whole payment chain on your machine: a virtual terminal, an acquirer host, a terminal management system and a cash register, talking the nexo protocols to each other. Use it to see a7pay at work, to try a configuration or a card, or as a stand-in for any of the four when you integrate your own. Terms in bold are in the glossary.

Program Plays Speaks
vpoi The terminal (POI): nexo FAST on the emvco kernels, with a simulated card (or a real one on a PC/SC reader) All three protocols below
acqsim The acquirer’s host: answers authorisations from rules you write, checks the terminal’s MACs and cryptograms nexo Acquirer protocol
tmssim The TMS: sends the terminal its configuration nexo TMS protocol
salesim The sale system (cash register): asks for payments, refunds, reversals, reconciliations nexo Retailer protocol
The test environment The test environment

Any of the four can be replaced by a real system:

  • point vpoi at your acquirer host or TMS (--acquirer, --tms host:port);
  • point your cash register at vpoi (port 9003);
  • point your terminal at acqsim and tmssim.

The programs live in apps/nexo/; their configuration, sample cards and test cases in apps/nexo/deploy/.

A lab setup. Plain TCP with nexo’s 4-byte length framing, as the Acquirer message usage guide specifies; the messages carry their own security (MACs, enciphered PIN and card data). There is no TLS, which some acquirers impose. The keys in apps/nexo/deploy/config/ are the nexo Security specification’s public test keys. Never put real keys here.

Four programs, one window each, all started from apps/nexo/deploy/ (the configurations’ paths are relative to it). Ports 9001 (acquirer), 9002 (TMS) and 9003 (terminal) must be free.

cd apps/nexo/deploy
cargo build -p acqsim -p tmssim -p vpoi -p salesim      # once
Window Command What it does
1 cargo run -q -p acqsim -- config/acqsim.toml The acquirer host, on 9001
2 cargo run -q -p tmssim -- config/tmssim.toml The TMS, on 9002
3 cargo run -q -p vpoi -- config/vpoi.toml tms The terminal gets its configuration from the TMS…
3 cargo run -q -p vpoi -- config/vpoi.toml serve …then waits for the cash register, on 9003
4 cargo run -q -p salesim -- config/salesim.toml pay 12.50 The cash register asks for one payment

Payments to try. The acquirer’s answer depends on the amount (samples/profiles/default.xml):

cargo run -q -p salesim -- config/salesim.toml pay 12.50    # approved
cargo run -q -p salesim -- config/salesim.toml pay 150.00   # declined by the host
cargo run -q -p salesim -- config/salesim.toml pay 13.13    # the host doesn't answer
cargo run -q -p salesim -- config/salesim.toml refund 5.00  # a refund, approved offline
cargo run -q -p salesim -- config/salesim.toml cancel <reference> 12.50   # reverses a payment
cargo run -q -p salesim -- config/salesim.toml reconcile    # the period's totals, with the acquirer
  • References: each answer ends with the request’s reference, which cancel takes. The terminal finds that payment in its transaction log (kept in memory since it started) and cancels it online.
  • Reconciliation: reconcile has the terminal send its totals to the acquirer and start a new period; a second one finds nothing left.
  • Batch capture: with capture = "batch" in config/vpoi.toml’s [acquirer], the terminal sends no advice per payment, but a batch every batch_limit payments and before a reconciliation.

Each window shows one line per message its program sends (→) or receives (←). A fifth window can follow the whole exchange in order: tail -f logs/timeline.log. Stop each program with Ctrl-C.

Built with their tui feature, the terminal and the cash register run as screens instead of log lines (windows 3 and 4):

cargo run -q -p vpoi --features tui -- config/vpoi.toml --tui serve   # add --choose-card to pick the card
cargo run -q -p salesim --features tui -- config/salesim.toml --tui
  • The cash register:
    • type an amount;
    • p pays it, r refunds it;
    • c reverses the payment selected in its list (↑ ↓);
    • its messages are shown beside.
  • The terminal:
    • it presents the configured card or, with --choose-card, asks before each payment which card of samples/cards/ to present (↑ ↓, Enter);
    • its display shows what the card reader asks it to (“Present card”, “Authorising, please wait”, “Approved”, …);
    • its messages with the cash register, the acquirer and the TMS are shown beside.

q quits either.

File, in apps/nexo/deploy/logs/ Holds
timeline.log One line per message, every program’s, in order
vpoi/, acqsim/, tmssim/, salesim/ Every message the program sent or received, in full: <time>-<count>-<sent or received>-<message>.xml
acqsim/online-messages.xml The acquirer’s exchanges as an EMVCo L3 Online Message log, rewritten after each one
vpoi/card-terminal-<time>-<process>-<payment>.xml One per payment: every command to the card and its answer (EMVCo L3 Card/Terminal log)

RUST_LOG=info,exchange=debug in front of a command adds each message’s XML. RUST_LOG=debug adds everything, including the terminal’s card commands and the kernels’ processing.

The simulated cards are EMVCo Level 3 card images (see Level 3 test platform), in apps/nexo/deploy/samples/cards/:

Card Scheme, kernel At 12.50
k2-online.xml Mastercard, Kernel 2 Online, approved
k2-other-interface.xml Mastercard, Kernel 2 The card declines; since the reader has a contact interface, Kernel 2 asks for it: “Please insert card”, aborted
k3-online.xml Visa, Kernel 3 Online, approved
k3-declined.xml Visa, Kernel 3 Declined offline by the card
k3-pin.xml Visa, Kernel 3 Asks for an online PIN. The host expects 1234 and declines any other
k4-online.xml American Express, Kernel 4 Online, approved
k6-online.xml Discover, Kernel 6 Online, approved
k8-offline.xml Mastercard’s AID on Kernel 8 Authenticated locally with ECC certificates, records read over the secure channel: approved offline

Which card is presented:

  • the one config/vpoi.toml names ([card] image), by default;
  • --card <image.xml> for another;
  • --choose-card: the terminal asks before each payment, among the cards in the same directory.

cargo run -q -p vpoi -- config/vpoi.toml --card samples/cards/k4-online.xml pay 1250 pays once, without a cash register.

apps/nexo/deploy/tests/suite.toml lists test cases. Each is one payment of the terminal with a card image, against an acquirer simulator started for it. A case passes when:

  • the payment ends with the expected result;
  • the host found the terminal’s MAC and cryptogram valid;
  • its pass criteria all pass (tests/criteria.csv, in EMVCo’s Level 3 format, checked over the card exchanges and the host messages).
cargo run -p vpoi -- suite tests/suite.toml                     # from apps/nexo/deploy/: every case
cargo run -p vpoi -- suite tests/suite.toml K2-ONLINE-APPROVED  # one case
cargo test -p vpoi --test suite                                 # the same, as a cargo test
PASS  K2-ONLINE-APPROVED           Approved
FAIL  K3-ONLINE-DECLINED           Approved
      - Transaction Result Approved, expected Declined
      - AUTQ: the host found its ARQC invalid
...
12/13 passed

A failed check shows as - <check> failed. A check the tool can’t decide (a manual check, or one it can’t evaluate) shows as ? <check>, neither passing nor failing the case. Each case’s logs go to logs/suite/<case>/.

The 13 cases cover Kernels 2, 3, 4, 6 and 8:

  • online approvals and declines;
  • an offline decline;
  • the other interface;
  • online PIN: right, wrong and cancelled;
  • Kernel 8’s offline approval.

To add a case:

  1. add a card image under samples/cards/. The configuration knows Visa on Kernel 3, Mastercard on Kernels 2 and 8, American Express on Kernel 4 and Discover on Kernel 6;
  2. add a [[case]] entry to suite.toml;
  3. add its rows to criteria.csv.

The suite file (paths relative to it):

Key Default Meaning
terminal The terminal’s configuration (vpoi.toml); each case replaces its card, host and logs
acquirer The host’s configuration (acqsim.toml): its keys
fast_config the terminal’s The FAST configuration to use
criteria none The pass criteria file; each case checks the rows whose Test is its name
log_dir Where each case’s logs go: <log_dir>/<case>/
timeout_secs 2 How long the terminal waits for the host (the “no answer” cases wait this long)
[[case]] One per test case:
name The case’s name, as the criteria file’s Test column
description ""
card The card image
profiles The host’s response profiles
pin none The PIN entered if the card asks for one; none: PIN entry is cancelled
amount In minor units (1250 is 12.50)
expect The Transaction Result expected, as FAST names it: Approved, Declined, Aborted, …
config/             one file per program: addresses, identifications, test keys
samples/tms/        the FAST configuration tmssim sends (nexo IS TLV templates, as hex)
samples/cards/      card images, one per scheme and outcome
samples/profiles/   acqsim's response profiles
tests/              test cases: suite.toml and criteria.csv
logs/               written at run time: messages, timeline, logs
state/              written at run time: the terminal's configuration from the TMS

Common to all four:

  • The configuration is a TOML file, given as the first argument (any argument ending in .toml), or <program>.toml in the current directory.
  • Errors print <program>: <error> and exit with status 1.
  • Logging goes to standard error, at info by default (salesim: warn); RUST_LOG changes it.
  • Every message sent or received is:
    • one line on the console, e.g. → acquirer AcceptorAuthorisationRequest AUTQ 12.50 EUR (log target exchange);
    • a file in log_dir, e.g. 20261201-105957.083-0002-sent-AcceptorAuthorisationRequest.xml.
  • timeline: a file the programs share, where each appends a line for every message it sends: the whole environment’s exchanges in order, each once.
  • Keys are [[keys]] entries (see Keys). Test keys only.
vpoi [config.toml] [--acquirer <host:port>] [--tms <host:port>] [--card <image.xml>] [--pin <digits>] pay <amount>
vpoi [config.toml] [--tms <host:port>] tms
vpoi [config.toml] [--acquirer <host:port>] [--card <image.xml>] [--choose-card] [--pin <digits>] [--tui] serve
vpoi suite <suite.toml> [case...]
Command Does
pay <amount> One payment, the amount in minor units (1250 is 12.50), then prints its result
tms A terminal management session: asks the TMS for its management plan, then performs its actions. A parameters download stores the FAST configuration at terminal.fast_config
serve Waits for a cash register on retailer.listen and runs the payments, refunds, reversals and reconciliations it asks for, until stopped
suite <suite.toml> [case...] Runs test cases (all, or those named) and prints a report; exits with 1 if a case fails
Option Overrides or adds
--acquirer <host:port> acquirer.address
--tms <host:port> tms.address
--card <image.xml> card.image (relative to the current directory)
--choose-card serve: before each payment or refund, asks which card image of card.image’s directory to present (Enter: card.image)
--pin <digits> The cardholder’s PIN whenever the card asks for one. Without it, the PIN is asked on standard input (Enter alone cancels), or with --tui on a PIN pad on the screen
--tui serve, feature tui: the terminal as a screen

Online PIN. When the card asks for a PIN, it goes to the virtual PIN pad, which enciphers it under acquirer.pin_key_id. The payment application only ever sees the enciphered PIN, as with a real PIN pad. PIN bypass isn’t offered: nexo FAST allows it for chip, magnetic stripe and fallback, not contactless.

Transaction log, reconciliation, capture. serve keeps the transaction log in memory (lost when vpoi stops): it is what a reversal looks up and a reconciliation totals. A reconciliation sends each acquirer the period’s totals, marks them reconciled when approved, and starts a new period. With acquirer.capture = "batch", transactions send no advice: they are captured in one batch once batch_limit of them wait, and before a reconciliation.

Real cards. Built with --features pcsc, vpoi reads cards with a PC/SC contactless reader instead of a card image (card.reader):

cargo run -p vpoi --features pcsc -- config/vpoi.toml pay 1250

vpoi.toml (paths relative to it):

Key Default Meaning
[terminal]
fast_config The FAST configuration: the nexo IS TLV templates (E0-F2) as hex. vpoi tms writes it
poi_id The terminal’s identification
parameters_version "1" The version of the acquirer parameters
log_dir Where the Card/Terminal logs and the messages go
timeline none The shared timeline file
[card] One of:
image A card image, played by the card simulator
reader A PC/SC reader’s name (feature pcsc)
[acquirer]
address The acquirer host, host:port
key_id, key_version The key protecting the messages, by the name and version messages use
timeout_secs 30 How long to wait for a response
pin_key_id, pin_key_version none The key enciphering online PINs (a DUKPT initial key of [[keys]]); none: a card asking for a PIN can’t be paid
capture "advice" "advice": a completion advice per transaction; "batch": capture by batch
batch_limit 5 With capture = "batch": how many transactions make a batch due
[tms] Optional: needed by vpoi tms
address The TMS, host:port
terminal_manager The TMS’s identification
key_id, key_version The key protecting the messages
timeout_secs 30
[retailer] Optional: needed by vpoi serve
listen Where to wait for the cash register, e.g. 0.0.0.0:9003
[[keys]] The terminal’s keys: DUKPT initial keys
acqsim [config.toml]

Runs until stopped. It answers authorisations, completion advices, cancellations and their advices, reconciliations and batches. Each request is answered from response profiles (EMVCo’s Level 3 format), or approved when there are none. Profiles:

  • match requests on their fields;
  • shape the response: decline, delay, no answer, set or remove fields;
  • add the issuer’s ARPC or scripts;
  • check the online PIN (emvsim.pin_validation(pin): a wrong PIN declines).

samples/profiles/default.xml declines amounts above 100.00, doesn’t answer 13.13, approves the rest, and expects PIN 1234. The Online Message log is rewritten after every exchange.

Key Default Meaning
listen Where to listen, e.g. 0.0.0.0:9001
profiles none: approve everything The response profiles file
log_dir Where online-messages.xml and the messages go
timeline none The shared timeline file
[[keys]] The acquirer’s keys: the terminals’ DUKPT base derivation keys, for the messages and the PINs
tmssim [config.toml]

Runs until stopped. It answers each status report with what it asks for:

  • a management plan (one action, downloading the parameters) for “MGTP”;
  • otherwise, a configuration update carrying the FAST configuration.
Key Default Meaning
listen Where to listen, e.g. 0.0.0.0:9002
terminal_manager This TMS’s identification
fast_config The FAST configuration sent: nexo IS TLV templates as hex (# comments allowed)
application_id "FAST" The ApplicationIdentification of the parameters
log_dir Where the messages go
timeline none The shared timeline file
[[keys]] The TMS’s keys: the terminals’ DUKPT base derivation keys
salesim [config.toml] [--poi <host:port>] pay <amount>
salesim [config.toml] [--poi <host:port>] refund <amount>
salesim [config.toml] [--poi <host:port>] cancel <reference> <amount>
salesim [config.toml] [--poi <host:port>] reconcile
salesim [config.toml] [--poi <host:port>] --tui
Argument Meaning
pay <amount> A payment, the amount as a decimal, e.g. 12.50
refund <amount> A refund
cancel <reference> <amount> Reverses the payment reference (what pay printed) of amount
reconcile The terminal reconciles with its acquirers, then answers with the totals
--poi <host:port> Overrides poi
--tui Feature tui: an interactive screen instead of one command. Type an amount, p pays, r refunds, c reverses the selected payment (↑ ↓), e reconciles, q quits

The terminal runs:

  • a payment as a FAST Payment;
  • a refund as a Refund (approved offline, then its advice);
  • a reversal as a Cancellation by reference: it looks the payment up in its transaction log and cancels it online.

Messages the terminal sends meanwhile (display, input requests) are logged and not answered.

Key Default Meaning
poi The terminal, host:port
sale_id This sale system’s identification
poi_id The terminal’s identification
currency ISO 4217 alphabetic code, e.g. EUR
timeout_secs 120 How long to wait for the payment to end
log_dir none Where the messages go
timeline none The shared timeline file

[[keys]] entries load keys into the program’s software security module (VCrypto, see Platform). Messages name their key by id and version.

Key Meaning
id, version The key’s name and version, as messages carry them
kind dukpt-bdk, aes-dukpt-bdk: a host’s base derivation key. dukpt-initial, aes-dukpt-initial: a terminal’s initial key (with ksn). ukpt-tdes, ukpt-aes
value The key in hex (spaces allowed)
ksn A terminal’s DUKPT Key Serial Number, in hex
derive_from_bdk true: value is the BDK the terminal’s initial key is derived from. For test environments only: a real terminal never sees its BDK
[[keys]]
id = "AcqKey"
version = "1"
kind = "dukpt-initial"
value = "37233E89 0B0104E9 BC943D0E 45EAE5A7"
ksn = "398725A501E290200000"
derive_from_bdk = true

Only ever use test keys here, such as the nexo Security specification’s test BDK above. The keys are held in memory, in clear.

apps/nexo/common (apps-common) is the programs’ shared code: TOML loading, [[keys]], hex files with comments, UTC time, the message journal and the timeline.

  • salesim: login and logout (the terminal accepts payments without them); answering the terminal’s display and input requests.
  • tmssim:
    • management plans beyond “download the parameters”;
    • key download;
    • events reported back (vpoi tms logs a plan’s events but doesn’t send them).
  • vpoi:
    • FAST’s other services;
    • retransmission of reversals and advices;
    • a persistent transaction log (in memory today);
    • TLS, should a deployment need it.