-
Notifications
You must be signed in to change notification settings - Fork 662
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
Link Cvc & Expiry recollection VM #9882
Conversation
@@ -23,7 +30,11 @@ internal data class WalletUiState( | |||
val isExpired = card?.isExpired ?: false | |||
val requiresCvcRecollection = card?.cvcCheck?.requiresRecollection ?: false | |||
|
|||
val disableButton = isExpired || requiresCvcRecollection | |||
val isMissingExpiryDateInput = (expiryDateInput.isComplete && cvcInput.isComplete).not() |
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.
The isMissingExpiryDateInput
check appears to have an unintended dependency on cvcInput.isComplete
. For validating expiry date input, the condition should be simplified to expiryDateInput.isComplete.not()
since the CVC completion state is handled separately by isMissingCvcInput
.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
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.
expired cards requires both updated expiryDate and cvc
Diffuse output:
APK
DEX
|
paymentsheet/src/main/java/com/stripe/android/link/ui/wallet/WalletViewModel.kt
Outdated
Show resolved
Hide resolved
69e29e5
to
7026722
Compare
is LinkConfirmationResult.Failed -> { | ||
_uiState.update { | ||
it.copy(errorMessage = result.message) | ||
} | ||
} |
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.
The isProcessing
state should be set to false
when handling the error case, otherwise the UI will remain in a loading state after the error occurs. Consider updating the copy()
call:
it.copy(
errorMessage = result.message,
isProcessing = false
)
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
64aa78d
to
76e4129
Compare
when (result) { | ||
LinkConfirmationResult.Canceled -> Unit |
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.
The isProcessing
state should be reset when the confirmation is canceled. Consider updating the case to:
LinkConfirmationResult.Canceled -> _uiState.update { it.copy(isProcessing = false) }
This maintains consistency with the error handling case and prevents the UI from being stuck in a processing state.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
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.
the test suggestions are both optional -- just want to address the CardDetailsElement question before approving!
payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CardDetailsElement.kt
Outdated
Show resolved
Hide resolved
paymentsheet/src/test/java/com/stripe/android/link/ui/wallet/WalletUiStateTest.kt
Show resolved
Hide resolved
@Test | ||
fun `performPaymentConfirmation skips update for non-expired card`() = runTest(dispatcher) { | ||
val validCard = TestFactory.CONSUMER_PAYMENT_DETAILS_CARD.copy(expiryYear = 2099) | ||
val linkAccountManager = object : FakeLinkAccountManager() { |
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.
wdyt of creating a shared FakeLinkAccountManager and re-using it across tests? A lot of these tests seem to be quite long and are creating their own very similar fakes. I think we could simplify + increase code re-use by sharing a fake
Add confirmation block Update unit tests Lint Update WalletViewModelTest.kt Update FakeLinkConfirmationHandler.kt
f6dc691
to
b90d319
Compare
performPaymentDetailsUpdate(selectedPaymentDetails).fold( | ||
onSuccess = { result -> | ||
val updatedPaymentDetails = result.paymentDetails.single { | ||
it.id == selectedPaymentDetails.id | ||
} | ||
performPaymentConfirmation(updatedPaymentDetails) | ||
}, | ||
onFailure = { error -> | ||
_uiState.update { | ||
it.copy( | ||
alertMessage = error.stripeErrorMessage(), | ||
isProcessing = false | ||
) | ||
} | ||
} | ||
) |
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.
The onFailure
block needs to return early to prevent execution from continuing into payment confirmation. Add return
after updating the UI state to ensure the error case fully terminates the flow.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
Summary
Testing
Screenshots (UI not part of this PR)
Screen.Recording.2025-01-09.at.1.50.06.AM.mov
Changelog