Cycle Logo

PaymentController

Package: com.mpos.sdk
Class: PaymentController

The PaymentController class is the core entry point for managing transactions and interacting with card readers within the Cycle SDK.

Overview

  • Configure the payment environment
  • Authenticate users
  • Initialize sessions
  • Handle card reader events
  • Start and manage transactions
  • Cleanly enable and disable reader sessions
  • Pass transaction context and receive results via PaymentControllerListener

Key Usage Flow

Follow these steps before initiating any payment transaction.

  1. Authenticate user: paymentController.setCredentials(email, password);
  2. Set reader type: paymentController.setReaderType(PaymentController.ReaderType.DSPREAD_D60);
  3. Initialise session (recommended before each payment): paymentController.initPaymentSession();
  4. Enable the card reader: paymentController.enable();
  5. Wait for successful initialisation: Ensure listener receives ReaderEvent.INIT_SUCCESSFULLY.
  6. Start the transaction.
  7. After transaction or on exit, call paymentController.disable();.

Lifecycle Integration

To ensure proper lifecycle handling, call the corresponding methods of PaymentController within your parent Activity.

Activity Lifecycle MethodCall on PaymentController
onCreate()paymentController.onCreate()
onDestroy()paymentController.onDestroy()
onSaveInstanceState()paymentController.onSaveInstanceState()
onNewIntent()paymentController.onNewIntent()

Listener

You can register a listener to handle events:

paymentController.setPaymentControllerListener(myListener);

The listener implements the PaymentControllerListener interface and handles reader events, payment status updates, and error feedback.

Precision Rule

If you specify a payment amount with more decimals than the currency allows, it will be truncated (not rounded).

Example: If the currency supports 2 decimal places, 100.999 becomes 100.99.

Static Configuration Properties

PropertyDescription
DEBUGEnables/disables SDK debug mode
VERSIONCODECurrent SDK version code
MAX_EMV_RETRIESMaximum EMV (chip) transaction retry count before fallback to magstripe
CONNECTION_LOST_RETRIESNumber of automatic retries when confirming payment during a lost connection
CONNECTION_LOST_TIMEOUTWait time (in seconds) before retries start if connection is lost (0 = retry immediately)