1. Integration Steps

Before you start with the integration, enable the payment methods that you want to offer to your customers from Dashboard > Settings > Payment methods. We enable Cards, UPI, and other payment methods by default, and we recommend that you enable other payment methods that are relevant to you.

Step 1: Create a PayU account

First, create a PayU account. See Register for a Merchant Account.

Step 2: Set Up build.gradle

Add the following dependency in your application’s build.gradle:

'in.payu:payu-custom-browser:7.11.12'

🚧

Watch Out!

If you are getting the following error: Default interface methods are only supported starting with Android N (--min-api 24): Landroidx/lifecycle/DefaultLifecycleObserver;onCreate(Landroidx/lifecycle/LifecycleOwner;)V

Add the following compileOptions on your app's build.gradle:

android {
 compileOptions {
        sourceCompatibility 1.9
        targetCompatibility 1.9
    }
    }

From version 7.4.0 onwards, it is mandatory to import UPI SDK dependency if you want to make payments through any of the following UPI options along with the changes mentioned in the Third-Party Payments Support section.

  • UPI Intent
  • Collect
  • Google Pay
  • PhonePe
<uses-permission android:name="android.permission.RECEIVE_SMS" />

👉

Tip

Merchants are advised to add this permission in the application’s AndroidManifest.xml to support OTP assist. In case your application supports a minimum SDK of less than 20, do these changes in your surl/furl.

Step 3: Check for Payment Availability

The CheckForPaymentAvailability function in CustomBrowser class. Checks for payment option type availability:

Input:
Activity : activity instance
PaymentOption : Payment Option type e.g.PaymentOption.SAMSUNGPAY,PaymentOption.PHONEPE
PayUCustomBrowserCallback : this class provide callbacks 
paymentOptionHash : Payment Related Details Hash
merchantKey : PayU Merchant Key
user_credentials : User credentials or use "default"
new CustomBrowser().checkForPaymentAvailability(Activity activity, PaymentOption paymentOption, PayUCustomBrowserCallback payUCustomBrowserCallback, String paymentOptionHash, String merchantKey, String user_credentials)

Step 2: Invoke CustomBrowser

To invoke CustomBrowser:

Create a basic object of CustomBrowserConfig similar to the following code snippet. For more information on configurations supported, refer to CustomBrowser Configurations.

CustomBrowserConfig customBrowserConfig = new CustomBrowserConfig(merchantKey,txnId);
customBrowserConfig.setPayuPostData(<Post Data>);
customBrowserConfig.setPostUrl(<Post Url>);
  1. Create an object of PayUCustomBrowserCallback.
  2. Call method addCustomBrowser() similar to the following code snippet:

Input:

  • Activity: activity instance.
  • CustomBrowserConfig: configuration object of the custom browser.
  • PayUCustomBrowserCallback: this class provides callbacks.
Input:
    Activity : activity instance
    CustomBrowserConfig : configuration object of the custom browser
    PayUCustomBrowserCallback : this class provide callbacks   
        
new CustomBrowser().addCustomBrowser( Activity activity, CustomBrowserConfig customBrowserConfig, PayUCustomBrowserCallback cbPayUCustomBrowserCallback)