This SDK enables integration of SoftPOS functionality into Android applications. SoftPOS (Software Point of Sale) allows Android devices to function as secure card payment terminals.
To integrate the SoftPOS SDK into your Android application, follow these steps:
-
Add the SoftPOS SDK dependency to your project.
-
Call the following method in the onCreate method of your Application class:
SoftApplication.onCreate(this.applicationContext)
- Set up NFC in your application by calling the setupNfc method in your activity or any class of your choice:
fun setupNfc() {
val nfcAdapter = NfcAdapter.getDefaultAdapter(this)
SDKHelper.initialize(this.applicationContext, nfcAdapter!!)
}
- Handle the NFC reader mode in the onResume method of your activity:
override fun onResume() { super.onResume() SDKHelper.nfcListener?.let { val NFC_FLAGS = NfcAdapter.FLAG_READER_NFC_A or NfcAdapter.FLAG_READER_NFC_B or NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK or NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS nfcAdapter!!.enableReaderMode(this, it::onNfcTagDiscovered, NFC_FLAGS, null) }}
- Handle closing the NFC adapter interface in the onPause and onDestroy lifecycle methods:
override fun onPause() { super.onPause() SDKHelper.nfcListener?.resetNFCField() nfcAdapter!!.disableReaderMode(this) } override fun onDestroy() { super.onDestroy() SDKHelper.nfcListener?.resetNFCField() }
- Before performing transactions, perform key injection for the desired key mode:
SoftApplication.container.horizonPayUseCase.setPinKeyUseCase(isDukpt = false, key = "0000000000000000000000", ksn = "")
- Extend the TransactionLogger and ReadCardStates interfaces in your activity or class:
class MainActivity : AppCompatActivity(), TransactionLogger, ReadCardStates { // Implementation of interface methods...}
- Implement the necessary methods for transaction handling in your activity:
override fun onCardRead(cardType: String, cardNo: String) { // Implementation logic... // } override fun sendTransactionOnline(emvData: RequestIccData): OnlineRespEntity { // Implementation logic... } // Implement other interface methods...
- Perform transactions by calling appropriate methods:
runBlocking { useCases.emvPayUseCase.invoke("100".toInt().toLong(), this@MainActivity, this@MainActivity) }
- Run your application and test the SoftPOS functionality.
class MainActivity : AppCompatActivity(), TransactionLogger, ReadCardStates {
// Implementation of activity methods...
}
class SampleApplication: Application() {
override fun onCreate() {
super.onCreate()
SoftApplication.onCreate(this.applicationContext)
}
}