PayUIndia-OlaMoney 1.0.2

PayUIndia-OlaMoney 1.0.2

Rajvinder SinghUmang AryaAshish Jain 维护。



  • PayUbiz

N|Solid

PayU Mobile SDK - Ola Money (iOS)

PayU的Ola Money SDK是用于简便、高效和稳定地将Ola Money Postpaid + 钱包集成到您的应用程序中的框架。

Ola Money SDK 框架

PayU提供用于处理与Ola Money付款相关不同功能的SDK。

PayUOlaMoneySDK:它包含所有API、错误代码、请求构建器等。仅使用此SDK,您就可以创建Ola Money的postData。

所需依赖项(通过Cocoapods自动添加)
  1. PayU Networking:PayUOlaMoneySDK用它来处理网络请求。
  2. PayU Logger:PayUOlaMoneySDK用它来记录错误和详细信息。

集成

Cocapods集成

在您的Podfile中添加以下行

pod 'PayUIndia-OlaMoney'
手动集成
  1. 从这里下载框架文件。 https://github.com/payu-intrepos/payu-olamoney-ios/releases
  2. 链接到您的项目。
创建UPI支付
  1. 设置环境为测试或生产

    PayUOMCore.shared.environment = .production
    
  2. 设置记录器级别为详细、错误或禁用

    PayUOMCore.shared.logLevel = .verbose
    
  3. 设置支付所需的基本支付参数

    do {
            paymentParams = try PayUOMPaymentParams(
                merchantKey: "smsplus", //Your merchant key for the environment set in step 1
                transactionId: String.randomString(length: 10), //Your unique ID for this trasaction
                amount: "1", //Amount of transaction
                productInfo: "iPhone", // Description of the product
                firstName: "Ashish", lastName: "Jain", // First name of the user
                email: "[email protected]",// Email of the useer
                phoneNumber: phoneNumberTextField.text ?? "9717063173", // Phone of user
                //User defined parameters.
                //You can save additional details with each txn if you need them for your business logic.
                //You will get these details back in payment response and transaction verify API
                //Like, you can add SKUs for which payment is made.
                udf1: "SKU1|SKU2|SKU3",
                //You can keep all udf fields blank if you do not have any requirement to save txn specific data
                udf2: "asdf",
                udf3: "asdf",
                udf4: "asdf",
                udf5: "asdf")
    
            // Example userCredentials - "merchantKey:user'sUniqueIdentifier"
            paymentParams?.userCredentials = "smsplus:[email protected]"
            // Success URL. Not used but required due to mandatory check.
            paymentParams?.surl = "https://payu.herokuapp.com/ios_success"
            // Failure URL. Not used but required due to mandatory check.
            paymentParams?.furl = "https://payu.herokuapp.com/ios_failure"
            paymentParams?.offerKey = "cardnumber@8370,cardnumbers2@8380,for particular bins@8427,srioffer@8428,cc2@8429"
        } catch let error {
            //Helper.showAlert("Could not create post params due to: \(error.localizedDescription)", onController: self)
        }
    
  4. 获取哈希并将其保存到paymentParams对象中

    • 您需要在paymentParams中设置hashes属性。哈希验证API请求来自原始来源而不是来自中间人。属性hashes的类型为PayUOMHashes

    • PayUHashes有2个属性。这三个中的每一个都用于不同的API调用。下面定义了这三个属性

      1. paymentHash:这是在PayU端创建交易所必需的。
      2. eligibilityHash:这是checkEligibility API在检查用户是否有资格使用Ola Money时所必需的。
    • 在请求SDK发起支付和检查资格之前,您需要提供哈希。必须只在您的服务器上生成哈希,因为它需要一个秘密密钥(也称为盐)。您的应用程序决不应包含盐。

    • 请参见[此处文档],在您的服务器上生成哈希。

      • 查看第10页和第11页上的paymentHash生成公式。
      • 查看第36页上的paymentRelatedDetailsForMobileSDKHashvalidateVPAHash生成公式。
    • 生成paymentRelatedDetailsForMobileSDKHashvalidateVPAHashCommandvar1值如下

      参数的哈希值 命令 var1
      eligibilityHash get_eligible_payment_options {"amount":"1","txnid":""+txid+"","mobile_number":"12345678","first_name":"John","bankCode":"OLAM","email":"[email protected]","last_name":"Smith"}
  5. 在设置paymentParams中的哈希值后,调用类的以下方法以检查用户是否有资格通过Ola Money(分期付款+钱包)进行支付

    public func checkEligibility(params: PayUOMPaymentParams, completion:@escaping(_ status: Bool, _ response: PayUOMEligibilityModel?, _ error: Error?) -> Void)
    

    您将在成功参数中获得类型为PayUOMEligibilityModelResult响应。以下为示例代码

    PayUOMCore.shared.checkEligibility(params: self.paymentParams!, completion: { [unowned self] status, response, error in
                DispatchQueue.main.async {
                    self.makePaymentButton.isEnabled = status
                    if (error != nil) {
                        self.elegebilityLabel.text = error?.localizedDescription
                    } else {
                        self.elegebilityLabel.text = response?.msg
                    }
                }
            })
    
  6. 使用上面接收到的 PayUOMEligibilityModel 对象,您可以在您的结账屏幕上填充相关的选项。

  7. 检查资格后,我们可以通过方法获取post参数。可以使用自定义浏览器或WKWebView加载URL和PostData。

    public func getPostData(params: PayUOMPaymentParams) -> String 
    
  8. (可选)使用以下代码通过自定义浏览器加载数据。

    let customBrowser = try? PUCBWebVC(postParam: postData, url: PayUOMSecureEndPoint.securePayment.baseURL, merchantKey: "smsplus")
    customBrowser?.cbWebVCDelegate = self
    let navVC = UINavigationController(rootViewController: customBrowser!)
    self.present(navVC, animated: true, completion: nil)