UPI Intent in WebView – iOS
Enable UPI Intent payments inside a WKWebView in your iOS application to support seamless payment redirection using popular UPI apps.
This approach allows apps like PhonePe, Paytm, Google Pay (GPay/Tez), and Cred to open directly from a WebView-based payment flow.
UPI Deep Link Handling in iOS WebView
When processing payments inside a WKWebView, UPI applications are launched using custom URL schemes.
Common UPI Schemes
phonepe://paytmmp://gpay://tez://credpay://
To ensure smooth redirection, the WebView must intercept these URLs and open the corresponding UPI app instead of attempting to load them inside the WebView.
Code Example (Swift)
Implement WKNavigationDelegate to intercept UPI deep links:
extension CheckoutPaymentViewController: WKNavigationDelegate {
func webView(
_ webView: WKWebView,
decidePolicyFor navigationAction: WKNavigationAction,
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void
) {
guard let url = navigationAction.request.url else {
decisionHandler(.allow)
return
}
// Supported UPI / payment intent schemes
let upiSchemes = ["phonepe", "paytmmp", "gpay", "tez", "credpay"]
if let scheme = url.scheme,
upiSchemes.contains(where: { scheme.contains($0) }) {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(
url,
options: [:],
completionHandler: nil
)
decisionHandler(.cancel)
return
} else {
// Fallback if app is not installed
let alert = UIAlertController(
title: "App Not Installed",
message: "The selected payment app is not installed
on your device.",
preferredStyle: .alert
)
alert.addAction(
UIAlertAction(
title: "OK",
style: .default,
handler: nil
)
)
self.present(alert, animated: true)
decisionHandler(.cancel)
return
}
}
// Allow non-UPI URLs to load normally
decisionHandler(.allow)
}
}
Enable UPI Intent Support (Info.plist)
To allow iOS to query and open UPI apps, add the following entries toios/Runner/Info.plist under LSApplicationQueriesSchemes:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>upi</string>
<string>phonepe</string>
<string>paytmmp</string>
<string>gpay</string>
<string>tez</string>
<string>credpay</string>
</array>
Without these entries,
canOpenURLwill fail and UPI apps will not open.
Supported UPI Intent Apps
The following UPI apps are commonly supported for Mobile Web payments:
- Google Pay (GPay / Tez)
- PhonePe
- Paytm
- Cred
Best Practices
- Always validate the URL scheme before opening external apps
- Provide user-friendly fallback messaging if the UPI app is not installed
- Test UPI flows on real devices (simulators do not support UPI apps)