performFinalSelection

Performs the final application selection for contact-based EMV cards and reads all necessary data records from the card.

This method completes the application selection process for contact EMV transactions by finalizing the chosen application and executing all required "Read Record" commands to retrieve application data from the card. The data retrieved includes all records specified in the Application File Locator (AFL)

Prerequisites:

Processing steps:

  1. Final application selection - Confirms and activates the selected application

  2. Read application data - Executes READ RECORD commands for all files/records specified in the Application File Locator (AFL)

  3. Data validation - Performs basic validation of retrieved data records

  4. Kernel preparation - Prepares retrieved data for subsequent EMV processing

Post-conditions:

Next step: After successful completion, call getApplicationData to retrieve all data collected from the card

Thread safety: 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 NexusRet Any unexpected error must be mapped as NexusRet.INTERR

Return

NexusRet indicating the final selection and data reading result:

Implementation notes:

  • Method blocks until all required data is read from the card

  • Card removal during this operation will result in transaction failure

  • For magnetic stripe cards, this method has no effect and returns immediately

  • Failed data reading may require complete transaction restart

Example usage:

try {
val cardType = emvPort.startTransaction()
if (cardType == CardType.CONTACT) {
// Handle application selection if needed
val appResult = emvPort.startsContactAppSelection()
if (appResult == NexusRet.OK) {
// Perform final selection and read application data
val finalResult = emvPort.performFinalSelection()
if (finalResult == NexusRet.OK) {
// Application data ready, proceed to transaction processing
val tCardData = emv.getApplicationData()
} else {
// Handle final selection failure
println("Final selection failed: $finalResult")
}
}
}
} catch (e: NexusException) {
// Handle critical final selection error
println("Critical error during final selection: ${e.message}")
}