It might be required in some cases (when using an external Entry Point for example) to call Agnos only after SELECT PPSE and FINAL SELECT have been performed. Agnos is capable of handling such a scenario. Below the steps to perform (once the application selection was made).
Transaction Execution
The following Steps shall be executed for each Transaction.
...
It is important calling the function ola_contacless_clean()
once the Transaction is completed.
Exemple
Below an exemple of how to perform a transaction with an external EntryPoint :
Code Block | ||
---|---|---|
| ||
private fun performTransaction() { //Mock data of the SelectPPSE and FinalSelect from the external EP val selectPPSE = byteArrayOf(0x00, 0xA4.toByte(), 0x04, 0x00, 0x0e, 0x32, 0x50, 0x41, 0x59, 0x2e, 0x53, 0x59, 0x53, 0x2e, 0x44, 0x44, 0x46, 0x30, 0x31, 0x00) val selectFinal = byteArrayOf(0x00, 0xA4.toByte(), 0x04, 0x00, 0x07, 0xA0.toByte(), 0x00, 0x00, 0x00, 0x03, 0x10, 0x10, 0x00) // Beginning of transaction (card detection, SELECT PPSE, SELECT FINAL) if (detectCard(60) != 2) { Log.e("MainActivity", "performTransaction - error while detecting card") return } if (sendApdu(selectPPSE) == null) { Log.e("MainActivity", "performTransaction - error while sending SELECT PPSE") return } val fci = sendApdu(selectFinal) if (fci == null ){ Log.e("MainActivity", "performTransaction - error while sending SELECT FINAL") return } // Step 1 - Clean SDK context //agnos.olaContactlessPreprocess() agnos.olaContactlessFlushAIDSupported() // Step 2 - Set Transaction Related Data val now = LocalDateTime.now() agnos.olaEmvSetTag(OlaTag.TRANSACTION_DATE, Utils.bcdDate(now)) agnos.olaEmvSetTag(OlaTag.TRANSACTION_TIME, Utils.bcdTime(now)) val ccy = Currency.getInstance(Locale.getDefault()) agnos.olaEmvSetTag(OlaTag.AMOUNT_AUTHORISED, Utils.bcdAmount(100)) // 1.00$ agnos.olaEmvSetTag(OlaTag.TRANSACTION_CURRENCY_CODE, Utils.ccyCode(ccy)) agnos.olaEmvSetTag(OlaTag.TRANSACTION_CURRENCY_EXPONENT, Utils.ccyExponent(ccy)) agnos.olaEmvSetTag(OlaTag.TRANSACTION_TYPE, byteArrayOf(0x00)) agnos.olaEmvSetTag(OlaTag.TRANSACTION_CATEGORY_CODE, byteArrayOf(0x11)) // Step 3 - Pass FCI to SDK context agnos.olaEmvSetTag(fci[0].toInt(), fci.copyOfRange(2, fci.size - 2)) // Step 4 - Set kernel ID (only using Visa with this example) agnos.olaEmvSetTag(0x9F2A, byteArrayOf(0x03)) // Step 5 - Set AID data agnos.olaContactlessAddAIDSupported(ConfigData.products[4].AID(), ConfigData.products[4].partial, ConfigData.products[4].kernel.kernelId, ConfigData.products[4].kernel.config()) var tcc = Holders.SingleObjectHolder<ByteArray>() val err = agnos.olaEmvGetTag(OlaTag.TRANSACTION_CURRENCY_CODE, tcc) // Step 6 - Perform reste of transaction agnos.olaContactlessDoTransaction() var tcc2 = Holders.SingleObjectHolder<ByteArray>() val err2 = agnos.olaEmvGetTag(OlaTag.TRANSACTION_CURRENCY_CODE, tcc2) // Step 7 - Get results var outcome = Holders.SingleObjectHolder<OlaOutcomeParameter>() agnos.olaContactlessGetOutcome(outcome) var tcc3 = Holders.SingleObjectHolder<ByteArray>() val err3 = agnos.olaEmvGetTag(OlaTag.TRANSACTION_CURRENCY_CODE, tcc3) Log.v("MainActivity", "performTransaction - result for getTag(): $err3 => " + Utils.bytesToHex(tcc3.get())) Log.v("MainActivity", "performTransaction - transaction complete") } |