BasisPay-IOS-KIT
BasisPay iOS 支付网关开发工具包
简介
本文档描述了集成 Basispay 网络支付网关 iOS 套件的操作步骤。此支付网关可以以较低的用户努力完成在线支付交易。它接收支付详情作为输入并处理支付流程。最后,将支付响应返回给用户。用户必须手动将框架导入到他们的项目中才能使用。
示例
要运行示例项目,请克隆仓库并先从 Example 目录运行 pod install
要求
o iOS 11.0+ o Xcode 11.0+ o Swift 5.0+
安装
BasisPay 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile 中
pod 'BasisPay' , '~> 1.0.0'
步骤 1
通过在你的项目中导入 Basispay 初始化你的 PaymentGateway 控制器
import BasisPay
class PaymentProcessViewController: UIViewController {
var paymentGatewayViewController: PaymentGatewayController!
var amount:String?
var titleValue:String?
var descriptionValue:String?
@IBOutlet weak var viewContainer: UIView!
override func viewDidLoad() {
super.viewDidLoad()
paymentGatewayViewController = PaymentGatewayController()
viewContainer.addSubview(paymentGatewayViewController.view)
setDefaults()
setInputDictionary()
checkAndGetResponse()
}
步骤 2
分配你在 Basispay 组织收到的 Payment 默认设置到你的类中。
private func setDefaults() {
paymentGatewayViewController.paymentDefaults = PaymentDefaults(apiKey: "", saltKey: "", returnUrl: "", endPoint: .Testing)
}
步骤 3
将要在应用程序中使用支付网关的相关产品必需详情传递。
private func setInputDictionary() {
guard let amountVal = amount,let titleVal = titleValue,let descriptionVal = descriptionValue else {
return
}
let paymentRequestDictionary: NSDictionary = [
"orderId" : "253698",
"amount" : amountVal,
"currency" : "INR",
"description" : descriptionVal,
"name" : titleVal,
"email" : "[email protected]",
"phone" : "5876986087",
"addressLine1" : "address_line_1",
"addressLine2" : "address_line_2",
"city" : "city",
"state" : "state",
"country" : "country",
"zipCode" : "zip_code",
"udf1" : "Testing1",
"udf2" : "Testing2",
"udf3" : "Testing3",
"udf4" : "Testing4",
"udf5" : "Testing5"
]
paymentGatewayViewController.setInputDictionary(inputDictionary: paymentRequestDictionary)
}
步骤 4
支付成功和失败的处理方法可以通过此协议进行。
override func viewDidLoad(){
paymentGatewayViewController.delegate = self
}
extension PaymentProcessViewController:PaymentGatewayDelegate {
func onPaymentSucess(response: BasisPaymentResponse) {
self.navigationController?.popViewController(animated: true)
let alertController = UIAlertController(title: "SUCCESS", message: "order Id \(response.order_id)", preferredStyle: .alert)
let cancelAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(cancelAction)
self.view.window?.rootViewController?.present(alertController, animated: true, completion: nil)
}
func onPaymentFailure(response: BasisPaymentResponse) {
self.navigationController?.popViewController(animated: true)
let alertController = UIAlertController(title: "FAILURE", message: " message - \(response.description)", preferredStyle: .alert)
let cancelAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(cancelAction)
self.view.window?.rootViewController?.present(alertController, animated: true, completion: nil)
}
}
作者
BasisPay, [email protected]
许可证
BasisPay 可在 MIT 许可下使用。更多信息请参阅 LICENSE 文件。