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.
- Authenticate user:
paymentController.setCredentials(email, password); - Set reader type:
paymentController.setReaderType(PaymentController.ReaderType.DSPREAD_D60); - Initialise session (recommended before each payment):
paymentController.initPaymentSession(); - Enable the card reader:
paymentController.enable(); - Wait for successful initialisation: Ensure listener receives
ReaderEvent.INIT_SUCCESSFULLY. - Start the transaction.
- 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 Method | Call 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
| Property | Description |
|---|---|
DEBUG | Enables/disables SDK debug mode |
VERSIONCODE | Current SDK version code |
MAX_EMV_RETRIES | Maximum EMV (chip) transaction retry count before fallback to magstripe |
CONNECTION_LOST_RETRIES | Number of automatic retries when confirming payment during a lost connection |
CONNECTION_LOST_TIMEOUT | Wait time (in seconds) before retries start if connection is lost (0 = retry immediately) |