Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class ZvtTerminal

  1. Object
  2. PaymentTerminal
  3. ZvtTerminal

A card terminal that speaks ZVT, the till protocol of the German-speaking markets, over a serial cable, USB or the local network.

ZvtTerminal terminal = new ZvtTerminal(new TcpLink("192.168.1.80", 20007), 0);
terminal.collect(new TerminalPaymentRequest(1250, "EUR")).ready(result -> {
    if (result.isApproved()) {
        System.out.println("Keep " + result.getTransactionId() + " to reverse it");
    }
});

The terminal handles the card and the bank; the app sends an amount and gets the outcome. Over TCP the APDUs go as they are (20007 is the usual port); over a serial line or USB they are framed with DLE/STX and a CRC, and each frame is acknowledged. setSerialFraming(boolean) chooses, and defaults to framing on every link but a TcpLink.

Supported: sale, pre-authorisation and its booking (capture), reversal, unlinked refund and the end-of-day. ZVT has no refund of a given payment; reverse it the same day, or refund an amount. With setReceiptsToApp(boolean) the terminal sends its receipts to the app instead of printing them, and the app must then print them.

The transaction ID is the terminal’s receipt number, with what booking a pre-authorisation needs; keep it as an opaque string.

Constructors

public ZvtTerminal(ByteLink link, int password)

Methods

public void setSerialFraming(boolean serialFraming)Whether APDUs go in DLE/STX frames with a CRC and acknowledgement, as on a serial line, or as they are, as over TCP.
public void setReceiptsToApp(boolean receiptsToApp)Asks the terminal to send its receipts to the app, in TerminalResult.getReceipt(), rather than print them.
public void setCardTimeout(int cardTimeout)The longest the terminal may stay silent during an operation before the outcome is reported unknown.
public boolean supports(TerminalOperation operation)Whether this terminal can perform operation.
public AsyncResource<TerminalResult> collect(TerminalPaymentRequest request)Takes a payment: a sale, or a pre-authorization when the request says so.
public AsyncResource<TerminalResult> capture(String transactionId, long amount, String currency)Books a pre-authorisation (Book Total, 06 24) for amount.
public AsyncResource<TerminalResult> reverse(String transactionId)Reverses a payment of the current batch (06 30), or releases a pre-authorisation (06 25).
public AsyncResource<TerminalResult> refund(TerminalRefundRequest request)Refunds an amount (06 31).
public AsyncResource<TerminalReconciliation> reconcile()Runs the end-of-day (06 50), which closes the batch and sends it to the acquirer.
public void cancel()Asks the terminal to abort (06 B0).
protected void start(Runnable task)Runs task on a thread of its own; tests override it.
protected void deliver(Runnable task)Hands a result to the app on the EDT; tests override it.

Inherited methods

Constructor details

ZvtTerminal

public ZvtTerminal(ByteLink link, int password)

Parameters

link ByteLink
the connection to the terminal; it is opened when needed
password int
the terminal’s six digit till password, often 0 or 123456

Method details

setSerialFraming

public void setSerialFraming(boolean serialFraming)
Whether APDUs go in DLE/STX frames with a CRC and acknowledgement, as on a serial line, or as they are, as over TCP.

Parameters

serialFraming boolean
true to frame

setReceiptsToApp

public void setReceiptsToApp(boolean receiptsToApp)
Asks the terminal to send its receipts to the app, in TerminalResult.getReceipt(), rather than print them. The app is then responsible for printing; a cardholder is entitled to one.

Parameters

receiptsToApp boolean
true to receive the receipts

setCardTimeout

public void setCardTimeout(int cardTimeout)
The longest the terminal may stay silent during an operation before the outcome is reported unknown. Defaults to three minutes; a terminal sends intermediate status while it waits for the card.

Parameters

cardTimeout int
the limit in milliseconds

supports

public boolean supports(TerminalOperation operation)
Whether this terminal can perform operation.

Parameters

operation TerminalOperation
the operation to ask about

Returns

true when collect(TerminalPaymentRequest) or the matching method can carry it out

collect

public AsyncResource<TerminalResult> collect(TerminalPaymentRequest request)
Takes a payment: a sale, or a pre-authorization when the request says so.

Parameters

request TerminalPaymentRequest
what to charge

Returns

the outcome, delivered on the EDT

capture

public AsyncResource<TerminalResult> capture(String transactionId, long amount, String currency)
Books a pre-authorisation (Book Total, 06 24) for amount.

Parameters

transactionId String
the pre-authorization’s TerminalResult.getTransactionId()
amount long
the amount to take, in the minor unit; at most the reserved amount on most acquirers
currency String
the ISO 4217 code

Returns

the outcome, delivered on the EDT

reverse

public AsyncResource<TerminalResult> reverse(String transactionId)
Reverses a payment of the current batch (06 30), or releases a pre-authorisation (06 25).

Parameters

transactionId String
the payment’s TerminalResult.getTransactionId()

Returns

the outcome, delivered on the EDT

refund

public AsyncResource<TerminalResult> refund(TerminalRefundRequest request)
Refunds an amount (06 31). ZVT cannot refund a given payment, so a request naming one is refused; reverse it instead.

Parameters

request TerminalRefundRequest
what to return, and to which payment

Returns

the outcome, delivered on the EDT

reconcile

public AsyncResource<TerminalReconciliation> reconcile()
Runs the end-of-day (06 50), which closes the batch and sends it to the acquirer.

Returns

the report, delivered on the EDT

cancel

public void cancel()
Asks the terminal to abort (06 B0). Terminals honour it while waiting for the card; once the card is read the operation usually completes.

start

protected void start(Runnable task)
Runs task on a thread of its own; tests override it.

Parameters

task Runnable
the blocking work

deliver

protected void deliver(Runnable task)
Hands a result to the app on the EDT; tests override it.

Parameters

task Runnable
the delivery