When the doUPIPayment method is invoked the customer is shown a list of all the installed UPI applications on their phone. After the customer selects their preferred application, the payment confirmation page will open in the application. After payment completion, the response is delivered through onActivityResult().

You also have the option to display the UPI applications in your user interface and send the response to Cashfree to launch the application selected by the customer.

dependencies {
    ...
    //Dependencies used by all payment functions
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    //doUPIPayment - Only if you are using the default UI from the SDK instead of showing your own UI and calling setUpiClient()
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
}
public  void  upiPayment(Context context, Map<String, String> params, String token, String stage)

Parameters:

  • context: Context object of the calling activity is required for this method. In most of the cases this will mean sending the instance of the calling activity (this).
  • params: A map of all the relevant parameters described here
  • token: The token generated here
  • stage: Value should be either "TEST" or "PROD" for testing server or production server respectively.

When initiating the UPI intent the customer is shown a list of all the UPI client applications (BHIM, GPay, PhonePe etc.) on their phone. This allows the customer to select any UPI application they want to pay with. If you want the customer to pay with a particular app you can use the parameter upiClientPackage. After calling this method whenever upiPayment is called the customer will not see the application selection screen, instead will be redirected to the application whose package is provided in the parameters.

public void selectUpiClient(String upiClientPackage)

Parameters:

  • upiClientPackage: The string describing the java package of the upi client that is to be selected.

Get the packages of all the UPI Clients installed on the device as a string array. These packages can then be passed to selectUpiClient() method to initiate the payment.

public String[] getUpiClients(Context context)

Get the packages of all the UPI Clients installed on the device as a string array. These packages can then be passed to selectUpiClient() method to initiate payment.

Parameters:

  • context: Context object of the calling activity is required for this method.

© 2019 Cashfree Payments India Pvt Ltd