Skip to content
Merged
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 @@ -423,7 +423,6 @@ internal class PlaygroundSettings private constructor(
CustomerSessionRedisplaySettingsDefinition,
CustomerSessionRedisplayFiltersSettingsDefinition,
CustomerSessionOverrideRedisplaySettingsDefinition,
FeatureFlagSettingsDefinition(FeatureFlags.editSavedCardPaymentMethodEnabled),
CustomerSettingsDefinition,
CheckoutModeSettingsDefinition,
LinkSettingsDefinition,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.stripe.android.customersheet.data

import com.stripe.android.core.injection.IOContext
import com.stripe.android.core.utils.FeatureFlags
import com.stripe.android.customersheet.CustomerPermissions
import com.stripe.android.customersheet.CustomerSheet
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodSaveConsentBehavior
Expand Down Expand Up @@ -58,7 +57,8 @@ internal class CustomerSessionInitializationDataSource @Inject constructor(
component.isPaymentMethodRemoveEnabled
is ElementsSession.Customer.Components.CustomerSheet.Disabled -> false
},
canUpdateFullPaymentMethodDetails = FeatureFlags.editSavedCardPaymentMethodEnabled.isEnabled
// Should always be enabled when using `customer_session`
canUpdateFullPaymentMethodDetails = true
),
defaultPaymentMethodId = customer.defaultPaymentMethod,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.stripe.android.paymentsheet.state

import android.os.Parcelable
import com.stripe.android.common.model.CommonConfiguration
import com.stripe.android.core.utils.FeatureFlags
import com.stripe.android.model.ElementsSession
import com.stripe.android.model.PaymentMethod
import com.stripe.android.paymentsheet.PaymentSheet
Expand Down Expand Up @@ -76,7 +75,8 @@ internal data class CustomerState(
canRemoveLastPaymentMethod = canRemoveLastPaymentMethod,
// Should always remove duplicates when using `customer_session`
canRemoveDuplicates = true,
canUpdateFullPaymentMethodDetails = FeatureFlags.editSavedCardPaymentMethodEnabled.isEnabled,
// Should always be enabled when using `customer_session`
canUpdateFullPaymentMethodDetails = true,
),
defaultPaymentMethodId = customer.defaultPaymentMethod
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.stripe.android.customersheet

import android.app.Application
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.junit4.createAndroidComposeRule
Expand All @@ -9,6 +10,7 @@ import androidx.lifecycle.testing.TestLifecycleOwner
import androidx.test.core.app.ActivityScenario
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.stripe.android.common.configuration.ConfigurationDefaults
import com.stripe.android.core.utils.urlEncode
import com.stripe.android.customersheet.util.CustomerSheetHacks
import com.stripe.android.model.CardBrand
Expand All @@ -21,6 +23,7 @@ import com.stripe.android.networktesting.RequestMatchers.query
import com.stripe.android.networktesting.ResponseReplacement
import com.stripe.android.networktesting.testBodyFromFile
import com.stripe.android.paymentsheet.ExperimentalCustomerSessionApi
import com.stripe.android.paymentsheet.PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode
import com.stripe.android.paymentsheet.PaymentSheetFixtures
import com.stripe.android.paymentsheet.RemoveDialog
import com.stripe.android.paymentsheet.ui.FORM_ELEMENT_TEST_TAG
Expand Down Expand Up @@ -95,19 +98,19 @@ class CustomerSessionCustomerSheetActivityTest {
}

@Test
fun `When single PM with remove permissions but cannot remove last PM, edit button should not be displayed`() =
fun `When single PM with remove permissions but cannot remove last PM, edit button should be displayed`() =
runTest(
cards = listOf(
PaymentMethodFactory.card(last4 = "4242"),
),
isPaymentMethodRemoveEnabled = true,
allowsRemovalOfLastSavedPaymentMethod = false,
) {
savedPaymentMethodsPage.onEditButton().assertDoesNotExist()
savedPaymentMethodsPage.onEditButton().assertIsDisplayed()
}

