Skip to main content

Android Kotlin

The dedicated Kotlin sample repository is a wrapper around the same Android library. For current Google Pay APIs, ProGuard rules, and compileSdk 37 requirements, follow the Android Library (Java) guide and call PaymentActivity from Kotlin as shown below.

Repository: Mobile_XDK_Fiuu_Android_Kotlin

Requirements

RequirementVersion
compileSdk37+ (required by underlying library 3.34.41+)
targetSdkVersion37+
minSdkVersion26+
Android Gradle Plugin9.1.1+
JDK17

Installation

  1. Create a new Kotlin project (or add Kotlin to an existing Android project).
  2. Ensure JitPack is in your root build.gradle repositories:
allprojects {
repositories {
mavenCentral()
google()
maven { url 'https://jitpack.io' }
}
}
  1. Add the dependency in build.gradle (Module :app):
implementation 'com.github.FiuuPayment:Mobile_XDK_Fiuu_Android_Kotlin:<tag>'
  1. Sync the project.

Basic Integration

Import the Fiuu XDK classes:

import com.fiuu.xdk.PaymentActivity

Register the activity result launcher in onCreate:

startForResult = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
if (result.resultCode == Activity.RESULT_OK && result.data != null) {
val transactionResult = result.data!!
.getStringExtra(PaymentActivity.XDKTransactionResult)
Log.d(PaymentActivity.logXDK, "transaction result = $transactionResult")
}
}

Start payment:

private fun startPaymentXDK() {
val paymentDetails: HashMap<String, Any> = HashMap()
paymentDetails[PaymentActivity.mp_amount] = "1.01"
paymentDetails[PaymentActivity.mp_username] = ""
paymentDetails[PaymentActivity.mp_password] = ""
paymentDetails[PaymentActivity.mp_merchant_ID] = ""
paymentDetails[PaymentActivity.mp_app_name] = "mobile"
paymentDetails[PaymentActivity.mp_verification_key] = ""
paymentDetails[PaymentActivity.mp_order_ID] = Calendar.getInstance().timeInMillis
paymentDetails[PaymentActivity.mp_currency] = "MYR"
paymentDetails[PaymentActivity.mp_country] = "MY"
paymentDetails[PaymentActivity.mp_channel] = "multi"
paymentDetails[PaymentActivity.mp_bill_description] = "bill description"
paymentDetails[PaymentActivity.mp_bill_name] = "bill name"
paymentDetails[PaymentActivity.mp_bill_email] = "email@domain.com"
paymentDetails[PaymentActivity.mp_bill_mobile] = "123456789"
paymentDetails[PaymentActivity.mp_channel_editing] = false
paymentDetails[PaymentActivity.mp_editing_enabled] = false
paymentDetails[PaymentActivity.mp_express_mode] = false
paymentDetails[PaymentActivity.mp_dev_mode] = false

val intent = Intent(this@MainActivity, PaymentActivity::class.java)
intent.putExtra(PaymentActivity.XDKPaymentDetails, paymentDetails)
startForResult.launch(intent)
}

Trigger from a button:

binding.fab.setOnClickListener {
startPaymentXDK()
}

Payment results are returned as a JSON string via PaymentActivity.XDKTransactionResult. Parse and verify on your backend — see Response Handling.

Google Pay

For Google Pay integration (express mode via ActivityGP, mp_gpay_channel, production access requirements), see the Android Library (Java) guide. The underlying API is the same; only the calling language differs.

Payment Parameters

See Payment Parameters for the full list of mp_* parameters.