Fix several issues with proper pending state routing.
This commit is contained in:
parent
627c47b155
commit
f9cd3decb1
5 changed files with 57 additions and 3 deletions
|
@ -38,7 +38,8 @@ fun BadgeImage112(
|
|||
},
|
||||
update = {
|
||||
it.setBadge(badge)
|
||||
}
|
||||
},
|
||||
modifier = modifier
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.thoughtcrime.securesms.components.settings.app.subscription.donate.ga
|
|||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.paypal.PayPalPaymentInProgressFragment
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.stripe.StripePaymentInProgressFragment
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.stripe.StripePaymentInProgressViewModel
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.transfer.details.BankTransferDetailsFragment
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.errors.DonationError
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.errors.DonationErrorDialogs
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.errors.DonationErrorParams
|
||||
|
@ -89,6 +90,16 @@ class DonationCheckoutDelegate(
|
|||
handleDonationProcessorActionResult(result)
|
||||
}
|
||||
|
||||
fragment.setFragmentResultListener(BankTransferDetailsFragment.REQUEST_KEY) { _, bundle ->
|
||||
val result: DonationProcessorActionResult = bundle.getParcelableCompat(StripePaymentInProgressFragment.REQUEST_KEY, DonationProcessorActionResult::class.java)!!
|
||||
handleDonationProcessorActionResult(result)
|
||||
}
|
||||
|
||||
fragment.setFragmentResultListener(BankTransferDetailsFragment.PENDING_KEY) { _, bundle ->
|
||||
val request: GatewayRequest = bundle.getParcelableCompat(BankTransferDetailsFragment.PENDING_KEY, GatewayRequest::class.java)!!
|
||||
callback.navigateToDonationPending(gatewayRequest = request)
|
||||
}
|
||||
|
||||
fragment.setFragmentResultListener(PayPalPaymentInProgressFragment.REQUEST_KEY) { _, bundle ->
|
||||
val result: DonationProcessorActionResult = bundle.getParcelableCompat(PayPalPaymentInProgressFragment.REQUEST_KEY, DonationProcessorActionResult::class.java)!!
|
||||
handleDonationProcessorActionResult(result)
|
||||
|
|
|
@ -39,6 +39,9 @@ import androidx.compose.ui.text.input.KeyboardCapitalization
|
|||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.setFragmentResult
|
||||
import androidx.fragment.app.setFragmentResultListener
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
|
@ -47,12 +50,18 @@ import org.signal.core.ui.Buttons
|
|||
import org.signal.core.ui.Scaffolds
|
||||
import org.signal.core.ui.Texts
|
||||
import org.signal.core.ui.theme.SignalTheme
|
||||
import org.signal.core.util.getParcelableCompat
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.TemporaryScreenshotSecurity
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.DonationPaymentComponent
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.DonateToSignalType
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.DonationCheckoutDelegate
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.DonationProcessorAction
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.DonationProcessorActionResult
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.gateway.GatewayRequest
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.stripe.StripePaymentInProgressFragment
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.stripe.StripePaymentInProgressViewModel
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.errors.DonationErrorSource
|
||||
import org.thoughtcrime.securesms.compose.ComposeFragment
|
||||
import org.thoughtcrime.securesms.payments.FiatMoneyUtil
|
||||
import org.thoughtcrime.securesms.util.SpanUtil
|
||||
|
@ -62,7 +71,12 @@ import org.thoughtcrime.securesms.util.navigation.safeNavigate
|
|||
/**
|
||||
* Collects SEPA Debit bank transfer details from the user to proceed with donation.
|
||||
*/
|
||||
class BankTransferDetailsFragment : ComposeFragment() {
|
||||
class BankTransferDetailsFragment : ComposeFragment(), DonationCheckoutDelegate.ErrorHandlerCallback {
|
||||
|
||||
companion object {
|
||||
const val REQUEST_KEY = "bank.transfer.result"
|
||||
const val PENDING_KEY = "bank.transfer.pending"
|
||||
}
|
||||
|
||||
private val args: BankTransferDetailsFragmentArgs by navArgs()
|
||||
private val viewModel: BankTransferDetailsViewModel by viewModels()
|
||||
|
@ -76,6 +90,22 @@ class BankTransferDetailsFragment : ComposeFragment() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
TemporaryScreenshotSecurity.bindToViewLifecycleOwner(this)
|
||||
|
||||
val errorSource: DonationErrorSource = when (args.request.donateToSignalType) {
|
||||
DonateToSignalType.ONE_TIME -> DonationErrorSource.BOOST
|
||||
DonateToSignalType.MONTHLY -> DonationErrorSource.SUBSCRIPTION
|
||||
DonateToSignalType.GIFT -> DonationErrorSource.GIFT
|
||||
}
|
||||
|
||||
DonationCheckoutDelegate.ErrorHandler().attach(this, this, args.request.uiSessionKey, errorSource)
|
||||
|
||||
setFragmentResultListener(StripePaymentInProgressFragment.REQUEST_KEY) { _, bundle ->
|
||||
val result: DonationProcessorActionResult = bundle.getParcelableCompat(StripePaymentInProgressFragment.REQUEST_KEY, DonationProcessorActionResult::class.java)!!
|
||||
if (result.status == DonationProcessorActionResult.Status.SUCCESS) {
|
||||
findNavController().popBackStack(R.id.donateToSignalFragment, false)
|
||||
setFragmentResult(REQUEST_KEY, bundle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
@ -129,6 +159,15 @@ class BankTransferDetailsFragment : ComposeFragment() {
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onUserCancelledPaymentFlow() = Unit
|
||||
|
||||
override fun navigateToDonationPending(gatewayRequest: GatewayRequest) {
|
||||
findNavController().popBackStack()
|
||||
findNavController().popBackStack()
|
||||
|
||||
setFragmentResult(PENDING_KEY, bundleOf(PENDING_KEY to gatewayRequest))
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
|
|
|
@ -117,7 +117,7 @@ class DonationErrorParams<V> private constructor(
|
|||
val getStripeDeclineCodePositiveActionParams: (Context, Callback<V>, Int) -> DonationErrorParams<V> = when (declinedError.method) {
|
||||
PaymentSourceType.Stripe.CreditCard -> this::getTryCreditCardAgainParams
|
||||
PaymentSourceType.Stripe.GooglePay -> this::getGoToGooglePayParams
|
||||
PaymentSourceType.Stripe.SEPADebit -> error("Not implemented.")
|
||||
PaymentSourceType.Stripe.SEPADebit -> this::getLearnMoreParams
|
||||
}
|
||||
|
||||
return when (declinedError.declineCode) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.thoughtcrime.securesms.util.adapter.mapping.BindingFactory
|
|||
import org.thoughtcrime.securesms.util.adapter.mapping.BindingViewHolder
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingAdapter
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingModel
|
||||
import org.thoughtcrime.securesms.util.visible
|
||||
|
||||
/**
|
||||
* Holds state information about pending one-time donations.
|
||||
|
@ -59,6 +60,8 @@ object OneTimeDonationPreference {
|
|||
if (model.pendingOneTimeDonation.paymentMethodType == PendingOneTimeDonation.PaymentMethodType.SEPA_DEBIT) {
|
||||
itemView.setOnClickListener { model.onPendingClick(model.pendingOneTimeDonation.amount.toFiatMoney()) }
|
||||
}
|
||||
|
||||
progress.visible = model.pendingOneTimeDonation.paymentMethodType != PendingOneTimeDonation.PaymentMethodType.SEPA_DEBIT
|
||||
}
|
||||
|
||||
private fun getPendingSubtitle(paymentMethodType: PendingOneTimeDonation.PaymentMethodType): String {
|
||||
|
|
Loading…
Add table
Reference in a new issue