Integrating MIPS Payment SDK into Your iOS App


The MIPS Payment SDK is designed to facilitate seamless payment processing within your iOS applications. Written in Swift, it supports integration with both Swift and Objective-C projects. This guide will walk you through the steps to integrate the SDK into your app.
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
Step 1: Install the SDK via CocoaPods
To integrate the SDK using CocoaPods, add the following line to your Podfile:
pod 'MipsPaymentSdk', :git => 'https://github.com/MIPSIT-DIGITAL/ios-sdk'
After updating your Podfile, run the following command in your terminal:
pod install
This will install the MIPS Payment SDK into your project.
Step 2: Import the SDK
In the files where you intend to use the SDK, import it as follows:
import MipsPaymentSdk
Step 3: Configure Merchant Details and Credentials
Create instances of MerchantDetails and MerchantCredentials with the credentials provided:
let merchantDetails = MerchantDetails(
sIdMerchant: "YOUR_MERCHANT_ID",
id_entity: "YOUR_ID_ENTITY",
id_operator: "YOUR_ID_OPERATOR",
operator_password: "YOUR_OPERATOR_PASSWORD"
)
let credentials = MerchantCredentials(
username: "YOUR_USERNAME",
password: "YOUR_PASSWORD"
)
Step 4: Set Up Order Information
Define the order ID and amount for the transaction:
let orderID = "YOUR_ORDER_ID"
let amount = Amount(currency: .Mauritian_Rupee, price: 100)
Step 5: Initialize the Payment Page
Create an instance of MIPSViewController with the necessary details:
let paymentPage = MIPSViewController(
merchantDetails: merchantDetails,
credentials: credentials,
amount: amount,
orderID: orderID
)
To handle payment status updates, ensure your class conforms to the **MipsPaymentPageDelegate** protocol and set the delegate:
paymentPage.delegate = self
Step 6: Present the Payment Page
Display the payment page and initiate the payment process:
self.present(paymentPage, animated: true) {
paymentPage.createPayment()
}
Step 7: Handle Payment Success Callback
Implement the successPayment method from the MipsPaymentPageDelegate protocol to handle successful payments:
extension YourViewController: MipsPaymentPageDelegate {
func successPayment(_ sender: MIPSViewController, orderID: String, mode: PaymentMode) {
DispatchQueue.main.async {
sender.dismiss(animated: true) {
// Handle post-payment success actions here
}
}
}
}
By following these steps, you can seamlessly integrate the MIPS Payment SDK into your iOS application, providing a secure and efficient payment experience for your users.
For more details and updates, refer to the MIPS iOS SDK GitHub repository