MobPay - Interswitch 通过卡和移动支付集成的 iOS 库
此 Pod 使您能够将 Interswitch 支付集成到您的移动应用中。
将 MobpayiOS 添加到项目中
CocoaPods
CocoaPods 是 Cocoa 项目的依赖管理器。有关用法和安装指南,请访问他们的网站。要使用 CocoaPods 在 Xcode 项目中集成 Mobpay,请在 Podfile 中指定:要获取库,请将以下依赖项添加到 podfile 中
pod 'MobpayiOS'
然后运行以下命令
pod install
别忘了使用 .xcworkspace 文件在 Xcode 中打开您的项目,而不是从现在开始使用 .xcodeproj 文件。
将来,要更新到 SDK 的最新版本,只需运行
pod update MobpayiOS
使用示例
获取您 interswitch 商户账户的 interswitch 客户端 ID 和客户端密钥,然后执行以下操作来实例化 mobpay 对象:
import MobpayiOS
let card = Card(pan: "4111111111111111", cvv: "123", expiryYear: "20", expiryMonth: "02", tokenize: false)
let payment = Payment(amount: "100", transactionRef: "66809285644", orderId: "OID123453", terminalType: "MOBILE", terminalId: "3TLP0001", paymentItem: "CRD", currency: "KES")
let customer = Customer(customerId: "12", firstName: "Allan", secondName: "Mageto", email: "[email protected]", mobile: "0712345678", city: "NBI", country: "KE", postalCode: "00200", street: "WESTLANDS", state: "NBI")
let merchant = Merchant(merchantId: "your merchant id", domain: "your domain")
信用卡支付
要执行信用卡支付:
try!Mobpay.instance.submitCardPayment(card: cardInput, merchant: merchantInput, payment: paymentInput, customer: customerInput, clientId: self.clientId,clientSecret: self.clientSecret,previousUIViewController: self){(completion) in
self.showResponse(message: completion)
}
其中上一个视图控制器是你调用该函数的控制器
信用卡令牌支付
要执行信用卡令牌支付
try!Mobpay.instance.submitTokenPayment(cardToken: cardToken, merchant: merchantInput, payment: paymentInput, customer: customerInput, clientId: self.clientId,clientSecret: self.clientSecret,previousUIViewController: self){
(completion) in
self.showResponse(message: completion)
}
移动支付
要执行移动支付
try!Mobpay.instance.makeMobileMoneyPayment(mobile: mobileInput, merchant: merchantInput, payment: paymentInput, customer: customerInput, clientId: self.clientId, clientSecret:self.clientSecret)
{
(completion) in self.showResponse(message: completion)
}
确认移动支付
确认移动支付是否成功
try!Mobpay.instance.confirmMobileMoneyPayment(orderId: self.orderId, clientId: self.clientId,clientSecret: self.clientSecret){
(completion) in self.showResponse(message: completion)
}
源代码
访问 https://github.com/interswitch-kenya-limited/mobpay-ios-example 以获取本项目的源代码和发布版本,如果您想尝试手动集成过程。