支付U钱nsurl错误空字符串

时间:2018-05-08 09:34:20

标签: ios json swift payment-gateway nsurl

它没有带我到payUmoney付款页面屏幕。我在添加PayUmoney支付网关时在控制台中获取此信息。 PayUmoney Integration[8923:268037] -[NSURL init]致电;这会导致NSURL实例具有空URL字符串。请使用其中一个记录的NSURL初始化方法,而不是(initWithString:, initFileURLWithPath:, etc.)。此消息仅显示一次。这是我的代码。我已经检查了这个How to integrate PayUMoney iOS SDK in swift project提前致谢。

import UIKit

class ViewController: UIViewController {


  let paymentParam: PayUModelPaymentParams  = PayUModelPaymentParams()
  var hashes :PayUModelHashes  = PayUModelHashes()
  let PUSAhelper:PUSAHelperClass = PUSAHelperClass()
  var PayUBaseUrl = "https://secure.payu.in"

  override func viewDidLoad() {
    super.viewDidLoad()


  }

  @IBAction func showPass(_ sender: UIButton) {

    self.continueWithCardPayment()
  }
  func continueWithCardPayment()  {

    paymentParam.key = "gtKFFx"
    paymentParam.transactionID = "txnID20170220"
    paymentParam.amount = "10.0"
    paymentParam.productInfo = "Nokia"
    paymentParam.surl = "https://payu.herokuapp.com/success"
    paymentParam.furl = "https://payu.herokuapp.com/failure"
    paymentParam.firstName = "Baalak"
    paymentParam.email = "Baalak@gmail.com"
    paymentParam.environment = ENVIRONMENT_TEST
    paymentParam.udf1 = "udf1"
    paymentParam.udf2 = "udf2"
    paymentParam.udf3 = "udf3"
    paymentParam.udf4 = "udf4"
    paymentParam.udf5 = "udf5"
    paymentParam.offerKey = ""              // Set this property if you want to give offer:
    paymentParam.userCredentials = ""


    PUSAHelperClass.generateHash(fromServer: self.paymentParam) { (hashes, errorString) in
      self.hashes = hashes!
      self.paymentParam.hashes = hashes
      self.paymentParam.userCredentials = "gtKFFx:Baalak@gmail.com"
      self.paymentParam.environment = ENVIRONMENT_TEST
      self.callPaymentGateway()
    }
  }

  func callPaymentGateway()  {

    let webServiceResponse :PayUWebServiceResponse = PayUWebServiceResponse()

    webServiceResponse.getPayUPaymentRelatedDetail(forMobileSDK: paymentParam) { (paymentDetail, errString, extraParam) in

      if errString == nil {


        let stryBrd: UIStoryboard = UIStoryboard(name: "PUUIMainStoryBoard", bundle: nil)
        let payOptionVC : PUUIPaymentOptionVC = stryBrd.instantiateViewController(withIdentifier: VC_IDENTIFIER_PAYMENT_OPTION) as! PUUIPaymentOptionVC

        payOptionVC.paymentParam = self.paymentParam
        payOptionVC.paymentRelatedDetail = paymentDetail


        DispatchQueue.main.async {
          NotificationCenter.default.addObserver(self, selector: #selector(self.paymentResponseReceived(notify:)), name: NSNotification.Name(rawValue: kPUUINotiPaymentResponse), object: nil)
          self.navigationController?.pushViewController(payOptionVC, animated: true)
        }
      }
      else{
        print("Failed to proceed for payment : \(String(describing: errString))")
      }
    }
  }

  @objc func paymentResponseReceived(notify:NSNotification) {
    print(notify)
  }

}

1 个答案:

答案 0 :(得分:0)

我通过将导航控制器添加到我的View Controller中来解决了这个问题