UPI Intent Support on WebView


Overview

For merchants opening the Payment Page in a WebView in Android, UPI Intent does not work out of the box, as any android Intent needs the app containing the WebView to handle the Intent URI (upi://pay)

To have a near-native experience on WebView, we have made a lightweight SDK solution, which adds a JavaScriptInterface to your webview and thereby provides functionalities to fetch available UPI apps, and make payment with them natively

Android

Getting the SDK(Android)

Add the SDK maven repository to the allprojects repository in the root build.gradle file:

Add the SDK dependency in your app’s build.gradle:

Integrating the SDK(Android)

Step-1

Create an object of HyperWebViewServices, which takes activity and webview as parameters:

Step-2

Call attach method of HyperWebViewServices:

Step-3

Pass the activity result to SDK by overriding the onActivityResult method in the activity passed in Step-1:

iOS

Getting the SDK (iOS)

Add the SDK dependency in Podfile:

Add URI Schemes for required UPI Apps in Info.plist :

Integrating the SDK(iOS)

Create instance of HyperWebViewServices in didFinish callback of WebView, initialise the instance with webview as an argument and call attach method on it.

Note

Ideally hyper.attach should be called only when url loaded matches with Juspay Payment Page URL. Please add a check for URL match if needed.

Last updated 1 year ago