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'
}
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
public class MyApplication : TopApplication {...}
Initialize TransactionHandler
TransactionHandler posDevice = new TransactionHandler(
requireActivity(),
false,
false,
callback -> {
if (callback.getState() == DeviceState.INSERT_CARD) {
} else if (callback.getState() == DeviceState.PROCESSING) {
} else if (callback.getState() == DeviceState.INPUT_PIN) {
} else if (callback.getState() == DeviceState.CARD_DATA) {
//Get Transaction INFO
}else{
Log.e("ERROR", it.message)
}
return Unit.INSTANCE;
});
<aside> 💡 see TransactionHandler for more
</aside>