我使用 cloudpayments.ru 编写 iOS 移动应用程序目前我有大问题,无法使用 3d-secure 支付。
我成功地通过此代码获得“PaReq”参数:
Alamofire.request(.POST, apiURLString, parameters: paramsDictionary, encoding: ParameterEncoding.JSON, headers: nil)
.authenticate(user: _apiPublicID, password: _apiSecret)
.responseJSON{ response in
if (jsonData.object.objectForKey("Model") != nil){
if (jsonData["Model"].object.objectForKey("AcsUrl") != nil) && (jsonData["Model"].object.objectForKey("PaReq") != nil){
let acsURL = jsonData["Model"].object.objectForKey("AcsUrl") as! NSString
let pareqstr = jsonData["Model"].object.objectForKey("PaReq") as! NSString
但是当我尝试使用“PaReq”和“MD”参数去 AcsUrl
var postData = NSMutableData(data: "PaReq=fJxVUn9vgjAQ/SqG/6GFFinmrHFzy/xDYzb3AZpyKomAFpg/Pv1ahTmbNLn32r67e1eYnIv94AdN nVfl2AsD6g2w1FWWl9ux971+94U3kbDeGcTZF+rWoIQF1rXa4iDPxh6nKYuzTPibWG98vonRF6gz nyVUK6UYpyL1JKymn3iU0CWSNk8QAemhVTR6p8pGgtLHl/lScsZDFgPpIBRo5jMpaCIoE4mIGbUL yJ2GUhUo9b5qs4O6FFg2NZAbB7pqy8Fc5JAzID2A1uzlrmkOI0JOp1PQ6l0emBaI44E8ilm1Lqqt zjnP5GI2Pd33G11e55fFbHtZXOd3eZ2OgbgbkKkGZUTDIRXRcBCyEWej2DZ640EVrgAZpbfaOwQH l2T6dPSfAuu5sSPpe+gR4PlQlegeAfmLgTxqfv1wdurGOhRRnsRDxiIeiJCy1BqZpimNQifZ3XGC uXUnTGh4U3QAiFMh3fhIN3kbPf2IXxBBurI=".dataUsingEncoding(NSUTF8StringEncoding)!)
postData.appendData("&MD=8530327".dataUsingEncoding(NSUTF8StringEncoding)!)
postData.appendData("&TermUrl=https://test.ru".dataUsingEncoding(NSUTF8StringEncoding)!)
var request = NSMutableURLRequest(URL: NSURL(string: "https://acs.alfabank.ru/acs/PAReq")!,
cachePolicy: .UseProtocolCachePolicy,
timeoutInterval: 10.0)
request.HTTPMethod = "POST"
request.allHTTPHeaderFields = headers
request.HTTPBody = postData
let session = NSURLSession.sharedSession()
let dataTask = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? NSHTTPURLResponse
dispatch_async(dispatch_get_main_queue(),{
let webView = UIWebView.init(frame: self.view.frame)
webView.delegate = self
print("3D Secure here!!!")
self.view.addSubview(webView)
webView.loadData(data!, MIMEType: (response?.MIMEType)!,
textEncodingName: (response?.textEncodingName)!,
baseURL: (response?.URL)!)
})
print(httpResponse)
}
})
dataTask.resume()
我有闲置:(
可能与 PaReq 字段中的许多特定字符有关,例如:/%\n间距等
有谁能够帮我?