diff --git a/paymentsheet/src/main/java/com/stripe/android/customersheet/CustomerSheetViewModel.kt b/paymentsheet/src/main/java/com/stripe/android/customersheet/CustomerSheetViewModel.kt index 797699c51a2..612b5fe9225 100644 --- a/paymentsheet/src/main/java/com/stripe/android/customersheet/CustomerSheetViewModel.kt +++ b/paymentsheet/src/main/java/com/stripe/android/customersheet/CustomerSheetViewModel.kt @@ -450,6 +450,7 @@ internal class CustomerSheetViewModel( * `CustomerSheet` does not implement `Link` so we don't need a coordinator or callback. */ linkConfigurationCoordinator = null, + usBankAccountFormArguments = createDefaultUsBankArguments(paymentMethodMetadata.stripeIntent), onLinkInlineSignupStateChanged = { throw IllegalStateException( "`CustomerSheet` does not implement `Link` and should not " + @@ -458,9 +459,7 @@ internal class CustomerSheetViewModel( } ), ) ?: listOf(), - primaryButtonLabel = if ( - paymentMethod.code == USBankAccount.code && it.bankAccountSelection == null - ) { + primaryButtonLabel = if (paymentMethod.code == USBankAccount.code && it.bankAccountSelection == null) { UiCoreR.string.stripe_continue_button_label.resolvableString } else { R.string.stripe_paymentsheet_save.resolvableString @@ -802,8 +801,9 @@ internal class CustomerSheetViewModel( "`CustomerSheet` does not implement `Link` and should not " + "receive `InlineSignUpViewState` updates" ) - } - ) + }, + usBankAccountFormArguments = createDefaultUsBankArguments(stripeIntent), + ), ) ?: emptyList() transition( diff --git a/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/luxe/TransformSpecToElements.kt b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/luxe/TransformSpecToElements.kt index c373adb00a9..21a1d678a79 100644 --- a/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/luxe/TransformSpecToElements.kt +++ b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/luxe/TransformSpecToElements.kt @@ -1,6 +1,7 @@ package com.stripe.android.lpmfoundations.luxe import com.stripe.android.lpmfoundations.paymentmethod.UiDefinitionFactory +import com.stripe.android.paymentsheet.PaymentSheet import com.stripe.android.paymentsheet.forms.PlaceholderHelper.specsForConfiguration import com.stripe.android.ui.core.elements.AddressSpec import com.stripe.android.ui.core.elements.AffirmTextSpec @@ -39,7 +40,7 @@ import com.stripe.android.uicore.elements.IdentifierSpec * */ internal class TransformSpecToElements( - private val arguments: UiDefinitionFactory.Arguments, + private val arguments: Arguments, ) { fun transform( specs: List, @@ -79,4 +80,24 @@ internal class TransformSpecToElements( } } } + + data class Arguments( + val initialValues: Map, + val shippingValues: Map?, + val merchantName: String, + val billingDetailsCollectionConfiguration: PaymentSheet.BillingDetailsCollectionConfiguration, + val requiresMandate: Boolean, + ) +} + +internal fun TransformSpecToElements(arguments: UiDefinitionFactory.Arguments): TransformSpecToElements { + return TransformSpecToElements( + arguments = TransformSpecToElements.Arguments( + initialValues = arguments.initialValues, + shippingValues = arguments.shippingValues, + merchantName = arguments.merchantName, + billingDetailsCollectionConfiguration = arguments.billingDetailsCollectionConfiguration, + requiresMandate = arguments.requiresMandate, + ) + ) } diff --git a/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/UiDefinitionFactory.kt b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/UiDefinitionFactory.kt index 0fbd0ff96ec..9b983436789 100644 --- a/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/UiDefinitionFactory.kt +++ b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/UiDefinitionFactory.kt @@ -12,13 +12,14 @@ import com.stripe.android.model.PaymentMethodCreateParams import com.stripe.android.model.PaymentMethodExtraParams import com.stripe.android.paymentsheet.PaymentSheet import com.stripe.android.paymentsheet.addresselement.toIdentifierMap +import com.stripe.android.paymentsheet.paymentdatacollection.ach.USBankAccountFormArguments import com.stripe.android.ui.core.cbc.CardBrandChoiceEligibility import com.stripe.android.ui.core.elements.SharedDataSpec import com.stripe.android.uicore.elements.FormElement import com.stripe.android.uicore.elements.IdentifierSpec internal sealed interface UiDefinitionFactory { - class Arguments( + data class Arguments( val cardAccountRangeRepositoryFactory: CardAccountRangeRepository.Factory, val linkConfigurationCoordinator: LinkConfigurationCoordinator?, val initialValues: Map, @@ -28,6 +29,7 @@ internal sealed interface UiDefinitionFactory { val cbcEligibility: CardBrandChoiceEligibility, val billingDetailsCollectionConfiguration: PaymentSheet.BillingDetailsCollectionConfiguration, val requiresMandate: Boolean, + val usBankAccountFormArguments: USBankAccountFormArguments, val onLinkInlineSignupStateChanged: (InlineSignupViewState) -> Unit, val cardBrandFilter: CardBrandFilter, ) { @@ -43,6 +45,7 @@ internal sealed interface UiDefinitionFactory { private val onLinkInlineSignupStateChanged: (InlineSignupViewState) -> Unit, private val paymentMethodCreateParams: PaymentMethodCreateParams? = null, private val paymentMethodExtraParams: PaymentMethodExtraParams? = null, + private val usBankAccountFormArguments: USBankAccountFormArguments, ) : Factory { override fun create( metadata: PaymentMethodMetadata, @@ -62,6 +65,7 @@ internal sealed interface UiDefinitionFactory { saveForFutureUseInitialValue = false, billingDetailsCollectionConfiguration = metadata.billingDetailsCollectionConfiguration, requiresMandate = requiresMandate, + usBankAccountFormArguments = usBankAccountFormArguments, onLinkInlineSignupStateChanged = onLinkInlineSignupStateChanged, cardBrandFilter = metadata.cardBrandFilter, ) diff --git a/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/bank/BankFormElement.kt b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/bank/BankFormElement.kt new file mode 100644 index 00000000000..2ce7765cc44 --- /dev/null +++ b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/bank/BankFormElement.kt @@ -0,0 +1,90 @@ +package com.stripe.android.lpmfoundations.paymentmethod.bank + +import androidx.compose.runtime.Composable +import androidx.lifecycle.viewmodel.compose.viewModel +import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadata +import com.stripe.android.model.PaymentMethod +import com.stripe.android.paymentsheet.forms.FormArgumentsFactory +import com.stripe.android.paymentsheet.model.PaymentSelection.New +import com.stripe.android.paymentsheet.paymentdatacollection.FormArguments +import com.stripe.android.paymentsheet.paymentdatacollection.ach.USBankAccountEmitters +import com.stripe.android.paymentsheet.paymentdatacollection.ach.USBankAccountForm +import com.stripe.android.paymentsheet.paymentdatacollection.ach.USBankAccountFormArguments +import com.stripe.android.paymentsheet.paymentdatacollection.ach.USBankAccountFormViewModel +import com.stripe.android.ui.core.elements.RenderableFormElement +import com.stripe.android.uicore.elements.IdentifierSpec +import com.stripe.android.uicore.forms.FormFieldEntry +import com.stripe.android.uicore.utils.stateFlowOf +import kotlinx.coroutines.flow.StateFlow + +internal class BankFormElement( + private val formArgs: FormArguments, + private val usBankAccountFormArgs: USBankAccountFormArguments, +) : RenderableFormElement( + allowsUserInteraction = true, + identifier = IdentifierSpec.Generic("bank_form") +) { + + override fun getFormFieldValueFlow(): StateFlow>> { + return stateFlowOf(emptyList()) + } + + @Composable + override fun ComposeUI(enabled: Boolean) { + val viewModel = viewModel( + factory = USBankAccountFormViewModel.Factory { + makeViewModelArgs() + }, + ) + + USBankAccountEmitters( + viewModel = viewModel, + usBankAccountFormArgs = usBankAccountFormArgs, + ) + + USBankAccountForm( + viewModel = viewModel, + formArgs = formArgs, + usBankAccountFormArgs = usBankAccountFormArgs, + ) + } + + private fun makeViewModelArgs(): USBankAccountFormViewModel.Args { + return USBankAccountFormViewModel.Args( + instantDebits = usBankAccountFormArgs.instantDebits, + linkMode = usBankAccountFormArgs.linkMode, + formArgs = formArgs, + hostedSurface = usBankAccountFormArgs.hostedSurface, + showCheckbox = usBankAccountFormArgs.showCheckbox, + isCompleteFlow = usBankAccountFormArgs.isCompleteFlow, + isPaymentFlow = usBankAccountFormArgs.isPaymentFlow, + stripeIntentId = usBankAccountFormArgs.stripeIntentId, + clientSecret = usBankAccountFormArgs.clientSecret, + onBehalfOf = usBankAccountFormArgs.onBehalfOf, + savedPaymentMethod = usBankAccountFormArgs.draftPaymentSelection as? New.USBankAccount, + shippingDetails = usBankAccountFormArgs.shippingDetails, + ) + } + + companion object { + + fun create( + usBankAccountFormArgs: USBankAccountFormArguments, + metadata: PaymentMethodMetadata, + ): BankFormElement { + val formArgs = FormArgumentsFactory.create( + paymentMethodCode = if (usBankAccountFormArgs.instantDebits) { + PaymentMethod.Type.Link.code + } else { + PaymentMethod.Type.USBankAccount.code + }, + metadata = metadata, + ) + + return BankFormElement( + formArgs = formArgs, + usBankAccountFormArgs = usBankAccountFormArgs, + ) + } + } +} diff --git a/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/bank/BankFormElementsFactory.kt b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/bank/BankFormElementsFactory.kt new file mode 100644 index 00000000000..4ec23a30f2d --- /dev/null +++ b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/bank/BankFormElementsFactory.kt @@ -0,0 +1,36 @@ +package com.stripe.android.lpmfoundations.paymentmethod.bank + +import com.stripe.android.lpmfoundations.luxe.FormElementsBuilder +import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadata +import com.stripe.android.lpmfoundations.paymentmethod.UiDefinitionFactory +import com.stripe.android.paymentsheet.PaymentSheet +import com.stripe.android.uicore.elements.FormElement + +internal object BankFormElementsFactory { + + fun create( + metadata: PaymentMethodMetadata, + arguments: UiDefinitionFactory.Arguments, + ): List { + val bankFormElement = BankFormElement.create( + usBankAccountFormArgs = arguments.usBankAccountFormArguments, + metadata = metadata, + ) + + return FormElementsBuilder(arguments.stripBillingDetails()) + .element(bankFormElement) + .build() + } +} + +private fun UiDefinitionFactory.Arguments.stripBillingDetails(): UiDefinitionFactory.Arguments { + return copy( + billingDetailsCollectionConfiguration = PaymentSheet.BillingDetailsCollectionConfiguration( + name = PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Never, + phone = PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Never, + email = PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Never, + address = PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Never, + attachDefaultsToPaymentMethod = false, + ) + ) +} diff --git a/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/definitions/InstantDebitsDefinition.kt b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/definitions/InstantDebitsDefinition.kt index 3282c9ee4d6..f81f677875c 100644 --- a/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/definitions/InstantDebitsDefinition.kt +++ b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/definitions/InstantDebitsDefinition.kt @@ -5,6 +5,7 @@ import com.stripe.android.lpmfoundations.paymentmethod.AddPaymentMethodRequireme import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodDefinition import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadata import com.stripe.android.lpmfoundations.paymentmethod.UiDefinitionFactory +import com.stripe.android.lpmfoundations.paymentmethod.bank.BankFormElementsFactory import com.stripe.android.model.PaymentMethod import com.stripe.android.uicore.elements.FormElement import com.stripe.android.ui.core.R as PaymentsUiCoreR @@ -40,11 +41,10 @@ private object InstantDebitsUiDefinitionFactory : UiDefinitionFactory.Simple { ) } - // Instant Debits uses its own mechanism, not these form elements. override fun createFormElements( metadata: PaymentMethodMetadata, arguments: UiDefinitionFactory.Arguments, ): List { - return emptyList() + return BankFormElementsFactory.create(metadata, arguments) } } diff --git a/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/definitions/LinkCardBrandDefinition.kt b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/definitions/LinkCardBrandDefinition.kt index 71bb0ea3527..149a87ca3e5 100644 --- a/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/definitions/LinkCardBrandDefinition.kt +++ b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/definitions/LinkCardBrandDefinition.kt @@ -5,6 +5,7 @@ import com.stripe.android.lpmfoundations.paymentmethod.AddPaymentMethodRequireme import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodDefinition import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadata import com.stripe.android.lpmfoundations.paymentmethod.UiDefinitionFactory +import com.stripe.android.lpmfoundations.paymentmethod.bank.BankFormElementsFactory import com.stripe.android.model.PaymentMethod import com.stripe.android.uicore.elements.FormElement import com.stripe.android.ui.core.R as PaymentsUiCoreR @@ -40,11 +41,10 @@ private object LinkCardBrandDefinitionFactory : UiDefinitionFactory.Simple { ) } - // Link Card Brand uses its own mechanism, not these form elements. override fun createFormElements( metadata: PaymentMethodMetadata, arguments: UiDefinitionFactory.Arguments, ): List { - return emptyList() + return BankFormElementsFactory.create(metadata, arguments) } } diff --git a/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/definitions/UsBankAccountDefinition.kt b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/definitions/UsBankAccountDefinition.kt index 0cd2b6abef7..0a96291dbd6 100644 --- a/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/definitions/UsBankAccountDefinition.kt +++ b/paymentsheet/src/main/java/com/stripe/android/lpmfoundations/paymentmethod/definitions/UsBankAccountDefinition.kt @@ -7,6 +7,7 @@ import com.stripe.android.lpmfoundations.paymentmethod.AddPaymentMethodRequireme import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodDefinition import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadata import com.stripe.android.lpmfoundations.paymentmethod.UiDefinitionFactory +import com.stripe.android.lpmfoundations.paymentmethod.bank.BankFormElementsFactory import com.stripe.android.model.PaymentMethod import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.FormElement @@ -46,9 +47,10 @@ private object UsBankAccountUiDefinitionFactory : UiDefinitionFactory.Simple { ) } - // US Bank Account uses it's own mechanism, not these form elements. override fun createFormElements( metadata: PaymentMethodMetadata, - arguments: UiDefinitionFactory.Arguments, - ): List = emptyList() + arguments: UiDefinitionFactory.Arguments + ): List { + return BankFormElementsFactory.create(metadata, arguments) + } } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/FormHelper.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/FormHelper.kt index c3288cf1b2b..1e0eda49efb 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/FormHelper.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/FormHelper.kt @@ -12,6 +12,7 @@ import com.stripe.android.paymentsheet.forms.FormArgumentsFactory import com.stripe.android.paymentsheet.forms.FormFieldValues import com.stripe.android.paymentsheet.model.PaymentSelection import com.stripe.android.paymentsheet.paymentdatacollection.FormArguments +import com.stripe.android.paymentsheet.paymentdatacollection.ach.USBankAccountFormArguments import com.stripe.android.paymentsheet.ui.transformToPaymentSelection import com.stripe.android.paymentsheet.viewmodels.BaseSheetViewModel import com.stripe.android.uicore.elements.FormElement @@ -21,6 +22,7 @@ internal class FormHelper( private val paymentMethodMetadata: PaymentMethodMetadata, private val newPaymentSelectionProvider: () -> NewOrExternalPaymentSelection?, private val selectionUpdater: (PaymentSelection?) -> Unit, + private val usBankAccountFormArgumentsFactory: (PaymentMethodCode) -> USBankAccountFormArguments, private val linkConfigurationCoordinator: LinkConfigurationCoordinator, private val onLinkInlineSignupStateChanged: (InlineSignupViewState) -> Unit, ) { @@ -37,6 +39,14 @@ internal class FormHelper( viewModel.newPaymentSelection }, linkConfigurationCoordinator = viewModel.linkHandler.linkConfigurationCoordinator, + usBankAccountFormArgumentsFactory = { code -> + USBankAccountFormArguments.create( + viewModel = viewModel, + paymentMethodMetadata = paymentMethodMetadata, + hostedSurface = "payment_element", + selectedPaymentMethodCode = code, + ) + }, onLinkInlineSignupStateChanged = linkInlineHandler::onStateUpdated, selectionUpdater = { viewModel.updateSelection(it) @@ -48,6 +58,8 @@ internal class FormHelper( fun formElementsForCode(code: String): List { val currentSelection = newPaymentSelectionProvider()?.takeIf { it.getType() == code } + val usBankAccountFormArguments = usBankAccountFormArgumentsFactory(code) + return paymentMethodMetadata.formElementsForCode( code = code, uiDefinitionFactoryArgumentsFactory = UiDefinitionFactory.Arguments.Factory.Default( @@ -56,6 +68,7 @@ internal class FormHelper( onLinkInlineSignupStateChanged = onLinkInlineSignupStateChanged, paymentMethodCreateParams = currentSelection?.getPaymentMethodCreateParams(), paymentMethodExtraParams = currentSelection?.getPaymentMethodExtraParams(), + usBankAccountFormArguments = usBankAccountFormArguments, ), ) ?: emptyList() } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/addresselement/FormControllerModule.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/addresselement/FormControllerModule.kt index 1ac27b37bd0..567cb03280c 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/addresselement/FormControllerModule.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/addresselement/FormControllerModule.kt @@ -6,9 +6,7 @@ import com.stripe.android.cards.DefaultCardAccountRangeRepositoryFactory import com.stripe.android.core.injection.INITIAL_VALUES import com.stripe.android.core.injection.SHIPPING_VALUES import com.stripe.android.lpmfoundations.luxe.TransformSpecToElements -import com.stripe.android.lpmfoundations.paymentmethod.UiDefinitionFactory import com.stripe.android.paymentsheet.PaymentSheet -import com.stripe.android.ui.core.cbc.CardBrandChoiceEligibility import com.stripe.android.uicore.elements.IdentifierSpec import dagger.Module import dagger.Provides @@ -18,31 +16,16 @@ import javax.inject.Named internal object FormControllerModule { @Provides fun provideTransformSpecToElements( - context: Context, merchantName: String, @Named(INITIAL_VALUES) initialValues: Map, @Named(SHIPPING_VALUES) shippingValues: Map? ) = TransformSpecToElements( - arguments = UiDefinitionFactory.Arguments( + arguments = TransformSpecToElements.Arguments( initialValues = initialValues, shippingValues = shippingValues, - saveForFutureUseInitialValue = false, merchantName = merchantName, - cardAccountRangeRepositoryFactory = DefaultCardAccountRangeRepositoryFactory(context.applicationContext), - cbcEligibility = CardBrandChoiceEligibility.Ineligible, billingDetailsCollectionConfiguration = PaymentSheet.BillingDetailsCollectionConfiguration(), requiresMandate = false, - /* - * `FormController` is only used by `AddressElement` now so it does not require a - * `LinkConfigurationCoordinator` instance or a callback for reacting to `InlineSignUpViewState` changes. - */ - linkConfigurationCoordinator = null, - onLinkInlineSignupStateChanged = { - throw IllegalStateException( - "`InlineSignUpViewState` updates should not be received by `FormController`!" - ) - }, - cardBrandFilter = DefaultCardBrandFilter ) ) } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountForm.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountForm.kt index a3aa542cea4..1f67afff861 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountForm.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountForm.kt @@ -28,11 +28,9 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.unit.dp -import androidx.lifecycle.viewmodel.compose.viewModel import com.stripe.android.paymentsheet.PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode import com.stripe.android.paymentsheet.PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode import com.stripe.android.paymentsheet.R -import com.stripe.android.paymentsheet.model.PaymentSelection.New import com.stripe.android.paymentsheet.paymentdatacollection.FormArguments import com.stripe.android.ui.core.elements.SaveForFutureUseElement import com.stripe.android.ui.core.elements.SaveForFutureUseElementUI @@ -60,29 +58,11 @@ const val TEST_TAG_ACCOUNT_DETAILS = "TEST_TAG_ACCOUNT_DETAILS" @Composable internal fun USBankAccountForm( + viewModel: USBankAccountFormViewModel, formArgs: FormArguments, usBankAccountFormArgs: USBankAccountFormArguments, modifier: Modifier = Modifier, ) { - val viewModel = viewModel( - factory = USBankAccountFormViewModel.Factory { - USBankAccountFormViewModel.Args( - instantDebits = usBankAccountFormArgs.instantDebits, - linkMode = usBankAccountFormArgs.linkMode, - formArgs = formArgs, - hostedSurface = usBankAccountFormArgs.hostedSurface, - showCheckbox = usBankAccountFormArgs.showCheckbox, - isCompleteFlow = usBankAccountFormArgs.isCompleteFlow, - isPaymentFlow = usBankAccountFormArgs.isPaymentFlow, - stripeIntentId = usBankAccountFormArgs.stripeIntentId, - clientSecret = usBankAccountFormArgs.clientSecret, - onBehalfOf = usBankAccountFormArgs.onBehalfOf, - savedPaymentMethod = usBankAccountFormArgs.draftPaymentSelection as? New.USBankAccount, - shippingDetails = usBankAccountFormArgs.shippingDetails, - ) - }, - ) - val state by viewModel.currentScreenState.collectAsState() val lastTextFieldIdentifier by viewModel.lastTextFieldIdentifier.collectAsState() diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentElement.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentElement.kt index 777c00060bf..6afe0b7d3cd 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentElement.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentElement.kt @@ -19,13 +19,10 @@ import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.stripe.android.lpmfoundations.luxe.SupportedPaymentMethod -import com.stripe.android.model.PaymentMethod.Type.Link -import com.stripe.android.model.PaymentMethod.Type.USBankAccount import com.stripe.android.model.PaymentMethodCode import com.stripe.android.paymentsheet.R import com.stripe.android.paymentsheet.forms.FormFieldValues import com.stripe.android.paymentsheet.paymentdatacollection.FormArguments -import com.stripe.android.paymentsheet.paymentdatacollection.ach.USBankAccountForm import com.stripe.android.paymentsheet.paymentdatacollection.ach.USBankAccountFormArguments import com.stripe.android.uicore.elements.FormElement import com.stripe.android.uicore.image.StripeImageLoader @@ -56,9 +53,6 @@ internal fun PaymentElement( val selectedIndex = remember(selectedItemCode, supportedPaymentMethods) { supportedPaymentMethods.map { it.code }.indexOf(selectedItemCode) } - val selectedItem = remember(selectedIndex, supportedPaymentMethods) { - supportedPaymentMethods[selectedIndex] - } Column(modifier = modifier.fillMaxWidth()) { if (supportedPaymentMethods.size > 1) { @@ -74,7 +68,6 @@ internal fun PaymentElement( FormElement( enabled = enabled, - selectedPaymentMethodCode = selectedItem.code, formElements = formElements, formArguments = formArguments, usBankAccountFormArguments = usBankAccountFormArguments, @@ -88,7 +81,6 @@ internal fun PaymentElement( @Composable internal fun FormElement( enabled: Boolean, - selectedPaymentMethodCode: PaymentMethodCode, formElements: List, formArguments: FormArguments, usBankAccountFormArguments: USBankAccountFormArguments, @@ -119,22 +111,14 @@ internal fun FormElement( } } ) { - if (selectedPaymentMethodCode == USBankAccount.code || selectedPaymentMethodCode == Link.code) { - USBankAccountForm( - formArgs = formArguments, - usBankAccountFormArgs = usBankAccountFormArguments, - modifier = Modifier.padding(horizontal = horizontalPadding), - ) - } else { - PaymentMethodForm( - uuid = uuid, - args = formArguments, - enabled = enabled, - onFormFieldValuesChanged = onFormFieldValuesChanged, - formElements = formElements, - modifier = Modifier.padding(horizontal = horizontalPadding) - ) - } + PaymentMethodForm( + uuid = uuid, + args = formArguments, + enabled = enabled, + onFormFieldValuesChanged = onFormFieldValuesChanged, + formElements = formElements, + modifier = Modifier.padding(horizontal = horizontalPadding) + ) } } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/verticalmode/VerticalModeFormInteractor.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/verticalmode/VerticalModeFormInteractor.kt index c7982f42d54..2ef1263ff45 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/verticalmode/VerticalModeFormInteractor.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/verticalmode/VerticalModeFormInteractor.kt @@ -30,7 +30,6 @@ internal interface VerticalModeFormInteractor { fun close() data class State( - val selectedPaymentMethodCode: String, val isProcessing: Boolean, val usBankAccountFormArguments: USBankAccountFormArguments, val formArguments: FormArguments, @@ -59,7 +58,6 @@ internal class DefaultVerticalModeFormInteractor( ) : VerticalModeFormInteractor { override val state: StateFlow = processing.mapAsStateFlow { isProcessing -> VerticalModeFormInteractor.State( - selectedPaymentMethodCode = selectedPaymentMethodCode, isProcessing = isProcessing, usBankAccountFormArguments = usBankAccountArguments, formArguments = formArguments, diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/verticalmode/VerticalModeFormUI.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/verticalmode/VerticalModeFormUI.kt index f7d6e8924a7..becd1b39d9d 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/verticalmode/VerticalModeFormUI.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/verticalmode/VerticalModeFormUI.kt @@ -48,7 +48,6 @@ internal fun VerticalModeFormUI(interactor: VerticalModeFormInteractor) { FormElement( enabled = enabled, - selectedPaymentMethodCode = state.selectedPaymentMethodCode, formElements = state.formElements, formArguments = state.formArguments, usBankAccountFormArguments = state.usBankAccountFormArguments,