Add generic payment in progress strings.
This commit is contained in:
parent
853c934a5a
commit
cc806a2f79
6 changed files with 38 additions and 7 deletions
|
@ -6,6 +6,7 @@
|
|||
package org.thoughtcrime.securesms.components.settings.app.subscription
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.annotation.WorkerThread
|
||||
import io.reactivex.rxjava3.core.BackpressureStrategy
|
||||
import io.reactivex.rxjava3.core.Completable
|
||||
|
@ -24,6 +25,7 @@ import org.signal.libsignal.zkgroup.InvalidInputException
|
|||
import org.signal.libsignal.zkgroup.VerificationFailedException
|
||||
import org.signal.libsignal.zkgroup.receipts.ReceiptCredentialRequestContext
|
||||
import org.signal.libsignal.zkgroup.receipts.ReceiptSerial
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.DonationSerializationHelper.toFiatMoney
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.InAppPaymentError
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.errors.DonationError
|
||||
|
@ -65,6 +67,15 @@ object InAppPaymentsRepository {
|
|||
|
||||
private val temporaryErrorProcessor = PublishProcessor.create<Pair<InAppPaymentTable.InAppPaymentId, Throwable>>()
|
||||
|
||||
@get:StringRes
|
||||
val InAppPaymentType.labelResource: Int get() {
|
||||
return if (this == InAppPaymentType.RECURRING_BACKUP) {
|
||||
R.string.InAppPaymentInProgressFragment__payment
|
||||
} else {
|
||||
R.string.InAppPaymentInProgressFragment__donation
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps an in-app-payment update in a completable.
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.signal.core.util.getParcelableCompat
|
|||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.ViewBinderDelegate
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.InAppPaymentsRepository.labelResource
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.InAppPaymentsRepository.toErrorSource
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.InAppPaymentProcessorAction
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.InAppPaymentProcessorActionResult
|
||||
|
@ -82,8 +83,8 @@ class PayPalPaymentInProgressFragment : DialogFragment(R.layout.donation_in_prog
|
|||
|
||||
private fun presentUiState(stage: InAppPaymentProcessorStage) {
|
||||
when (stage) {
|
||||
InAppPaymentProcessorStage.INIT -> binding.progressCardStatus.setText(R.string.SubscribeFragment__processing_payment)
|
||||
InAppPaymentProcessorStage.PAYMENT_PIPELINE -> binding.progressCardStatus.setText(R.string.SubscribeFragment__processing_payment)
|
||||
InAppPaymentProcessorStage.INIT -> binding.progressCardStatus.text = getProcessingStatus()
|
||||
InAppPaymentProcessorStage.PAYMENT_PIPELINE -> binding.progressCardStatus.text = getProcessingStatus()
|
||||
InAppPaymentProcessorStage.FAILED -> {
|
||||
viewModel.onEndAction()
|
||||
findNavController().popBackStack()
|
||||
|
@ -120,6 +121,10 @@ class PayPalPaymentInProgressFragment : DialogFragment(R.layout.donation_in_prog
|
|||
}
|
||||
}
|
||||
|
||||
private fun getProcessingStatus(): String {
|
||||
return getString(R.string.InAppPaymentInProgressFragment__processing_s, getString(args.inAppPaymentType.labelResource))
|
||||
}
|
||||
|
||||
private fun oneTimeConfirmationPipeline(createPaymentIntentResponse: PayPalCreatePaymentIntentResponse): Single<PayPalConfirmationResult> {
|
||||
return routeToOneTimeConfirmation(createPaymentIntentResponse)
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.signal.donations.StripeIntentAccessor
|
|||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.ViewBinderDelegate
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.InAppPaymentComponent
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.InAppPaymentsRepository.labelResource
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.InAppPaymentsRepository.requireSubscriberType
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.InAppPaymentsRepository.toErrorSource
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.InAppPaymentProcessorAction
|
||||
|
@ -68,9 +69,11 @@ class StripePaymentInProgressFragment : DialogFragment(R.layout.donation_in_prog
|
|||
InAppPaymentProcessorAction.PROCESS_NEW_IN_APP_PAYMENT -> {
|
||||
viewModel.processNewDonation(args.inAppPayment!!, this::handleSecure3dsAction)
|
||||
}
|
||||
|
||||
InAppPaymentProcessorAction.UPDATE_SUBSCRIPTION -> {
|
||||
viewModel.updateSubscription(args.inAppPayment!!)
|
||||
}
|
||||
|
||||
InAppPaymentProcessorAction.CANCEL_SUBSCRIPTION -> {
|
||||
viewModel.cancelSubscription(args.inAppPaymentType.requireSubscriberType())
|
||||
}
|
||||
|
@ -85,8 +88,8 @@ class StripePaymentInProgressFragment : DialogFragment(R.layout.donation_in_prog
|
|||
|
||||
private fun presentUiState(stage: InAppPaymentProcessorStage) {
|
||||
when (stage) {
|
||||
InAppPaymentProcessorStage.INIT -> binding.progressCardStatus.setText(R.string.SubscribeFragment__processing_payment)
|
||||
InAppPaymentProcessorStage.PAYMENT_PIPELINE -> binding.progressCardStatus.setText(R.string.SubscribeFragment__processing_payment)
|
||||
InAppPaymentProcessorStage.INIT -> binding.progressCardStatus.text = getProcessingStatus()
|
||||
InAppPaymentProcessorStage.PAYMENT_PIPELINE -> binding.progressCardStatus.text = getProcessingStatus()
|
||||
InAppPaymentProcessorStage.FAILED -> {
|
||||
viewModel.onEndAction()
|
||||
findNavController().popBackStack()
|
||||
|
@ -102,6 +105,7 @@ class StripePaymentInProgressFragment : DialogFragment(R.layout.donation_in_prog
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
InAppPaymentProcessorStage.COMPLETE -> {
|
||||
viewModel.onEndAction()
|
||||
findNavController().popBackStack()
|
||||
|
@ -117,16 +121,22 @@ class StripePaymentInProgressFragment : DialogFragment(R.layout.donation_in_prog
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
InAppPaymentProcessorStage.CANCELLING -> binding.progressCardStatus.setText(R.string.StripePaymentInProgressFragment__cancelling)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getProcessingStatus(): String {
|
||||
return getString(R.string.InAppPaymentInProgressFragment__processing_s, getString(args.inAppPaymentType.labelResource))
|
||||
}
|
||||
|
||||
private fun handleSecure3dsAction(secure3dsAction: StripeApi.Secure3DSAction, inAppPayment: InAppPaymentTable.InAppPayment): Single<StripeIntentAccessor> {
|
||||
return when (secure3dsAction) {
|
||||
is StripeApi.Secure3DSAction.NotNeeded -> {
|
||||
Log.d(TAG, "No 3DS action required.")
|
||||
Single.just(StripeIntentAccessor.NO_ACTION_REQUIRED)
|
||||
}
|
||||
|
||||
is StripeApi.Secure3DSAction.ConfirmRequired -> {
|
||||
Log.d(TAG, "3DS action required. Displaying dialog...")
|
||||
Single.create { emitter ->
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/SubscribeFragment__processing_payment"
|
||||
android:textAppearance="@style/Signal.Text.BodyLarge"
|
||||
android:textColor="@color/signal_colorOnSurfaceVariant" />
|
||||
</LinearLayout>
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/SubscribeFragment__processing_payment"
|
||||
android:textAppearance="@style/Signal.Text.Body"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -5472,7 +5472,14 @@
|
|||
<string name="Subscription__contact_support">Contact Support</string>
|
||||
<string name="Subscription__get_a_s_badge">Get a %1$s badge</string>
|
||||
|
||||
<string name="SubscribeFragment__processing_payment">Processing donation…</string>
|
||||
<!-- *PaymentInProgressFragment strings -->
|
||||
<!-- String utilized for donation payments throughout status and error strings -->
|
||||
<string name="InAppPaymentInProgressFragment__donation">donation</string>
|
||||
<!-- String utilized for backup payments throughout status and error strings -->
|
||||
<string name="InAppPaymentInProgressFragment__payment">payment</string>
|
||||
<!-- Displayed in a dialog while a payment is being processed. Placeholder is donation or payment. -->
|
||||
<string name="InAppPaymentInProgressFragment__processing_s">Processing %1$s…</string>
|
||||
|
||||
<!-- Displayed in notification when user payment fails to process on Stripe -->
|
||||
<string name="DonationsErrors__error_processing_payment">Error processing donation</string>
|
||||
<!-- Displayed on manage donations screen as a dialog message when payment method failed -->
|
||||
|
|
Loading…
Add table
Reference in a new issue