这是 iOS 平台上 MIPS 支付网关的官方 SDK
pod "MIPS_iOS_SDK"
- sIdMerchant
- sIdForm
- salt
- sCipherKey
- id_entity
- id_operator
- operator_password
- username
- password
- 导入 MIPS_iOS_SDK
import MIPS_iOS_SDK
- 创建 mips 网络模型
let networkUrls : MipsNetworkUrls = .defaultUrls
- 创建商户详情模型
let merchantDetails : MerchantDetails = .init(
sIdMerchant: "YOUR_MERCHANT_ID",
sIdForm: "YOUR_ID_FORM",
salt: "YOUR_SALT",
sCipherKey: "YOUR_CIPHER_KEY",
id_entity: "YOUR_ID_ENTITY",
id_operator: "YOUR_ID_OPERATOR",
operator_password: "YOUR_OPERATOR_PASSWORD"
)
- 创建商户凭证模型
let credential : MerchantCredentials = .init(
username: "YOUR_USERNAME" ,
password: "YOUR_PASSWORD"
)
- 获取订单 ID 和订单金额
let orderID : String = "YOUR_ORDER_ID"
let amount : Amount = .init(currency: .Mauritian_Rupee, price: 100)
- 创建支付页面屏幕
let paymentPage : MIPSViewController = .init(
networkURL: networkUrls,
merchantDetails: merchantDetails,
credentials: credential,
amount: amount,
orderID: orderID
)
// to track payment status conform to MipsPaymentPageDelegate protocol and make your class delegate to paymet page
paymentPage.delegate = self
- 显示支付页面并开始支付交易
self.present(
paymentPage,
animated: true
) {
paymentPage.createPayment()
}
- 跟踪支付成功回调
// conform your class to MipsPaymentPageDelegate and set it as delegate of payment page
class ViewController: UIViewController, MipsPaymentPageDelegate {
func successPayment(
_ sender: MIPS_iOS_SDK.MIPSViewController,
orderID: String,
mode: MIPS_iOS_SDK.PaymentMode
){
// payment is completed,
DispatchQueue.main.async { // switch to main thread for ui operation
sender.dismiss(animated: true) { // remove payment page,
// handle the flow as payment is completed and
// payment page is removed now
}
}
}
}