Class 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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Asks the terminal to abort (06 B0).Books a pre-authorisation (Book Total, 06 24) foramount.collect(TerminalPaymentRequest request) Takes a payment: a sale, or a pre-authorization when the request says so.protected voidHands a result to the app on the EDT; tests override it.Runs the end-of-day (06 50), which closes the batch and sends it to the acquirer.refund(TerminalRefundRequest request) Refunds an amount (06 31).Reverses a payment of the current batch (06 30), or releases a pre-authorisation (06 25).voidsetCardTimeout(int cardTimeout) The longest the terminal may stay silent during an operation before the outcome is reported unknown.voidsetReceiptsToApp(boolean receiptsToApp) Asks the terminal to send its receipts to the app, inTerminalResult.getReceipt(), rather than print them.voidsetSerialFraming(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.protected voidRunstaskon a thread of its own; tests override it.booleansupports(TerminalOperation operation) Whether this terminal can performoperation.Methods inherited from class PaymentTerminal
failed, lookup, missingCapability, unsupported
-
Constructor Details
-
ZvtTerminal
Parameters
-
link: the connection to the terminal; it is opened when needed -
password: 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: 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: 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: the limit in milliseconds
-
supports
Description copied from class:PaymentTerminalWhether this terminal can perform
operation.Parameters
operation: the operation to ask about
Returns
true when
PaymentTerminal.collect(TerminalPaymentRequest)or the matching method can carry it out- Specified by:
supportsin classPaymentTerminal
-
collect
Description copied from class:PaymentTerminalTakes a payment: a sale, or a pre-authorization when the request says so.
Parameters
request: what to charge
Returns
the outcome, delivered on the EDT
- Specified by:
collectin classPaymentTerminal
-
capture
Books a pre-authorisation (Book Total, 06 24) foramount.- Overrides:
capturein classPaymentTerminal
-
reverse
Reverses a payment of the current batch (06 30), or releases a pre-authorisation (06 25).- Overrides:
reversein classPaymentTerminal
-
refund
Refunds an amount (06 31). ZVT cannot refund a given payment, so a request naming one is refused; reverse it instead.- Overrides:
refundin classPaymentTerminal
-
reconcile
Runs the end-of-day (06 50), which closes the batch and sends it to the acquirer.- Overrides:
reconcilein classPaymentTerminal
-
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.- Specified by:
cancelin classPaymentTerminal
-
start
Runs
taskon a thread of its own; tests override it.Parameters
task: the blocking work
-
deliver
Hands a result to the app on the EDT; tests override it.
Parameters
task: the delivery
-