Amadis

Agnos - Transaction sample code

Basic transaction

A basic OLA transaction includes the following steps:

OLA classes instantiation (once at startup)

private val ola: Ola private val contact: OlaContact private val contactless: OlaContactless private val emv: OlaEmv private val dev: Dev private val publicKey: OlaPublicKey ... init { ola = Ola.getInstance() contact = OlaContact.getInstance() contactless = OlaContactless.getInstance() emv = OlaEmv.getInstance() publicKey = OlaPublicKey() ... }

OLA component initialisation (once at startup)

/** * Configures OLA layer (key files paths, trace, etc...) */ private fun olaConfig() { val path = byteArrayOf(0xdf.toByte(), 0x01, 28) val pathValue = "/data/data/ca.amadis.tester/" val cakeys = byteArrayOf(0xdf.toByte(), 0x02, 34) val cakeysValue = "/data/data/ca.amadis.tester/CAKeys" val crl = byteArrayOf(0xdf.toByte(), 0x03, 31) val crlValue = "/data/data/ca.amadis.tester/CRL" val efl = byteArrayOf(0xdf.toByte(), 0x04, 31) val eflValue = "/data/data/ca.amadis.tester/EFL" val pcsc = byteArrayOf(0xdf.toByte(), 0x05, 0x00) // pcsc not used val lang = byteArrayOf(0xdf.toByte(), 0x06, 0x00) // lang not used val runtimeParams = byteArrayOf(0xdf.toByte(), 0x07, 0x07, 0x00, 0x0F, 0x04, 0x0F, 0x0A, 0x00, 0x01) val traceLevel = byteArrayOf(0xdf.toByte(), 0x08, 0x01, 0x05) val pollingTechno = byteArrayOf(0xdf.toByte(), 0x10, 0x01, 0x04) // Contactless only var sredMode: ByteArray if (BuildConfig.FLAVOR.lowercase().contains("nosred")) { sredMode = byteArrayOf(0xdf.toByte(), 0x17, 0x01, 0x00) // SRED mode not active } else { sredMode = byteArrayOf(0xdf.toByte(), 0x17, 0x01, 0x01) // SRED mode active } try { val out = ByteArrayOutputStream() out.write(path) out.write(pathValue.toByteArray()) out.write(cakeys) out.write(cakeysValue.toByteArray()) out.write(crl) out.write(crlValue.toByteArray()) out.write(efl) out.write(eflValue.toByteArray()) out.write(pcsc) out.write(lang) out.write(runtimeParams) out.write(traceLevel) out.write(pollingTechno) out.write(sredMode) ola.initializeAtStartUp(out.toByteArray()) } catch (e: IOException) { } }

AID configuration

private fun terminalContactlessConfig() { Log.v("Transaction", "terminalContactlessConfig") val contactlessCfg = arrayOf( ContactlessCfg(AID.FromBytes(byteArrayOf(0xA0.toByte(), 0x00, 0x00, 0x00, 0x04, 0x10, 0x10)), true, 2, mcCfg), ContactlessCfg(AID.FromBytes(byteArrayOf(0xA0.toByte(), 0x00, 0x00, 0x00, 0x04, 0x20, 0x10)), true, 2, mcCfg), ...) contactless.flushAIDSupported() for (config in contactlessCfg) { contactless.addAIDSupported( config.aid, config.partial, config.kernelId.toByte(), config.additionalData ) } contactless.commitSupportedAIDs() }

Keys configuration

Transaction related data ()

Preprocessing

Card detection

Do transaction

Outcome and errors management

At the end of a transaction, the OlaOutcomeParameter structure should be retrieved for analysis. To retrieve the outcome, use the following code:

Please refer to the Javadoc/Kotlindoc for more information on the OlaOutcomeParameter class.

The first element to verify is the value of the outcome member. In a Tap to Phone environement, its value should be either of the following:

  • SelectNext,

  • TryAgain,

  • Declined

  • OnlineRequest,

  • EndApplication

The transaction should never be accepted offline.

EndApplication outcome

In case the outcome is EndApplication, the application should look into OlaErrorIndicator element to understand what possibly caused the premature end of the transaction. To retrieve that information, one should use the following API:

The OlaErrorIndicator class contains different levels of errors represented by the following members:

Only one of them can be filled at once.

Â