-
Notifications
You must be signed in to change notification settings - Fork 663
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
Show blocked brands as disabled in CBC drop down #9979
base: master
Are you sure you want to change the base?
Changes from 11 commits
1ad03a3
40c64b1
a2a3721
e527569
147efff
401fb0d
3e6cf4b
564ce84
02f2e88
58c3ed8
ae24beb
b445665
7b5b154
a4ebd98
6c9b10c
7e36e22
053f854
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,12 @@ import com.stripe.android.cards.CardAccountRangeService | |
import com.stripe.android.cards.CardNumber | ||
import com.stripe.android.cards.DefaultStaticCardAccountRanges | ||
import com.stripe.android.cards.StaticCardAccountRanges | ||
import com.stripe.android.core.strings.plus | ||
import com.stripe.android.core.strings.resolvableString | ||
import com.stripe.android.model.AccountRange | ||
import com.stripe.android.model.CardBrand | ||
import com.stripe.android.stripecardscan.cardscan.CardScanSheetResult | ||
import com.stripe.android.ui.core.R | ||
import com.stripe.android.ui.core.asIndividualDigits | ||
import com.stripe.android.ui.core.elements.events.LocalCardBrandDisallowedReporter | ||
import com.stripe.android.ui.core.elements.events.LocalCardNumberCompletedEventReporter | ||
|
@@ -178,8 +180,7 @@ internal class DefaultCardNumberController( | |
brandChoices.value = newBrandChoices | ||
} | ||
}, | ||
isCbcEligible = { isEligibleForCardBrandChoice }, | ||
cardBrandFilter = cardBrandFilter | ||
isCbcEligible = { isEligibleForCardBrandChoice } | ||
) | ||
|
||
override val trailingIcon: StateFlow<TextFieldIcon?> = combineAsStateFlow( | ||
|
@@ -214,10 +215,18 @@ internal class DefaultCardNumberController( | |
} | ||
|
||
val items = brands.map { brand -> | ||
val enabled = cardBrandFilter.isAccepted(brand) | ||
TextFieldIcon.Dropdown.Item( | ||
id = brand.code, | ||
label = brand.displayName.resolvableString, | ||
icon = brand.icon | ||
label = if (enabled) { | ||
brand.displayName.resolvableString | ||
} else { | ||
brand.displayName.resolvableString + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be pretty easy to parameterize, let me know if you want to pair on it! |
||
" ".resolvableString + | ||
resolvableString(R.string.stripe_card_brand_not_accepted) | ||
}, | ||
icon = brand.icon, | ||
enabled = enabled | ||
) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,4 +222,6 @@ | |
<!-- A text notice shown when the user selects an expired card. --> | ||
<string name="stripe_wallet_update_expired_card_error">This card has expired. Update your card info or choose a different payment method.</string> | ||
<string name="stripe_wallet_expand_accessibility">Change selection</string> | ||
<!-- Shown in a dropdown picker next to a card brand that is not accepted by a merchant. E.g. "Visa (not accepted)" --> | ||
<string name="stripe_card_brand_not_accepted">(not accepted)</string> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there one file where I can put these rather than in two strings.xml files? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can access the one in |
||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,27 @@ | ||
package com.stripe.android.paymentsheet.ui | ||
|
||
import com.stripe.android.core.strings.ResolvableString | ||
import com.stripe.android.core.strings.plus | ||
import com.stripe.android.core.strings.resolvableString | ||
import com.stripe.android.model.CardBrand | ||
import com.stripe.android.paymentsheet.R | ||
import com.stripe.android.uicore.elements.SingleChoiceDropdownItem | ||
|
||
internal data class CardBrandChoice( | ||
val brand: CardBrand | ||
val brand: CardBrand, | ||
override val enabled: Boolean | ||
) : SingleChoiceDropdownItem { | ||
|
||
override val icon: Int | ||
get() = brand.icon | ||
|
||
override val label: ResolvableString | ||
get() = brand.displayName.resolvableString | ||
get() = if (enabled) { | ||
brand.displayName.resolvableString | ||
} else { | ||
// If it's disabled, append "not accepted" to the end of the brand display name | ||
brand.displayName.resolvableString + | ||
" ".resolvableString + | ||
resolvableString(R.string.stripe_card_brand_not_accepted) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a parameterized string (I know some languages won't have the same ordering as english).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's a good idea. I should do this on iOS too.