SDK Integration

Add Dependencies & Android Manifest declarations

  1. Add the CloudRepo Maven Repository in build.gradle:
allprojects {
    repositories {
        maven {
            url ""
  1. Add the below line to the 'dependencies' section of your app build.gradle
implementation ''
implementation ''

( Optional - If you aren’t using Kotlin in your app, add the following Kotlin stdlib dependency

implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50'
  1. Add below line inside application tag of your AndroidManifest.xml file
<!-- Keep it false in production environment--> 
<!-- Keep it false in production environment-->
<!-- Get the MerchantId & App Id from PhonePe-->
    android:value="@string/<appId-shared-by-phonepe>" />

Android SDK Integration

  1. Initialize the SDK ( ideally in onCreate of your MainActivity ) using:
  1. Get a list of UPI Apps installed on the user’s device:
try {
    List<UPIApplicationInfo> upiApps = PhonePe.getUpiApps();
} catch (PhonePeInitException exception) {

UPIApplicationInfo Model

public class UPIApplicationInfo {
    String packageName;
    String applicationName;
    Long version;
  1. Show your custom UI containing the list of apps obtained from step 2. Make Sure packageName is accessible when the user selects any of the UPI Application.

  2. Create transactionRequest as follows:

TransactionRequest transactionRequest = new TransactionRequestBuilder()



base64Body and checksum need to be constructed on the server-side.
Please refer to the section Server Side Steps for details.

  1. Start the transaction activity by passing the packageName of the App selected by the user & transactionRequest obtained from step 4.
private static final int PHONEPE_PAYMENT_REQUEST_CODE = 101;

try {
} catch (PhonePeInitException e) {
    //handle invalid packageName & app not installed cases here.
  1. Handle onActivityResult
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == PHONEPE_PAYMENT_REQUEST_CODE) {
        /*This callback indicates only about completion of UI flow.
        Inform your server to make the transaction
        status call to get the status. Update your app with the
        success/failure status.*/

Server Side Steps

  1. Define the API endPoint and request parameters at your server as follows:
String apiEndPoint = "/v4/debit";
  1. Construct the base64Body request of the defined data as follows:
HashMap<String, Object> data = new HashMap<>();
data.put("merchantId", “UATMERCHANT”); //String. Mandatory
data.put("transactionId", “TX123456789”); //String. Mandatory.
data.put("amount", 100); //Long. Mandatory
data.put("merchantOrderId", “OD1234”); //String. Mandatory
data.put("message", “Payment for order 001234”); //String. Optional
data.put("mobileNumber", “9xxxxxxxxx”); //String. Optional
data.put("paymentScope", "ALL_UPI_APPS"); //Mandatory
data.put("openIntentWithApp",packageName); //Mandatory
// transactionId length should be less than 38 characters.
// merchantOrderId length should be less than 48 characters.
// Put more info as intimated. Nesting is allowed

String base64Body = Base64(new GSON().toJson(data));
  1. Select one of the API keys shared with you and note its index. Construct the checksum at your server, as follows:
String checksum = SHA256(base64Body + apiEndPoint + salt) + ### + saltIndex;


  • Use the Check Transaction Status API to check the status of the payment transaction. Refer to this link.

  • S2S Callback, Refer to this link

  • For refund API, Refer to this link.