The Android SDK is designed to allow the integration of KKiaPay into your mobile application.
Integrating the Android SDK into your mobile application will require adding these few lines of code to your build.gradle file:
build.gradle
implementation 'co.opensi.kkiapay:kkiapay:1.1.8'
Required for further integration your API key is available on your dashboard.
In the singleton class of your application: the one that extends the Application class of the Android framework, add the following code in the onCreate method:
The SdkConfig parameter of the above function is optional. It allows you to configure your preferences.
The SDK is now initialized. Add a listener to it to hear the payment status events.
For example, add the following lines of code within the onCreate method of your activity.
Kkiapay.get().setListener{ status, transactionId ->// listen the end of the transaction ( status contains the different possible statuses ) Toast.makeText(activity, "Transaction: ${status.name} -> $transactionId", Toast.LENGTH_LONG).show() }
Within the onActivityResult method of your activity, add the handler
For example, add the following lines of code within the onCreate method of your activity.
Kkiapay.INSTANCE.get().setListener(new Function2<STATUS, String, Unit>() {@Overridepublic Unit invoke(STATUS status, String s) {// ecouter la fin du paiement ( status contient les différents status possibles ) Toast.makeText(MA.this, "Transaction: ${status.name} -> $transactionId", Toast.LENGTH_LONG).show();returnnull; } });
Within the onActivityResult method of your activity, add the handler