Class Terminal


  • public class Terminal
    extends Object

    Terminal base implementation. Create instance of TerminalApi to connect to payment terminal.

    Most simple usage is using synchronous methods like this example:

     
     // Create settings with Terminal-ID of terminal to connect to 
     com.six.TerminalSettings settings = new com.six.TerminalSettings();
     settings.setTerminalId("12345678");
     
     // Create terminal 
     com.six.Terminal terminal = new com.six.Terminal(settings);
     
     // Run transaction
     terminal.transaction(com.six.constants.TransactionType.PURCHASE,
        new com.six.Amount(8.5, com.six.constants.Currency.CHF));
     
     // Disconnect from terminal and clean up properly
     terminal.dispose(); 
     
     

    The above example blocks until the transaction finishes. To create a responsive application use asynchronous methods like this example:

     
     // Asynchronous listener handling terminal events.
     class TerminalHandler extends com.six.DefaultTerminalListener {
        @Override
        public void transactionCompleted(com.six.TimEvent event, final com.six.TransactionResponse data) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    // handle transaction finished using data
                }
            });
        }
     }
     
     // Create settings with Terminal-ID of terminal to connect to 
     com.six.TerminalSettings settings = new com.six.TerminalSettings();
     settings.setTerminalId("12345678");
     
     // Create terminal 
     com.six.Terminal terminal = new com.six.Terminal(settings);
     
     // Add listener to handle events
     terminal.addListener(new TerminalHandler());
     
     // Run transaction
     terminal.transactionAsync(com.six.constants.TransactionType.PURCHASE,
        new com.six.Amount(8.5, com.six.constants.Currency.CHF));
     
     // Once the transaction completes TerminalHandler.transactionCompleted will be called