search
Your Paytm for business app is working and will keep working beyond March 15th, 2024. Click to know more

Integration with JS Checkout: Android

Webview for Android Platform

To support UPI intent PSP apps, merchants need to make the following changes mentioned below.

Note: This solution is for the merchants who have integrated JS Checkout. To know more about JS Checkout integration, please refer to the JS Checkout document.

Steps to follow:-

  1. Merchants integrate the Webview in their Android application to open the Paytm gateway and show payable instruments to the user.
  2. Integrate WeClient in Webview to listen to events related to Webview.
  3. Add the below-mentioned method in Webclient to support UPI PSP apps from the Webview.

 

Mandatory code: 

 

To update Paytm UI about enabling the UPI intent. One needs to follow the below steps: 

 

1. Create a Javascript Interface and attach it with the Webview created for handling the transaction.


public  class PaytmJavaScriptInterface {
    @JavascriptInterface
    public synchronized boolean openUpiApp(String url) {
        try {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
        }catch (ActivityNotFoundException e){
            return false;
        }
        return true;
    }
}

 

2. Add the JS interface created to the Webview so that UI is notified about enabling the UPI intent. Now, Add the below piece of code where you are initializing the Webview.

webView.addJavascriptInterface(new PaytmJavaScriptInterface(),"checkoutUpiIntent");

 

 Note: Java version is independent of the above piece of code.