Skip to main content
Available in🇮🇳 India
With Razorpay OTP-Assist, your customers gain a faster and enhanced checkout experience with Razorpay OTP auto-read and auto-submit. The system automatically reads the OTP received, with your customer’s consent, and submits it. It prevents errors and the users do not need to navigate or interact with additional elements to complete verification, making the process seamless.

Prerequisites

  • Create a Razorpay account.
  • Generate the API keys from the Dashboard. To go live with the integration and start accepting real payments, generate Live Mode API Keys and replace them in the integration.
  • Integrate with Android Custom SDK.

Dependencies

Add the following line in your build.gradle(app-level) file in the dependencies block:
Dependencies

Integration Steps

1. Initialise RazorpayOtpAssist Object.
2. OTP Auto-Submission.
3. Override onActivityResultReceived.
4. Reset All Objects.

Step 1: Initialise RazorpayOtpAssist Object

In the S2S flow, since you have not integrated with any of Razorpay’s Checkout SDKs, you must create the RazorpayOtpAssist object.
activity : object Activity object within which the RazorpayOtpAssist object is created. This activity object displays the UI timer for the OTP submit cancellation. apiKey : string API Key ID generated from the Dashboard, used to ensure the feature is enabled.

Sample Code

Use the sample code given below:

Step 2: OTP Auto-Submission

You can use one of the options below based on your requirement:

WebView-based Payments

Since you load the URL provided by Razorpay in WebView for payment completion, this step allows us to auto-fill and auto-submit the OTP directly in WebView.
WebView : object Used to load the URL provided by Razorpay for payment completion.

Sample Code

Use the sample code given below:

Business OTP Page-based Payments

Razorpay offers Native OTP solutions where you can submit the OTP by using Razorpay APIs. To enable OTP auto-read and auto-submit of payments with this feature, we use a separate function that uses an interface to send the callback to you once the OTP is received.
OtpListener : object Acts as a callback, triggered when the OTP is received and parsed after the timer is displayed. onOtpReceived : Triggered when the message is received and the SDK extracts OTP. Values:
  • sender: Sender of the message (default: razorpay).
  • body: The entire message.
  • OTP: OTP pin extracted from the message.
onOtpConfirmed : Triggered when the timer for OTP Auto-submit is allowed/confirmed by the user. Values:
  • sender: Sender of the message (default: razorpay).
  • body: The entire message.
  • OTP: OTP pin extracted from the message.

Sample Code

Use the sample code given below:

Step 3: Override onActivityResultReceived

When the application does not use the RECEIVE_SMS permission, we use the SmsRetreiverClient API provided by Google, which enables the user to give a one-time consent for the application to read the incoming message. The user’s response for the one-time consent is passed to the activity’s onActivityResult function. Since the SDK cannot override this, we request you send this data to us.
requestCode : string Passed by RazorpayOtpAssist SDK when the startActivityForResult is triggered. resultCode : string Contains user-selected action. data : intent Contains data from the user-selected action.

Sample Code

Use the sample code given below:

Step 4: Reset All Objects

You can use this function to destroy all objects used by the RazorpayOtpAssist SDK to avoid leaks or when starting a new transaction with the same Razorpay object.

Sample Code

Use the code given below:
Reset