diff --git a/app/src/main/java/org/thoughtcrime/securesms/badges/self/expired/MonthlyDonationCanceledViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/badges/self/expired/MonthlyDonationCanceledViewModel.kt index 7cdec89ad2..8068d15848 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/badges/self/expired/MonthlyDonationCanceledViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/badges/self/expired/MonthlyDonationCanceledViewModel.kt @@ -13,6 +13,7 @@ import androidx.lifecycle.viewModelScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import org.signal.donations.InAppPaymentType import org.signal.donations.StripeDeclineCode import org.signal.donations.StripeFailureCode import org.thoughtcrime.securesms.badges.Badges @@ -71,7 +72,7 @@ class MonthlyDonationCanceledViewModel( return if (declineCode.isKnown()) { declineCode.mapToErrorStringResource() } else if (failureCode.isKnown) { - failureCode.mapToErrorStringResource() + failureCode.mapToErrorStringResource(InAppPaymentType.RECURRING_DONATION) } else { declineCode.mapToErrorStringResource() } diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/errors/DonationErrorParams.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/errors/DonationErrorParams.kt index 4d428e7e27..765871af9d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/errors/DonationErrorParams.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/errors/DonationErrorParams.kt @@ -99,8 +99,8 @@ class DonationErrorParams private constructor( ) else -> DonationErrorParams( - title = R.string.DonationsErrors__couldnt_add_badge, - message = R.string.DonationsErrors__your_badge_could_not, + title = R.string.DonationsErrors__couldnt_add_badge, // TODO [message-backups] -- This will need a backups-specific string + message = R.string.DonationsErrors__your_badge_could_not, // TODO [message-backups] -- This will need a backups-specific string positiveAction = callback.onContactSupport(context), negativeAction = null ) @@ -252,7 +252,7 @@ class DonationErrorParams private constructor( } ) - StripeDeclineCode.Code.ISSUER_NOT_AVAILABLE -> getLearnMoreParams(context, callback, inAppPaymentType, R.string.DeclineCode__try_completing_the_payment_again) + StripeDeclineCode.Code.ISSUER_NOT_AVAILABLE -> getLearnMoreParams(context, callback, inAppPaymentType, InAppPaymentErrorStrings.getStripeIssuerNotAvailableErrorMessage(inAppPaymentType)) StripeDeclineCode.Code.PROCESSING_ERROR -> getLearnMoreParams(context, callback, inAppPaymentType, R.string.DeclineCode__try_again) StripeDeclineCode.Code.REENTER_TRANSACTION -> getLearnMoreParams(context, callback, inAppPaymentType, R.string.DeclineCode__try_again) else -> getLearnMoreParams(context, callback, inAppPaymentType, R.string.DeclineCode__try_another_payment_method_or_contact_your_bank) @@ -275,7 +275,7 @@ class DonationErrorParams private constructor( return when (failureCode) { is StripeFailureCode.Known -> { - val errorText = failureCode.mapToErrorStringResource() + val errorText = failureCode.mapToErrorStringResource(inAppPaymentType) when (failureCode.code) { StripeFailureCode.Code.REFER_TO_CUSTOMER -> getTryBankTransferAgainParams(context, callback, inAppPaymentType, errorText) StripeFailureCode.Code.INSUFFICIENT_FUNDS -> getLearnMoreParams(context, callback, inAppPaymentType, errorText) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/errors/DonationErrors.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/errors/DonationErrors.kt index 0c1137cc66..47e013d37b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/errors/DonationErrors.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/errors/DonationErrors.kt @@ -1,22 +1,23 @@ package org.thoughtcrime.securesms.components.settings.app.subscription.errors import androidx.annotation.StringRes +import org.signal.donations.InAppPaymentType import org.signal.donations.StripeDeclineCode import org.signal.donations.StripeFailureCode import org.thoughtcrime.securesms.R @StringRes -fun StripeFailureCode.mapToErrorStringResource(): Int { +fun StripeFailureCode.mapToErrorStringResource(inAppPaymentType: InAppPaymentType): Int { return when (this) { is StripeFailureCode.Known -> when (this.code) { StripeFailureCode.Code.REFER_TO_CUSTOMER -> R.string.StripeFailureCode__verify_your_bank_details_are_correct StripeFailureCode.Code.INSUFFICIENT_FUNDS -> R.string.StripeFailureCode__the_bank_account_provided StripeFailureCode.Code.DEBIT_DISPUTED -> R.string.StripeFailureCode__verify_your_bank_details_are_correct - StripeFailureCode.Code.AUTHORIZATION_REVOKED -> R.string.StripeFailureCode__this_payment_was_revoked - StripeFailureCode.Code.DEBIT_NOT_AUTHORIZED -> R.string.StripeFailureCode__this_payment_was_revoked + StripeFailureCode.Code.AUTHORIZATION_REVOKED -> InAppPaymentErrorStrings.getStripeFailureCodeAuthorizationRevokedErrorMessage(inAppPaymentType) + StripeFailureCode.Code.DEBIT_NOT_AUTHORIZED -> InAppPaymentErrorStrings.getStripeFailureCodeAuthorizationRevokedErrorMessage(inAppPaymentType) StripeFailureCode.Code.ACCOUNT_CLOSED -> R.string.StripeFailureCode__the_bank_details_provided_could_not_be_processed StripeFailureCode.Code.BANK_ACCOUNT_RESTRICTED -> R.string.StripeFailureCode__the_bank_details_provided_could_not_be_processed - StripeFailureCode.Code.DEBIT_AUTHORIZATION_NOT_MATCH -> R.string.StripeFailureCode__an_error_occurred_while_processing_this_payment + StripeFailureCode.Code.DEBIT_AUTHORIZATION_NOT_MATCH -> InAppPaymentErrorStrings.getStripeFailureCodeDebitAuthorizationNotMatchErrorMessage(inAppPaymentType) StripeFailureCode.Code.RECIPIENT_DECEASED -> R.string.StripeFailureCode__the_bank_details_provided_could_not_be_processed StripeFailureCode.Code.BRANCH_DOES_NOT_EXIST -> R.string.StripeFailureCode__verify_your_bank_details_are_correct StripeFailureCode.Code.INCORRECT_ACCOUNT_HOLDER_NAME -> R.string.StripeFailureCode__verify_your_bank_details_are_correct diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/errors/InAppPaymentErrorStrings.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/errors/InAppPaymentErrorStrings.kt index 5aafde4253..28eb48b8a2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/errors/InAppPaymentErrorStrings.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/errors/InAppPaymentErrorStrings.kt @@ -42,4 +42,31 @@ object InAppPaymentErrorStrings { R.string.DonationsErrors__your_payment_is_still } } + + @StringRes + fun getStripeIssuerNotAvailableErrorMessage(inAppPaymentType: InAppPaymentType): Int { + return if (inAppPaymentType == InAppPaymentType.RECURRING_BACKUP) { + R.string.InAppPaymentErrors__StripeDeclineCode__try_completing_the_payment_again + } else { + R.string.DeclineCode__try_completing_the_payment_again + } + } + + @StringRes + fun getStripeFailureCodeAuthorizationRevokedErrorMessage(inAppPaymentType: InAppPaymentType): Int { + return if (inAppPaymentType == InAppPaymentType.RECURRING_BACKUP) { + R.string.InAppPaymentErrors__StripeFailureCode__this_payment_was_revoked + } else { + R.string.StripeFailureCode__this_payment_was_revoked + } + } + + @StringRes + fun getStripeFailureCodeDebitAuthorizationNotMatchErrorMessage(inAppPaymentType: InAppPaymentType): Int { + return if (inAppPaymentType == InAppPaymentType.RECURRING_BACKUP) { + R.string.InAppPaymentErrors__StripeFailureCode__an_error_occurred_while_processing_this_payment + } else { + R.string.StripeFailureCode__an_error_occurred_while_processing_this_payment + } + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7d26a37959..641fad517e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5493,6 +5493,12 @@ Your payment couldn\'t be processed and you have not been charged. Please try again. Your payment is still being processed. This can take a few minutes depending on your connection. + + Try completing the payment again or contact your bank for more information. + + This payment was revoked by the account holder and could not be processed. You haven\'t been charged. + + An error occurred while processing this payment, please try again. Error processing donation