Integration
Last updated
Was this helpful?
Last updated
Was this helpful?
Integration with the Native OTP Assist mobile SDK in 4 steps:
Include the SDK in your application.
Set up the payment hash and postdata
Initiate the payment.
Verify the transaction.
Watch the complete integration video of .
Compatibility
Refer this document:
Initialize the Native OTP Assist SDK by providing the PayUOtpAssistConfig object having postdata and reference to the PayUOtpAssistCallback to listen to the SDK events.
Make sure to add internet permission in your manifest file.
List of the callback function provided by PayUOtpAssistCallback class:
fun onPaymentSuccess(merchantResponse: String?, payUResponse: String?)- Called when payment succeeds. merchantResponse:
fun onPaymentFailure(merchantResponse: String?, payUResponse: String?)- Called when payment fails.
fun onError(errorCode: String?, errorMessage: String?)- Called when we got some error where,
errorCode : Error Code
errorMessage : Error Description
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");
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.