@Test
fun `When multiple PMs but no remove permissions, edit button should not be displayed`() =
fun `When multiple PMs but no remove permissions, edit button should be displayed`() =
runTest(
cards = listOf(
PaymentMethodFactory.card(last4 = "4242"),
Expand All @@ -116,7 +119,7 @@ class CustomerSessionCustomerSheetActivityTest {
isPaymentMethodRemoveEnabled = false,
allowsRemovalOfLastSavedPaymentMethod = true,
) {
savedPaymentMethodsPage.onEditButton().assertDoesNotExist()
savedPaymentMethodsPage.onEditButton().assertIsDisplayed()
}

@Test
Expand Down Expand Up @@ -261,6 +264,7 @@ class CustomerSessionCustomerSheetActivityTest {
),
isPaymentMethodRemoveEnabled = true,
allowsRemovalOfLastSavedPaymentMethod = true,
addressCollectionMode = AddressCollectionMode.Never
) {
savedPaymentMethodsPage.onEditButton().performClick()
savedPaymentMethodsPage.onModifyBadgeFor(last4 = "4242").performClick()
Expand Down Expand Up @@ -292,6 +296,7 @@ class CustomerSessionCustomerSheetActivityTest {
createDuplicateCard(id = "pm_1", addCbcNetworks = true),
PaymentMethodFactory.card(last4 = "1001"),
),
addressCollectionMode = AddressCollectionMode.Never
) {
savedPaymentMethodsPage.onEditButton().performClick()
savedPaymentMethodsPage.onModifyBadgeFor(last4 = "4242").performClick()
Expand Down Expand Up @@ -324,6 +329,7 @@ class CustomerSessionCustomerSheetActivityTest {
PaymentMethodFactory.card(id = "pm_1")
.update(last4 = "1001", addCbcNetworks = true),
),
addressCollectionMode = AddressCollectionMode.Never
) {
savedPaymentMethodsPage.onEditButton().performClick()
savedPaymentMethodsPage.onModifyBadgeFor(last4 = "1001").performClick()
Expand All @@ -343,6 +349,7 @@ class CustomerSessionCustomerSheetActivityTest {
isPaymentMethodRemoveEnabled: Boolean = true,
isCanRemoveLastPaymentMethodEnabled: Boolean = true,
allowsRemovalOfLastSavedPaymentMethod: Boolean = true,
addressCollectionMode: AddressCollectionMode = AddressCollectionMode.Automatic,
test: (CustomerSheetActivity) -> Unit,
) {
CustomerSheetHacks.initialize(
Expand Down Expand Up @@ -393,6 +400,10 @@ class CustomerSessionCustomerSheetActivityTest {
merchantDisplayName = "Merchant, Inc.",
allowsRemovalOfLastSavedPaymentMethod = allowsRemovalOfLastSavedPaymentMethod,
preferredNetworks = listOf(CardBrand.CartesBancaires, CardBrand.Visa),
billingDetailsCollectionConfiguration = ConfigurationDefaults
.billingDetailsCollectionConfiguration.copy(
address = addressCollectionMode
)
),
statusBarColor = PaymentSheetFixtures.STATUS_BAR_COLOR,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,20 @@ package com.stripe.android.customersheet.data

import com.google.common.truth.Truth.assertThat
import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi
import com.stripe.android.core.utils.FeatureFlags
import com.stripe.android.customersheet.CustomerSheet
import com.stripe.android.customersheet.CustomerSheetFixtures
import com.stripe.android.isInstanceOf
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodSaveConsentBehavior
import com.stripe.android.model.ElementsSession
import com.stripe.android.model.PaymentMethod
import com.stripe.android.paymentsheet.model.SavedSelection
import com.stripe.android.testing.FeatureFlagTestRule
import com.stripe.android.testing.PaymentMethodFactory
import com.stripe.android.testing.SetupIntentFactory
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
import kotlin.coroutines.coroutineContext

class CustomerSessionInitializationDataSourceTest {
@get:Rule
val editSavedCardPaymentMethodEnabledFeatureFlagTestRule = FeatureFlagTestRule(
featureFlag = FeatureFlags.editSavedCardPaymentMethodEnabled,
isEnabled = false
)

@Test
fun `on load, should return expected successful state`() = runTest {
Expand Down Expand Up @@ -105,8 +97,7 @@ class CustomerSessionInitializationDataSourceTest {
}

@Test
fun `on load, canUpdateFullPaymentMethodDetails should enabled when feature flag is enabled`() = runTest {
editSavedCardPaymentMethodEnabledFeatureFlagTestRule.setEnabled(true)
fun `on load, canUpdateFullPaymentMethodDetails should be enabled`() = runTest {
val dataSource = createInitializationDataSource(
elementsSessionManager = FakeCustomerSessionElementsSessionManager(
customerSheetComponent = ElementsSession.Customer.Components.CustomerSheet.Disabled,
Expand All @@ -119,21 +110,6 @@ class CustomerSessionInitializationDataSourceTest {
assertThat(customerSheetSession.permissions.canUpdateFullPaymentMethodDetails).isTrue()
}

@Test
fun `on load, canUpdateFullPaymentMethodDetails should enabled when feature flag is disabled`() = runTest {
editSavedCardPaymentMethodEnabledFeatureFlagTestRule.setEnabled(false)
val dataSource = createInitializationDataSource(
elementsSessionManager = FakeCustomerSessionElementsSessionManager(
customerSheetComponent = ElementsSession.Customer.Components.CustomerSheet.Disabled,
),
)

val result = dataSource.loadCustomerSheetSession(createConfiguration())
val customerSheetSession = result.asSuccess().value

assertThat(customerSheetSession.permissions.canUpdateFullPaymentMethodDetails).isFalse()
}

@Test
fun `on load, should use customer default PM if default PM feature is enabled`() = runTest {
val expectedDefaultPaymentMethodId = "pm_123"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Application
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.hasAnyAncestor
import androidx.compose.ui.test.hasAnyDescendant
Expand Down Expand Up @@ -78,11 +79,11 @@ internal class CustomerSessionPaymentSheetActivityTest {
) {
composeTestRule.onEditButton().performClick()

composeTestRule.onSavedPaymentMethod(last4 = "4242").assertIsEnabled()
composeTestRule.onSavedPaymentMethod(last4 = "4242").assertIsDisplayed()
}

@Test
fun `When single PM with remove permissions and cannot remove last PM from server, edit should not be shown`() =
fun `When single PM with remove permissions and cannot remove last PM from server, edit should be shown`() =
runTest(
cards = listOf(
PaymentMethodFactory.card(last4 = "4242"),
Expand All @@ -91,11 +92,11 @@ internal class CustomerSessionPaymentSheetActivityTest {
canRemoveLastPaymentMethodConfig = true,
canRemoveLastPaymentMethodServer = false,
) {
composeTestRule.onEditButton().assertDoesNotExist()
composeTestRule.onEditButton().assertIsDisplayed()
}

@Test
fun `When single PM with remove permissions & cannot remove last PM from config, edit should not be shown`() =
fun `When single PM with remove permissions & cannot remove last PM from config, edit should be shown`() =
runTest(
cards = listOf(
PaymentMethodFactory.card(last4 = "4242"),
Expand All @@ -104,11 +105,11 @@ internal class CustomerSessionPaymentSheetActivityTest {
canRemoveLastPaymentMethodConfig = false,
canRemoveLastPaymentMethodServer = true,
) {
composeTestRule.onEditButton().assertDoesNotExist()
composeTestRule.onEditButton().assertIsDisplayed()
}

@Test
fun `When single PM with remove permissions but cannot remove last PM, edit button should not be displayed`() =
fun `When single PM with remove permissions but cannot remove last PM, edit button should be displayed`() =
runTest(
cards = listOf(
PaymentMethodFactory.card(last4 = "4242"),
Expand All @@ -117,11 +118,11 @@ internal class CustomerSessionPaymentSheetActivityTest {
canRemoveLastPaymentMethodConfig = false,
canRemoveLastPaymentMethodServer = false,
) {
composeTestRule.onEditButton().assertDoesNotExist()
composeTestRule.onEditButton().assertExists()
}

@Test
fun `When multiple PMs but no remove permissions, edit button should not be displayed`() =
fun `When multiple PMs but no remove permissions, edit button should be displayed`() =
runTest(
cards = listOf(
PaymentMethodFactory.card(last4 = "4242"),
Expand All @@ -131,7 +132,7 @@ internal class CustomerSessionPaymentSheetActivityTest {
canRemoveLastPaymentMethodConfig = true,
canRemoveLastPaymentMethodServer = false,
) {
composeTestRule.onEditButton().assertDoesNotExist()
composeTestRule.onEditButton().assertIsDisplayed()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.stripe.android.core.Logger
import com.stripe.android.core.exception.APIConnectionException
import com.stripe.android.core.model.CountryCode
import com.stripe.android.core.strings.resolvableString
import com.stripe.android.core.utils.FeatureFlags
import com.stripe.android.googlepaylauncher.GooglePayRepository
import com.stripe.android.isInstanceOf
import com.stripe.android.link.LinkConfiguration
Expand Down Expand Up @@ -48,7 +47,6 @@ import com.stripe.android.paymentsheet.repositories.ElementsSessionRepository
import com.stripe.android.paymentsheet.state.PaymentSheetLoadingException.PaymentIntentInTerminalState
import com.stripe.android.paymentsheet.utils.FakeUserFacingLogger
import com.stripe.android.testing.FakeErrorReporter
import com.stripe.android.testing.FeatureFlagTestRule
import com.stripe.android.testing.PaymentMethodFactory
import com.stripe.android.testing.PaymentMethodFactory.update
import com.stripe.android.ui.core.cbc.CardBrandChoiceEligibility
Expand All @@ -58,7 +56,6 @@ import com.stripe.android.utils.FakeElementsSessionRepository
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.MockitoAnnotations
Expand All @@ -77,12 +74,6 @@ import kotlin.test.Test
@OptIn(ExperimentalCustomPaymentMethodsApi::class)
internal class DefaultPaymentElementLoaderTest {

@get:Rule
val editSavedCardPaymentMethodEnabledFeatureFlagTestRule = FeatureFlagTestRule(
featureFlag = FeatureFlags.editSavedCardPaymentMethodEnabled,
isEnabled = false
)

private val testDispatcher = UnconfinedTestDispatcher()
private val eventReporter = mock<EventReporter>()

Expand Down Expand Up @@ -1611,7 +1602,7 @@ internal class DefaultPaymentElementLoaderTest {
canRemovePaymentMethods = true,
canRemoveLastPaymentMethod = true,
canRemoveDuplicates = true,
canUpdateFullPaymentMethodDetails = false
canUpdateFullPaymentMethodDetails = true
)
)
}
Expand Down Expand Up @@ -1654,7 +1645,7 @@ internal class DefaultPaymentElementLoaderTest {
canRemovePaymentMethods = false,
canRemoveLastPaymentMethod = true,
canRemoveDuplicates = true,
canUpdateFullPaymentMethodDetails = false
canUpdateFullPaymentMethodDetails = true
)
)
}
Expand Down Expand Up @@ -1697,16 +1688,15 @@ internal class DefaultPaymentElementLoaderTest {
canRemovePaymentMethods = false,
canRemoveLastPaymentMethod = true,
canRemoveDuplicates = true,
canUpdateFullPaymentMethodDetails = false
canUpdateFullPaymentMethodDetails = true
)
)
}

@OptIn(ExperimentalCustomerSessionApi::class)
@Test
fun `customer session with edit saved payment method enabled, should enable canUpdateFullPaymentMethodDetails permission`() =
fun `customer session should have canUpdateFullPaymentMethodDetails permission enabled`() =
runTest {
editSavedCardPaymentMethodEnabledFeatureFlagTestRule.setEnabled(true)
val loader = createPaymentElementLoader(
customer = ElementsSession.Customer(
paymentMethods = PaymentMethodFactory.cards(4),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ object FeatureFlags {
val nativeLinkEnabled = FeatureFlag("Native Link")
val nativeLinkAttestationEnabled = FeatureFlag("Native Link Attestation")
val instantDebitsIncentives = FeatureFlag("Instant Bank Payments Incentives")
val editSavedCardPaymentMethodEnabled = FeatureFlag("Edit Saved Card Payment Method")
val financialConnectionsFullSdkUnavailable = FeatureFlag("FC Full SDK Unavailable")
val enableCardEditInLinkNative = FeatureFlag("Enable Card Edit In Link Native")
}
Expand Down
Loading