Installation

Add it in your root build.gradle at the end of repositories:

allprojects {
            repositories {
                //...
                maven { url 'https://jitpack.io' }
            }
        }

Add the dependency to app level build.gradle

dependencies {
    implementation 'com.github.mikroafrica.topwise-mini:topwise-mini:2.0.3'
}
Similarly, you can add dependencies for other devices
see [Dependencies](https://trylux.notion.site/Setup-Dependency-1ee17414bfd84a83a3b4a83f453193ee)

Setup

Internet permission is required to use this library. Add internet permission to your app AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />

Depending on whether you override the Application class, perform one of the following: If you do not override the Application class, edit your manifest file to set android:name in the <application> tag as follows:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.myapp">
     <application
         android:name="com.topwise.library.TopApplication">
         ...
     </application>
</manifest>

If you do override the Application class, change it to extend TopApplication as follows:

import com.posdevice.ApplicationHandler

class MyApplication : TopApplication() {...}

Usage

Initialize TransactionHandler

private val posDevice by lazy {
        TransactionHandler(requireActivity()) {transactionMonitor ->
            when (transactionMonitor.state) {
                DeviceState.INSERT_CARD -> {

                }
                DeviceState.PROCESSING -> {

                }
                DeviceState.INPUT_PIN -> {

                }
                DeviceState.PIN_DATA -> {

                }
                DeviceState.CARD_DATA -> {
                    //Get Transaction INFO
                }
                else -> {
                    Log.e("ERROR", it.message)
                }
            }
        }
    }

<aside> 💡 see TransactionHandler for more

</aside>