Skip to content

[Link in FlowController] Consumes backend linkSettings and removes client flag #10891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ data class ElementsSession(
val suppressLink2faModal: Boolean
get() = linkSettings?.suppress2faModal ?: false

val disableRuxInFlowController: Boolean
get() = linkSettings?.disableLinkRuxInFlowController ?: false

val enableLinkInSpm: Boolean
get() = flags[Flag.ELEMENTS_ENABLE_LINK_SPM] == true

Expand All @@ -65,7 +68,8 @@ data class ElementsSession(
val disableLinkSignup: Boolean,
val linkConsumerIncentive: LinkConsumerIncentive?,
val useAttestationEndpoints: Boolean,
val suppress2faModal: Boolean
val suppress2faModal: Boolean,
val disableLinkRuxInFlowController: Boolean
) : StripeModel

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ internal class ElementsSessionJsonParser(
val disableLinkSignup = json?.optBoolean(FIELD_DISABLE_LINK_SIGNUP) == true
val linkPassthroughModeEnabled = json?.optBoolean(FIELD_LINK_PASSTHROUGH_MODE_ENABLED) == true
val useLinkAttestationEndpoints = json?.optBoolean(FIELD_USE_LINK_ATTESTATION_ENDPOINTS) == true
val disableLinkRuxInFlowController = json?.optBoolean(FIELD_LINK_MOBILE_DISABLE_RUX_IN_FLOW_CONTROLLER) == true
val suppressLink2faModal = json?.optBoolean(FIELD_LINK_SUPPRESS_2FA_MODAL) == true

val linkMode = json?.optString(FIELD_LINK_MODE)?.let { mode ->
Expand All @@ -193,7 +194,8 @@ internal class ElementsSessionJsonParser(
disableLinkSignup = disableLinkSignup,
linkConsumerIncentive = linkConsumerIncentive,
useAttestationEndpoints = useLinkAttestationEndpoints,
suppress2faModal = suppressLink2faModal
suppress2faModal = suppressLink2faModal,
disableLinkRuxInFlowController = disableLinkRuxInFlowController
)
}

Expand Down Expand Up @@ -439,6 +441,8 @@ internal class ElementsSessionJsonParser(
private const val FIELD_LINK_MODE = "link_mode"
private const val FIELD_DISABLE_LINK_SIGNUP = "link_mobile_disable_signup"
private const val FIELD_USE_LINK_ATTESTATION_ENDPOINTS = "link_mobile_use_attestation_endpoints"
private const val FIELD_LINK_MOBILE_DISABLE_RUX_IN_FLOW_CONTROLLER =
"link_mobile_disable_rux_in_flow_controller"
private const val FIELD_LINK_SUPPRESS_2FA_MODAL = "link_mobile_suppress_2fa_modal"
private const val FIELD_MERCHANT_COUNTRY = "merchant_country"
private const val FIELD_PAYMENT_METHOD_PREFERENCE = "payment_method_preference"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ internal class PlaygroundSettings private constructor(
PaymentMethodOptionsSetupFutureUsageSettingsDefinition,
PaymentMethodOptionsSetupFutureUsageOverrideSettingsDefinition,
WalletButtonsSettingsDefinition,
FeatureFlagSettingsDefinition(FeatureFlags.linkProminenceInFlowController),
FeatureFlagSettingsDefinition(FeatureFlags.showInlineOtpInWalletButtons),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal data class LinkConfiguration(
val cardBrandFilter: CardBrandFilter,
val useAttestationEndpointsForLink: Boolean,
val suppress2faModal: Boolean,
val disableRuxInFlowController: Boolean,
val initializationMode: PaymentElementLoader.InitializationMode,
val elementsSessionId: String,
val linkMode: LinkMode?,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ internal class DefaultLinkGate @Inject constructor(
}

override val useInlineOtpInWalletButtons: Boolean
get() {
return FeatureFlags.showInlineOtpInWalletButtons.isEnabled && useNativeLink
}
get() = FeatureFlags.showInlineOtpInWalletButtons.isEnabled && useNativeLink

override val showRuxInFlowController: Boolean
get() = useNativeLink && configuration.disableRuxInFlowController == false

class Factory @Inject constructor() : LinkGate.Factory {
override fun create(configuration: LinkConfiguration): LinkGate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ package com.stripe.android.link.gate

import com.stripe.android.link.LinkConfiguration

/**
* Provider interface for Link feature settings and behaviors, handling
* the logic for determining when to show special Link UI elements or trigger automatic
* behaviors to enhance the Link payment experience.
*/
Comment on lines +5 to +9
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially missed this class and then created LinkProminenceFeatureProvider. Deleted the latter and added docs to LinkGate so this doesn't happen to others in the future.

internal interface LinkGate {
val useNativeLink: Boolean
val useAttestationEndpoints: Boolean
val suppress2faModal: Boolean
val useInlineOtpInWalletButtons: Boolean
val showRuxInFlowController: Boolean

fun interface Factory {
fun create(configuration: LinkConfiguration): LinkGate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.stripe.android.link.LinkLaunchMode
import com.stripe.android.link.LinkPaymentLauncher
import com.stripe.android.link.account.LinkAccountHolder
import com.stripe.android.link.account.updateLinkAccount
import com.stripe.android.link.domain.LinkProminenceFeatureProvider
import com.stripe.android.link.gate.LinkGate
import com.stripe.android.link.model.LinkAccount
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadata
import com.stripe.android.lpmfoundations.paymentmethod.WalletType
Expand Down Expand Up @@ -52,8 +52,8 @@ import kotlin.coroutines.CoroutineContext
@JvmSuppressWildcards
internal class PaymentOptionsViewModel @Inject constructor(
private val args: PaymentOptionContract.Args,
private val linkProminenceFeatureProvider: LinkProminenceFeatureProvider,
private val linkAccountHolder: LinkAccountHolder,
private val linkGateFactory: LinkGate.Factory,
val linkPaymentLauncher: LinkPaymentLauncher,
eventReporter: EventReporter,
customerRepository: CustomerRepository,
Expand Down Expand Up @@ -277,7 +277,7 @@ internal class PaymentOptionsViewModel @Inject constructor(
linkConfiguration: LinkConfiguration
): Boolean {
return paymentSelection is Link &&
linkProminenceFeatureProvider.shouldShowEarlyVerificationInFlowController(linkConfiguration)
linkGateFactory.create(linkConfiguration).showRuxInFlowController
}

override fun handlePaymentMethodSelected(selection: PaymentSelection?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.stripe.android.link.LinkPaymentLauncher
import com.stripe.android.link.LinkPaymentMethod
import com.stripe.android.link.account.LinkAccountHolder
import com.stripe.android.link.account.updateLinkAccount
import com.stripe.android.link.domain.LinkProminenceFeatureProvider
import com.stripe.android.link.gate.LinkGate
import com.stripe.android.link.model.AccountStatus
import com.stripe.android.link.model.toLoginState
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadata
Expand Down Expand Up @@ -91,7 +91,7 @@ internal class DefaultFlowController @Inject internal constructor(
private val eventReporter: EventReporter,
private val viewModel: FlowControllerViewModel,
private val confirmationHandler: ConfirmationHandler,
private val linkProminenceFeatureProvider: LinkProminenceFeatureProvider,
private val linkGateFactory: LinkGate.Factory,
private val linkHandler: LinkHandler,
private val linkAccountHolder: LinkAccountHolder,
@Named(FLOW_CONTROLLER_LINK_LAUNCHER) private val flowControllerLinkLauncher: LinkPaymentLauncher,
Expand Down Expand Up @@ -268,12 +268,13 @@ internal class DefaultFlowController @Inject internal constructor(
val paymentSelection = viewModel.paymentSelection
val linkAccountInfo = linkAccountHolder.linkAccountInfo.value

if (linkConfiguration != null && shouldPresentLinkInsteadOfPaymentOptions(
paymentSelection = paymentSelection,
linkAccountInfo = linkAccountInfo,
linkConfiguration = linkConfiguration
)
) {
val shouldPresentLink = linkConfiguration != null && shouldPresentLinkInsteadOfPaymentOptions(
paymentSelection = paymentSelection,
linkAccountInfo = linkAccountInfo,
linkConfiguration = linkConfiguration
)

if (shouldPresentLink) {
flowControllerLinkLauncher.present(
configuration = linkConfiguration,
linkAccountInfo = linkAccountInfo,
Expand All @@ -300,7 +301,7 @@ internal class DefaultFlowController @Inject internal constructor(
// The current user has a Link account (not necessarily logged in)
linkAccountInfo.account != null &&
// feature flag and other conditions are met
linkProminenceFeatureProvider.shouldShowEarlyVerificationInFlowController(linkConfiguration)
linkGateFactory.create(linkConfiguration).showRuxInFlowController
}

private fun showPaymentOptionList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import com.stripe.android.core.utils.UserFacingLogger
import com.stripe.android.link.LinkConfigurationCoordinator
import com.stripe.android.link.RealLinkConfigurationCoordinator
import com.stripe.android.link.account.LinkAccountHolder
import com.stripe.android.link.domain.DefaultLinkProminenceFeatureProvider
import com.stripe.android.link.domain.LinkProminenceFeatureProvider
import com.stripe.android.link.gate.DefaultLinkGate
import com.stripe.android.link.gate.LinkGate
import com.stripe.android.link.injection.LinkAnalyticsComponent
Expand Down Expand Up @@ -115,9 +113,6 @@ internal abstract class PaymentSheetCommonModule {
@Binds
abstract fun bindLinkGateFactory(linkGateFactory: DefaultLinkGate.Factory): LinkGate.Factory

@Binds
abstract fun bindLinkProminence(provider: DefaultLinkProminenceFeatureProvider): LinkProminenceFeatureProvider

@Binds
abstract fun bindsCardAccountRangeRepositoryFactory(
defaultCardAccountRangeRepositoryFactory: DefaultCardAccountRangeRepositoryFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ internal class DefaultPaymentElementLoader @Inject constructor(
flags = elementsSession.linkFlags,
useAttestationEndpointsForLink = elementsSession.useAttestationEndpointsForLink,
suppress2faModal = elementsSession.suppressLink2faModal,
disableRuxInFlowController = elementsSession.disableRuxInFlowController,
elementsSessionId = elementsSession.elementsSessionId,
initializationMode = initializationMode,
linkMode = elementsSession.linkSettings?.linkMode,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ internal object TestFactory {
elementsSessionId = "session_1234",
linkMode = LinkMode.LinkPaymentMethod,
allowDefaultOptIn = false,
disableRuxInFlowController = false
)

val LINK_WALLET_PRIMARY_BUTTON_LABEL = Amount(
Expand Down

This file was deleted.

Loading
Loading