ios - 如何在我的Xcode项目中集成Razorpay付款网关?

标签 ios swift swift5 razorpay

这是我第一次尝试在我的项目中实现支付网关。
我从官方Razorpay链接中正确地执行了所有步骤https://razorpay.com/docs/payment-gateway/ios-integration/standard/
我添加了模块import Razorpay并设置了它的委托协议。
请帮我解决这个问题。
我的Xcode版本是11.1

//
//  RPViewController.swift

import UIKit
import Razorpay
class RPViewController: UIViewController  , RazorpayPaymentCompletionProtocol {
   var razorpay : Razorpay!
    override func viewDidLoad() {
        super.viewDidLoad()
razorpay = Razorpay.initWithKey("rzp_test_oaXFcpSvVQ9Ry9", andDelegate: self)

        showPaymentForm()
        // Do any additional setup after loading the view.
    }

    internal func showPaymentForm(){
        let options: [String:Any] = [
                    "amount": "100", //This is in currency subunits. 100 = 100 paise= INR 1.
                    "currency": "INR",//We support more that 92 international currencies.
                    "description": "purchase description",
                    "order_id": "order_4xbQrmEoA5WJ0G",
                    "image": "https://image.flaticon.com/icons/svg/124/124010.svg",
                    "name": "business or product name" ,
                    "prefill": [
                        "contact": "9797979797",
                        "email": "foo@bar.com"
                    ],
                    "theme": [
                        "color": "#F37254"
                    ]
                ]


        print(options)
        razorpay.open(options)
    }

    func onPaymentError(_ code: Int32, description str: String) {
           let alertController = UIAlertController(title: "FAILURE", message: str, preferredStyle: UIAlertController.Style.alert)
           let cancelAction = UIAlertAction(title: "OK", style: UIAlertAction.Style.cancel, handler: nil)
           alertController.addAction(cancelAction)
           print("code",code)
           self.view.window?.rootViewController?.present(alertController, animated: true, completion: nil)
       }

       func onPaymentSuccess(_ payment_id: String) {
           let alertController = UIAlertController(title: "SUCCESS", message: "Payment Id \(payment_id)", preferredStyle: UIAlertController.Style.alert)
           print("hdfvsd",payment_id)
           let cancelAction = UIAlertAction(title: "OK", style: UIAlertAction.Style.cancel, handler: nil)
              alertController.addAction(cancelAction)
              self.view.window?.rootViewController?.present(alertController, animated: true, completion: nil)
       }


}

//But I'm getting this error

2019-11-11 09:52:25.298995+0530 PaymentGateway[2355:30306] [Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.}

最佳答案

我得到了答案。
错误在于我传递了不需要的参数orderId

关于ios - 如何在我的Xcode项目中集成Razorpay付款网关?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58761352/

相关文章:

ios - 在多个类中调用闭包?

objective-c - iPad+将图像选择器质量设置为低

ios - 关闭 UITextField 的键盘

swift - 将 xcode 6 转换为 7 时出错

ios - Alamofire 请求给出内存警告

swift - 如何在 iOS 13 中串流远程音频? ( swift 用户界面)

ios - 尝试在Xcode Objective-C中创建按钮

ios - 禁用在 iTunes 文件共享中添加文件

Swift randomFloat 问题 : '4294967295' is not exactly representable as 'Float'

ios - 无法启动 iOS 应用程序 - bundle ID 重复错误