Cycle Logo

PaymentController Class Methods

A detailed reference for all methods available in the PaymentController class.

Initialization & Configuration

getInstance

Returns a singleton instance of PaymentController. Always use this method to access the controller.

Signature

PaymentController getInstance()

onCreate

Must be called in the parent Activity’s onCreate() method to initialise the controller correctly.

Signature

void onCreate(Context context, Bundle savedInstanceState)

Inputs

InputDescription
contextApplication context
savedInstanceStatePassed from the parent Activity

onDestroy

Must be called in the parent Activity’s onDestroy() to clean up resources.

Signature

void onDestroy()

onSaveInstanceState

Must be called from the parent Activity’s onSaveInstanceState().

Signature

void onSaveInstanceState(Context context, Bundle savedInstanceState)

Inputs

InputDescription
contextApplication context
savedInstanceStateFrom the parent Activity

enable

Begins interaction with the card reader. Required before transactions.

Signature

void enable()

disable

Ends interaction with the card reader. Should be called after a session ends. Interrupts any ongoing transaction.

Signature

void disable()

isConnected

Confirms if the card reader is connected and ready.

Signature

boolean isConnected()

Returns

true if reader is connected

initPaymentSession

Initializes internal counters. An exception PaymentControllerException will be generated with an attempt to call it while making a transaction.

Signature

void initPaymentSession() throws PaymentControllerException

Authentication & Listeners

setPaymentControllerListener

Assigns a listener to handle card reader and transaction events.

Signature

void setPaymentControllerListener(PaymentControllerListener listener)

Inputs

InputDescription
listenerInterface for transaction events

setCredentials

Sets the login credentials for authentication. Must be set before any transaction. Throws PaymentControllerException if called during a transaction.

Signature

void setCredentials(String email, String password) throws PaymentControllerException

Inputs

InputDescription
emailCycle account email
passwordCycle account password

auth

Validates the current user credentials and retrieves account information.

Signature

APIAuthResult auth(Context context)

Inputs

InputDescription
contextApplication context

Returns

APIAuthResult containing user/account info

Reader & Device Configuration

getBluetoothDevices

Scans and returns all available paired Bluetooth readers.

Signature

ArrayList<BluetoothDevice> getBluetoothDevices(Context context)

Inputs

InputDescription
contextApplication context

Returns

List of paired Bluetooth devices

setReaderType

Sets the type and source of the card reader device. Must not be called during an active transaction.

Signature

void setReaderType(Context context, ReaderType readerType, String address, String config) throws PaymentControllerException

Inputs

InputDescription
contextApp context (Activity required for NFC)
readerTypeType of reader (e.g. DSPREAD_D60)
addressMAC address (Bluetooth) or USB_MODE_KEY for USB
configReader config parameters

getReaderType

Returns the type of the card reader currently configured.

Signature

ReaderType getReaderType()

Returns

The current ReaderType

startAutoConfig

Enables to get the configuration of a card reader for a further operation. An exception PaymentControllerException will be generated with an attempt to call it while making a transaction or changing the configuration.

Signature

String startAutoConfig() throws PaymentControllerException

Returns

Card reader configuration string

readerSetConfig

Initiates the reader configuration procedure. An exception PaymentControllerException will be generated with an attempt to call it while making a transaction or changing a configuration.

Signature

void readerSetConfig(String config) throws PaymentControllerException

Inputs

InputDescription
configConfiguration string

readerInjectKeys

Embarks on a procedure of reader’s keys firmware. Available for Urovo devices only. An exception PaymentControllerException will be generated with an attempt to make a payment or change a configuration.

Signature

void readerInjectKeys(String host) throws PaymentControllerException

Inputs

InputDescription
hostHost URL for key firmware

getKeysHosts

Enables to get a list of hosts for flashing a reader.

Signature

Map<String, String> getKeysHosts(Context context, String pin)

Inputs

InputDescription
contextApplication context
pinAccess key

Returns

The list of pairs of a type <Host name, host url >

setCustomReaderParams

Sets the parameters for a reader operation. An exception PaymentControllerException will be generated with an attempt to call it while making a transaction or changing a configuration. Possible parameters: NOTUP (true/false) – automatic activation of NFC on the reader Cycle One while making a transaction.

Signature

void setCustomReaderParams(Hashtable<String, Object> data) throws PaymentControllerException

Inputs

InputDescription
dataReader operation parameters

setSoundEnabled

Enables or disables sounds of the reader while making a transaction. Available for a reader Cycle One only.

Signature

void setSoundEnabled(boolean enabled)

Inputs

InputDescription
enabledSound enabling / disabling

readerBeep

Initializes the set number of the reader sound signals in case it is connected. Available for a reader Cycle One only.

Signature

void readerBeep(int count)

