-
Notifications
You must be signed in to change notification settings - Fork 673
[Link OTP in WalletsButton] Resend code logic #10929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…-otp-2-complete-verification # Conflicts: # paymentsheet/src/main/java/com/stripe/android/link/verification/DefaultLinkInlineInteractor.kt # paymentsheet/src/test/java/com/stripe/android/link/account/FakeLinkAccountManager.kt
Diffuse output:
APK
|
edd2759
to
8fe186a
Compare
…arlosmuvi/embedded-otp-3-resend # Conflicts: # paymentsheet/src/main/java/com/stripe/android/link/verification/DefaultLinkInlineInteractor.kt
…-otp-3-resend # Conflicts: # paymentsheet/src/main/java/com/stripe/android/link/verification/DefaultLinkInlineInteractor.kt # paymentsheet/src/test/java/com/stripe/android/link/verification/DefaultLinkInlineInteractorTest.kt
override val useInlineOtpInWalletButtons: Boolean | ||
get() { | ||
return FeatureFlags.showInlineOtpInWalletButtons.isEnabled && useNativeLink | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using LinkGate to also avoid showing the inline 2FA on non-native-link scenarios.
OTPSection( | ||
verificationState = verificationState, | ||
otpElement = otpElement | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no new code, just extracted to method + added the resend code button.
private fun update2FAState( | ||
block: (VerificationViewState) -> VerificationViewState, | ||
) { | ||
val currentState = state.value.verificationState | ||
if (currentState is Render2FA) { | ||
val newState = currentState.copy(viewState = block(currentState.viewState)) | ||
updateState { it.copy(verificationState = newState) } | ||
} else { | ||
logger.error( | ||
"Expected Render2FA state but found ${currentState::class.simpleName}. Resetting to RenderButton." | ||
) | ||
updateState { it.copy(verificationState = VerificationState.RenderButton) } | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracted this update logic to a method as it's reused on several places.
paymentsheet/src/main/java/com/stripe/android/link/ui/wallet/LinkInline2FASection.kt
Show resolved
Hide resolved
paymentsheet/src/main/java/com/stripe/android/link/ui/wallet/LinkInline2FASection.kt
Show resolved
Hide resolved
val currentState = state.value.verificationState | ||
if (currentState is Render2FA) { | ||
val linkAccountManager = currentState.linkAccountManager() | ||
val result = linkAccountManager.startVerification() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we show the loading indicator for a minimum amount of time, so that it's obvious that a new code is being sent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be good here:
- The loading shows while the verification API call takes place. We also show a toast when the verification completes.
- This is the pattern on other OTP instances
We can potentially ad a delay
after startVerification to hold the state change a bit, but feels wrong.
Attached a video of how it looks today on a real device.
loading_2fa.mp4
@@ -22,15 +28,18 @@ internal class WalletButtonsContent( | |||
@Composable | |||
fun Content() { | |||
val state by interactor.state.collectAsState() | |||
val context = LocalContext.current |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Let's move this into ResendCodeNotificationEffect
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
linkGate
to enable inline OTP instead of directly checking the fflag.record_2fa_resend.mp4
Testing