Custom Checkout Integration - Android

The integration can be completed in three steps and should not take more than 30 minutes.

  • Create Order Create an order in Cashfree's system from your backend
  • Pay Order - Do a form submit from your app’s webview as mentioned in this document.
  • Handle redirection Detect URL redirection to return URL and close the webview

Create Order

Please follow the steps mentioned in this link to create an order.


Don't forget to provide the return URL while creating the order as this will be used to detect payment completion.

Pay Order

Open the payment link present in the create order response in your applications webview.


Handle Redirection

Once the payment flow has ended cashfree page will redirect to the URL you have specified while creating the order. Detect the URL redirection to this return URL and close the webview appropriately.

yourWebView.setWebViewClient(new WebViewClient(){
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                //Find if the url is the return URL you gave while creating the order 
                // and close the webview
                return super.shouldOverrideUrlLoading(view, url);

UPI Intent from Checkout

If you are doing a custom integration of Cashfree's Web Checkout in Android and want to add UPI intent functionality, then follow the steps below. Read more about UPI Intent functionality from here.

  1. Add the queries element in AndroidManifest file.
  2. Add the JSBridge functions for the checkout page to get the list of UPI apps installed and for opening the UPI app selected by the user.
  3. Once the user comes back from the UPI app, inside onActivityResult function notify the checkout page by calling a javascript function inside the checkout page.

You need to add the following to your AndroidManifest.xml

<manifest package="">
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="upi" android:host="pay"/>
    <package android:name="" />

Sample Code

import android.content.Intent;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.List;

public class CFWebIntentJSInterface {
    private final CFWebIntentInterface cfWebIntentInterface;

    public CFWebIntentJSInterface(CFWebIntentInterface cfWebIntentInterface) {
        this.cfWebIntentInterface = cfWebIntentInterface;

    public interface CFWebIntentInterface {
        List<ResolveInfo> getAppList(String link);

        String getAppName(ApplicationInfo pkg);

        void openApp(String appPkg, String url);

        void enableDisableCancelButton(Boolean flag);

    public void enableCancelButton() {

    public void disableCancelButton() {

    public String getAppList(String name) {
        final List<ResolveInfo> resInfo = cfWebIntentInterface.getAppList(name);
        JSONArray packageNames = new JSONArray();
        try {
            for (ResolveInfo info : resInfo) {
                JSONObject appInfo = new JSONObject();
                appInfo.put("appName", cfWebIntentInterface.getAppName(info.activityInfo.applicationInfo));
                appInfo.put("appPackage", info.activityInfo.packageName);
        } catch (Exception ex) {

        return packageNames.toString();

    public boolean openApp(String upiClientPackage, String upiURL) {
        cfWebIntentInterface.openApp(upiClientPackage, upiURL);
        return true;
public class YourWebViewActivity extends AppCompatActivity implements CFWebIntentJSInterface.CFWebIntentInterface {
	private boolean backEnabled = true;
  private WebView yourWebView;
	private static final int REQ_CODE_UPI = 9901;

  @SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
  protected void onCreate(Bundle savedInstanceState) {


		CFWebIntentJSInterface wbInInterface = new CFWebIntentJSInterface(this);
		yourWebView.addJavascriptInterface(wbInInterface, "Android");

  public List<ResolveInfo> getAppList(String link) {
		ArrayList<ResolveInfo> resolveInfos = new ArrayList<>();
		Intent shareIntent = new Intent(Intent.ACTION_VIEW);
		final List<ResolveInfo> resInfos = getPackageManager().queryIntentActivities(shareIntent, 0);
		if (resInfos != null) {
			resolveInfos = new ArrayList<>(resInfos);
		return resolveInfos;
  public String getAppName(ApplicationInfo pkg) {
		return (String) getPackageManager().getApplicationLabel(pkg);
  public void openApp(String appPkg, String url) {
		final Intent intent = new Intent();
		runOnUiThread(() -> {
			if ("others.upiapp".equals(appPkg)) {
				Intent chooser = Intent.createChooser(intent, "Pay with");
				startActivityForResult(chooser, REQ_CODE_UPI);
			} else {
				startActivityForResult(intent, REQ_CODE_UPI);

	public void enableDisableCancelButton(Boolean flag) {
		backEnabled = flag;
	protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && requestCode == REQ_CODE_UPI) {
			yourWebView.evaluateJavascript("window.showVerifyUI()", (ValueCallback<String>) s -> {});
	public void onBackPressed() {
		if (backEnabled)