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
  • Include the SDK in your app build.gradle
  • Generate Payment Hash
  • Payment Post Data
  • Initiate Payment
  • Callbacks
  • Error codes and their description.
  • Verify the transaction through Webhooks or polling
  • Implementation of PayU WebHook

Was this helpful?

  1. Android
  2. Native OTP Assist

Integration

PreviousNative OTP AssistNextCustomization

Last updated 3 years ago

Was this helpful?

Integration with the Native OTP Assist mobile SDK in 4 steps:

  1. Include the SDK in your application.

  2. Set up the payment hash and postdata

  3. Initiate the payment.

  4. Verify the transaction.

Watch the complete integration video of .

Include the SDK in your app build.gradle

implementation 'in.payu:native-otp-assist:1.2.1' 

Compatibility

Min SDK Version: 21

Compile SDK Version: 30

Generate Payment Hash

Refer this document:

Every transaction (payment or non-payment) needs a hash by the merchant before sending the transaction details to PayU. This is required for PayU to validate the authenticity of the transaction. This should be done on your server.

Payment Post Data

Initiate Payment

Initialize the Native OTP Assist SDK by providing the PayUOtpAssistConfig object having postdata and reference to the PayUOtpAssistCallback to listen to the SDK events.

PayUOtpAssistConfig payUOtpAssistConfig = PayUOtpAssistConfig();
payUOtpAssistConfig.setPostData("POST_DATA_FOR_TRANSACTION");


PayUOtpAssist.open(
    Context context, 
    PayUOtpAssistCallback payUOtpAssistCallback, 
    PayUOtpAssistConfig payUOtpAssistConfig)
val payUOtpAssistConfig = PayUOtpAssistConfig()
payUOtpAssistConfig.postData = "POST_DATA_FOR_TRANSACTION"
PayUOtpAssist.open(
    context: Context, 
    payUOtpAssistCallback: PayUOtpAssistCallback,  
    payUOtpAssistConfig: PayUOtpAssistConfig) 

Make sure to add internet permission in your manifest file.


<uses-permission android:name="android.permission.INTERNET" />

Callbacks

List of the callback function provided by PayUOtpAssistCallback class:

  1. fun onPaymentSuccess(merchantResponse: String?, payUResponse: String?)- Called when payment succeeds. merchantResponse:

  2. fun onPaymentFailure(merchantResponse: String?, payUResponse: String?)- Called when payment fails.

  3. fun onError(errorCode: String?, errorMessage: String?)- Called when we got some error where,

    • errorCode : Error Code

    • errorMessage : Error Description

 boolean shouldHandleFallback(PayUAcsRequest payUAcsRequest){
 
 CustomBrowserConfig customBrowserConfig = new CustomBrowserConfig(merchantKey, txnId);
   
  //Set the issuerUrl and issuerPostData to open in WebView for otp assist redirection to bank page
  if (payUAcsRequest.getIssuerUrl()!=null && payUAcsRequest.getIssuerPostData()!=null) {
    customBrowserConfig.setPostURL(payUAcsRequest.getIssuerUrl());
    customBrowserConfig.setPayuPostData(payUAcsRequest.getIssuerPostData())

}else if (payUAcsRequest.getAcsTemplate()!=null){
    customBrowserConfig.setHtmlData(payUAcsRequest.getAcsTemplate());
}else {
    //Set the first url to open in WebView
    customBrowserConfig.setPostURL(url);
    customBrowserConfig.setPayuPostData(payuConfig.getData);
}
return false;
}
fun shouldHandleFallback(payUAcsRequest: PayUAcsRequest) : Boolean {

val customBrowserConfig = CustomBrowserConfig(merchantKey, txnId)
   
  //Set the issuerUrl and issuerPostData to open in WebView for otp assist redirection to bank page
  if (!payUAcsRequest?.issuerUrl.isNullOrEmpty() && !payUAcsRequest?.issuerPostData.isNullOrEmpty()) {
    customBrowserConfig.postURL = payUAcsRequest?.issuerUrl
    customBrowserConfig.payuPostData = payUAcsRequest?.issuerPostData

}else if (!payUAcsRequest?.acsTemplate.isNullOrEmpty()){
    customBrowserConfig.htmlData = payUAcsRequest?.acsTemplate
}else {
    //Set the first url to open in WebView
    customBrowserConfig.postURL = url
    customBrowserConfig.payuPostData = payuConfig.data
}
return false
}

You will get PayUAcsRequest on shouldHandleFallback() callback. whether you will get issuerUrl and issuerPostData or acsTemplate on PayUAcsRequest acsTemplate is the Html string that you need to load to the Webview.

PayUAcsRequest field

Description

issuerUrl

It's the Bank/ACS page Url.

issuerPostData

You need to load issuerUrl to the Webview

along with this issuerPostdata string.

Ex: webView.postUrl(issuerUrl, issuerPostData.toByteArray())

acsTemplate

If issuerUrl is empty, you need to load acsTemplate to the Webview.

Ex: webView.loadData(acsTemplate, "text/html", "UTF-8");

Error codes and their description.

   - ErrorCode: Description

   - 1001     : No Internet
       
   - 1002     : Network timeout, please verify with your server.
   
   - 1003     : Gateway timeout, please verify with your server.
   
   - 1004     : User cancelled it, please verify with your server.
      
   - 1005     : Something went wrong , please verify with your server.
   
   - 1006     : Bank page timed out, please verify with your server.

Verify the transaction through Webhooks or polling

Once you get the response from SDK, make sure to confirm it with the PayU server. It is recommended to implement the PayU Webhook or backend verify call from your backend.

Implementation of PayU WebHook

Webhook is a server-to-server callback. Once this feature is activated for merchants, PayU would send an S2S response, in addition to SDK callback, to the merchant. It is recommended for the merchant to process the transaction order status – based upon the S2S response and not via the Browser Redirection/SDK callback response to ensure optimum translation outcomes.

Use library to generate payment postdata.

We fetch the OTP via RECEIVE_SMS if RECEIVE_SMS permission granted, otherwise, fetch the OTP using Google Consent API. To understand the flow, refer to this .

fun shouldHandleFallback(payUAcsRequest: PayUAcsRequest) : Boolean - It's an optional callback, override when you want to handle the Bank page redirection flow. You just need to change the return value to false. You can also open in fallback scenarios. Below is the code snippet to open the CustomBrowser.

Refer to this , for Webhook implementation.

There is another option to through polling, the transaction status after the SDK callback from your backend.

Core Sdk
page
CustomeBrowser
document
verify payment
PayU OTP Assist
Generate Hash