Inputs

InputDescription
countThe number of signals

readerConfigEmv (deprecated)

Outdated, use readerSetConfig. Embarks on a procedure of EMV-configuration change. Available for Urovo devices only.

Signature

void readerConfigEmv(Hashtable<String, Object> data) throws PaymentControllerException

Inputs

InputDescription
dataConfiguration parameters

readerConfigCapk (deprecated)

Outdated, use readerSetConfig. Embarks on a procedure of CAPK-configuration changing. Available for Urovo devices only.

Signature

void readerConfigCapk(Hashtable<String, Object> data) throws PaymentControllerException

Inputs

InputDescription
dataConfiguration parameters

Transaction & Payment

startPayment

Initiates a transaction. Throws a PaymentException if parameters are invalid or if a transaction is already in progress.

Signature

void startPayment(Context context, PaymentContext paymentContext) throws PaymentException

Inputs

InputDescription
contextApplication context
paymentContextAll payment-related parameters

reversePayment (deprecated)

Legacy method for initiating a cancellation or refund. Use the updated ReversePaymentContext version.

Signature

void reversePayment(Context context, String transactionID, ReverseAction action, Double amountToReverse, Currency currency, String receiptPhone, String receiptEmail) throws PaymentException

Inputs

InputDescription
transactionIDOriginal transaction ID
actionCancellation type (CANCEL, RETURN)
amountToReverseAmount to refund (use null for full refund)
currencyCurrency to refund in
receiptPhonePhone number for SMS receipt
receiptEmailEmail for receipt

reversePayment (recommended)

Recommended method for initiating a refund or cancellation. Throws PaymentException if a transaction is in progress or request is invalid.

Signature

void reversePayment(Context context, ReversePaymentContext reversePaymentContext) throws PaymentException

Inputs

InputDescription
contextApplication context
reversePaymentContextEncapsulates all refund data

setSingleStepEMV

Enables payments with single-factor authentication.

Signature

void setSingleStepEMV(boolean singleStepEMV)

Inputs

InputDescription
singleStepEMVSingle-factor authorization feature

getSingleStepEMV

Returns the sign of a single-factor authentication.

Signature

boolean isSingleStepEMV()

Returns

Sign of a single-factor authentication

setRepeatOnError

Allows to enable/disable the mode of repeated card request by the card reader in case of transaction error.

Signature

void setRepeatOnError(boolean repeatOnError)

Inputs

InputDescription
repeatOnErrorIndicator for repeated card request on error

getRepeatOnError

Returns an indication of the need to re-request the card in case of a transaction error.

Signature

boolean getRepeatOnError()

Returns

An indicator of the need to request the card again

prepare

Fills out the fields for a custom product that has a preparable property according to data in its preparable-fields.

Signature

APIPrepareResult prepare(Context context, String productCode, Map<String, String> fields)

Inputs

InputDescription
contextApplication context
productCodeProduct code that requires filling out the fields
fieldsValues of product preparable-fields

Returns

Operation result

submitCash

Synchronous. Conducts a cash payment. An exception ProcessingException will be generated if an error occurs during the request operation.

Signature

PaymentResultContext submitCash(Context context, PaymentContext paymentContext) throws ProcessingException

Inputs

InputDescription
contextApplication context
paymentContextPayment information

Returns

The result of making a transaction

submitDeferred

Synchronous. Sends the authorization data received previously. An exception PaymentException will be generated if a deferred authorization error occurs.

Signature

PaymentResultContext submitDeferred(Context context, String data) throws PaymentException, ProcessingException

Inputs

InputDescription
contextApplication context
dataData for a deferred authorization

Returns

Operation result

settlement

TTK Protocol settlement. An exception PaymentControllerException will be generated with an attempt to call it while making a transaction.

Signature

SettlementResult settlement() throws PaymentControllerException

Returns

Operation result

Signature & Receipt Methods

adjust (for one-time payments)

Sends a signature and receipt for a one-time payment transaction.

Signature

APIResult adjust(Context context, String transactionID, String receiptPhone, String receiptEmail, byte[] signature)

Inputs

InputDescription
transactionIDRelated transaction ID
receiptPhoneSMS destination
receiptEmailEmail destination
signatureSignature image in bytes

Returns

APIResult

adjust (for recurring payments)

Sends a signature for a recurring transaction. No receipt options in this method.

Signature

APIResult adjust(Context context, int regularID, byte[] signature)

Inputs

InputDescription
regularIDRecurring transaction ID
signatureSignature image

Returns

APIResult

adjustReverse

Sends a signature and receipt for a reversed (refunded) transaction.

Signature

APIResult adjustReverse(Context context, String transactionID, String receiptPhone, String receiptEmail, byte[] signature)

Inputs

