Getting Started

Add below url in root project's build.gradle.

allprojects {
    repositories {
        maven {
            url ""

Add below dependency in your application's build.gradle

implementation 'in.payu:phonepe-intent:1.6.1'


PayUPhonePeCallback provides following callback methods.

  • onPaymentOptionFailure (String payuResponse, String merchantResponse) - Calls when payment fails.

  • onPaymentOptionSuccess (String payuResponse, String merchantResponse) - Calls when payment succeeds.

  • onPaymentOptionInitialisationFailure (int errorCode,String description) - Called for PhonePe initialisation failure.

  • onPaymentOptionInitialisationSuccess (boolean result) - Callback when PhonePe is successfully initialised.

Following are error messages w.r.t. PhonePe initialisation failure.

- ErrorCode        : Description 

- 1                : MERCHANT_KEY_NOT_REGISTER_FOR_PHONEPE        // Merchant is not registered for 
                                                                         PhonePe with PayU 

Create an instance of PayUPhonePeCallback like below.

PayUPhonePeCallback payUPhonePeCallback = new PayUPhonePeCallback() {
                 public void onPaymentOptionFailure(String payuResponse, String merchantResponse) {
                   //Called when Payment gets failed.

                public void onPaymentOptionInitialisationSuccess(boolean result) {
                   // Merchants are advised to show PhonePe option on their UI after this callback is called.

               public void onPaymentOptionSuccess(String payuResponse, String merchantResponse) {
                //Called when Payment gets successful.

                public void onPaymentOptionInitialisationFailure (int errorCode, String description) {
                  //Callback thrown in case PhonePe initialisation fails.


Set up for Test/Sandbox Merchant

If you are using the SDK with a test merchant, please provide this metadata value to the manifest file else removed these lines below.

        android:value="" />

        android:value="" />


Check for PhonePe Availability

SDK provides method checkForPaymentAvailability to check if PhonePe payment is available or not on device.This method is called before showing PhonePe as a checkout option.

PhonePe.getInstance().checkForPaymentAvailability(Activity activity, PayUPhonePeCallback callback, String paymentOptionHash, String merchantKey, String user_credentials)

        PayUPhonePeCallback : the class to provide callbacks
        Activity : Activity
        paymentOptionHash : Payment Related Details hash
        merchantKey : PayU Merchant Key 
        user_credentials : Provide user credentials or use "default"

To generate PaymentOption Hash visit here.

Make Payment by PhonePe

After successful initialisation of PhonePe by calling checkForPaymentAvailability method call makePayment method to make payment.

PhonePe.getInstance().makePayment(PayUPhonePeCallback callback, Activity activity, String postData,boolean isUserCacheEnabled, View customDialogView);


PayUPhonePeCallback : the class to provide callbacks
Activity : activity instance
postData : PayU postdata
isUserCacheEnabled : To Enable/Disable User Cache
customDialogView : Provide your Custom Progress Dialog View(Optional)

To generate Payment Hash visit here.

Sample PostData


Last updated