Skip to content
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

Fix issue where sepa mandate text is incorrectly being displayed #7303

Merged
merged 1 commit into from
Sep 13, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [ADDED] PaymentSheet now supports the following payment methods for PaymentIntents:
* [7281](https://github.com/stripe/stripe-android/pull/7281) OXXO
* [ADDED][7282](https://github.com/stripe/stripe-android/pull/7282) PaymentSheet now supports Boleto for PaymentIntents, SetupIntents, and PaymentIntents with setup for future usage.
* [FIXED][7303](https://github.com/stripe/stripe-android/pull/7303) Fixed an issue where SEPA mandate texts were being displayed for payment methods when they shouldn't be.

## 20.30.1 - 2023-09-11

Expand Down
1 change: 1 addition & 0 deletions paymentsheet/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<ID>LongMethod:PaymentOptionFactory.kt$PaymentOptionFactory$fun create(selection: PaymentSelection): PaymentOption</ID>
<ID>LongMethod:PaymentSheetConfigurationKtx.kt$internal fun PaymentSheet.Appearance.parseAppearance()</ID>
<ID>LongMethod:PaymentSheetLoader.kt$DefaultPaymentSheetLoader$private suspend fun create( elementsSession: ElementsSession, config: PaymentSheet.Configuration?, isGooglePayReady: Boolean, ): PaymentSheetState.Full</ID>
<ID>LongMethod:PlaceholderHelperTest.kt$PlaceholderHelperTest$@Test fun `Test correct placeholder is removed for placeholder spec`()</ID>
<ID>LongMethod:USBankAccountForm.kt$@Composable internal fun USBankAccountForm( formArgs: FormArguments, usBankAccountFormArgs: USBankAccountFormArguments, isProcessing: Boolean, modifier: Modifier = Modifier, )</ID>
<ID>LongMethod:USBankAccountForm.kt$@Composable private fun AccountDetailsForm( formArgs: FormArguments, isProcessing: Boolean, bankName: String?, last4: String?, saveForFutureUseElement: SaveForFutureUseElement, onRemoveAccount: () -> Unit, )</ID>
<ID>MagicNumber:AutocompleteScreen.kt$0.07f</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ internal object PlaceholderHelper {
PlaceholderField.Email,
PlaceholderField.Phone,
PlaceholderField.BillingAddress,
PlaceholderField.SepaMandate,
)

val modifiedSpecs = specs.mapNotNull {
Expand All @@ -61,10 +60,6 @@ internal object PlaceholderHelper {
configuration.address == AddressCollectionMode.Never
}

is SepaMandateTextSpec -> it.takeIf {
requiresMandate
}

is PlaceholderSpec -> specForPlaceholderField(
it.field,
placeholderOverrideList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class PlaceholderHelperTest {
EmailSpec(),
PhoneSpec(),
AddressSpec(),
SepaMandateTextSpec(),
),
)
assertThat(specs).isEmpty()
Expand Down Expand Up @@ -109,7 +108,54 @@ class PlaceholderHelperTest {
)
}

@Suppress("LongMethod")
@Test
fun `Test when requiresMandate is true, SepaMandateSpec is only added when specified`() {
val specs = specsForConfiguration(
configuration = PaymentSheet.BillingDetailsCollectionConfiguration(),
placeholderOverrideList = emptyList(),
requiresMandate = true,
specs = listOf(
NameSpec(),
),
)

assertThat(specs).containsExactly(
NameSpec(),
)

val specsWithSepa = specsForConfiguration(
configuration = PaymentSheet.BillingDetailsCollectionConfiguration(),
placeholderOverrideList = emptyList(),
requiresMandate = true,
specs = listOf(
NameSpec(),
SepaMandateTextSpec()
),
)

assertThat(specsWithSepa).containsExactly(
NameSpec(),
SepaMandateTextSpec()
)

val specsWithSepaPlaceholder = specsForConfiguration(
configuration = PaymentSheet.BillingDetailsCollectionConfiguration(),
placeholderOverrideList = emptyList(),
requiresMandate = true,
specs = listOf(
NameSpec(),
PlaceholderSpec(
field = PlaceholderSpec.PlaceholderField.SepaMandate,
)
),
)

assertThat(specsWithSepaPlaceholder).containsExactly(
NameSpec(),
SepaMandateTextSpec()
)
}

@Test
fun `Test correct spec is returned for placeholder fields`() {
val billingDetailsCollectionConfiguration = PaymentSheet.BillingDetailsCollectionConfiguration(
Expand Down Expand Up @@ -160,6 +206,14 @@ class PlaceholderHelperTest {
configuration = billingDetailsCollectionConfiguration,
)
).isEqualTo(AddressSpec(hideCountry = true))
assertThat(
specForPlaceholderField(
field = PlaceholderField.SepaMandate,
placeholderOverrideList = emptyList(),
requiresMandate = true,
configuration = billingDetailsCollectionConfiguration,
)
).isEqualTo(SepaMandateTextSpec())
}

@Test
Expand Down Expand Up @@ -222,6 +276,7 @@ class PlaceholderHelperTest {
PlaceholderField.Email,
PlaceholderField.Phone,
PlaceholderField.BillingAddress,
PlaceholderField.SepaMandate,
)

placeholders = basePlaceholders()
Expand All @@ -230,6 +285,7 @@ class PlaceholderHelperTest {
PlaceholderField.Name,
PlaceholderField.Phone,
PlaceholderField.BillingAddress,
PlaceholderField.SepaMandate,
)

placeholders = basePlaceholders()
Expand All @@ -238,6 +294,7 @@ class PlaceholderHelperTest {
PlaceholderField.Name,
PlaceholderField.Email,
PlaceholderField.BillingAddress,
PlaceholderField.SepaMandate,
)

placeholders = basePlaceholders()
Expand All @@ -246,6 +303,16 @@ class PlaceholderHelperTest {
PlaceholderField.Name,
PlaceholderField.Email,
PlaceholderField.Phone,
PlaceholderField.SepaMandate,
)

placeholders = basePlaceholders()
removeCorrespondingPlaceholder(placeholders, SepaMandateTextSpec())
assertThat(placeholders).containsExactly(
PlaceholderField.Name,
PlaceholderField.Email,
PlaceholderField.Phone,
PlaceholderField.BillingAddress,
)
}

Expand All @@ -257,6 +324,7 @@ class PlaceholderHelperTest {
PlaceholderField.Email,
PlaceholderField.Phone,
PlaceholderField.BillingAddress,
PlaceholderField.SepaMandate,
)

placeholders = basePlaceholders()
Expand All @@ -268,6 +336,7 @@ class PlaceholderHelperTest {
PlaceholderField.Name,
PlaceholderField.Phone,
PlaceholderField.BillingAddress,
PlaceholderField.SepaMandate,
)

placeholders = basePlaceholders()
Expand All @@ -279,6 +348,7 @@ class PlaceholderHelperTest {
PlaceholderField.Name,
PlaceholderField.Email,
PlaceholderField.BillingAddress,
PlaceholderField.SepaMandate,
)

placeholders = basePlaceholders()
Expand All @@ -290,6 +360,7 @@ class PlaceholderHelperTest {
PlaceholderField.Name,
PlaceholderField.Email,
PlaceholderField.Phone,
PlaceholderField.SepaMandate,
)

placeholders = basePlaceholders()
Expand All @@ -301,6 +372,19 @@ class PlaceholderHelperTest {
PlaceholderField.Name,
PlaceholderField.Email,
PlaceholderField.Phone,
PlaceholderField.SepaMandate,
)

placeholders = basePlaceholders()
removeCorrespondingPlaceholder(
placeholders,
PlaceholderSpec(field = PlaceholderField.SepaMandate)
)
assertThat(placeholders).containsExactly(
PlaceholderField.Name,
PlaceholderField.Email,
PlaceholderField.Phone,
PlaceholderField.BillingAddress,
)
}

Expand Down Expand Up @@ -383,5 +467,6 @@ class PlaceholderHelperTest {
PlaceholderField.Email,
PlaceholderField.Phone,
PlaceholderField.BillingAddress,
PlaceholderField.SepaMandate,
)
}