The MIPS Android SDK makes it easy to embed secure payment functionality into your native Android apps. This guide will help you get started.
Before you begin, ensure you have the following credentials provided by MIPS Admin:
sIdMerchant
id_entity
id_operator
operator_password
username
password
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")
Ensure that your project's minSdkVersion is set to 24 or higher:
minSdkVersion 24
Add the necessary permissions to your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Create instances of MerchantDetails and MerchantCredentials with your provided credentials.
MerchantDetails merchantDetails = new MerchantDetails(
"YOUR_MERCHANT_ID",
"YOUR_ENTITY_ID",
"YOUR_OPERATOR_ID",
"YOUR_OPERATOR_PASSWORD"
);
MerchantCredentials credentials = new MerchantCredentials(
"YOUR_USERNAME",
"YOUR_PASSWORD"
);
val detail = MerchantDetails(
sIdMerchant = "XXXXXXXXXX",
id_entity = "XXXXXXXXXX",
id_operator = "XXXXXXXXXX",
operator_password = "XXXXXXXXXX"
)
val credential = MerchantCredentials(
username = "XXXXXXXXXX",
password = "XXXXXXXXXX"
)
Define the order ID and amount for the transaction.
Amount amount = new Amount(Currency.MAURITIAN_RUPEE, 100);
String orderID = UUID.randomUUID().toString();
val orderID = "YOUR_ORDER_ID"
val amount = Amount(Currency.Mauritian_Rupee, 100)
Create a fragment of type MIPS_Payment_Fragment and handle payment success and error in callback functions.
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;
}
);
var paymentFrag: MIPS_Payment_Fragment =
MIPS_Payment_Fragment.getInstance(
detail,
credential,
amount,
orderID,
successCallback = { mode ->
showSuccessScreen()
},
failureHandler = { failureReason ->
showFailureScreen()
}
)
Show the payment fragment to start the payment flow.
import androidx.fragment.app.FragmentTransaction;
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.CONTAINER_ID, paymentFrag).commit();
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.
---
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