Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class ZvtTerminal
- Object
- PaymentTerminal
- 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
Inherited methods
Constructor details
ZvtTerminal
public ZvtTerminal(ByteLink link, int password)Parameters
linkByteLink- the connection to the terminal; it is opened when needed
passwordint- the terminal’s six digit till password, often 0 or 123456
Method details
setSerialFraming
public void setSerialFraming(boolean serialFraming)Parameters
serialFramingboolean- true to frame
setReceiptsToApp
public void setReceiptsToApp(boolean receiptsToApp)TerminalResult.getReceipt(), rather than print them. The app is
then responsible for printing; a cardholder is entitled to one.Parameters
receiptsToAppboolean- true to receive the receipts
setCardTimeout
public void setCardTimeout(int cardTimeout)Parameters
cardTimeoutint- the limit in milliseconds
supports
public boolean supports(TerminalOperation operation)operation.Parameters
operationTerminalOperation- the operation to ask about
Returns
collect(TerminalPaymentRequest) or the matching method
can carry it outcollect
public AsyncResource<TerminalResult> collect(TerminalPaymentRequest request)Parameters
requestTerminalPaymentRequest- what to charge
Returns
capture
public AsyncResource<TerminalResult> capture(String transactionId, long amount, String currency)amount.Parameters
transactionIdString- the pre-authorization’s
TerminalResult.getTransactionId() amountlong- the amount to take, in the minor unit; at most the reserved amount on most acquirers
currencyString- the ISO 4217 code
Returns
reverse
public AsyncResource<TerminalResult> reverse(String transactionId)Parameters
transactionIdString- the payment’s
TerminalResult.getTransactionId()
Returns
refund
public AsyncResource<TerminalResult> refund(TerminalRefundRequest request)Parameters
requestTerminalRefundRequest- what to return, and to which payment
Returns
reconcile
public AsyncResource<TerminalReconciliation> reconcile()Returns
cancel
public void cancel()start
protected void start(Runnable task)task on a thread of its own; tests override it.Parameters
taskRunnable- the blocking work
deliver
protected void deliver(Runnable task)Parameters
taskRunnable- the delivery