Skip to content

Commit

Permalink
Remove local feature flag for Instant Debits
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe committed May 9, 2024
1 parent ec923ae commit d11cd61
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.compose.ui.test.isEnabled
import androidx.compose.ui.test.onNodeWithText
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.stripe.android.BasePlaygroundTest
import com.stripe.android.core.utils.FeatureFlags
import com.stripe.android.model.PaymentMethod
import com.stripe.android.paymentsheet.example.playground.settings.AutomaticPaymentMethodsSettingsDefinition
import com.stripe.android.paymentsheet.example.playground.settings.Country
Expand All @@ -15,16 +14,13 @@ import com.stripe.android.paymentsheet.example.playground.settings.Currency
import com.stripe.android.paymentsheet.example.playground.settings.CurrencySettingsDefinition
import com.stripe.android.paymentsheet.example.playground.settings.DefaultBillingAddress
import com.stripe.android.paymentsheet.example.playground.settings.DefaultBillingAddressSettingsDefinition
import com.stripe.android.paymentsheet.example.playground.settings.EnableInstantDebitsSettingsDefinition
import com.stripe.android.paymentsheet.example.playground.settings.LinkSettingsDefinition
import com.stripe.android.paymentsheet.example.playground.settings.SupportedPaymentMethodsSettingsDefinition
import com.stripe.android.paymentsheet.ui.PAYMENT_SHEET_PRIMARY_BUTTON_TEST_TAG
import com.stripe.android.test.core.AuthorizeAction
import com.stripe.android.test.core.TestParameters
import com.stripe.android.test.core.ui.ComposeButton
import com.stripe.android.testing.FeatureFlagTestRule
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

Expand All @@ -43,15 +39,8 @@ internal class TestInstantDebits : BasePlaygroundTest() {
PaymentMethod.Type.Card,
PaymentMethod.Type.Link
).joinToString(",")
settings[EnableInstantDebitsSettingsDefinition] = true
}

@get:Rule
val instantDebitsFeatureRule = FeatureFlagTestRule(
featureFlag = FeatureFlags.instantDebits,
isEnabled = true,
)

@Test
@Ignore
fun testInstantDebitsSuccess() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ internal class PlaygroundSettings private constructor(
CustomerSettingsDefinition,
CheckoutModeSettingsDefinition,
LinkSettingsDefinition,
EnableInstantDebitsSettingsDefinition,
CountrySettingsDefinition,
CurrencySettingsDefinition,
GooglePaySettingsDefinition,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.stripe.android.lpmfoundations.paymentmethod

import com.stripe.android.core.utils.FeatureFlags
import com.stripe.android.model.PaymentIntent
import com.stripe.android.model.PaymentMethod.Type.USBankAccount

Expand Down Expand Up @@ -64,8 +63,7 @@ internal enum class AddPaymentMethodRequirement {
val noUsBankAccount = USBankAccount.code !in paymentMethodTypes
val supportsBankAccounts = "bank_account" in metadata.stripeIntent.linkFundingSources
val isDeferred = metadata.stripeIntent.clientSecret == null
val isEnabled = FeatureFlags.instantDebits.isEnabled
return noUsBankAccount && supportsBankAccounts && !isDeferred && isEnabled
return noUsBankAccount && supportsBankAccounts && !isDeferred
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
package com.stripe.android.lpmfoundations.paymentmethod

import com.google.common.truth.Truth.assertThat
import com.stripe.android.core.utils.FeatureFlags
import com.stripe.android.lpmfoundations.paymentmethod.AddPaymentMethodRequirement.InstantDebits
import com.stripe.android.model.Address
import com.stripe.android.model.PaymentIntent
import com.stripe.android.model.PaymentIntentFixtures
import com.stripe.android.model.SetupIntentFixtures
import com.stripe.android.model.StripeIntent
import com.stripe.android.testing.FeatureFlagTestRule
import com.stripe.android.testing.PaymentIntentFactory
import org.junit.Rule
import org.junit.Test

internal class AddPaymentMethodRequirementTest {

@get:Rule
val instantDebitsFeatureRule = FeatureFlagTestRule(
featureFlag = FeatureFlags.instantDebits,
isEnabled = false,
)

@Test
fun testUnsupportedReturnsFalse() {
val metadata = PaymentMethodMetadataFactory.create()
Expand Down Expand Up @@ -171,30 +162,15 @@ internal class AddPaymentMethodRequirementTest {

@Test
fun testInstantDebitsReturnsTrue() {
instantDebitsFeatureRule.setEnabled(true)

val metadata = PaymentMethodMetadataFactory.create(
stripeIntent = createValidInstantDebitsPaymentIntent(),
)

assertThat(InstantDebits.isMetBy(metadata)).isTrue()
}

@Test
fun testInstantDebitsReturnsFalseIfFeatureNotEnabled() {
instantDebitsFeatureRule.setEnabled(false)

val metadata = PaymentMethodMetadataFactory.create(
stripeIntent = createValidInstantDebitsPaymentIntent(),
)

assertThat(InstantDebits.isMetBy(metadata)).isFalse()
}

@Test
fun testInstantDebitsReturnsFalseIfDeferredIntent() {
instantDebitsFeatureRule.setEnabled(true)

val metadata = PaymentMethodMetadataFactory.create(
stripeIntent = createValidInstantDebitsPaymentIntent().copy(
clientSecret = null,
Expand All @@ -206,8 +182,6 @@ internal class AddPaymentMethodRequirementTest {

@Test
fun testInstantDebitsReturnsFalseIfShowingUsBankAccount() {
instantDebitsFeatureRule.setEnabled(true)

val metadata = PaymentMethodMetadataFactory.create(
stripeIntent = createValidInstantDebitsPaymentIntent().copy(
paymentMethodTypes = listOf("card", "link", "us_bank_account"),
Expand All @@ -219,8 +193,6 @@ internal class AddPaymentMethodRequirementTest {

@Test
fun testInstantDebitsReturnsFalseIfOnlyCardFundingSource() {
instantDebitsFeatureRule.setEnabled(true)

val metadata = PaymentMethodMetadataFactory.create(
stripeIntent = createValidInstantDebitsPaymentIntent().copy(
linkFundingSources = listOf("card"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import androidx.annotation.RestrictTo
import com.stripe.android.core.BuildConfig

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Suppress("unused")
object FeatureFlags {
val instantDebits = FeatureFlag()
// Add any feature flags here
}

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
Expand Down

0 comments on commit d11cd61

Please sign in to comment.