【问题标题】:Razorpay Signature and Order ID are not getting in success method of onPaymentSuccessRazorpay 签名和订单 ID 未进入 onPaymentSuccess 的成功方法
【发布时间】:2020-12-19 11:39:05
【问题描述】:

在 Razorpay 的测试和直播模式下,我只得到了成功方法中的payment_id。我无法获得razorpay_signaturerazorpay_order_id

我已使用RazorpayPaymentCompletionProtocolWithData 委托来获得我的结果。

这是我的代码:

extension ViewController: RazorpayPaymentCompletionProtocolWithData  {

func openRazorpayCheckout(){
    //Register RazorpayTestKey
    razorpay = RazorpayCheckout.initWithKey(kRazorpayLiveKey, andDelegateWithData: self)
    let options: [String:Any] = [
        "description": ServerConfig.shared.businessDescription!,
        "order_id": viewModel.model.orderID!,
        "image": ServerConfig.shared.businessImage!,
        "name": ServerConfig.shared.businessName!,
        "prefill": [
            "contact": LoggedInUser.shared.phoneNumber!,
            "email": LoggedInUser.shared.email!
        ]
    ]
    
    if let rzp = razorpay {
        rzp.open(options)
    } else {
        print("Unable to initialize")
    }
}

func onPaymentError(_ code: Int32, description str: String, andData response: [AnyHashable : Any]?) {
    _ = response!["razorpay_payment_id"]
    _ = response!["razorpay_order_id"]
    _ = response!["razorpay_signature"]
}

func onPaymentSuccess(_ payment_id: String, andData response: [AnyHashable : Any]?) {
    _ = response!["razorpay_payment_id"]
    _ = response!["razorpay_order_id"]
    _ = response!["razorpay_signature"]
}
}

【问题讨论】:

    标签: ios objective-c swift razorpay


    【解决方案1】:

    如果您没有得到签名,这意味着您的订单 ID 可能是错误的,请交叉检查您的订单 ID。我在android中犯了同样的错误。我没有传递导致空签名的订单 ID。

    【讨论】:

      【解决方案2】:

      通过回复节省了我的时间:

      如果您没有得到签名,则意味着您的订单 ID 可能有误,请交叉检查您的订单 ID。我在android中犯了同样的错误。我没有传递导致空签名的订单 ID。

      请务必传递正确的订单 ID。那你可以试试。您需要将 andDelegate 更改为 andDelegateWithData

      // razorpay = RazorpayCheckout.initWithKey(razorpayTestKey, andDelegate: self)
      razorpay = RazorpayCheckout.initWithKey("razorpayTestKey", andDelegateWithData: self)
      
      
      Then Use RazorpayPaymentCompletionProtocolWithData: 
      

      扩展视图控制器:RazorpayPaymentCompletionProtocolWithData {

      func onPaymentError(_ code: Int32, description str: String, andData response: [AnyHashable : Any]?) {
          print("error: ", code)
         // self.presentAlert(withTitle: "Alert", message: str)
      }
      
      func onPaymentSuccess(_ payment_id: String, andData response: [AnyHashable : Any]?) {
        
          print("success: ", payment_id)
        
          print("Response is: ", (String(describing: response)))
          
         let paymentId = response?["razorpay_payment_id"] as! String
         let rezorSignature = response?["razorpay_signature"] as! String
         print("rezorSignature", rezorSignature)
         print(" paymentId", paymentId)
         //self.presentAlert(withTitle: "Success", message: "Payment Succeeded")
      }
      

      }

      【讨论】:

        猜你喜欢
        • 2021-07-09
        • 2020-09-27
        • 2020-12-25
        • 2021-07-18
        • 1970-01-01
        • 1970-01-01
        • 2020-05-15
        • 2021-11-03
        • 2020-09-12
        相关资源
        最近更新 更多