Skip to content

Commit

Permalink
Try to verify purchases directly after a purchase has failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Dec 6, 2023
1 parent fdfd71b commit 9967b12
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ class AccountViewModel(
fun onClosePurchaseResultDialog(success: Boolean) {
// We are closing the dialog without any action, this can happen either if an error occurred
// during the purchase or the purchase ended successfully.
// In those cases we want to update the both the payment availability and the account
// expiry.
// If the payment was successful we want to update the account expiry. If not successful we
// should check payment availability and verify any purchases to handle potential errors.
if (success) {
updateAccountExpiry()
} else {
fetchPaymentAvailability()
verifyPurchases() // Attempt to verify again
}
viewModelScope.launch {
paymentUseCase.resetPurchaseResult() // So that we do not show the dialog again.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,14 @@ class OutOfTimeViewModel(
fun onClosePurchaseResultDialog(success: Boolean) {
// We are closing the dialog without any action, this can happen either if an error occurred
// during the purchase or the purchase ended successfully.
// In those cases we want to update the both the payment availability and the account
// expiry.
// If the payment was successful we want to update the account expiry. If not successful we
// should check payment availability and verify any purchases to handle potential errors.
if (success) {
updateAccountExpiry()
_uiSideEffect.tryEmit(UiSideEffect.OpenConnectScreen)
} else {
fetchPaymentAvailability()
verifyPurchases() // Attempt to verify again
}
viewModelScope.launch {
paymentUseCase.resetPurchaseResult() // So that we do not show the dialog again.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,14 @@ class WelcomeViewModel(
fun onClosePurchaseResultDialog(success: Boolean) {
// We are closing the dialog without any action, this can happen either if an error occurred
// during the purchase or the purchase ended successfully.
// In those cases we want to update the both the payment availability and the account
// expiry.
// If the payment was successful we want to update the account expiry. If not successful we
// should check payment availability and verify any purchases to handle potential errors.
if (success) {
updateAccountExpiry()
_uiSideEffect.tryEmit(UiSideEffect.OpenConnectScreen)
} else {
fetchPaymentAvailability()
verifyPurchases() // Attempt to verify again
}
viewModelScope.launch {
paymentUseCase.resetPurchaseResult() // So that we do not show the dialog again.
Expand Down

0 comments on commit 9967b12

Please sign in to comment.