Custom Browser- Android – PayU Documentation

Custom Browser Android


1. A mobile app to accept payments.

Steps Involved


On a broader level, you need to complete the following steps to integrate Custom Browser:

  1. Importing the .aar file or add dependency in gradle.
  2. Add CB as a module and make sure the app has a dependency on CB.
  3. Grant a permission.
  4. Add a code snippet to launch the custom browser after the “Pay Now” has been hit by user.
  5. Set values to the various configurations and callbacks.

The first step towards integrating custom browser would be to import the .aar files or adding a dependency in gradle.

Importing the .aar file


In order to import the .aar file, importing Custom Browser as a module and creating an app dependent on Custom Browser, please follow the following steps:


Step 1

Step 1


Step 2

Step 2


Step 3

Step 3

Step 4

Step 4

Step 5

Step 5

Adding dependency in gradle

You need to add to following dependency

Grant a permission

You will have to grant the following permission so as to auto read the OTP SMS that a bank sends to a customer.

Launching default Custom Browser


Custom browser will function after the customer has clicked “Pay Now”. Please follow following steps to integrate with CB

The lines of code that needs to be replaced (in case of using Payubiz SDK as PG):

The lines of code that will replace the above mentioned intent to make way for Custom Browser to appear:

Sample code (complete) for Net Banking flow where Custom browser will be launched (in case of using Payubiz SDK as PG):

CB configurations


The above mentioned code will launch a custom browser with the default values of the configurations but these are configurable, which you can enable/disable at your end. This provides a lot of control to the kind of payment experience you want your customers to have once a user clicks “Pay Now” and is on the Bank Page for second factor authentication.

You can start making changes to configuration of CB by initializing CustomBrowserConfig which takes merchantID and transaction ID set input params in constructor.

CustomBrowserConfig provide merchant various method to customize the CB  according to the requirement of the merchant.

Parameter Description Example
key Prod merchant key as provided by PayU
txnid’ Reference ID/ order ID as generated at your end.

Once you have CustomBrowserConfig object, various configuration can be set as using mentioned methods available in CustomBrowserConfig.

Configuration Description Implications: Enabled Implications: Disabled Default values
view_port This configuration is set to true for netbanking, so that custom browser give better support to net banking. Bank pages for net Banking are taken care by CB and shown in optimised manner


Netbanking Bank pages are shown as default manner.


auto_select_otp Automatically select the OTP option, if available, as the payment option and start reading the OTP. Auto select the OTP as the payment option


No selection of payment option is done


auto_approve After reading the bank’s SMS about OTP, this configuration automatically approves the OTP as well without conforming from customer. OTP will be auto approved.


OTP will not be auto approved.


back_button In the middle of a transaction, if a customer presses a back button, a dialogue box appears asking the user about confirmation on cancellation of transaction. This configuration controls the occurrence of dialogue box. The dialogue box will appear.


The dialogue box will never appear and transaction will be cancelled.


magic_retry This configuration prevents all the transactions getting dropped due to bank pages not loading up due to network drops. It stores the last URL of the transaction and allows the customer to continue the transaction from where he left it. Allows magic_retry


Does not allow magic retry.


merchant sms permission For Android M, If merchant want to take sms receive permission from user, set it true else false Dialog will appear, which ask for sms receiving permission when needed.


No permission dialog will appear on screen during transaction.



CB callbacks


Apart from configuring various features, our Custom Browser provides various callbacks as well so as to provide customizations in UI of Custom browser, and to redirect the customer back to the merchant app depending upon the status of transaction.


Callback Description Code
Success response Is called after a successful transaction.

Provide merchant payu response (response provided by payu) and merchant response (merchant wants to pass data through surl)

where, merchant will receive the payuresponse for all transaction and merchanyt response depends on surl provided by merchant

public void onPaymentSuccess(String payuResult,String merchantResponse){}
failure response Is called after the failed transaction.

Provides merchant payu response and merchant response.

Where, merchant will receive the payuresponse for all the transaction and merchant response depending on the furl provided by merchant

public void onPaymentFailure(String payuResult,String merchantResponse){}
CB error received Is called when some error occur in CB. public void onCBErrorReceived(int code,String errormsg){}
set CB properties Abstract method, compulsory to override.
Provides merchant webview object and bank object.
Merchant load PG url and post params in webview inside this method.
public abstract void setCBProperties(WebView webview,Bank payUCustomBrowser);
Back button Is called on back button press. Merchant get the alertDialog object so that if customisation is required by merchant, he can do it public void onBackButton(AlertDialog.Builder alertDialogBuilder){}
Back approve Is called when Back button is approved. So that merchant can handle the dismiss event of the alert and do the needful public void onBackApprove(){}
Back dismiss Is called when backButton is dismiss. So that merchant can handle the dismiss event of the alert and do the needful public void onBackDismiss(){}
Initialize magic retry Merchant can add on url on which he want to see the magic retry(magic retry supporting url). To increase the scope of magic retry and improving the success rate, public void initializeMagicRetry(Bank payUCustomBrowser,WebView webview,MagicRetryFragment magicRetryFragment){}

Sample code after setting all the configurations and overriding all the callbacks:

Sample code of NB flow after all the changes have been made in CB (in case of using Payubiz SDK as PG)

Still have questions?

Our team will be more than happy to help you. You can reach out to them at