Flutter webview Razorpay netbanking issue

Viewed 210

I am newbie in flutter, i am using its Webview and have website with Razorpay integrated, but when I click on Razorpay and on netbanking the website isn't taking me to payment page, instead it just keeps loading

enter image description here

I get this in terminal

Initializing SystemTextClassifier, type = System  

Wallet - Amazonpay method seems to redirect to amazon page, but phonepe doesn't I tried with launch URL as well, doesnt' work

class TestApp extends StatelessWidget {
  const TestApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    const _testHomeUrl = "https://www.test.in";
    const _proxyUserAgent =
        "Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19";
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'Test',
        home: Scaffold(
          appBar: PreferredSize(
              preferredSize: Size.fromHeight(0),
              child: AppBar(
                title: const SizedBox(
                  height: kToolbarHeight,
                ),
              )),
          body: WebView(
            initialUrl: _testHomeUrl,
            javascriptMode: JavascriptMode.unrestricted,
            userAgent: _proxyUserAgent,
            navigationDelegate: (NavigationRequest request) {
              if (request.url.startsWith("https://www.test.in/")) {
                return NavigationDecision.navigate;
              } else {
                _launchURL(request.url);
                return NavigationDecision.prevent;
              }
            },
          ),
        ));
  }
}

_launchURL(String url) async {
  await launch(url);
}
1 Answers

I was able to solve this by adding Razor adding https://pub.dev/packages/razorpay_flutter to my webview

I add javascript on click method to the same button to give it a more web feel and then using the Javascript channel, on click I trigger a function that triggers Razorpay plugin

Related