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

Compose credit element #4358

Merged
merged 127 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
c5ef5ec
[WIP]
michelleb-stripe Aug 9, 2021
0c95106
Display and receive input for Credit Card number and CVC.
michelleb-stripe Aug 12, 2021
75e54d1
Add in the credit billing fields, need hidden visibility to work on a…
michelleb-stripe Aug 12, 2021
cd4ff51
Merge with master.
michelleb-stripe Aug 12, 2021
da41eb0
Billing code now shows the correct fields.
michelleb-stripe Aug 12, 2021
a9a04ac
Billing now added to the credit element.
michelleb-stripe Aug 12, 2021
2ceac10
Credit card number length verification corrected.
michelleb-stripe Aug 12, 2021
e35e2c7
Refactor Elements so each element (including sections) provide the fo…
michelleb-stripe Aug 17, 2021
f897f12
Add in the expiration date functionality.
michelleb-stripe Aug 18, 2021
53661e1
Merge branch 'master' into michelleb/credit-card-compose
michelleb-stripe Aug 21, 2021
4f20fb2
Refactor so that each element returns a flow of FormFieldEntries, so …
michelleb-stripe Aug 21, 2021
940f304
Fix unit test
michelleb-stripe Aug 23, 2021
e8fc0ff
Merge with master.
michelleb-stripe Aug 23, 2021
7e5ee6a
Rename class
michelleb-stripe Aug 23, 2021
c3d7b28
More rework
michelleb-stripe Aug 23, 2021
a61ea99
Merge with michelleb/refactor-section-form-fields
michelleb-stripe Aug 23, 2021
b3be29c
Get ready for merge with master
michelleb-stripe Aug 27, 2021
9a258ec
Merge with master.
michelleb-stripe Aug 29, 2021
57b617c
Merge with master
michelleb-stripe Sep 20, 2021
3e60136
Merge with master.
michelleb-stripe Nov 2, 2021
4d8ec20
Change from liveData to flow.
michelleb-stripe Nov 2, 2021
591a73e
Merge branch 'michelleb/convert-to-flow' into michelleb/credit-card-c…
michelleb-stripe Nov 2, 2021
2aeb3ef
Row is working but not expiry date
michelleb-stripe Nov 2, 2021
9161d4f
Make the keypad just numbers.
michelleb-stripe Nov 2, 2021
0441d0a
Make the keypad just numbers.
michelleb-stripe Nov 2, 2021
c41ec5d
Set the expiration month and date correctly in the formFieldValues
michelleb-stripe Nov 2, 2021
fdad41f
Update the focus to visit the CVC
michelleb-stripe Nov 2, 2021
43c9127
Handle a full text field state.
michelleb-stripe Nov 3, 2021
317a841
Merge with master
michelleb-stripe Nov 4, 2021
8e649c8
Unit tests
michelleb-stripe Nov 5, 2021
9ead541
ktlintFormat
michelleb-stripe Nov 5, 2021
939dba9
Format card number based on max pan for card number
michelleb-stripe Nov 5, 2021
60da73f
Cleanup date util for expiration month
michelleb-stripe Nov 5, 2021
f51f90b
Make the label flowable
michelleb-stripe Nov 5, 2021
fef63b3
Fix internals
michelleb-stripe Nov 9, 2021
f19cbe2
Cleanup
michelleb-stripe Nov 9, 2021
07cfa62
Cleanup
michelleb-stripe Nov 9, 2021
bd5d754
Merge with master
michelleb-stripe Nov 9, 2021
2722977
Fix unit tests
michelleb-stripe Nov 9, 2021
4bee0c1
ktlintFormat
michelleb-stripe Nov 9, 2021
4b78747
Undos
michelleb-stripe Nov 9, 2021
9242d80
ktlintFormat
michelleb-stripe Nov 9, 2021
b1cd5b0
Merge with master
michelleb-stripe Nov 11, 2021
239273d
Merge remote-tracking branch 'origin/master' into michelleb/credit-ca…
michelleb-stripe Nov 17, 2021
8eb4204
Merge with master
michelleb-stripe Nov 29, 2021
40fe6c0
Merge with master
michelleb-stripe Dec 2, 2021
adaed05
Ignore tests that cause other failures
michelleb-stripe Dec 5, 2021
667bd39
Merge branch 'master' into michelleb/credit-card-compose
michelleb-stripe Feb 3, 2022
7c5e474
Working on the merge.
michelleb-stripe Feb 4, 2022
1eee681
Almost building
michelleb-stripe Feb 4, 2022
7ed49f3
Get closer to master
michelleb-stripe Feb 4, 2022
e68a86a
Update files.
michelleb-stripe Feb 4, 2022
f0fa03a
Iterating
michelleb-stripe Feb 4, 2022
5ad3f10
Building
michelleb-stripe Feb 4, 2022
a3c9eae
Fix unit tests
michelleb-stripe Feb 4, 2022
e2f39c4
Cleanup
michelleb-stripe Feb 8, 2022
57677d8
Remove extra comment
michelleb-stripe Feb 8, 2022
6bee0a4
Fix failing tests
epan-stripe Feb 8, 2022
2c6e45c
Fix linting
epan-stripe Feb 8, 2022
8b5d2ae
Fix SaveForFutureUseController.label not showing
epan-stripe Feb 8, 2022
313f52a
Merge with master
michelleb-stripe Feb 8, 2022
c1e78f7
Cleanup
michelleb-stripe Feb 8, 2022
6c9cb94
apiDump
michelleb-stripe Feb 9, 2022
508b5ad
Merge with master
michelleb-stripe Feb 9, 2022
33b754a
apiDump
michelleb-stripe Feb 9, 2022
7819db6
Fix some failing tests, apiDump, ktlintFormat
michelleb-stripe Feb 10, 2022
b3917f9
Fix remaining failing tests, apiDump, ktlintFormat
michelleb-stripe Feb 10, 2022
95d8557
Fix todo
michelleb-stripe Feb 10, 2022
7af4ff5
Merge remote-tracking branch 'origin/master' into michelleb/credit-ca…
michelleb-stripe Feb 10, 2022
afd06c9
Simplify and add DateConfig tests and cleanup commented out code in T…
michelleb-stripe Feb 11, 2022
98043bd
Merge with master
michelleb-stripe Feb 11, 2022
8ca28d2
Merge remote-tracking branch 'origin/master' into michelleb/credit-ca…
michelleb-stripe Feb 14, 2022
9bf81f2
ktlintFormat apiDump
michelleb-stripe Feb 14, 2022
783039a
Merge with master
michelleb-stripe Feb 15, 2022
bf51053
Add icons to the IBAN, credit card and CVC fields. (#4359)
michelleb-stripe Feb 18, 2022
7979d18
Merge with master
michelleb-stripe Feb 22, 2022
bd3fb81
Merge with remote
michelleb-stripe Feb 22, 2022
a18c6c2
Add Card Metadata Service to CardNumberController (#4573)
epan-stripe Feb 25, 2022
b4cacba
Don't show cardbrand if there are multiple possibilities
epan-stripe Feb 25, 2022
06c5d00
Don't show cardbrand if there are multiple possibilities
epan-stripe Feb 25, 2022
c179b73
Merge branch 'michelleb/credit-card-compose' of github.com:stripe/str…
epan-stripe Feb 25, 2022
61200f9
Merge remote-tracking branch 'origin/master' into michelleb/credit-ca…
michelleb-stripe Feb 25, 2022
110ecd3
Merge with master
michelleb-stripe Feb 25, 2022
067ea3b
Material Theme information gathering.
michelleb-stripe Feb 25, 2022
36913d3
Revert "Material Theme information gathering."
michelleb-stripe Feb 25, 2022
167b00f
Immediately detect invalid card numbers (no brand)
epan-stripe Mar 1, 2022
8701f44
Fix invalid vs incomplete dateconfig error text
epan-stripe Mar 1, 2022
b6fff48
Fix CVC icon and next field focus
epan-stripe Mar 2, 2022
3ed0104
Fix expiry date accessibility reader
epan-stripe Mar 2, 2022
7f3d2f2
Merge branch 'master' into michelleb/credit-card-compose
epan-stripe Mar 2, 2022
d92df95
Fix merge issues
epan-stripe Mar 2, 2022
e2880f4
Add ability to move focus on delete
jameswoo-stripe Mar 3, 2022
81042c0
Merge remote-tracking branch 'origin/master' into michelleb/credit-ca…
michelleb-stripe Mar 3, 2022
219e999
Fix dark mode error underline
epan-stripe Mar 3, 2022
126de9a
Fix cursor and spacing position in card details
epan-stripe Mar 4, 2022
10f4f47
update icons and colors for future wardrobe work
skyler-stripe Mar 4, 2022
da16b49
Merge branch 'master' into michelleb/credit-card-compose
michelleb-stripe Mar 8, 2022
0d7f077
Merge branch 'michelleb/credit-card-compose' of github.com:stripe/str…
michelleb-stripe Mar 8, 2022
ba21e4a
Add card information title
epan-stripe Mar 8, 2022
0c87580
Add tests for card number formatting
epan-stripe Mar 9, 2022
7a60b61
Revert "Add tests for card number formatting"
epan-stripe Mar 9, 2022
d2ff7ba
Add country list to card and sepa billing spec. (#4669)
michelleb-stripe Mar 9, 2022
55a143b
Credit Card Address and focus bug fixes (#4665)
michelleb-stripe Mar 9, 2022
f111ac0
Fix width of rows (#4676)
epan-stripe Mar 11, 2022
f3d960b
Fix spacing for AMEX and Discover cards (#4672)
epan-stripe Mar 11, 2022
f8c7ec7
Don't show CVC error when CardBrand is unknown (#4681)
epan-stripe Mar 14, 2022
5fbad06
Stop accessibility talkback reading textfields twice (#4683)
epan-stripe Mar 14, 2022
c6363f2
Merge with master
michelleb-stripe Mar 14, 2022
c5c70e5
Merge branch 'michelleb/credit-card-compose' of github.com:stripe/str…
michelleb-stripe Mar 14, 2022
2ba55b8
ktformat
michelleb-stripe Mar 14, 2022
6fb7a3f
Fix detekt
michelleb-stripe Mar 14, 2022
b9095ff
checkbox colors read from theme object now
skyler-stripe Mar 15, 2022
23a2a48
Fix the delete button move to previous. (#4706)
michelleb-stripe Mar 15, 2022
e23283b
Improve performance of dropdown in forms. (#4705)
michelleb-stripe Mar 16, 2022
eafd4c3
Merge with master. (Sepa debit address is broken - the row fields ar…
michelleb-stripe Mar 16, 2022
e89c5c1
Card now showing up correctly.
michelleb-stripe Mar 16, 2022
3b818e7
Merge branch 'michelleb/credit-card-compose' of github.com:stripe/str…
michelleb-stripe Mar 16, 2022
4119def
Fix compile error.
michelleb-stripe Mar 16, 2022
33a004c
Don't show cardbrand if there are multiple possible (#4682)
epan-stripe Mar 16, 2022
cd76630
Merge branch 'master' into michelleb/credit-card-compose
michelleb-stripe Mar 17, 2022
bcc452e
Merge branch 'michelleb/credit-card-compose' of github.com:stripe/str…
michelleb-stripe Mar 17, 2022
e3c29bb
Merge remote-tracking branch 'origin/master' into michelleb/credit-ca…
michelleb-stripe Mar 20, 2022
e79cfdd
merge master
skyler-stripe Mar 24, 2022
8f8c288
Merge remote-tracking branch 'origin/master' into michelleb/credit-ca…
michelleb-stripe Mar 30, 2022
c777dfc
Merge with master
michelleb-stripe Mar 31, 2022
f2e59b9
Fix merge errors.
michelleb-stripe Mar 31, 2022
51dfa5d
Update the changedoc.
michelleb-stripe Mar 31, 2022
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
2 changes: 1 addition & 1 deletion docs/scripts/pages.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.stripe.android

import androidx.annotation.RestrictTo
import com.stripe.android.cards.CardNumber
import com.stripe.android.model.CardBrand

Expand Down Expand Up @@ -29,7 +30,8 @@ object CardUtils {
* @param cardNumber a String that may or may not represent a valid Luhn number
* @return `true` if and only if the input value is a valid Luhn number
*/
internal fun isValidLuhnNumber(cardNumber: String?): Boolean {
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun isValidLuhnNumber(cardNumber: String?): Boolean {
if (cardNumber == null) {
return false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.stripe.android.model

import androidx.annotation.DrawableRes
import androidx.annotation.RestrictTo
import com.stripe.android.R
import com.stripe.android.cards.CardNumber
import java.util.regex.Pattern
Expand Down Expand Up @@ -174,7 +175,8 @@ enum class CardBrand(
*
* Note: currently only [CardBrand.DinersClub] has variants
*/
internal fun getMaxLengthForCardNumber(cardNumber: String): Int {
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun getMaxLengthForCardNumber(cardNumber: String): Int {
val normalizedCardNumber = CardNumber.Unvalidated(cardNumber).normalized
return variantMaxLength.entries.firstOrNull { (pattern, _) ->
pattern.matcher(normalizedCardNumber).matches()
Expand All @@ -191,7 +193,8 @@ enum class CardBrand(
* @return the [CardBrand] that matches the [cardNumber]'s prefix, if one is found;
* otherwise, [CardBrand.Unknown]
*/
internal fun fromCardNumber(cardNumber: String?): CardBrand {
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun fromCardNumber(cardNumber: String?): CardBrand {
if (cardNumber.isNullOrBlank()) {
return Unknown
}
Expand All @@ -205,7 +208,8 @@ enum class CardBrand(
).first()
}

internal fun getCardBrands(cardNumber: String?): List<CardBrand> {
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun getCardBrands(cardNumber: String?): List<CardBrand> {
if (cardNumber.isNullOrBlank()) {
return listOf(Unknown)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import com.stripe.android.networking.PaymentAnalyticsRequestFactory
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlin.coroutines.CoroutineContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import org.robolectric.shadows.ShadowLooper.idleMainLooper

internal object TestUtils {
object TestUtils {
@JvmStatic
fun idleLooper() = idleMainLooper()

Expand Down
5 changes: 5 additions & 0 deletions payments-ui-core/api/payments-ui-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ public final class com/stripe/android/ui/core/forms/BancontactSpecKt {
public static final fun getBancontactParamKey ()Ljava/util/Map;
}

public final class com/stripe/android/ui/core/forms/CardSpecKt {
public static final fun getCardForm ()Lcom/stripe/android/ui/core/elements/LayoutSpec;
public static final fun getCardParamKey ()Ljava/util/Map;
}

public final class com/stripe/android/ui/core/forms/EpsSpecKt {
public static final fun getEpsForm ()Lcom/stripe/android/ui/core/elements/LayoutSpec;
public static final fun getEpsParamKey ()Ljava/util/Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<!--
Items here need to be entered in our translation tool
-->
<string name="card_number_longer_than_expected" tools:ignore="ExtraTranslation">The card number is longer than expected, but you can still submit it.</string>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expect this to be removed when other work is complete.

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private fun isCityOrPostal(identifierSpec: IdentifierSpec) =
identifierSpec == IdentifierSpec.City

private fun getKeyboard(fieldSchema: FieldSchema?) = if (fieldSchema?.isNumeric == true) {
KeyboardType.Number
KeyboardType.NumberPassword
} else {
KeyboardType.Text
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
class AddressElement constructor(
open class AddressElement constructor(
_identifier: IdentifierSpec,
private val addressFieldRepository: AddressFieldElementRepository,
private var rawValuesMap: Map<IdentifierSpec, String?> = emptyMap(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ import androidx.compose.ui.Modifier
@Composable
internal fun AddressElementUI(
enabled: Boolean,
controller: AddressController
controller: AddressController,
hiddenIdentifiers: List<IdentifierSpec>?
) {
val fields by controller.fieldsFlowable.collectAsState(null)
fields?.let { fieldList ->
Column {
fieldList.forEachIndexed { index, field ->
SectionFieldElementUI(enabled, field)
if (index != fieldList.size - 1) {
SectionFieldElementUI(enabled, field, hiddenIdentifiers = hiddenIdentifiers)
if ((hiddenIdentifiers?.contains(field.identifier) == false) &&
(index != fieldList.size - 1)
) {
val cardStyle = CardStyle(isSystemInDarkTheme())
Divider(
color = cardStyle.cardBorderColor,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.stripe.android.ui.core.elements

import androidx.annotation.RestrictTo
import com.stripe.android.ui.core.address.AddressFieldElementRepository
import com.stripe.android.ui.core.address.FieldType
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

/**
* This is a special type of AddressElement that
* removes fields from the address based on the country. It
* is only intended to be used with the card payment method.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
class CardBillingAddressElement(
identifier: IdentifierSpec,
addressFieldRepository: AddressFieldElementRepository,
countryCodes: Set<String> = emptySet(),
countryDropdownFieldController: DropdownFieldController = DropdownFieldController(
CountryConfig(countryCodes)
),
rawValuesMap: Map<IdentifierSpec, String?> = emptyMap(),
) : AddressElement(
identifier,
addressFieldRepository,
rawValuesMap,
countryCodes,
countryDropdownFieldController
) {
// Save for future use puts this in the controller rather than element
val hiddenIdentifiers: Flow<List<IdentifierSpec>> =
countryDropdownFieldController.rawFieldValue.map { countryCode ->
when (countryCode) {
"US", "GB", "CA" -> {
FieldType.values()
.filterNot { it == FieldType.PostalCode }
.map { it.identifierSpec }
}
else -> {
FieldType.values()
.map { it.identifierSpec }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.stripe.android.ui.core.elements

import com.stripe.android.ui.core.address.AddressFieldElementRepository
import kotlinx.parcelize.Parcelize

@Parcelize
internal object CardBillingSpec : SectionFieldSpec(IdentifierSpec.Generic("card_billing")) {
fun transform(
addressRepository: AddressFieldElementRepository
) = CardBillingAddressElement(
IdentifierSpec.Generic("credit_billing"),
addressRepository
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.stripe.android.ui.core.elements

import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.combine
import java.util.UUID

internal class CardDetailsController : SectionFieldErrorController {

val label: Int? = null
val numberElement = CardNumberElement(
IdentifierSpec.Generic("number"),
CardNumberController(CardNumberConfig())
)

val cvcElement = CvcElement(
IdentifierSpec.Generic("cvc"),
CvcController(CvcConfig(), numberElement.controller.cardBrandFlow)
)

val expirationDateElement = SimpleTextElement(
IdentifierSpec.Generic("date"),
SimpleTextFieldController(DateConfig())
)

private val rowFields = listOf(expirationDateElement, cvcElement)
val fields = listOf(
numberElement,
RowElement(
IdentifierSpec.Generic("row_" + UUID.randomUUID().leastSignificantBits),
rowFields,
RowController(rowFields)
)
)

@ExperimentalCoroutinesApi
override val error = combine(
listOf(numberElement, expirationDateElement, cvcElement)
.map { it.controller }
.map { it.error }
) {
it.filterNotNull().firstOrNull()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.stripe.android.ui.core.elements

import kotlinx.coroutines.flow.combine

/**
* This is the element that represent the collection of all the card details:
* card number, expiration date, and CVC.
*/
internal class CardDetailsElement(
identifier: IdentifierSpec,
val controller: CardDetailsController = CardDetailsController(),
) : SectionMultiFieldElement(identifier) {
override fun sectionFieldErrorController(): SectionFieldErrorController =
controller

override fun setRawValue(rawValuesMap: Map<IdentifierSpec, String?>) {
// Nothing from formFragmentArguments to populate
}

override fun getFormFieldValueFlow() = combine(
controller.numberElement.controller.formFieldValue,
controller.cvcElement.controller.formFieldValue,
controller.expirationDateElement.controller.formFieldValue
) { number, cvc, expirationDate ->
var month = -1
var year = -1
expirationDate.value?.let { date ->
val newString = convertTo4DigitDate(date)
if (newString.length == 4) {
month = requireNotNull(newString.take(2).toIntOrNull())
year = requireNotNull(newString.takeLast(2).toIntOrNull())
}
}

listOf(
controller.numberElement.identifier to number,
controller.cvcElement.identifier to cvc,
IdentifierSpec.Generic("exp_month") to expirationDate.copy(
value = month.toString()
),
IdentifierSpec.Generic("exp_year") to expirationDate.copy(
value = year.toString()
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.stripe.android.ui.core.elements

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Divider
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

@Composable
internal fun CardDetailsElementUI(
enabled: Boolean,
controller: CardDetailsController,
hiddenIdentifiers: List<IdentifierSpec>?
) {
controller.fields.forEachIndexed { index, field ->
SectionFieldElementUI(enabled, field, hiddenIdentifiers = hiddenIdentifiers)
if (index != controller.fields.size - 1) {
val cardStyle = CardStyle(isSystemInDarkTheme())
Divider(
color = cardStyle.cardBorderColor,
thickness = cardStyle.cardBorderWidth,
modifier = Modifier.padding(
horizontal = cardStyle.cardBorderWidth
)
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.stripe.android.ui.core.elements

import kotlinx.parcelize.Parcelize

@Parcelize
internal object CardDetailsSpec : SectionFieldSpec(IdentifierSpec.Generic("card_details")) {
fun transform(): SectionFieldElement = CardDetailsElement(
IdentifierSpec.Generic("credit_detail")
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.stripe.android.ui.core.elements

import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.VisualTransformation
import com.stripe.android.model.CardBrand

/**
* This is similar to the [TextFieldConfig], but in order to determine
* the state the card brand is required.
*/
internal interface CardDetailsTextFieldConfig {
val capitalization: KeyboardCapitalization
val debugLabel: String
val label: Int
val keyboard: KeyboardType
val visualTransformation: VisualTransformation
fun determineState(brand: CardBrand, number: String): TextFieldState
fun filter(userTyped: String): String
fun convertToRaw(displayName: String): String
fun convertFromRaw(rawValue: String): String
}
Loading