From 65993f5a5ef20f10e77259f8781f3fc597c355ce Mon Sep 17 00:00:00 2001 From: Jonatan Rhodin Date: Tue, 28 Nov 2023 13:09:46 +0100 Subject: [PATCH] Try to verify purchases directly after a purchase has failed --- .../net/mullvad/mullvadvpn/viewmodel/AccountViewModel.kt | 5 +++-- .../net/mullvad/mullvadvpn/viewmodel/OutOfTimeViewModel.kt | 5 +++-- .../net/mullvad/mullvadvpn/viewmodel/WelcomeViewModel.kt | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/AccountViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/AccountViewModel.kt index 5f721674990a..439d0c3c3b1d 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/AccountViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/AccountViewModel.kt @@ -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. diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/OutOfTimeViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/OutOfTimeViewModel.kt index 675ca7ef9439..001469c26b4d 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/OutOfTimeViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/OutOfTimeViewModel.kt @@ -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. diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/WelcomeViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/WelcomeViewModel.kt index 566aa319819f..69e9764d4f21 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/WelcomeViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/WelcomeViewModel.kt @@ -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.