SDK Integration
  • Getting Started
  • Onboarding Requirements
  • Hash Generation
  • Test Merchant list
  • Android
    • Android SDK Offering
    • PayUCheckoutPro
      • Integration
      • Build the Payment Params
        • Additional Params
      • Hash Generation
      • Set up the payment hashes
      • Initiate the Payment
      • Customized Integration
        • Set Webview Properties
        • SDK Configuration
        • Additional Offerings
      • Offers Integration
      • Convenience Fee Integration
      • Custom Note Integration
      • MCP Integration
    • Core
      • Supported Payment Types
      • TPV Integration
      • Merchant Web Services
        • Getting Enabled Payment Options
        • GetCheckoutDetails API
        • Lookup API
    • Custom Browser
      • Integration
        • CustomBrowser Config
        • CustomBrowserCallback
        • Supporting below Lollipop Versions
        • Third-Party Payments Support
      • Sample App
      • Change Logs
    • Native OTP Assist
      • Integration
      • Customization
      • Change Logs
    • UPI
      • Integration
      • TPV Integration in UPI
      • Sample App
      • Change Logs
    • Google Pay™
      • Integration
      • Sample App
    • PhonePe
      • Integration
      • Sample App
      • Change Logs
    • OlaMoney
    • PayU OTP Parser
      • Integration
    • FAQ Android
  • iOS
    • PayUCheckoutPro
      • Integration
      • Advanced Integration
      • Set up the payment hashes
      • Convenience Fee Integration
      • MCP Integration
      • Custom Note Integration
    • Core
      • POD Integration
      • Seamless
      • Web Services
      • Objective C-Non-Seamless
      • Standing Instructions
      • TPV Integration
      • Sample App
    • Custom Browser
      • Sample App
    • OlaMoney
    • Native OTP Assist
      • Integration
      • Customization
    • UPI
      • Integration
      • Sample App
    • PayUParams
      • PayUSIParams
      • PayUBeneficiaryParams
  • Releasing to Apple
  • React-Native
    • PayUCheckoutPro
      • Integration
      • Set up the payment hashes
      • Advanced Integration
      • Change Logs
    • Core
    • Non-Seamless Wrapper
    • TPV (beta)
      • Integration
  • FAQ iOS
Powered by GitBook
On this page
  • Getting Started
  • Callbacks
  • Set up for Test/Sandbox Merchant
  • Check for PhonePe Availability
  • Make Payment by PhonePe

Was this helpful?

  1. Android
  2. PhonePe

Integration

Getting Started

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

allprojects {
    repositories {
        maven {
            url "https://phonepe.mycloudrepo.io/public/repositories/phonepe-intentsdk-android"
        }
    }
}

Add below dependency in your application's build.gradle

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

Callbacks

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() {
                @Override
                 public void onPaymentOptionFailure(String payuResponse, String merchantResponse) {
                   //Called when Payment gets failed.
                 }

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

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

                @Override
                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.

    <application
    <meta-data
        android:name="payu_web_service_url"
        android:value="https://test.payu.in" />

    <meta-data
        android:name="payu_post_url"
        android:value="https://test.payu.in" />

</application>

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)

where
        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"

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);

where

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)

Sample PostData

txnid=1524122818080&productinfo=product_info&user_credentials=default&key=*****&surl=**SUCCESS_URL**&furl=**FAILURE_URL&firstname=firstname&email=test@gmail.com&amount=10&udf1=udf1&udf2=udf2&udf3=udf3&udf4=udf4&udf5=udf5&pg=CASH&bankcode=PPINTENT&hash=***PAYMENT_HASH***
PreviousPhonePeNextChange Logs

Last updated 3 years ago

Was this helpful?

To generate PaymentOption Hash visit .

To generate Payment Hash visit .

here
here