Activate binding with OTP
Last updated
Was this helpful?
Was this helpful?
@Override
public void onIssuerAuthenticationRequired(PendingBindingSession pendingBindingSession) {
// Submit OTP_SMS ID&V Method
for (IDVMethod idvMethod : pendingBindingSession.getIdvMethods()) {
if (idvMethod.getType().equals(IDVType.OTP_SMS)) {
pendingBindingSession.submitIdvMethod(idvMethod);
}
}
}
@Override
public void onIssuerAuthenticationReady(PendingBindingSession pendingBindingSession,
@Nullable OtpActivationStatus status) {
}
@Override
public void onError(TMGClientException exception) {
// Check if there's any error
int errorCode = exception.getErrorCode();
int errorMessage = exception.getMessage();
}guard let idvSession = VisaService.shared.idvSession else {
// no idv session
return
}
// 1. Display list of idv methods
do {
let idvMethods = try idvSession.idvMethods
let selectedIdvMethod = idvMethods[0] // user select an OTP idv method (OTP_SMS)
// 2. submit the idv method
idvSession.selectIDVMethod(selectedIdvMethod) { (result) in
if let otpActivationStatus = result {
let maxOtpVerificationAllowed = otpActivationStatus.maxOTPVerificationAllowed
let maxOtpRequestsAllowed = otpActivationStatus.maxOTPRequestsAllowed
let otpExpiration = otpActivationStatus.otpExpiration
// 3. Display page to enter OTP
}
}
} catch let error {
// handle error
}
// 4. Failure in step 2, selectIDVMethod, will be handled in completionHandler.
VisaService.shared.completionHandler = { (session, error) in
// 5. Check if it is a selectIDVMethod error.
if let session = session,
let error = error,
error.description == TMGError.invalidIdvMethod.description {
VisaService.shared.idvSession = session
// 6. Retry the IDV flow.
}
}@Override
public void onIssuerAuthenticationReady(IDVSession idvSession,
@Nullable OtpActivationStatus status) {
// Activate binding
String otp;
idvSession.activateBinding(otp);
}
@Override
public void onIssuerAuthenticationError(@Nullable IDVSession idvSession,
TMGClientException tmgClientException) {
// Check the error or retry
}// 1. OTP value from user input
let otp = ""
guard let idvSession = VisaService.shared.idvSession else {
// no idv session
return
}
// 2. Call activate
idvSession.activateBinding(withValue: otp)
VisaService.shared.completionHandler = { (session, error) in
// 2. Binding successful
if error == nil {
} else if let error = error,
let session = session,
error.description == TMGError.serverErrorWrongOTP.description {
VisaService.shared.idvSession = session
// 3. Retry OTP input and display error message
}
}