|
| 1 | +# SoftPOS SDK for Android |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +To integrate the SoftPOS SDK into your Android application, follow these steps: |
| 8 | + |
| 9 | +1. Add the SoftPOS SDK dependency to your project. |
| 10 | + |
| 11 | + ```gradle |
| 12 | +2. Call the following method in the onCreate method of your Application class: |
| 13 | + ```kotlin |
| 14 | + SoftApplication.onCreate(this.applicationContext) |
| 15 | + ``` |
| 16 | +3. Set up NFC in your application by calling the setupNfc method in your activity or any class of your choice: |
| 17 | + ```kotlin |
| 18 | +fun setupNfc() { |
| 19 | + val nfcAdapter = NfcAdapter.getDefaultAdapter(this) |
| 20 | + SDKHelper.initialize(this.applicationContext, nfcAdapter!!) |
| 21 | +} |
| 22 | +``` |
| 23 | +4. Handle the NFC reader mode in the onResume method of your activity: |
| 24 | + ```kotlin |
| 25 | + override fun onResume() { |
| 26 | + super.onResume() |
| 27 | + SDKHelper.nfcListener?.let { |
| 28 | + val NFC_FLAGS = |
| 29 | + 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 |
| 30 | + nfcAdapter!!.enableReaderMode(this, it::onNfcTagDiscovered, NFC_FLAGS, null) |
| 31 | + }} |
| 32 | + ``` |
| 33 | +5. Handle closing the NFC adapter interface in the onPause and onDestroy lifecycle methods: |
| 34 | + ```kotlin |
| 35 | + override fun onPause() { |
| 36 | + super.onPause() |
| 37 | + SDKHelper.nfcListener?.resetNFCField() |
| 38 | + nfcAdapter!!.disableReaderMode(this) |
| 39 | + } |
| 40 | + |
| 41 | + override fun onDestroy() { |
| 42 | + super.onDestroy() |
| 43 | + SDKHelper.nfcListener?.resetNFCField() |
| 44 | + } |
| 45 | + ``` |
| 46 | +6. Before performing transactions, perform key injection for the desired key mode: |
| 47 | + ```kotlin |
| 48 | + SoftApplication.container.horizonPayUseCase.setPinKeyUseCase(isDukpt = false, key = "0000000000000000000000", ksn = "") |
| 49 | + ``` |
| 50 | +7. Extend the TransactionLogger and ReadCardStates interfaces in your activity or class: |
| 51 | + ```kotlin |
| 52 | + class MainActivity : AppCompatActivity(), TransactionLogger, ReadCardStates { |
| 53 | + // Implementation of interface methods...} |
| 54 | + ``` |
| 55 | +8. Implement the necessary methods for transaction handling in your activity: |
| 56 | + ```kotlin |
| 57 | + override fun onCardRead(cardType: String, cardNo: String) { |
| 58 | + // Implementation logic... |
| 59 | + // } |
| 60 | + override fun sendTransactionOnline(emvData: RequestIccData): OnlineRespEntity { |
| 61 | + // Implementation logic... |
| 62 | + } |
| 63 | + // Implement other interface methods... |
| 64 | + ``` |
| 65 | +9. Perform transactions by calling appropriate methods: |
| 66 | + ```kotlin |
| 67 | + runBlocking { |
| 68 | + useCases.emvPayUseCase.invoke("100".toInt().toLong(), this@MainActivity, this@MainActivity) |
| 69 | + } |
| 70 | + ``` |
| 71 | +10. Run your application and test the SoftPOS functionality. |
| 72 | + |
| 73 | +# EXAMPLES |
| 74 | +```kotlin |
| 75 | + class MainActivity : AppCompatActivity(), TransactionLogger, ReadCardStates { |
| 76 | + // Implementation of activity methods... |
| 77 | +} |
| 78 | + |
| 79 | +class SampleApplication: Application() { |
| 80 | + override fun onCreate() { |
| 81 | + super.onCreate() |
| 82 | + SoftApplication.onCreate(this.applicationContext) |
| 83 | + } |
| 84 | +} |
| 85 | + |
| 86 | +``` |
| 87 | + |
| 88 | +### This markdown README provides comprehensive guidance for integrating the SoftPOS SDK into Android applications. It includes step-by-step instructions, code snippets, and example implementations to facilitate the integration process for developers. |
0 commit comments