现有的 3DS 实施是这样的,在结帐和支付阶段,它涉及将客户从您的应用程序重定向到银行/发卡机构网站,客户可以在其中输入他们之前设置的密码来验证他们确实是持卡人. 然后,该网站会将客户重定向回您的网站,并提供完成交易所需的信息。如何读取银行服务器对重定向的响应?我尝试通过 webview_flutter 执行此操作,但只能获取 URL 重定向。
Widget _view3ds(PaymentAnswer answer) {
final url = answer.model['AcsUrl'];
return Scaffold(
appBar: AppBar(
title: const Text('Pay'),
),
body: WebView(
initialUrl: url,
initialPostParameters: answer.paramPost3DS(),
javascriptMode: JavascriptMode.unrestricted,
onPageFinished: _pageFinished
),
);
}
void _pageFinished(String url) {
print(url);
url.response ??? // Is there a way to get to the server response? Maybe there is another plugin that allows this?
}
有一个运行良好的快速代码:
/// Handle result from 3DS form
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
let urlString = request.url?.absoluteString
if (urlString == Constants.cloudpaymentsURL) {
var response: String? = nil
if let aBody = request.httpBody {
response = String(data: aBody, encoding: .ascii)
}
let responseDictionary = parse(response: response)
webView.removeFromSuperview()
post3ds(transactionId: responseDictionary?["MD"] as! String, paRes: responseDictionary?["PaRes"] as! String)
return false
}
return true
}
我可以在纯颤振上得到这样的东西吗?