Features 02

Integrating MIPS Payment SDK into Your Android App

Written by ShyankApril 2025
Shyank
img

SHARE

The MIPS Android SDK makes it easy to embed secure payment functionality into your native Android apps. This guide will help you get started.

Prerequisites

Before you begin, ensure you have the following credentials provided by MIPS Admin:

Merchant Details:

  • sIdMerchant
  • id_entity
  • id_operator
  • operator_password

Merchant Credentials:

  • username
  • password

Add the SDK Dependency

Step 1: Add the SDK Dependency

Include the MIPS SDK in your project's build.gradle file:

implementation 'mu.mips:android_sdk:0.2.11'

OR

implementation("mu.mips:android_sdk:0.2.11")

Step 2: Check min android sdk version

Ensure that your project's minSdkVersion is set to 24 or higher:

minSdkVersion 24

Update Android Manifest

Add the necessary permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Start Writing Payment Code

Step 1: Initialize Merchant Details and Credentials

Create instances of MerchantDetails and MerchantCredentials with your provided credentials.

Java
MerchantDetails merchantDetails = new MerchantDetails(
    "YOUR_MERCHANT_ID",
    "YOUR_ENTITY_ID",
    "YOUR_OPERATOR_ID",
    "YOUR_OPERATOR_PASSWORD"
);

MerchantCredentials credentials = new MerchantCredentials(
    "YOUR_USERNAME",
    "YOUR_PASSWORD"
);
Kotlin
val detail = MerchantDetails(
    sIdMerchant = "XXXXXXXXXX",
    id_entity = "XXXXXXXXXX",
    id_operator = "XXXXXXXXXX",
    operator_password = "XXXXXXXXXX"
)

val credential = MerchantCredentials(
    username = "XXXXXXXXXX",
    password = "XXXXXXXXXX"
)

Step 2: Set Up Order ID and Order Amount

Define the order ID and amount for the transaction.

Java
Amount amount = new Amount(Currency.MAURITIAN_RUPEE, 100);
String orderID = UUID.randomUUID().toString();
Kotlin
val orderID = "YOUR_ORDER_ID"
val amount = Amount(Currency.Mauritian_Rupee, 100)

Step 3: Create Payment Screen

Create a fragment of type MIPS_Payment_Fragment and handle payment success and error in callback functions.

Java
MIPS_Payment_Fragment paymentFrag =
    MIPS_Payment_Fragment.Companion.getInstance(
        detail,
        credential,
        amount,
        orderID,
        paymentMode -> {   // success handler
            PaymentMode mode = paymentMode;
            showSuccessScreen();
            return Unit.INSTANCE;
        },
        failureReason -> {  // failure handler
            showFailureScreen();
            return Unit.INSTANCE;
        }
);

Kotlin
var paymentFrag: MIPS_Payment_Fragment =
    MIPS_Payment_Fragment.getInstance(
        detail,
        credential,
        amount,
        orderID,
        successCallback = { mode ->
            showSuccessScreen()
        },
        failureHandler = { failureReason ->
            showFailureScreen()
        }
    )

Step 4: Show Payment Screen and Start Payment Flow

Show the payment fragment to start the payment flow.

Java
import androidx.fragment.app.FragmentTransaction;

FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.CONTAINER_ID, paymentFrag).commit();

Kotlin
import androidx.fragment.app.FragmentTransaction

val transaction = supportFragmentManager.beginTransaction()
transaction.add(R.id.CONTAINER, paymentFrag).commit()

By following these steps, you can seamlessly integrate the MIPS Payment SDK into your Android application, providing a secure and efficient payment experience for your users.

Check full Android SDK on GitHub

About Me

---

Testimonial 01
Shyank Akshar

Hi! I'm Shyank, a full-stack Software developer and a call-of-duty enthusiast, I help businesses grow their company with the the help of technology, improve their work, save time, and serve their customers well, I have worked with many global startups and Govt bodies to develop some of the most secure and scaled apps