0
PayUの支払いゲートウェイをアプリケーションに統合しようとしています。しかし、支払いが成功した後、私は応答や支払い状況を得ることができません。私は自分のコードも投稿しています。これから私を助けてください。私の場合はPayU決済ゲートウェイからの支払いが成功した後の対応方法を教えてください。
import UIKit
class PayUWebViewController: UIViewController, UIWebViewDelegate {
static let KEY = "W0weql"
static let SALT = "Q00w5qtc"
var params : PUMRequestParams = PUMRequestParams.shared()
var utils : Utils = Utils()
@IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
params.amount = "0.50"
params.environment = PUMEnvironment.production;
params.firstname = "Akshat";
params.key = PayUWebViewController.KEY;
params.merchantid = "1234567"; //Merchant merchantid
params.logo_url = ""; //Merchant logo_url
params.productinfo = "Product Info";
params.email = "[email protected]"; //user email
params.phone = "1234567890"; //user phone
params.txnid = utils.getRandomString(2) //set your correct transaction id here
params.surl = "https://www.google.com";
params.furl = "https://www.facebook.com";
params.udf1 = "";
params.udf2 = "";
params.udf3 = "";
params.udf4 = "";
params.udf5 = "";
params.udf6 = "";
params.udf7 = "";
params.udf8 = "";
params.udf9 = "";
params.udf10 = "";
let hashSequence : NSString = "\(params.key!)|\(params.txnid!)|\(params.amount!)|\(params.productinfo!)|\(params.firstname!)|\(params.email!)|||||||||||\(PayUWebViewController.SALT)" as NSString
let data :NSString = utils.createSHA512(hashSequence as String!) as NSString
params.hashValue = data as String!
params.delegate = self
makePayURequest()
}
func makePayURequest()
{
let url = URL(string: "https://secure.payu.in/_payment")!
var request = URLRequest(url: url)
let params = "key=\(self.params.key!)&txnid=\(self.params.txnid!)&amount=\(self.params.amount!)&productinfo=\(self.params.productinfo!)&firstname=\(self.params.firstname!)&email=\(self.params.email!)&phone=\(self.params.phone!)&surl=\(self.params.surl!)&furl=\(self.params.furl!)&hash=\(self.params.hashValue!)"
request.httpBody = params.data(using: String.Encoding.utf8)
request.httpMethod = "POST"
request.cachePolicy = NSURLRequest.CachePolicy.reloadIgnoringCacheData
request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
webView.loadRequest(request)
}
func webViewDidStartLoad(_ webView: UIWebView) {
}
func webViewDidFinishLoad(_ webView: UIWebView) {
let requestURL = self.webView.request?.url
let requestString:String = (requestURL?.absoluteString)!
if requestString == "https://www.google.com" {
print("success payment done")
}
else if requestString == "https://www.facebook.com" {
print("payment failure")
}
}
func webView(_ webView: UIWebView, didFailLoadWithError error: Error) {
print(error.localizedDescription)
}
}
を設定する必要のあるhttps://github.com/payu-intrepos/PayUMoney-IOS-SDK例を使用していました。機密情報の投稿には十分注意してください。 – Scriptable
ここではwebviewを使用しないでください。APIを使用する必要があります。この他の答えを見てください:http://stackoverflow.com/questions/33908484/payu-money-gateway-ios-swift – Scriptable
@Scriptableはいこれらのキーと塩の値はここではランダムであり、実際の値ではありません。 私はこのリンクをチェックしました。ここではウェブビューも使用されており、私たちは何の反応も得ていません。 –