SDK Integration
Search…
⌃K

Integration

Integration with the PayU OTP Parser SDK in 3 steps:
  1. 1.
    Include the SDK in your application.
  2. 2.
    Initiate the SDK.
  3. 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

Java
Kotlin
OtpParser otpParser = OtpParser.Companion.getInstance(ComponentActivity activity);
otpParser.startListening(OtpCallback otpCallback)
OtpCallback otpCallback = new OtpCallback() {
@Override
public void onOtpReceived(@NotNull String otp) {
//When user gets the OTP
}
@Override
public void onUserDenied() {
//User user denied the permission
}
};
val otpParser = OtpParser.getInstance(activity: ComponentActivity)
otpParser?.startListening(otpCallback: OtpCallback)
val otpCallback= object: OtpCallback {
override fun onOtpReceived(otp: String) {
//When user gets the OTP
}
override fun onUserDenied() {
//User user denied the permission
}
}

Override these Callbacks

You need to override these ActivityCompat callbacks and call OtpParser methods.
Java
Kotlin
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
otpParser.onRequestPermissionsResult(requestCode, permissions, grantResults);
//calling OtpParser onRequestPermissionsResult
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
otpParser.onActivityResult(requestCode, resultCode, data);
//calling OtpParser onActivityResult
}
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
otpParser?.onRequestPermissionsResult(requestCode, permissions, grantResults)
//calling OtpParser onRequestPermissionsResult
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
otpParser?.onActivityResult(requestCode,resultCode,data)
//calling OtpParser onActivityResult
}