PGWNavigationDelegate constructor
PGWNavigationDelegate({})
Implementation
PGWNavigationDelegate({
super.onNavigationRequest,
super.onPageStarted,
super.onPageFinished,
super.onProgress,
super.onWebResourceError,
void Function(UrlChange change)? onUrlChange,
super.onHttpAuthRequest,
void Function(String paymentToken)? onInquiry
}) {
platform.setOnUrlChange((change) {
if(onUrlChange != null) onUrlChange(change);
String? url = change.url ?? '';
final bool doWebUrlCapture = RegExp(_defaultResultWebUrlCaptureRegex, caseSensitive: false).hasMatch(url);
final bool doAppSchemeCapture = RegExp(_defaultResultAppSchemeCaptureRegex, caseSensitive: false).hasMatch(url);
if(doWebUrlCapture || doAppSchemeCapture) {
if(onInquiry != null) {
String paymentToken = '';
if(doWebUrlCapture) {
try {
Iterable<RegExpMatch> webUrlFindMatcher = RegExp(_defaultResultWebUrlCaptureRegex, caseSensitive: false).allMatches(url);
for (var match in webUrlFindMatcher) {
paymentToken = match[3] != null ? match[3]! : '';
}
} catch(e) {
paymentToken = '';
}
}
onInquiry(paymentToken);
}
}
});
}