summaryrefslogtreecommitdiffhomepage
path: root/android/app/src
diff options
context:
space:
mode:
authorJonatan Rhodin <jonatan.rhodin@mullvad.net>2023-11-28 13:09:46 +0100
committerJonatan Rhodin <jonatan.rhodin@mullvad.net>2023-12-06 23:35:00 +0100
commit9967b12362e296f66ce44f75f0f02a77934cbae3 (patch)
tree306ef7b7d0cc1f37b85fb158834d31bddda334c8 /android/app/src
parentfdfd71bbd099645bd1cd99bb9b754ea6cc48800a (diff)
downloadmullvadvpn-9967b12362e296f66ce44f75f0f02a77934cbae3.tar.xz
mullvadvpn-9967b12362e296f66ce44f75f0f02a77934cbae3.zip
Try to verify purchases directly after a purchase has failed
Diffstat (limited to 'android/app/src')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/AccountViewModel.kt5
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/OutOfTimeViewModel.kt5
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/WelcomeViewModel.kt5
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 5f72167499..439d0c3c3b 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 675ca7ef94..001469c26b 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 566aa31981..69e9764d4f 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.