InputDescription
transactionID, receiptPhone, receiptEmail, signatureSame as one-time adjust()

Returns

APIResult

printText

Command operates with WISEPAD2_PLUS readers only, otherwise an exception PaymentControllerException will be generated.

Signature

PrintResult printText(String text, Layout.Alignment alignment) throws PaymentControllerException

Inputs

InputDescription
textText for printing
alignmentText alignment

Returns

Printing results

submitEmailNotification

Enables to send a notification to a user’s email. Images in an email should be placed according to their code in scr as an attribute cis:image_code.

Signature

APIResult submitEmailNotification(Context context, String email, String subj, String body, Map<String, byte[]> images)

Inputs

InputDescription
contextApplication context
emailForwarding address
subjEmail subject
bodyHTML email content
imagesSet of images

Returns

Result of sending a request

Card Linking & Balance Inquiry

addLinkedCard (outdated)

Embarks on a card linking procedure. An exception PaymentException will be generated in an attempt to link the card before the payment (reversal) completion. Asynchronous, see PaymentControllerListener.

Signature

void addLinkedCard(Context context, AttachCardContext attachCardContext) throws PaymentException

Inputs

InputDescription
contextApplication context
attachCardContextCard linking parameters

addLinkedCard (outdated)

Embarks on a card linking procedure. An exception PaymentException will be generated in an attempt to link the card before the payment (reversal) completion. Asynchronous, see PaymentControllerListener.

Signature

void addLinkedCard(Context context, PaymentController.Currency currency, String acquirerCode) throws PaymentException

Inputs

InputDescription
contextApplication context
currencyCard currency
acquirerCodeBank code

removeLinkedCard

Deletes the linked card for the active account. Synchronous.

Signature

APIResult removeLinkedCard(Context context, int cardID)

Inputs

InputDescription
contextApplication context
cardIDID of the deleted card

Returns

Operation result

getLinkedCards

Requests a set of linked cards for the active account. Synchronous.

Signature

APIReadLinkedCardsResult getLinkedCards(Context context)

Inputs

InputDescription
contextApplication context

Returns

ObjectAPIReadLinkedCardsResult that contains a set of linked cards

balanceInquiry

Embarks on a procedure of requesting a card balance. Asynchronous, see PaymentControllerListener.

Signature

void balanceInquiry(Context context, PaymentController.Currency currency, String acquirerCode) throws PaymentException

Inputs

InputDescription
contextApplication context
currencyCard currency
acquirerCodeBank code

balanceInquiry (outdated)

See balanceInquiry(Context context, PaymentController.Currency currency, null)

Signature

void balanceInquiry(Context context, PaymentController.Currency currency) throws PaymentException

Inputs

InputDescription
contextApplication context
currencyCard currency

Transaction Query Methods

isPaymentInProgress

Useful for checking controller state before starting new transactions.

Signature

boolean isPaymentInProgress()

Returns

true if a transaction is in progress

getHistory

Fetches transaction history, paginated.

Signature

APIGetHistoryResult getHistory(Context context, int page)

Inputs

InputDescription
contextApp context
pagePage number for pagination

Returns

APIGetHistoryResult

getTransactionByID

Retrieve transaction by internal ID.

Signature

APIGetHistoryResult getTransactionByID(Context context, String transactionID)

Inputs

InputDescription
transactionIDCycle internal transaction ID

Returns

APIGetHistoryResult

getTransactionByExtID

Lookup a transaction by external ID.

Signature

APIGetHistoryResult getTransactionByExtID(Context context, String extID)

Inputs

InputDescription
extIDExternal ID

Returns

APIGetHistoryResult

getTransactionByRRN

Retrieve a transaction using the RRN (ISO8583 standard).

Signature

APIGetHistoryResult getTransactionByRRN(Context context, String rrn)

Inputs

InputDescription
rrnRetrieval Reference Number

Returns

APIGetHistoryResult

getTransactionByInvoice

Fetches transaction details by receipt number.

Signature

APIGetHistoryResult getTransactionByInvoice(Context context, String invoice)

Inputs

InputDescription
invoicePrinted receipt number

Returns

APIGetHistoryResult

tryGetPaymentStatus

Enables to request a payment status with a request timeout of 60 seconds. It is used for payments via “payment link”.

Signature

APITryGetPaymentStatusResult tryGetPaymentStatus(Context context, String transactionID)

Inputs

InputDescription
contextApplication context
transactionIDTransaction ID

Returns

Request result that contains TransactionItem with an updated data

setClientProductCode

Sets the client application code.

Signature

void setClientProductCode(String clientProductCode)

Inputs

InputDescription
clientProductCodeClient application code

getClientProductCode

Returns the set code of a client application.

Signature

String getClientProductCode()

Returns

Code that is set for a client application