Skip to content

Commit

Permalink
Remove CustomerSheet ACHv2 flag. (#8176)
Browse files Browse the repository at this point in the history
* Remove CustomerSheet `ACHv2` flag.

* Remove `isFinancialConnectionsAvailable` check and consolidate tests in `CustomerSheetActivity` into a single test.

* Add changelog item for enabling `ACH` in `CustomerSheet`
  • Loading branch information
samer-stripe committed Mar 29, 2024
1 parent 50b3857 commit 8d1d87d
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 133 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## XX.XX.XX - 2023-XX-XX

### CustomerSheet
* [Added][8176](https://github.com/stripe/stripe-android/pull/8176) Enabled ACH Direct Debit in CustomerSheet

### Financial Connections
* [CHANGED][8157](https://github.com/stripe/stripe-android/pull/8157) Financial Connections no longer depends on the Mavericks library.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,6 @@ class CustomerSheetPlaygroundActivity : AppCompatActivity() {
configurationState = configurationState,
viewActionHandler = viewActionHandler,
)
AchEnabledSwitch(
configurationState = configurationState,
viewActionHandler = viewActionHandler,
)
BillingDetailsConfiguration(
configurationState = configurationState,
viewActionHandler = viewActionHandler,
Expand Down Expand Up @@ -380,29 +376,6 @@ class CustomerSheetPlaygroundActivity : AppCompatActivity() {
}
}

@Composable
private fun AchEnabledSwitch(
configurationState: CustomerSheetPlaygroundConfigurationState,
viewActionHandler: (CustomerSheetPlaygroundViewAction) -> Unit,
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.fillMaxWidth()
) {
Text(
text = "US Bank Accounts",
color = MaterialTheme.colors.onBackground,
)
Switch(
checked = configurationState.achEnabled,
onCheckedChange = {
viewActionHandler(CustomerSheetPlaygroundViewAction.ToggleAchEnabled)
},
)
}
}

@Suppress("LongMethod")
@Composable
private fun BillingDetailsConfiguration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ sealed class CustomerSheetPlaygroundViewAction {
object ToggleExistingCustomer : CustomerSheetPlaygroundViewAction()
object ToggleUseDefaultBillingAddress : CustomerSheetPlaygroundViewAction()
object ToggleAttachDefaultBillingAddress : CustomerSheetPlaygroundViewAction()
object ToggleAchEnabled : CustomerSheetPlaygroundViewAction()
object ToggleAllowsRemovalOfLastSavedPaymentMethod : CustomerSheetPlaygroundViewAction()
data class UpdateBillingNameCollection(val value: String) : CustomerSheetPlaygroundViewAction()
data class UpdateBillingEmailCollection(val value: String) : CustomerSheetPlaygroundViewAction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.github.kittinunf.fuel.core.requests.suspendable
import com.github.kittinunf.result.Result
import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi
import com.stripe.android.PaymentConfiguration
import com.stripe.android.core.utils.FeatureFlags.customerSheetACHv2
import com.stripe.android.core.utils.requireApplication
import com.stripe.android.customersheet.CustomerAdapter
import com.stripe.android.customersheet.CustomerEphemeralKey
Expand Down Expand Up @@ -230,8 +229,6 @@ class CustomerSheetPlaygroundViewModel(
toggleSetupIntentEnabled()
is CustomerSheetPlaygroundViewAction.ToggleExistingCustomer ->
toggleExistingCustomer()
is CustomerSheetPlaygroundViewAction.ToggleAchEnabled ->
toggleAchEnabled()
is CustomerSheetPlaygroundViewAction.ToggleUseDefaultBillingAddress ->
toggleUseDefaultBillingAddress()
is CustomerSheetPlaygroundViewAction.ToggleAttachDefaultBillingAddress ->
Expand Down Expand Up @@ -315,15 +312,6 @@ class CustomerSheetPlaygroundViewModel(
}
}

private fun toggleAchEnabled() {
updateConfiguration {
customerSheetACHv2.setEnabled(!it.achEnabled)
it.copy(
achEnabled = !it.achEnabled,
)
}
}

private fun toggleUseDefaultBillingAddress() {
updateConfiguration {
it.copy(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.stripe.android.customersheet

import com.stripe.android.core.injection.IS_LIVE_MODE
import com.stripe.android.core.utils.FeatureFlags.customerSheetACHv2
import com.stripe.android.customersheet.util.CustomerSheetHacks
import com.stripe.android.googlepaylauncher.GooglePayEnvironment
import com.stripe.android.googlepaylauncher.GooglePayRepository
Expand Down Expand Up @@ -173,10 +172,7 @@ internal class DefaultCustomerSheetLoader(

val supportedPaymentMethods = metadata.sortedSupportedPaymentMethods()

val validSupportedPaymentMethods = filterSupportedPaymentMethods(
supportedPaymentMethods,
isFinancialConnectionsAvailable,
)
val validSupportedPaymentMethods = filterSupportedPaymentMethods(supportedPaymentMethods)

Result.success(
CustomerSheetState.Full(
Expand All @@ -198,13 +194,10 @@ internal class DefaultCustomerSheetLoader(

private fun filterSupportedPaymentMethods(
supportedPaymentMethods: List<SupportedPaymentMethod>,
isFinancialConnectionsAvailable: IsFinancialConnectionsAvailable,
): List<SupportedPaymentMethod> {
val supported = setOfNotNull(
PaymentMethod.Type.Card.code,
PaymentMethod.Type.USBankAccount.code.takeIf {
customerSheetACHv2.isEnabled && isFinancialConnectionsAvailable()
}
PaymentMethod.Type.USBankAccount.code
)
return supportedPaymentMethods.filter {
supported.contains(it.code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.google.common.truth.Truth.assertThat
import com.stripe.android.PaymentConfiguration
import com.stripe.android.core.StripeError
import com.stripe.android.core.exception.APIException
import com.stripe.android.core.utils.FeatureFlags
import com.stripe.android.customersheet.CustomerAdapter.PaymentOption.Companion.toPaymentOption
import com.stripe.android.customersheet.StripeCustomerAdapter.Companion.CACHED_CUSTOMER_MAX_AGE_MILLIS
import com.stripe.android.customersheet.util.CustomerSheetHacks
Expand All @@ -20,13 +19,11 @@ import com.stripe.android.paymentsheet.PrefsRepository
import com.stripe.android.paymentsheet.model.PaymentSelection
import com.stripe.android.paymentsheet.model.SavedSelection
import com.stripe.android.paymentsheet.repositories.CustomerRepository
import com.stripe.android.testing.FeatureFlagTestRule
import com.stripe.android.utils.FakeCustomerRepository
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.any
Expand All @@ -45,12 +42,6 @@ class CustomerAdapterTest {
private val application = ApplicationProvider.getApplicationContext<Application>()
private val testDispatcher = UnconfinedTestDispatcher()

@get:Rule
val featureFlagTestRule = FeatureFlagTestRule(
featureFlag = FeatureFlags.customerSheetACHv2,
isEnabled = true,
)

@Before
fun setup() {
PaymentConfiguration.init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import com.google.common.truth.Truth.assertThat
import com.stripe.android.ApiKeyFixtures
import com.stripe.android.PaymentConfiguration
import com.stripe.android.core.strings.resolvableString
import com.stripe.android.core.utils.FeatureFlags
import com.stripe.android.customersheet.analytics.CustomerSheetEventReporter
import com.stripe.android.customersheet.utils.CustomerSheetTestHelper.createViewModel
import com.stripe.android.lpmfoundations.luxe.LpmRepositoryTestHelpers
Expand All @@ -22,7 +21,6 @@ import com.stripe.android.model.PaymentMethodFixtures
import com.stripe.android.paymentsheet.forms.FormViewModel
import com.stripe.android.paymentsheet.model.PaymentSelection
import com.stripe.android.paymentsheet.paymentdatacollection.FormArguments
import com.stripe.android.testing.FeatureFlagTestRule
import com.stripe.android.ui.core.cbc.CardBrandChoiceEligibility
import com.stripe.android.utils.InjectableActivityScenario
import com.stripe.android.utils.TestUtils.viewModelFactoryFor
Expand All @@ -43,12 +41,6 @@ internal class CustomerSheetActivityTest {
@get:Rule
val rule = InstantTaskExecutorRule()

@get:Rule
val featureFlagTestRule = FeatureFlagTestRule(
FeatureFlags.customerSheetACHv2,
isEnabled = true
)

@get:Rule
val composeTestRule = createEmptyComposeRule()

Expand Down Expand Up @@ -222,7 +214,7 @@ internal class CustomerSheetActivityTest {
}

@Test
fun `When customer ACHv2 is enabled, should display form elements`() {
fun `When add payment method screen is shown, should display form elements`() {
val eventReporter: CustomerSheetEventReporter = mock()

runActivityScenario(
Expand All @@ -233,17 +225,6 @@ internal class CustomerSheetActivityTest {
}
}

@Test
fun `When customer ACHv2 is disabled, should display form elements`() {
featureFlagTestRule.setEnabled(false)

runActivityScenario(
viewState = createAddPaymentMethodViewState(),
) {
page.waitForText("Card number")
}
}

@Test
fun `When card number is completed, should execute event`() {
val eventReporter: CustomerSheetEventReporter = mock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.stripe.android.core.strings.resolvableString
import com.stripe.android.core.utils.FeatureFlags
import com.stripe.android.customersheet.ui.CustomerSheetScreen
import com.stripe.android.lpmfoundations.luxe.LpmRepositoryTestHelpers
import com.stripe.android.model.CardBrand
Expand All @@ -17,7 +16,6 @@ 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.DefaultEditPaymentMethodViewInteractor
import com.stripe.android.testing.FeatureFlagTestRule
import com.stripe.android.testing.PaymentMethodFactory
import com.stripe.android.ui.core.cbc.CardBrandChoiceEligibility
import com.stripe.android.utils.screenshots.FontSize
Expand All @@ -38,12 +36,6 @@ internal class CustomerSheetScreenshotTest {
.fillMaxWidth(),
)

@get:Rule
val featureFlagTestRule = FeatureFlagTestRule(
featureFlag = FeatureFlags.customerSheetACHv2,
isEnabled = false,
)

private val usBankAccountFormArguments = USBankAccountFormArguments(
onBehalfOf = null,
isCompleteFlow = false,
Expand Down Expand Up @@ -230,7 +222,6 @@ internal class CustomerSheetScreenshotTest {

@Test
fun testMandateAbovePrimaryButton() {
featureFlagTestRule.setEnabled(true)
paparazzi.snapshot {
CustomerSheetScreen(
viewState = addPaymentMethodViewState.copy(
Expand All @@ -249,7 +240,6 @@ internal class CustomerSheetScreenshotTest {

@Test
fun testMandateBelowPrimaryButton() {
featureFlagTestRule.setEnabled(true)
paparazzi.snapshot {
CustomerSheetScreen(
viewState = addPaymentMethodViewState.copy(
Expand All @@ -268,7 +258,6 @@ internal class CustomerSheetScreenshotTest {

@Test
fun testConfirmCloseDialog() {
featureFlagTestRule.setEnabled(true)
paparazzi.snapshot {
CustomerSheetScreen(
viewState = addPaymentMethodViewState.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.stripe.android.PaymentConfiguration
import com.stripe.android.core.StripeError
import com.stripe.android.core.exception.APIException
import com.stripe.android.core.strings.resolvableString
import com.stripe.android.core.utils.FeatureFlags
import com.stripe.android.customersheet.CustomerSheetViewState.AddPaymentMethod
import com.stripe.android.customersheet.CustomerSheetViewState.SelectPaymentMethod
import com.stripe.android.customersheet.analytics.CustomerSheetEventReporter
Expand Down Expand Up @@ -44,7 +43,6 @@ import com.stripe.android.paymentsheet.ui.EditPaymentMethodViewAction.OnUpdatePr
import com.stripe.android.paymentsheet.ui.EditPaymentMethodViewState
import com.stripe.android.paymentsheet.ui.PrimaryButton
import com.stripe.android.testing.CoroutineTestRule
import com.stripe.android.testing.FeatureFlagTestRule
import com.stripe.android.testing.PaymentMethodFactory
import com.stripe.android.ui.core.elements.CardBillingAddressElement
import com.stripe.android.ui.core.elements.CardDetailsSectionElement
Expand Down Expand Up @@ -75,12 +73,6 @@ class CustomerSheetViewModelTest {

private val testDispatcher = UnconfinedTestDispatcher(TestCoroutineScheduler())

@get:Rule
val featureFlagTestRule = FeatureFlagTestRule(
featureFlag = FeatureFlags.customerSheetACHv2,
isEnabled = false,
)

@get:Rule
val coroutineTestRule = CoroutineTestRule(testDispatcher)

Expand Down Expand Up @@ -472,8 +464,6 @@ class CustomerSheetViewModelTest {

@Test
fun `When CustomerViewAction#OnAddCardPressed & ACHv2 disabled, view state is updated to CustomerViewAction#AddPaymentMethod and fields are shwon`() = runTest(testDispatcher) {
featureFlagTestRule.setEnabled(false)

val viewModel = createViewModel(
workContext = testDispatcher
)
Expand Down Expand Up @@ -1704,8 +1694,6 @@ class CustomerSheetViewModelTest {

@Test
fun `Payment method form changes on user selection`() = runTest(testDispatcher) {
featureFlagTestRule.setEnabled(true)

val viewModel = createViewModel(
workContext = testDispatcher,
initialBackStack = listOf(
Expand All @@ -1732,8 +1720,6 @@ class CustomerSheetViewModelTest {

@Test
fun `Payment method user selection saved after returning to add screen`() = runTest(testDispatcher) {
featureFlagTestRule.setEnabled(true)

val viewModel = createViewModel(
workContext = testDispatcher,
initialBackStack = listOf(
Expand Down Expand Up @@ -1773,8 +1759,6 @@ class CustomerSheetViewModelTest {

@Test
fun `When the payment method form is us bank account, the primary button label is continue`() = runTest(testDispatcher) {
featureFlagTestRule.setEnabled(true)

val viewModel = createViewModel(
workContext = testDispatcher,
initialBackStack = listOf(
Expand Down
Loading

0 comments on commit 8d1d87d

Please sign in to comment.