Integration
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.
1
implementation 'in.payu:native-otp-reader:1.1.3'
Copied!

Initiate the SDK

Java
Kotlin
1
OtpParser otpParser = OtpParser.Companion.getInstance(ComponentActivity activity);
2
otpParser.startListening(OtpCallback otpCallback)
3
4
OtpCallback otpCallback = new OtpCallback() {
5
@Override
6
public void onOtpReceived(@NotNull String otp) {
7
//When user gets the OTP
8
}
9
10
@Override
11
public void onUserDenied() {
12
//User user denied the permission
13
}
14
};
Copied!
1
val otpParser = OtpParser.getInstance(activity: ComponentActivity)
2
otpParser?.startListening(otpCallback: OtpCallback)
3
4
val otpCallback= object: OtpCallback {
5
override fun onOtpReceived(otp: String) {
6
//When user gets the OTP
7
}
8
9
override fun onUserDenied() {
10
//User user denied the permission
11
}
12
13
}
14
Copied!

Override these Callbacks

You need to override these ActivityCompat callbacks and call OtpParser methods.
Java
Kotlin
1
@Override
2
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
3
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
4
5
otpParser.onRequestPermissionsResult(requestCode, permissions, grantResults);
6
//calling OtpParser onRequestPermissionsResult
7
}
8
9
@Override
10
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
11
super.onActivityResult(requestCode, resultCode, data);
12
13
otpParser.onActivityResult(requestCode, resultCode, data);
14
//calling OtpParser onActivityResult
15
16
}
17
18
Copied!
1
override fun onRequestPermissionsResult(
2
requestCode: Int,
3
permissions: Array<out String>,
4
grantResults: IntArray
5
) {
6
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
7
8
otpParser?.onRequestPermissionsResult(requestCode, permissions, grantResults)
9
//calling OtpParser onRequestPermissionsResult
10
}
11
12
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
13
super.onActivityResult(requestCode, resultCode, data)
14
15
otpParser?.onActivityResult(requestCode,resultCode,data)
16
//calling OtpParser onActivityResult
17
}
18
Copied!
Last modified 1mo ago