2

I use Stripe Checkout in a WebView in Flutter.

During the payment flow using Ideal (Netherlands based banking system) the flow tries to open an external app and sends a URL like the following:

nl.abnamro.ideal://%7B%22idealTransaction%22...

this is the WebView relevant code:

WebView(
   initialUrl: initialUrl,
   javascriptMode: JavascriptMode.unrestricted,
   onWebViewCreated: (controller) => _controller = controller,
   navigationDelegate: (NavigationRequest request) async {
          if (request.url.startsWith('https://example.com/succes')) {
            ...
            Navigator.pop(context, status); // <-- Handle success case
          } else if (request.url.startsWith('https://example.com/cancel')) {
            Navigator.pop(context, Status.paymentCanceled); // <-- Handle cancel case
          }
          if (request.url.startsWith("https") || request.url.startsWith("http")) {
            return NavigationDecision.navigate;
          }
          _launchURL(request.url);
          return NavigationDecision.prevent;
        })

the _launcURL method is

_launchURL(String url) async {
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not launch $url';
    }}

and what I get in output is

Could not launch nl.abnamro.ideal://%7B%22idealTransaction%22%3A%7B%22i...

and my flow gets stuck.

This deep link should open the ABN Amro app, which is installed on my device. This actually works on iOS.

Do you know what is the best way to deal with this flow?

alexlipa
  • 1,131
  • 2
  • 12
  • 27
  • https://stackoverflow.com/questions/41693263/android-webview-err-unknown-url-scheme/53059413#53059413 – karllekko Feb 04 '22 at 10:11
  • But overall you should not use Checkout in a WebView, you should either do payments in the system browser entirely outside of your app, or use the Stripe Flutter plugin. – karllekko Feb 04 '22 at 10:12
  • how will I get back the outcome of the payment if I do everything on the browser? Do you have any example/link? – alexlipa Feb 04 '22 at 13:01
  • Your backend gets a webhook and you could notify your app from the backend. Or set the `success_url` on the CheckoutSession to a URL that redirects to a URL scheme your app opens. Or you could integrate using the Stripe Flutter SDK which I believe works with callbacks when the payment is complete – karllekko Feb 04 '22 at 17:25
  • Have this same issue but with MangoPay, instead of Stripe Checkout. – Martin Berger Dec 13 '22 at 13:01
  • @alexlipa So what was the solution for this in the end? – Martin Berger Dec 14 '22 at 11:48

0 Answers0