3DS の既存の実装では、チェックアウトと支払いの段階で、顧客をアプリから銀行/カード発行会社の Web サイトにリダイレクトし、そこで顧客は以前に設定したパスワードを入力して、実際にカード所有者であることを認証できます。 . その後、ウェブサイトは、トランザクションを完了するために必要な情報とともに、顧客をあなたのウェブサイトにリダイレクトします。リダイレクトに対する銀行サーバーの応答を読み取るにはどうすればよいですか? 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
}
純粋なフラッターでこのようなものを得ることができますか?