Class ZvtTerminal

java.lang.Object
com.codename1.payment.terminal.PaymentTerminal
com.codename1.payment.terminal.zvt.ZvtTerminal

public class ZvtTerminal extends PaymentTerminal

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 Details

    • ZvtTerminal

      public ZvtTerminal(ByteLink link, int password)
      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

      public boolean supports(TerminalOperation operation)
      Description copied from class: PaymentTerminal

      Whether 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:
      supports in class PaymentTerminal
    • collect

      Description copied from class: PaymentTerminal

      Takes 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:
      collect in class PaymentTerminal
    • capture

      public AsyncResource<TerminalResult> capture(String transactionId, long amount, String currency)
      Books a pre-authorisation (Book Total, 06 24) for amount.
      Overrides:
      capture in class PaymentTerminal
    • reverse

      public AsyncResource<TerminalResult> reverse(String transactionId)
      Reverses a payment of the current batch (06 30), or releases a pre-authorisation (06 25).
      Overrides:
      reverse in class PaymentTerminal
    • refund

      Refunds an amount (06 31). ZVT cannot refund a given payment, so a request naming one is refused; reverse it instead.
      Overrides:
      refund in class PaymentTerminal
    • reconcile

      Runs the end-of-day (06 50), which closes the batch and sends it to the acquirer.
      Overrides:
      reconcile in class PaymentTerminal
    • 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:
      cancel in class PaymentTerminal
    • start

      protected void start(Runnable task)

      Runs task on a thread of its own; tests override it.

      Parameters
      • task: the blocking work
    • deliver

      protected void deliver(Runnable task)

      Hands a result to the app on the EDT; tests override it.

      Parameters
      • task: the delivery