BasisPay_V2 1.0.2

BasisPay_V2 1.0.2

“BasisPay” 维护。



  • Basis Pay

BasisPay-IOS-KIT

BasisPay_V2 iOS 支付网关套件,适用于开发者

概述

本文件描述了集成 Basispay 在线支付网关 iOS 套件的步骤。此支付网关通过减少用户努力来完成在线支付交易。它接收支付详情作为输入并处理支付流程。最后将支付响应返回给用户。用户必须手动将其框架导入到自己的项目中才能使用它

示例

要运行示例项目,请克隆仓库,然后首先从示例目录运行 pod install

要求

o iOS 13.0+ o Xcode 12.0+ o Swift 5.0+

安装

BasisPay_V2 可通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中

pod 'BasisPay_V2' , '~> 1.0.2'

步骤 1

通过在项目中导入 Basispay 初始化您的 PaymentGateway 控制器

import BasisPay

class PaymentProcessViewController: UIViewController {
    
    var paymentGatewayViewController: PaymentGatewayController!
    var apiKey:String?
    var returnURL:String?
    var orderReference:String?
    var secureHash:String?
    @IBOutlet weak var viewContainer: UIView!
    override func viewDidLoad() {
        super.viewDidLoad()
        setDefaults()
        setInputDictionary()
        checkAndGetResponse()
    }

步骤 2

在您的类中分配来自 Basispay 组织的 Payment 默认值。

    private func setInputDictionary() {
        guard let apiKey = apiKey,let orderReference = orderReference,let secureHash = secureHash else {
            return
        }
        let paymentRequestDictionary: NSDictionary = [
            //Required PG Params
            "apiKey" : apiKey,
            "secureHash" : secureHash,
            "orderReference" : orderReference,
            "customerName" : "xxxx",
            "customerEmail" : "xxxx",
            "customerMobile" : "xxxx",
            "address" : "xxxx",
            "postalCode" : "xxxx",
            "city" : "xxxx",
            "region" : "xxxx",
            "country" : "IND",
            //Optional Params
            "deliveryAddress" : "",
            "deliveryName" : "",
            "deliveryMobile" : "",
            "deliveryPostalCode" : "",
            "deliveryCity" : "",
            "deliveryRegion" : "",
            "deliveryCountry" : "IND"
        ]
        paymentGatewayViewController.setInputDictionary(inputDictionary: paymentRequestDictionary)
        
    }  

步骤 3

传递有关您将要使用该支付网关的应用中的产品的用户界面连接详情。

    private func setDefaults() {
        paymentGatewayViewController = PaymentGatewayController()
        paymentGatewayViewController.paymentDefaults = PaymentDefaults(apiKey: apiKey!, returnUrl: returnURL!, endPoint: .Testing)
        paymentGatewayViewController.delegate = self
        viewContainer.addSubview(paymentGatewayViewController.view)
    }

步骤 4

可以使用此协议处理 onPaymentSucess 和 onPaymentFailure 的委托方法。



extension PaymentProcessViewController:PaymentGatewayDelegate {

    func onPaymentSucess(reference: String, success:String) {
        self.navigationController?.popViewController(animated: true)
        print(reference)
        print(success)
        let alertController = UIAlertController(title: "SUCCESS", message: reference, 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(reference: String, success:String) {
        self.navigationController?.popViewController(animated: true)
        print(reference)
        print(success)
        let alertController = UIAlertController(title: "FAILURE", message: reference, 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 prot

BasisPay 可在 MIT 许可下获得。有关更多信息,请参阅 LICENSE 文件。