Documentation

UPI Intent in WebView – Flutter

Enable UPI Intent payments inside a WebView in your Flutter application without using a native SDK.
This approach allows UPI apps like Google Pay, PhonePe, Paytm, Cred, etc. to open seamlessly from a WebView flow.


Steps to Implement UPI Intent

1. Dependencies

Add the following packages to your pubspec.yaml:

dependencies:
  flutter_inappwebview: ^6.1.5
  url_launcher: ^6.3.0

url_launcher is used to open installed UPI apps (PhonePe, Paytm, GPay/Tez, Cred, etc.) from the WebView callback.


2. Android Setup

a) Minimum Requirements

  • minSdkVersion: 21+ (recommended 23+)
  • AndroidX enabled (default for most Flutter projects)

Verify android/app/build.gradle:

android {
  defaultConfig {
    minSdkVersion 21
    targetSdkVersion 34
  }
}

b) Permissions

Add Internet permission in
android/app/src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
  <uses-permission android:name="android.permission.INTERNET" />

  <application>
    <!-- Application config -->
  </application>
</manifest>

3. iOS Setup

a) URL Schemes

If you use canLaunchUrl (recommended), add supported UPI schemes to
ios/Runner/Info.plist under LSApplicationQueriesSchemes:

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>upi</string>
  <string>phonepe</string>
  <string>paytmmp</string>
  <string>tez</string>
  <string>gpay</string>
  <string>credpay</string>
</array>

4. WebView Widget – Example

Intercept UPI URLs and open them in an external application:

shouldOverrideUrlLoading: (controller, navigationAction) async {
  final uri = navigationAction.request.url!;
  debugPrint("URL intercepted: ${uri.scheme}");

  if ([
    "upi",
    "phonepe",
    "paytmmp",
    "tez",
    "gpay",
    "credpay",
  ].contains(uri.scheme)) {
    await launchUrl(
      uri,
      mode: LaunchMode.externalApplication,
    );
    return NavigationActionPolicy.CANCEL;
  }

  return NavigationActionPolicy.ALLOW;
},

Make sure useShouldOverrideUrlLoading: true is enabled in WebView settings.


5. Common Issues & Fixes

  • Handler not triggered
    Ensure useShouldOverrideUrlLoading: true is set in initialSettings.

  • UPI app not opening on iOS
    Confirm the scheme is added to LSApplicationQueriesSchemes.

  • Android error: “No Activity found to handle Intent”
    The UPI app may not be installed or the scheme is incorrect.


Supported UPI Intent Apps

The following UPI apps are commonly supported for Mobile Web flows:

  • Google Pay
  • PhonePe
  • Paytm
  • Cred
  • Other UPI-compliant apps

Best Practices

  • Always provide a fallback UI if no UPI app is installed
  • Validate UPI URLs before launching
  • Test on real devices (emulators often lack UPI apps)

Related Information