This is a fully functional Fiuu Android payment library designed for seamless integration for android native projects. It can be integrated using the com.molpay.molpayxdk package via Gradle, sourced from Maven repository. For reference, we have included a sample application (com.fiuu.xdkandroid) that demonstrates the integration process with the Fiuu Android payment library.
For commercial use, you must be a registered Fiuu merchant. To obtain your credentials for testing or production purposes, please contact us at sales-sa@fiuu.com.
This library is designed for native Android projects using Android Studio.
For integration with other development frameworks, kindly refer to the following links :
- iOS : https://cocoapods.org/pods/fiuu-mobile-xdk-cocoapods
- Flutter : https://pub.dev/packages/fiuu_mobile_xdk_flutter
- React Native : https://www.npmjs.com/package/fiuu-mobile-xdk-reactnative
- Others : https://github.com/FiuuPayment
When implementing Payment XDK into your project, consider the following:
-
compileSdk: >= 34
-
targetSdkVersion: >= 34
-
minSdkVersion: >= 26
-
Android Gradle Plugin >= 7.4.2
Set maven google & mavenCentral in build.gradle (Project:) level
buildscript {
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}
allprojects {
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
Add dependencies in build.gradle (Module :app)
dependencies {
implementation 'com.github.FiuuPayment:Mobile-XDK-Fiuu_Android_Library:<latest_version>'
}
Import the required library class
import com.molpay.molpayxdk.MOLPayActivity;
Import these extra classes for Google Pay
import com.molpay.molpayxdk.googlepay.ActivityGP;
import com.molpay.molpayxdk.googlepay.UtilGP;
import com.google.android.gms.wallet.button.ButtonConstants;
import com.google.android.gms.wallet.button.ButtonOptions;
import com.google.android.gms.wallet.button.PayButton;
Import the others required library classes for your class e.g.
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import java.util.HashMap;
Add rules in proguard-rules.pro
# For WebView / Javascript bridge
# Keep all methods annotated with @JavascriptInterface
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
# Keep XDK classes (prevents obfuscation of JS functions)
-keep class com.molpay.** { *; }
HashMap<Object, Object> paymentDetails = new HashMap<>();
private void restartmolpay() {
// Compulsory String. Values obtained from Fiuu.
paymentDetails.put(MOLPayActivity.mp_username, "");
paymentDetails.put(MOLPayActivity.mp_password, "");
paymentDetails.put(MOLPayActivity.mp_app_name, "");
paymentDetails.put(MOLPayActivity.mp_merchant_ID, "");
paymentDetails.put(MOLPayActivity.mp_verification_key, "");
// Compulsory String. Payment info.
paymentDetails.put(MOLPayActivity.mp_amount, "1.10"); // 2 decimal points format
paymentDetails.put(MOLPayActivity.mp_order_ID, Calendar.getInstance().getTimeInMillis()); // Any unique alphanumeric String. For symbol only allowed hypen "-" and underscore "_"
paymentDetails.put(MOLPayActivity.mp_currency, "MYR");
paymentDetails.put(MOLPayActivity.mp_country, "MY");
paymentDetails.put(MOLPayActivity.mp_bill_description, "The bill description");
paymentDetails.put(MOLPayActivity.mp_bill_name, "The bill name");
paymentDetails.put(MOLPayActivity.mp_bill_email, "payer.email@fiuu.com");
paymentDetails.put(MOLPayActivity.mp_bill_mobile, "123456789");
openStartActivityResult();
}
private void openStartActivityResult(){
Intent intent = new Intent(MainActivity.this, MOLPayActivity.class);
intent.putExtra(MOLPayActivity.MOLPayPaymentDetails, paymentDetails);
paymentActivityResultLauncher.launch(intent);
}
ActivityResultLauncher<Intent> paymentActivityResultLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
result -> {
if (result.getData() != null) {
Intent data = result.getData();
// Get the payment result in String
String transactionResult = data.getStringExtra(MOLPayActivity.MOLPayTransactionResult);
Log.d(MOLPayActivity.MOLPAY, "transaction result = " + transactionResult);
} else {
// Data null handler
}
}
);
Required a valid mp_channel value, this will skip the payment info page and go direct to the payment screen. Add mp_express_mode & set mp_channel as below :
e.g. Express Mode to FPX Maybank online banking
paymentDetails.put(MOLPayActivity.mp_express_mode, true);
paymentDetails.put(MOLPayActivity.mp_channel, "maybank2u");
e.g. Express Mode to Touch 'n Go payment
paymentDetails.put(MOLPayActivity.mp_express_mode, true);
paymentDetails.put(MOLPayActivity.mp_channel, "TNG-EWALLET");
Find all mp_channel list here https://github.com/FiuuPayment/Mobile-XDK-Fiuu_Examples/blob/master/channel-list.md
NOTE:
- Can only select subscribed mp_channel.
- credit channel cannot use express mode due to security reasons.
Need refer column mp_channel in https://github.com/FiuuPayment/Mobile-XDK-Fiuu_Examples/blob/master/channel-list.md Then add the selected channels in allowedchannels[] e.g. :
String allowedchannels[] = {"TNG-EWALLET","maybank2u"};
paymentDetails.put(MOLPayActivity.mp_allowed_channels, allowedchannels);
This will only show maybank2u & TNG-EWALLET channels in the channel listing.
Learn more about optional parameters here https://github.com/RazerMS/Mobile-XDK-RazerMS_Android_Studio/wiki/Installation-Guidance#prepare-the-payment-detail-object
// -------------------------------- Most commonly used -------------------------------------
// Optional, set Environment for Webview Core URL
// paymentDetails.put(MOLPayActivity.mp_core_env, "2"); //default = 2. Refer here for more info: https://github.com/FiuuPayment/Mobile-XDK-Fiuu_Android_Library?tab=readme-ov-file#environment-configuration
// To pre-select channel, refer column mp_channel in https://github.com/FiuuPayment/Mobile-XDK-Fiuu_Examples/blob/master/channel-list.md
// e.g. set mp_channel = credit to directly load required card info.
paymentDetails.put(MOLPayActivity.mp_channel, "credit");
// Simulate offline payment (demo without actual charges).
// Need set true for Google Pay Test Environment
paymentDetails.put(MOLPayActivity.mp_core_env, "4"); // sandbox
// Set true if your account enabled extended Verify Payment
paymentDetails.put(MOLPayActivity.mp_extended_vcode, false);
// Show close button (by default hidden)
paymentDetails.put(MOLPayActivity.mp_closebutton_display, true);
// Allow change channel for pre-select mp_channel
paymentDetails.put(MOLPayActivity.mp_channel_editing, true);
// Allow payer information editing.
paymentDetails.put(MOLPayActivity.mp_editing_enabled, false);
// Explicitly force disable user input by field.
paymentDetails.put(MOLPayActivity.mp_bill_name_edit_disabled, true);
paymentDetails.put(MOLPayActivity.mp_bill_email_edit_disabled, false);
paymentDetails.put(MOLPayActivity.mp_bill_mobile_edit_disabled, true);
paymentDetails.put(MOLPayActivity.mp_bill_description_edit_disabled, false);
// Set language : EN, MS, VI, TH, FIL, MY, KM, ID, ZH.
paymentDetails.put(MOLPayActivity.mp_language, "MS");
The library supports multiple environments. You can configure which environment to use by setting the mp_core_env value.
mp_core_env is a string ("1", "2", "3", "4")
Each value maps to a specific environment base URL.
If no value is set, the default environment will be used.
mp_core_env Value |
Environment | Base URL |
|---|---|---|
1 |
Production - V1 | https://pay.fiuu.com/RMS/API/xdk/ |
2 |
Production - V2 | https://xdk.fiuu.com/ |
3 |
UAT - V2 | https://uat-xdk.fiuu.com/ |
4 |
Sandbox -V2 | https://sandbox-xdk.fiuu.com/ |
| Default | Production - V2 | https://xdk.fiuu.com/ |
In order to use Production or Dev account (actual transactions testing), Google Pay production access is required for your app package name.
Follow Google’s instructions to request production access for your app: https://developers.google.com/pay/api/android/guides/test-and-deploy/request-prod-access
Google Pay Console : https://pay.google.com/business/console
- Choose the integration type Gateway when prompted, and provide screenshots of your app for review.
- After your app has been approved, test your integration in production by set mp_core_env = "2" or just remove it & use production or Dev mp_verification_key & mp_merchant_ID.
- Then launching Google Pay from a signed, release build of your app.
Request Production Access Example 1 :
Request Production Access Example 2 :
NOTE: Can only use TEST environment & Sandbox account if not yet get Google Pay production approval.
- Create Google Pay button
Add Google Pay button in XML layout e.g. :
<ImageView
android:id="@+id/btnGPay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/btn_gpay"
android:layout_alignParentBottom="true"
android:visibility="visible"/>
<com.google.android.gms.wallet.button.PayButton
android:id="@+id/googlePayButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="19dp"
android:visibility="gone"/>
In Java class add this in onCreate :
ImageView btnGPay = findViewById(R.id.btnGPay);
btnGPay.setOnClickListener(v -> {
googlePayPayment();
});
PayButton googlePayButton = findViewById(R.id.googlePayButton);
try {
googlePayButton.initialize(
ButtonOptions.newBuilder()
.setButtonTheme(ButtonConstants.ButtonTheme.DARK)
.setButtonType(ButtonConstants.ButtonType.PAY)
.setCornerRadius(99)
.setAllowedPaymentMethods(UtilGP.getAllowedPaymentMethods().toString())
.build()
);
googlePayButton.setOnClickListener(view -> {
googlePayPayment();
});
} catch (JSONException e) {
// Keep Google Pay button hidden (consider logging this to your app analytics service)
}
-
Prepare paymentDetails
HashMap<Object, Object> paymentDetails = new HashMap<>();/* TODO: Follow Google’s instructions to request production access for your app: https://developers.google.com/pay/api/android/guides/test-and-deploy/request-prod-access * Choose the integration type Gateway when prompted, and provide screenshots of your app for review. After your app has been approved, test your integration in production by set mp_core_env = "2" or just remove it & use production / Dev mp_verification_key & mp_merchant_ID. Then launching Google Pay from a signed, release build of your app. */
private void googlePayPayment() { paymentDetails = new HashMap<>(); // Compulsory String. Values obtained from Fiuu. paymentDetails.put(MOLPayActivity.mp_merchant_ID, ""); // Sandbox ID for TEST environment & Production/Dev ID once Google approved production access paymentDetails.put(MOLPayActivity.mp_verification_key, ""); // Sandbox ID for TEST environment & Production/Dev ID once Google approved production access // Compulsory String. Payment info. paymentDetails.put(MOLPayActivity.mp_amount, "1.01"); // 2 decimal points format paymentDetails.put(MOLPayActivity.mp_order_ID, Calendar.getInstance().getTimeInMillis()); // Any unique alphanumeric String. For symbol only allowed hypen "-" and underscore "_" paymentDetails.put(MOLPayActivity.mp_currency, "MYR"); paymentDetails.put(MOLPayActivity.mp_country, "MY"); paymentDetails.put(MOLPayActivity.mp_bill_description, "The bill description"); paymentDetails.put(MOLPayActivity.mp_bill_name, "The bill name"); paymentDetails.put(MOLPayActivity.mp_bill_email, "payer.email@fiuu.com"); paymentDetails.put(MOLPayActivity.mp_bill_mobile, "123456789"); paymentDetails.put(MOLPayActivity.mp_core_env, "4"); // 4 = Test Environment & Default/2 = production (required Google Pay production access approval) // GPay payment methods setting examples : (by default will show all payment methods) paymentDetails.put(MOLPayActivity.mp_gpay_channel, new String[] { "CC", "TNG-EWALLET" }); // Enable Card & TNG eWallet Only paymentDetails.put(MOLPayActivity.mp_gpay_channel, new String[] { "SHOPEEPAY", "TNG-EWALLET" }); // Enable ShopeePay & TNG eWallet Only // NOTE: SHOPEEPAY & TNG-EWALLET only applicable to MY & MYR. Others currency & country only supported CC. // Optional paymentDetails.put(MOLPayActivity.mp_company, "Your Company Name"); // Show merchant name in Google Pay paymentDetails.put(MOLPayActivity.mp_closebutton_display, true); // Enable close button paymentDetails.put(MOLPayActivity.mp_enable_fullscreen, true); //enable fullscreen paymentDetails.put(MOLPayActivity.mp_extended_vcode, false); // Set true if your account enabled extended Verify Payment paymentDetails.put(MOLPayActivity.mp_hide_googlepay, true); // Optional : Hide Google Pay button (by default false) openGPActivityWithResult(); } -
Start payment by sending paymentDetails to ActivityGP.class
private void openGPActivityWithResult() { Intent intent = new Intent(MainActivity.this, ActivityGP.class); // Used ActivityGP for Google Pay intent.putExtra(MOLPayActivity.MOLPayPaymentDetails, paymentDetails); gpActivityResultLauncher.launch(intent); } -
Handle activity result listener
ActivityResultLauncher<Intent> gpActivityResultLauncher = registerForActivityResult( new ActivityResultContracts.StartActivityForResult(), result -> { if (result.getData() != null) { Intent data = result.getData(); // Get payment result in String String transactionResult = data.getStringExtra(MOLPayActivity.MOLPayTransactionResult); Log.d("logGooglePay", "transactionResult = " + transactionResult); } else { // If payment cancelled Log.d("logGooglePay" , "RESULT_CANCELED data == null"); } } );
Same with Show All Subscribed Channels in above.
Just need to control these parameters :
paymentDetails.put(MOLPayActivity.mp_merchant_ID, ""); // Sandbox ID for TEST environment & Production/Dev ID once Google approved production access
paymentDetails.put(MOLPayActivity.mp_verification_key, ""); // Sandbox ID for TEST environment & Production/Dev ID once Google approved production access
paymentDetails.put(MOLPayActivity.mp_core_env, "4"); // 4 = Test Environment & Default/2 = production (required Google Pay production access approval)
// Optional
paymentDetails.put(MOLPayActivity.mp_company, "Your Company Name"); // Show merchant name in Google Pay
paymentDetails.put(MOLPayActivity.mp_closebutton_display, true); // Enable close button
paymentDetails.put(MOLPayActivity.mp_enable_fullscreen, true); //enable fullscreen
paymentDetails.put(MOLPayActivity.mp_extended_vcode, false); // Set true if your account enabled extended Verify Payment
paymentDetails.put(MOLPayActivity.mp_hide_googlepay, true); // Optional : Hide Google Pay button (by default false)
// MY (MYR) GPay payment methods setting examples : (by default will show all payment methods)
paymentDetails.put(MOLPayActivity.mp_gpay_channel, new String[] { "CC", "TNG-EWALLET" }); // Enable Card & TNG eWallet Only
paymentDetails.put(MOLPayActivity.mp_gpay_channel, new String[] { "SHOPEEPAY", "TNG-EWALLET" }); // Enable ShopeePay & TNG eWallet Only
// NOTE: SHOPEEPAY & TNG-EWALLET only applicable to MY & MYR. Others currency & country only supported CC.
=========================================
Sample transaction result in JSON string:
=========================================
{
"StatCode": "00",
"StatName": "captured",
"TranID": "30959687",
"Amount": "1.10",
"Domain": "",
"VrfKey": "",
"Channel": "credit",
"OrderID": "1741853136969",
"Currency": "MYR",
"ErrorCode": null,
"ErrorDesc": null,
"ProcessorResponseCode": "000",
"ProcessorCVVResponse": null,
"SchemeTransactionID": "123456",
"MerchantAdviceCode": null,
"ECI": null,
"3DSVersion": "2.2",
"ACSTransactionID": null,
"3DSTransactionID": null
}
Parameter and meaning:
"StatCode" - "00" for Success, "11" for Failed, "22" for Pending.
"Amount" - The transaction amount
"OrderID" - The transaction order ID
"Channel" - The card type use
"TranID" - The transaction ID generated by Fiuu
"Domain" - Your Merchant ID
"VrfKey" - You can verify payment using this formula -> VrfKey = md5(Amount+secret_key+Domain+TranID+StatCode)
* Note 1: secret_key = Your account Secret Key in https://portal.fiuu.com/
* Note 2: The other parameters and values not described above are for recorded purpose only
=====================================
* Sample error result in JSON string:
=====================================
{
"status":false,
"error_code":"P03",
"error_desc":"Your payment info format not correct."
}
{
"error_code" = A01;
"error_desc" = "Fail to detokenize Google Pay Token given";
status = 0;
}
{
"status": false,
"error_code": null,
"error_desc": "Your transaction has been denied due to merchant account issue."
}
Error info:
Error P03 - Your payment info format not correct
1) Need makesure all required parameters filled correctly.
2) Need set mp_extended_vcode = true if enabled extended Verify Payment.
Error A01 - "Fail to detokenize Google Pay Token given" - Error starting a payment process due to several possible reasons, please contact Fiuu support if the error unresolved.
1) Misconfigure GooglePay setup
2) API credentials (username, password, merchant id, verify key)
3) Payment Server Offline.
"Your transaction has been denied due to merchant account issue."
OR
"This merchant is having trouble accepting your payment at the moment.Try installing the latest version of the merchant's app or use a different payment method. [OR_BIBED_13]"
1) Need check mp_core_env, mp_merchant_ID & mp_verification_key
2) mp_core_env = 4 , need use Sandbox mp_merchant_ID & mp_verification_key
3) mp_core_env = 2 or if did not send mp_core_env , need use Production/Dev mp_merchant_ID & mp_verification_key
4) Check Requirements for Production Environment notes for production/dev testing
Sample transaction result in JSON string:
{
"txn_ID": "2754048669",
"paydate": 1741858781,
"order_id": "1741858760492",
"amount": "1.00",
"status_code": "00",
"channel": "THE_CHANNEL_USED",
"err_desc": "",
"app_code": "",
"chksum": "abcdefghijklmnopqrstuvwxyz1234567890",
"pInstruction": 0,
"msgType": "C6",
"mp_secured_verified": false
}
Transaction result info:
"status_code" - "00" for Success, "11" for Failed, "22" for Pending. (Pending status only applicable to cash channels only)
"amount" - The transaction amount
"paydate" - The transaction date
"order_id" - The transaction order id
"channel" - The transaction channel description
"txn_ID" - The transaction id generated by Fiuu
"chksum" - MD5(mp_merchant_ID + msgType + txn_ID + amount + status_code + secret_key)
* Note 1: secret_key = Your account Secret Key in https://portal.fiuu.com/
* Note 2: The other parameters and values not described above are for recorded purpose only
- GitHub: https://github.com/FiuuPayment
- Website: https://fiuu.com/
- Twitter: https://twitter.com/FiuuPayment
- YouTube: https://www.youtube.com/FiuuPayment
- Facebook: https://www.facebook.com/FiuuPayment/
- Instagram: https://www.instagram.com/FiuuPayment/
Submit issue to this repository or email to our support-sa@fiuu.com
Merchant Technical Support / Customer Care : support-sa@fiuu.com
Sales/Reseller Enquiry : sales-sa@fiuu.com
Marketing Campaign : marketing-sa@fiuu.com
Channel/Partner Enquiry : channel-sa@fiuu.com
Media Contact : media-sa@fiuu.com
R&D and Tech-related Suggestion : technical-sa@fiuu.com
Abuse Reporting : abuse-sa@fiuu.com


