Add backups error string for payment setup errors.

This commit is contained in:
Alex Hart 2024-07-24 11:30:17 -03:00 committed by Nicholas Tinsley
parent 31ddc5bcc0
commit 4e07c07ca9
3 changed files with 57 additions and 28 deletions

View file

@ -36,8 +36,8 @@ class DonationErrorParams<V> private constructor(
is DonationError.PaymentSetupError.StripeFailureCodeError -> getStripeFailureCodeErrorParams(context, throwable.method, throwable.failureCode, throwable.source.toInAppPaymentType(), callback)
is DonationError.PaymentSetupError.PayPalDeclinedError -> getPayPalDeclinedErrorParams(context, throwable.code, callback, throwable.source.toInAppPaymentType())
is DonationError.PaymentSetupError -> getGenericPaymentSetupErrorParams(context, callback, throwable.source.toInAppPaymentType())
is DonationError.BadgeRedemptionError.DonationPending -> getStillProcessingErrorParams(context, callback)
is DonationError.BadgeRedemptionError.TimeoutWaitingForTokenError -> getStillProcessingErrorParams(context, callback)
is DonationError.BadgeRedemptionError.DonationPending -> getStillProcessingErrorParams(context, callback, throwable.source.toInAppPaymentType())
is DonationError.BadgeRedemptionError.TimeoutWaitingForTokenError -> getStillProcessingErrorParams(context, callback, throwable.source.toInAppPaymentType())
is DonationError.BadgeRedemptionError.FailedToValidateCredentialError -> getBadgeCredentialValidationErrorParams(context, callback)
is DonationError.BadgeRedemptionError.GenericError -> getGenericRedemptionError(context, throwable.source.toInAppPaymentType(), callback)
else -> getGenericRedemptionError(context, InAppPaymentType.ONE_TIME_DONATION, callback)
@ -297,10 +297,10 @@ class DonationErrorParams<V> private constructor(
}
}
private fun <V> getStillProcessingErrorParams(context: Context, callback: Callback<V>): DonationErrorParams<V> {
private fun <V> getStillProcessingErrorParams(context: Context, callback: Callback<V>, inAppPaymentType: InAppPaymentType): DonationErrorParams<V> {
return DonationErrorParams(
title = R.string.DonationsErrors__still_processing,
message = R.string.DonationsErrors__your_payment_is_still,
message = InAppPaymentErrorStrings.getStillProcessingErrorMessage(inAppPaymentType),
positiveAction = callback.onOk(context),
negativeAction = null
)
@ -317,8 +317,8 @@ class DonationErrorParams<V> private constructor(
private fun <V> getGenericPaymentSetupErrorParams(context: Context, callback: Callback<V>, inAppPaymentType: InAppPaymentType): DonationErrorParams<V> {
return DonationErrorParams(
title = getGenericErrorProcessingTitle(inAppPaymentType),
message = getPaymentSetupErrorMessage(inAppPaymentType),
title = InAppPaymentErrorStrings.getGenericErrorProcessingTitle(inAppPaymentType),
message = InAppPaymentErrorStrings.getPaymentSetupErrorMessage(inAppPaymentType),
positiveAction = callback.onOk(context),
negativeAction = null
)
@ -326,7 +326,7 @@ class DonationErrorParams<V> private constructor(
private fun <V> getLearnMoreParams(context: Context, callback: Callback<V>, inAppPaymentType: InAppPaymentType, message: Int): DonationErrorParams<V> {
return DonationErrorParams(
title = getGenericErrorProcessingTitle(inAppPaymentType),
title = InAppPaymentErrorStrings.getGenericErrorProcessingTitle(inAppPaymentType),
message = message,
positiveAction = callback.onOk(context),
negativeAction = callback.onLearnMore(context)
@ -335,7 +335,7 @@ class DonationErrorParams<V> private constructor(
private fun <V> getGoToGooglePayParams(context: Context, callback: Callback<V>, inAppPaymentType: InAppPaymentType, message: Int): DonationErrorParams<V> {
return DonationErrorParams(
title = getGenericErrorProcessingTitle(inAppPaymentType),
title = InAppPaymentErrorStrings.getGenericErrorProcessingTitle(inAppPaymentType),
message = message,
positiveAction = callback.onGoToGooglePay(context),
negativeAction = callback.onCancel(context)
@ -344,7 +344,7 @@ class DonationErrorParams<V> private constructor(
private fun <V> getTryCreditCardAgainParams(context: Context, callback: Callback<V>, inAppPaymentType: InAppPaymentType, message: Int): DonationErrorParams<V> {
return DonationErrorParams(
title = getGenericErrorProcessingTitle(inAppPaymentType),
title = InAppPaymentErrorStrings.getGenericErrorProcessingTitle(inAppPaymentType),
message = message,
positiveAction = callback.onTryCreditCardAgain(context),
negativeAction = callback.onCancel(context)
@ -353,30 +353,12 @@ class DonationErrorParams<V> private constructor(
private fun <V> getTryBankTransferAgainParams(context: Context, callback: Callback<V>, inAppPaymentType: InAppPaymentType, message: Int): DonationErrorParams<V> {
return DonationErrorParams(
title = getGenericErrorProcessingTitle(inAppPaymentType),
title = InAppPaymentErrorStrings.getGenericErrorProcessingTitle(inAppPaymentType),
message = message,
positiveAction = callback.onTryBankTransferAgain(context),
negativeAction = callback.onCancel(context)
)
}
@StringRes
private fun getGenericErrorProcessingTitle(inAppPaymentType: InAppPaymentType): Int {
return if (inAppPaymentType == InAppPaymentType.RECURRING_BACKUP) {
R.string.InAppPaymentErrors__error_processing_payment
} else {
R.string.DonationsErrors__error_processing_payment
}
}
@StringRes
private fun getPaymentSetupErrorMessage(inAppPaymentType: InAppPaymentType): Int {
return if (inAppPaymentType == InAppPaymentType.RECURRING_BACKUP) {
R.string.InAppPaymentErrors__your_payment_couldnt_be_processed
} else {
R.string.DonationsErrors__your_payment
}
}
}
interface Callback<V> {

View file

@ -0,0 +1,45 @@
/*
* Copyright 2024 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.thoughtcrime.securesms.components.settings.app.subscription.errors
import androidx.annotation.StringRes
import org.signal.donations.InAppPaymentType
import org.thoughtcrime.securesms.R
/**
* Methods to delineate donation vs backup payment error strings.
*
* The format here should remain that the last word in the method name is that of where
* it is being placed in a given error dialog/notification.
*/
object InAppPaymentErrorStrings {
@StringRes
fun getGenericErrorProcessingTitle(inAppPaymentType: InAppPaymentType): Int {
return if (inAppPaymentType == InAppPaymentType.RECURRING_BACKUP) {
R.string.InAppPaymentErrors__error_processing_payment
} else {
R.string.DonationsErrors__error_processing_payment
}
}
@StringRes
fun getPaymentSetupErrorMessage(inAppPaymentType: InAppPaymentType): Int {
return if (inAppPaymentType == InAppPaymentType.RECURRING_BACKUP) {
R.string.InAppPaymentErrors__your_payment_couldnt_be_processed
} else {
R.string.DonationsErrors__your_payment
}
}
@StringRes
fun getStillProcessingErrorMessage(inAppPaymentType: InAppPaymentType): Int {
return if (inAppPaymentType == InAppPaymentType.RECURRING_BACKUP) {
R.string.InAppPaymentErrors__your_payment_is_still
} else {
R.string.DonationsErrors__your_payment_is_still
}
}
}

View file

@ -5491,6 +5491,8 @@
<string name="InAppPaymentErrors__error_processing_payment">Error processing payment</string>
<!-- Displayed as a message in a dialog or notification when a payment setup error happens. -->
<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 in notification when user payment fails to process on Stripe -->
<string name="DonationsErrors__error_processing_payment">Error processing donation</string>