I was trying to add a payment gateway using WebView flutter library.On successful completion of payment, the gateway redirects to a return url or webhook with transaction response. Now instead of redirection to some outside url, I want redirection to my app and want to read the status of transaction from response that is sent.
All I want to know whether transaction is success or fail.
”’
WebView(
navigationDelegate: (action) {
return NavigationDecision.navigate;
},
onPageStarted: (url) => _onPageStart(url),
onPageFinished: (url) => _onPageFinish(url),
gestureNavigationEnabled: true,
debuggingEnabled: true,
javascriptMode: JavascriptMode.unrestricted,
initialUrl: url,
onWebViewCreated: (WebViewController webcontroller) {
_controller = webcontroller;
},
),
void _onPageStart(url) {
Future<String> future = _controller
.runJavascriptReturningResult("window.document.body.outerHTML");
future.then((data) {
print("ONpage start $data");
});
}
Future<void> _onPageFinish(url) async {
Future<String> future = _controller
.runJavascriptReturningResult("window.document.body.outerHTML");
future.then((data) {
print(data);
});
}
”’