Server Side

  1. Save the below assigned apiEndPoint value at your server for the debit request.
String apiEndPoint = "/v4/debit";

2.Collect the phonePeVersionCode from your app.

3.Call /v4/debit API. Refer this link for more details.

4.Select one of the API keys shared with you and note it's index.
Construct the checksum at your server as follows:

String checksum = sha256(base64Body + apiEndPoint + saltKey) + ### + saltKeyIndex;

5.Initiate the payment process using Accept Payments API from the server and in the response you will receive the redirectURL which needs to be passed to the app side.

App Side

  1. Check whether the PhonePe app is installed or not on the user’s device. Display PhonePe Option on the checkout page only when the isUpiRegistered() function return TRUE
private boolean isUpiRegistered() {
    String phonepePackageNameUat = ""; // UAT Environment 
    String phonepePackageNameProduction = ""; // Production Environment
    Uri uri = Uri.parse(String.format("%s://%s", "upi", "pay"));
    Intent upiUriIntent = new Intent();
    PackageManager packageManager = getApplication().getPackageManager();
    List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(upiUriIntent, PackageManager.MATCH_DEFAULT_ONLY);
    if (resolveInfoList != null) {
        for (ResolveInfo resolveInfo : resolveInfoList) {
            String packageName = resolveInfo.activityInfo.packageName;
            if (packageName != null && !packageName.isEmpty() && phonepePackageNameUat.matches(packageName)) {
                return true;
    return false;
  1. Add the below line in your AndroidManifest.xml file
    <package android:name="" />
    <package android:name="" />
  1. If the PhonePe app is installed on the user’s device, then you need to get the PhonePe app version code and give it to your server.

  2. Once the merchant app receives the redirectUrl from the server, the deep linking option would be shown where the merchant has to handle intent flow by using the below code:

Intent flow:

Intent i = new Intent(Intent.ACTION_VIEW);
startActivityForResult(i, PHONEPE_REQUEST);


  • In this case, you will receive the intent URI in the "redirectURL" parameter in the response of the Accept Payment API response.
  • On loading this url, the merchant will invoke the PhonePe app only and completes the payment.
  • Upon payment completion merchant will receive the UI callback in onActivityResult.
  • Once you receive the UI callback, It indicates that payment flow is completed then you should check the payment status with server.



  • You will get redirectURL in the response of the Accept Payment API response.
  • For pre prod environment PhonePe package name is “”.

4.Override onActivityResult to listen to debit result:

private static final int PHONEPE_REQUEST = 123;
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (requestCode == PHONEPE_REQUEST) {
     /*This callback indicates only about
          completion of flow. 
          Inform your server to make the transaction 
          status call to get the status. Update your app with the 
          success/failure status.*/
  • Inform your server about the completion of the transaction flow from your app.
  • Your server should make the Check Transaction Status API call to PhonePe server to check the transaction status(Even for RESULT_CANCELED).
  • Get the result and notify your app.
  • Based on the result inform the user about success or failure status of the transaction.

Server Side

1. Refer to Check Transaction Status API for the server to server call to get the transaction status.
The payment status can be Success, Failed, Pending or any of codes. For Pending, merchants should retry until the status changes to Success or Failed.

2.Refer to Refund API for the reconciliation.
There could be cases where amount gets deducted but you receive payment in Pending in the Check Transaction Status. For such cases either you can show order failed immediately and refund the amount when pending changes to success using Refund API or show order placed according to your use case.