Add more error messaging for backups.

This commit is contained in:
Alex Hart 2024-07-24 12:06:11 -03:00 committed by Nicholas Tinsley
parent 4e07c07ca9
commit 36640edfee
5 changed files with 44 additions and 9 deletions

View file

@ -13,6 +13,7 @@ import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.signal.donations.InAppPaymentType
import org.signal.donations.StripeDeclineCode import org.signal.donations.StripeDeclineCode
import org.signal.donations.StripeFailureCode import org.signal.donations.StripeFailureCode
import org.thoughtcrime.securesms.badges.Badges import org.thoughtcrime.securesms.badges.Badges
@ -71,7 +72,7 @@ class MonthlyDonationCanceledViewModel(
return if (declineCode.isKnown()) { return if (declineCode.isKnown()) {
declineCode.mapToErrorStringResource() declineCode.mapToErrorStringResource()
} else if (failureCode.isKnown) { } else if (failureCode.isKnown) {
failureCode.mapToErrorStringResource() failureCode.mapToErrorStringResource(InAppPaymentType.RECURRING_DONATION)
} else { } else {
declineCode.mapToErrorStringResource() declineCode.mapToErrorStringResource()
} }

View file

@ -99,8 +99,8 @@ class DonationErrorParams<V> private constructor(
) )
else -> DonationErrorParams( else -> DonationErrorParams(
title = R.string.DonationsErrors__couldnt_add_badge, 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, message = R.string.DonationsErrors__your_badge_could_not, // TODO [message-backups] -- This will need a backups-specific string
positiveAction = callback.onContactSupport(context), positiveAction = callback.onContactSupport(context),
negativeAction = null negativeAction = null
) )
@ -252,7 +252,7 @@ class DonationErrorParams<V> 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.PROCESSING_ERROR -> getLearnMoreParams(context, callback, inAppPaymentType, R.string.DeclineCode__try_again)
StripeDeclineCode.Code.REENTER_TRANSACTION -> 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) else -> getLearnMoreParams(context, callback, inAppPaymentType, R.string.DeclineCode__try_another_payment_method_or_contact_your_bank)
@ -275,7 +275,7 @@ class DonationErrorParams<V> private constructor(
return when (failureCode) { return when (failureCode) {
is StripeFailureCode.Known -> { is StripeFailureCode.Known -> {
val errorText = failureCode.mapToErrorStringResource() val errorText = failureCode.mapToErrorStringResource(inAppPaymentType)
when (failureCode.code) { when (failureCode.code) {
StripeFailureCode.Code.REFER_TO_CUSTOMER -> getTryBankTransferAgainParams(context, callback, inAppPaymentType, errorText) StripeFailureCode.Code.REFER_TO_CUSTOMER -> getTryBankTransferAgainParams(context, callback, inAppPaymentType, errorText)
StripeFailureCode.Code.INSUFFICIENT_FUNDS -> getLearnMoreParams(context, callback, inAppPaymentType, errorText) StripeFailureCode.Code.INSUFFICIENT_FUNDS -> getLearnMoreParams(context, callback, inAppPaymentType, errorText)

View file

@ -1,22 +1,23 @@
package org.thoughtcrime.securesms.components.settings.app.subscription.errors package org.thoughtcrime.securesms.components.settings.app.subscription.errors
import androidx.annotation.StringRes import androidx.annotation.StringRes
import org.signal.donations.InAppPaymentType
import org.signal.donations.StripeDeclineCode import org.signal.donations.StripeDeclineCode
import org.signal.donations.StripeFailureCode import org.signal.donations.StripeFailureCode
import org.thoughtcrime.securesms.R import org.thoughtcrime.securesms.R
@StringRes @StringRes
fun StripeFailureCode.mapToErrorStringResource(): Int { fun StripeFailureCode.mapToErrorStringResource(inAppPaymentType: InAppPaymentType): Int {
return when (this) { return when (this) {
is StripeFailureCode.Known -> when (this.code) { is StripeFailureCode.Known -> when (this.code) {
StripeFailureCode.Code.REFER_TO_CUSTOMER -> R.string.StripeFailureCode__verify_your_bank_details_are_correct 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.INSUFFICIENT_FUNDS -> R.string.StripeFailureCode__the_bank_account_provided
StripeFailureCode.Code.DEBIT_DISPUTED -> R.string.StripeFailureCode__verify_your_bank_details_are_correct 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.AUTHORIZATION_REVOKED -> InAppPaymentErrorStrings.getStripeFailureCodeAuthorizationRevokedErrorMessage(inAppPaymentType)
StripeFailureCode.Code.DEBIT_NOT_AUTHORIZED -> R.string.StripeFailureCode__this_payment_was_revoked 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.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.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.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.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 StripeFailureCode.Code.INCORRECT_ACCOUNT_HOLDER_NAME -> R.string.StripeFailureCode__verify_your_bank_details_are_correct

View file

@ -42,4 +42,31 @@ object InAppPaymentErrorStrings {
R.string.DonationsErrors__your_payment_is_still 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
}
}
} }

View file

@ -5493,6 +5493,12 @@
<string name="InAppPaymentErrors__your_payment_couldnt_be_processed">Your payment couldn\'t be processed and you have not been charged. Please try again.</string> <string name="InAppPaymentErrors__your_payment_couldnt_be_processed">Your payment couldn\'t be processed and you have not been charged. Please try again.</string>
<!-- Displayed as a message in a dialog when we timeout waiting for a payment to be processed and token to be redeemed --> <!-- Displayed as a message in a dialog when we timeout waiting for a payment to be processed and token to be redeemed -->
<string name="InAppPaymentErrors__your_payment_is_still">Your payment is still being processed. This can take a few minutes depending on your connection.</string> <string name="InAppPaymentErrors__your_payment_is_still">Your payment is still being processed. This can take a few minutes depending on your connection.</string>
<!-- Displayed as a message in a dialog or notification when stripe decline code issuer not available for backup payment. -->
<string name="InAppPaymentErrors__StripeDeclineCode__try_completing_the_payment_again">Try completing the payment again or contact your bank for more information.</string>
<!-- Failure code text for revoked authorization of payment, displayed in a dialog or notification as a message. -->
<string name="InAppPaymentErrors__StripeFailureCode__this_payment_was_revoked">This payment was revoked by the account holder and could not be processed. You haven\'t been charged.</string>
<!-- Failure code text for a payment lacking an authorized mandate or incorrect mandate, displayed in a dialog or notification as a message.-->
<string name="InAppPaymentErrors__StripeFailureCode__an_error_occurred_while_processing_this_payment">An error occurred while processing this payment, please try again.</string>
<!-- Displayed in notification when user payment fails to process on Stripe --> <!-- Displayed in notification when user payment fails to process on Stripe -->
<string name="DonationsErrors__error_processing_payment">Error processing donation</string> <string name="DonationsErrors__error_processing_payment">Error processing donation</string>