start Transaction
Initiates an EMV transaction by detecting and identifying the card type present.
This method starts the EMV transaction flow by activating card detection mechanisms for all supported card interfaces (contact, contactless, and magnetic stripe). It waits for a card to be presented and returns the detected card type, which determines the subsequent transaction flow.
Prerequisites:
EMV kernel environment must be initialized via initializeKernelEnvironment
Display callbacks must be set via setDspCallback
Transaction parameters should be configured via setTransactionParams
Application data and CAPKs should be loaded into the kernels (via setContactKernelAppData, endContactKernelAppDataLoad, setContactlessKernelAppData, endContactlessKernelAppDataLoad, setContactCAPKs, endContactCAPKLoad, setContactlessCAPKs, and endContactlessCAPKLoad)
Detection process:
Contact detection - Monitors chip card insertion
Contactless detection - Activates NFC/RFID field for tap/wave cards
Magnetic stripe detection - Monitors swipe card reader
Timeout handling - Uses configured timeout from transaction parameters
Post-conditions:
Card is detected and basic communication is established
Card type is identified for subsequent processing steps
Transaction context is prepared for the detected card type
For contact cards: Card is powered up and ATR is received
For contactless cards: Initial communication is established
For magnetic stripe: Track data is read
Next steps based on card type:
Contact: Call startsContactAppSelection followed by performFinalSelection and getApplicationData
Contactless: Proceed directly to performTransaction followed by getApplicationData
Magnetic stripe: Retrieve data via getApplicationData
Thread safety: This method blocks until a card is detected or timeout occurs. Should be called from a background thread to avoid blocking the UI.
Exceptions: This function MUST NOT throw any exception. Any error must be indicated through TypeOutputStartTransaction.iNexusRet Any unexpected error must be mapped as NexusRet.INTERR
Possible TypeOutputStartTransaction.iNexusRet values:
NexusRet.TIMEOUT when no card detected in the given time
NexusRet.MCDATAERR if magstripe read error occurs
NexusRet.CTLSSMULTIPLE if multiple contactless cards detected
NexusRet.CANCEL if abort signal triggered
NexusRet.INTERR on any unexpected exception
Implementation notes:
Method blocks until card detection or timeout
First detected card type takes precedence
If a ctls card is detected, it must verify if there was any MSR activity, if so it must consider that a magstripe was swiped and not a ctls card tapped
Return
TypeOutputStartTransaction The detected card type (CONTACT, CONTACTLESS, or MSR) and the status of the processing.
Example usage:
// Initialize kernel environment, display callbacks, and transaction parameters
// Then...
val tOutputStartTransaction = emvPort.startTransaction()
val iOutputStartTransactionStatus = tOutputStartTransaction.iNexusRet
if(iOutputStartTransactionStatus != NexusRet.OK) {
// Handle error
}
val eCardType = tOutputStartTransaction.eCardType
val tCardData = when (eCardType) {
CardType.CONTACT -> {
// Handle contact card flow
emvPort.startsContactAppSelection()
emvPort.performFinalSelection()
emvPort.getApplicationData()
}
CardType.CONTACTLESS -> {
// Handle contactless card flow
emvPort.performTransaction()
emvPort.getApplicationData()
}
CardType.MAGSTRIPE -> {
// Handle magnetic stripe flow
emvPort.getApplicationData()
}
}