Integration with the PayU OTP Parser SDK in 3 steps:

  1. Include the SDK in your application.

  2. Initiate the SDK.

  3. Override these callbacks

Include the SDK in your Application

Add below dependency in the application's build.gradle.

implementation 'in.payu:native-otp-reader:1.1.3'

Initiate the SDK

OtpParser otpParser = OtpParser.Companion.getInstance(ComponentActivity activity);
otpParser.startListening(OtpCallback otpCallback)
    OtpCallback otpCallback = new OtpCallback() {
           public void onOtpReceived(@NotNull String otp) {
             //When user gets the OTP  

           public void onUserDenied() {
//User user denied the permission

Override these Callbacks

You need to override these ActivityCompat callbacks and call OtpParser methods.

    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
             otpParser.onRequestPermissionsResult(requestCode, permissions, grantResults);
//calling OtpParser onRequestPermissionsResult
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
          otpParser.onActivityResult(requestCode, resultCode, data);
        //calling OtpParser onActivityResult



Last updated