It doesn't take me to payUmoney
payment page screen. I am getting this in console while adding PayUmoney
payment gateway. PayUmoney
Integration[8923:268037] -[NSURL init]
called; this results in an NSURL
instance with an empty URL string. Please use one of the documented NSURL
initialization methods instead (initWithString:, initFileURLWithPath:, etc.)
. This message shown only once. Here is my code. I already checked this How to integrate PayUMoney iOS SDK in swift project Thanks in advance.
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)
}
}