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

Was this helpful?

  1. Android
  2. Custom Browser
  3. Integration

CustomBrowserCallback

Describes how to create an object of PayUCustomBrowserCallback.

PayUCustomBrowserCallback provides following callback methods.

  • onPaymentFailure(String payuResult,String merchantResponse) - Calls when payment fails.

  • onPaymentSuccess(String payuResult,String merchantResponse) - Calls when payment succeeds.

  • onCBErrorReceived(int errorCode,String errormsg) - Called for any error in custom browser.

Following error messages are thrown in callback method.

Error code         : Errormsg 

1                : VENDOR_NOT_SUPPORTED   // Device Vendor is not supported
2                : DEVICE_NOT_SUPPORTED   // Device is not supported 
3                : APP_VERSION_MISMATCH   // Samsung Pay version doesn't meet requirements 
4                : COUNTRY_NOT_SUPPORTED  // Country of device origin is not supported by Samsung Pay 
5                : MERCHANT_KEY_NOT_REGISTER_FOR_SAMSUNG_PAY        // Merchant is not registered for 
                                                                         Samsung Pay with PayU 
                                                                         
6                : CONTEXT_NULL           // Context is null
7                : PAYMENT_ID_NOT_PRESENT // Check your postdata
1001             : DEVICE_NOT_SUPPORTED //In case enablewebflow is set to false for Tez payment and Tez app is not present on device following error would be thrown
1002             : MERCHANT_INFO_NOT_PRESENT // In case below error is received while processing payment please check your postData and hash
  • setCBProperties(WebView webview, Bank payUCustomBrowser) - Callback where webview setting is done.

  • onBackButton(AlertDialog.Builder alertDialogBuilder) - This callback provides alert dialog access, so customisation can be done to alert dialog.

  • onBackApprove() - Calls when ‘ok’ is selected from alert dialog.

  • onBackDismiss()- Calls when ‘cancel’ is selected from alert dialog.

  • onPaymentTerminate() - Called when payment is terminated.

  • isPaymentOptionAvailable(CustomBrowserResultData resultData):Merchant must check for Samsung Pay/PhonePe payment option availability on customer device before showing Samsung Pay/PhonePe/Google Pay/UPI as payment option.This callback is called in response of checkForPaymentAvailability method present in CustomBrowser.Merchant can use value of resultData object like below.

resultData.getPaymentOption() - Gives PaymentOption i.e. SamsungPay/PhonePe/Google Pay/UPI.
resultData.isPaymentOptionAvailable() - Boolean whether Payment via selected PaymentOption is possible.
resultData.getSamsungPayVpa() - Gives SamsungPay Vpa associated with device.
resultData.getErrorMessage() - Gives error message in case PaymentOption is not available.
  • onVpaEntered(String vpa, PackageListDialogFragment packageListDialogFragment)(Available since version 7.3.0) - Merchant must override this function and provide verifyVpaHash in case they want payment via UPI Collect flow.

packageListDialogFragment.verifyVpa(verifyVpaHash);

Sample code for PayUCustomBrowserCallback:

PayUCustomBrowserCallback payUCustomBrowserCallback = new PayUCustomBrowserCallback() {
                @Override
                public void onPaymentFailure(String payuResponse,String merchantResponse) {
                    Intent intent = new Intent();
                    intent.putExtra(getString(R.string.cb_result), merchantResponse);
                    intent.putExtra(getString(R.string.cb_payu_response), payuResponse);
                    setResult(Activity.RESULT_CANCELED, intent);
                    finish();
                }

                @Override
                public void onPaymentTerminate() {
                }

                @Override
                public void onPaymentSuccess(String payuResponse,String merchantResponse) {
                    Intent intent = new Intent();
                    intent.putExtra(getString(R.string.cb_result), merchantResponse);
                    intent.putExtra(getString(R.string.cb_payu_response), payuResponse);
                    setResult(Activity.RESULT_OK, intent);
                    finish();
                }

                @Override
                public void onCBErrorReceived(int code, String errormsg) {
                }



                @Override
                public void setCBProperties(WebView webview, Bank payUCustomBrowser) {
                    webview.setWebChromeClient(new PayUWebChromeClient(payUCustomBrowser));
                    webview.setWebViewClient(new PayUWebViewClient(payUCustomBrowser,merchantKey));
                    webview.postUrl(url, payuConfig.getData().getBytes());
                   //comment above line if you are using CB is 6.1 or above
                }

                @Override
                public void onBackApprove() {
                    PaymentsActivity.this.finish();
                }

                @Override
                public void onBackDismiss() {
                    super.onBackDismiss();
                }

                @Override
                public void onBackButton(AlertDialog.Builder alertDialogBuilder) {
                    super.onBackButton(alertDialogBuilder);
                }

                //Below method is available since version 7.1.3+
                @Override
                public void isPaymentOptionAvailable(CustomBrowserResultData resultData) {
                    Toast.makeText(PaymentsActivity.this, "isPaymentOptionAvailable"+resultData.getSamsungPayVpa() 
                     , Toast.LENGTH_SHORT).show();
                }

                //Below method is available since version 7.3.0+
                @Override
                public void onVpaEntered(String vpa, PackageListDialogFragment packageListDialogFragment) {
                    //Calculate validateVpahash using vpa and provide to verifyVpa method of 
                    PackageListDialogFragment like below.
                    packageListDialogFragment.verifyVpa(calculateHash(input));
                }

            };
PreviousCustomBrowser ConfigNextSupporting below Lollipop Versions

Last updated 5 years ago

Was this helpful?

To generate verifyVpaHash use command as validateVPA and var1 as Vpa address and calculate hash as described .

here