startTransaction

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:

Detection process:

  1. Contact detection - Monitors chip card insertion

  2. Contactless detection - Activates NFC/RFID field for tap/wave cards

  3. Magnetic stripe detection - Monitors swipe card reader

  4. 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:

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:

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()
}
}