Integration
This section describes how to integrate CustomBrowser in your app module.

Getting Started

Add below dependency in your application's build.gradle.
1
'in.payu:payu-custom-browser:7.10.0'
Copied!
If you are getting this error, Default interface methods are only supported starting with Android N (--min-api 24): Landroidx/lifecycle/DefaultLifecycleObserver;onCreate(Landroidx/lifecycle/LifecycleOwner;)V Add compileOptions on Apps Gradle,
1
android {
2
compileOptions {
3
sourceCompatibility 1.8
4
targetCompatibility 1.8
5
}
6
}
Copied!
From version 7.4.0 onwards it is mandatory to import UPI sdk dependency in case you want to make payments via any UPI option viz. : UPI Intent, Collect, Google Pay, PhonePe ,SamsungPay along with the changes mentioned here.
Merchants are advised to add below permission in application's AndroidManifest.xml to support OTP assist.
1
<uses-permission android:name="android.permission.RECEIVE_SMS" />
Copied!
In case your application's supports min sdk less than 20 then kindly do these changes in your surl/furl.

CheckForPaymentAvailability

Function in CustomBrowser class. Checks for payment option type availability.
1
Input:
2
Activity : activity instance
3
PaymentOption : Payment Option type e.g.PaymentOption.SAMSUNGPAY,PaymentOption.PHONEPE
4
PayUCustomBrowserCallback : this class provide callbacks
5
paymentOptionHash : Payment Related Details Hash
6
merchantKey : PayU Merchant Key
7
user_credentials : User credentials or use "default"
8
9
//Code Sample
10
11
new CustomBrowser().checkForPaymentAvailability(Activity activity, PaymentOption paymentOption, PayUCustomBrowserCallback payUCustomBrowserCallback, String paymentOptionHash, String merchantKey, String user_credentials)
Copied!

Invoking CustomBrowser

Invoking Custombrowser is just a 3 step procedure.
    1.
    Create a basic object of CustomBrowserConfig like below(For more Configurations supported visit here):
Post Url can be any of the following:
1
CustomBrowserConfig customBrowserConfig = new CustomBrowserConfig(merchantKey,txnId);
2
customBrowserConfig.setPayuPostData(<Post Data>);
3
customBrowserConfig.setPostUrl(<Post Url>);
Copied!
2. Create an object of PayUCustomBrowserCallback.
3. Call method addCustomBrowser() like below:
1
Input:
2
Activity : activity instance
3
CustomBrowserConfig : configuration object of the custom browser
4
PayUCustomBrowserCallback : this class provide callbacks
5
6
//Code Sample
7
8
new CustomBrowser().addCustomBrowser( Activity activity, CustomBrowserConfig customBrowserConfig, PayUCustomBrowserCallback cbPayUCustomBrowserCallback)
Copied!
Last modified 2mo ago