skip to Main Content

I’m working on the Flutter app, and need to create a callback URL after
a customer success/fails payment. Which event/function can be used with webview_flutter?

I checked the same questions here but didn’t find solutions

2

Answers


  1. You can create webview client and use shouldOverrideUrlLoading or onLoadResource to create a callback url in webview_flutter

    Login or Signup to reply.
  2. You can use webview_flutter and do what you want in navigationDelegate callback

    WebView(
                    initialUrl: yourPaymenntUrl,
                    javascriptMode: JavascriptMode.unrestricted,
                    navigationDelegate: (navigationDelegate) async {
    
                      if (navigationDelegate.url
                          .contains(yourReturnUrl)) {
                        // payment completed
                        // do what ever you want
                       String? merchantId = Uri.parse(navigationDelegate.url)
                       .queryParameters['merchantId'];
                        Navigator.pop(context, merchantId);
                      } else if (navigationDelegate.url
                          .contains(cancelUrl)) {
                        // TODO implementation
                       Navigator.pop(context);
                      }
    
                      return NavigationDecision.navigate;
                    },
                  )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search