Android SDK

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:

MyApplication.kt
Kkiapay.init(applicationContext,"<your-kkiapay-api-key>",
            SdkConfig(themeColor = R.color.colorPrimary, 
            imageResource = R.raw.your_logo,
            enableSandbox = true))

Initialized to true the enableSandbox attribute allows you to switch to test mode.

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

Kkiapay.get().handleActivityResult(requestCode, resultCode, data)

Once the environment is ready, trigger a payment request in your application with the following code:

    
    Kkiapay.get().requestPayment(this, "1","Payment for services","Jhon Doe")

The parameters of the function are:

  1. The context of the activity

  2. The amount to be debited to the customer (without charges)

  3. The reason (Example: The object, the description of the service purchased, the description of the product...)

  4. The name of the customer

  5. Phone number (Optional)

The different statuses

Last updated