Add more error messaging for backups.
This commit is contained in:
parent
4e07c07ca9
commit
36640edfee
5 changed files with 44 additions and 9 deletions
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -99,8 +99,8 @@ class DonationErrorParams<V> 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<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.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<V> 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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
<!-- 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>
|
||||
<!-- 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 -->
|
||||
<string name="DonationsErrors__error_processing_payment">Error processing donation</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue