Package com.stripe.android.ui.core.elements

Types

Link copied to clipboard
class AddressController(val fieldsFlowable: Flow<List<SectionFieldElement>>) : SectionFieldErrorController

This is the controller for a section with a changing number and set of fields. This is in contrast to the SectionController which is a section in which the fields in it do not change.

Link copied to clipboard
open class AddressElement(    _identifier: IdentifierSpec,     addressFieldRepository: AddressFieldElementRepository,     rawValuesMap: Map<IdentifierSpec, String?> = emptyMap(),     countryCodes: Set<String> = emptySet(),     countryDropdownFieldController: DropdownFieldController = DropdownFieldController( CountryConfig(countryCodes), rawValuesMap[IdentifierSpec.Country] )) : SectionMultiFieldElement
Link copied to clipboard
data class AddressSpec(    val apiPath: IdentifierSpec = IdentifierSpec.Generic("billing_details[address]"),     val allowedCountryCodes: Set<String> = supportedBillingCountries,     val displayFields: Set<DisplayField> = emptySet()) : FormItemSpec
Link copied to clipboard
data class AffirmHeaderElement(val identifier: IdentifierSpec, val controller: Controller? = null) : FormElement
Link copied to clipboard
data class AfterpayClearpayHeaderElement(    val identifier: IdentifierSpec,     amount: Amount,     val controller: Controller? = null) : FormElement
Link copied to clipboard

A text field configuration for an AU bank account number

Link copied to clipboard
class AuBankAccountNumberSpec(val apiPath: IdentifierSpec = IdentifierSpec.Generic( "au_becs_debit[account_number]" )) : FormItemSpec
Link copied to clipboard
data class AuBecsDebitMandateTextElement(    val identifier: IdentifierSpec,     val merchantName: String?,     val controller: InputController? = null) : FormElement

This is an element that has static text because it takes no user input, it is not outputted from the list of form field values. If the stringResId contains a %s, the first one will be populated in the form with the merchantName parameter.

Link copied to clipboard
class BsbConfig(banks: List<BecsDebitBanks.Bank>) : TextFieldConfig

A text field configuration for a BSB number, or Bank State Branch Number, a six-digit number used to identify the individual branch of an Australian financial institution

Link copied to clipboard
class BsbElement(    identifierSpec: IdentifierSpec,     banks: List<BecsDebitBanks.Bank>,     initialValue: String?) : FormElement
Link copied to clipboard
data class BsbSpec(val apiPath: IdentifierSpec = IdentifierSpec.Generic( "au_becs_debit[bsb_number]" )) : FormItemSpec
Link copied to clipboard
enum Capitalization : Enum<Capitalization>
Link copied to clipboard
class CardBillingAddressElement(    val identifier: IdentifierSpec,     rawValuesMap: Map<IdentifierSpec, String?> = emptyMap(),     addressFieldRepository: AddressFieldElementRepository,     countryCodes: Set<String> = emptySet(),     countryDropdownFieldController: DropdownFieldController = DropdownFieldController( CountryConfig(countryCodes), rawValuesMap[IdentifierSpec.Country] )) : AddressElement

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.

Link copied to clipboard
data class CardBillingSpec(val apiPath: IdentifierSpec = IdentifierSpec.Generic("card_billing"), val allowedCountryCodes: Set<String> = supportedBillingCountries) : FormItemSpec
Link copied to clipboard
class CardDetailsSectionController(    context: Context,     initialValues: Map<IdentifierSpec, String?>,     viewOnlyFields: Set<IdentifierSpec>) : SectionFieldErrorController
Link copied to clipboard
class CardDetailsSectionElement(    val context: Context,     initialValues: Map<IdentifierSpec, String?>,     viewOnlyFields: Set<IdentifierSpec>,     val identifier: IdentifierSpec,     val controller: CardDetailsSectionController = CardDetailsSectionController(context, initialValues, viewOnlyFields)) : FormElement
Link copied to clipboard
data class CardDetailsSectionSpec(val apiPath: IdentifierSpec = IdentifierSpec.Generic("card_details")) : FormItemSpec

Section containing card details form

Link copied to clipboard
sealed class CardNumberController : TextFieldController, SectionFieldErrorController
Link copied to clipboard
interface Controller

This is a generic controller

Link copied to clipboard
class CountryConfig(    val onlyShowCountryCodes: Set<String> = emptySet(),     val locale: Locale = Locale.getDefault(),     val flagMode: Boolean = false) : DropdownConfig

This is the configuration for a country dropdown.

Link copied to clipboard
data class CountryElement(val identifier: IdentifierSpec, val controller: DropdownFieldController) : SectionSingleFieldElement
Link copied to clipboard
data class CountrySpec(val apiPath: IdentifierSpec = IdentifierSpec.Country, val allowedCountryCodes: Set<String> = supportedBillingCountries) : FormItemSpec

This is the specification for a country field.

Link copied to clipboard
enum DisplayField : Enum<DisplayField>
Link copied to clipboard
interface DropdownConfig
Link copied to clipboard
class DropdownFieldController(config: DropdownConfig, initialValue: String? = null) : InputController, SectionFieldErrorController

This class controls the dropdown view and implements the InputController interface. Because it can never be in error the errorMessage is always null. It is also designed to always have a value selected, so isComplete is always true.

Link copied to clipboard
data class DropdownItemSpec(val apiValue: String? = null, val displayText: String = "Other")
Link copied to clipboard
data class DropdownSpec(    val apiPath: IdentifierSpec,     val labelTranslationId: TranslationId,     val items: List<DropdownItemSpec>) : FormItemSpec
Link copied to clipboard
class EmailConfig : TextFieldConfig
Link copied to clipboard
data class EmailElement(    val identifier: IdentifierSpec = IdentifierSpec.Email,     val initialValue: String? = "",     val controller: TextFieldController = SimpleTextFieldController( EmailConfig(), initialValue = initialValue )) : SectionSingleFieldElement
Link copied to clipboard
data class EmailSpec(val apiPath: IdentifierSpec = IdentifierSpec.Email) : FormItemSpec
Link copied to clipboard
data class EmbeddableImage(@DrawableRes val id: Int, @StringRes val contentDescription: Int)
Link copied to clipboard
data class EmptyFormElement(val identifier: IdentifierSpec = IdentifierSpec.Generic("empty_form"), val controller: Controller? = null) : FormElement
Link copied to clipboard
class FieldError(@StringRes val errorMessage: Int, val formatArgs: Array<out Any>? = null)

Encapsulates an error message including the string resource and the variable arguments

Link copied to clipboard
sealed class FormElement

This is used to define each section in the visual form layout. Each item in the layout has an identifier and a controller associated with it.

Link copied to clipboard
sealed class FormItemSpec

This is used to define each section in the visual form layout specification

Link copied to clipboard
object FormItemSpecSerializer : JsonContentPolymorphicSerializer<FormItemSpec>
Link copied to clipboard
class IbanConfig : TextFieldConfig

A text field configuration for an IBAN, or International Bank Account Number, as defined in ISO 13616-1.

Link copied to clipboard
data class IbanSpec(val apiPath: IdentifierSpec = IdentifierSpec.Generic("sepa_debit[iban]")) : FormItemSpec
Link copied to clipboard
data class IdentifierSpec(val v1: String)

This uniquely identifies a element in the form. The vals here are for identifier specs that need to be found when pre-populating fields, or when extracting data.

Link copied to clipboard

This class provides the logic behind the fields.

Link copied to clipboard
enum KeyboardType : Enum<KeyboardType>
Link copied to clipboard
class KlarnaCountrySpec(val apiPath: IdentifierSpec = IdentifierSpec.Country) : FormItemSpec

This is the specification for a klarna country field

Link copied to clipboard
object KlarnaHelper
Link copied to clipboard
data class LayoutFormDescriptor(    val layoutSpec: LayoutSpec?,     val showCheckbox: Boolean,     val showCheckboxControlledFields: Boolean)
Link copied to clipboard
data class LayoutSpec(val items: List<FormItemSpec>)

This is a data representation of the layout of UI fields on the screen.

Link copied to clipboard
data class MandateTextElement(    val identifier: IdentifierSpec,     val stringResId: Int,     val merchantName: String?,     val controller: InputController? = null) : FormElement
Link copied to clipboard
data class MandateTextSpec(val apiPath: IdentifierSpec = IdentifierSpec.Generic("mandate"), @StringRes val stringResId: Int) : FormItemSpec

Mandate text element spec.

Link copied to clipboard
class NameConfig : TextFieldConfig
Link copied to clipboard
data class NameSpec(val apiPath: IdentifierSpec = IdentifierSpec.Name, val labelTranslationId: TranslationId = TranslationId.AddressName) : FormItemSpec
Link copied to clipboard
class OTPController(val otpLength: Int = 6) : Controller
Link copied to clipboard
data class OTPElement(val identifier: IdentifierSpec, val controller: OTPController) : FormElement
Link copied to clipboard
data class OTPElementColors(val selectedBorder: Color, val placeholder: Color)
Link copied to clipboard
object OTPSpec : FormItemSpec
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
class RowElement(    _identifier: IdentifierSpec,     val fields: List<SectionSingleFieldElement>,     val controller: RowController) : SectionMultiFieldElement
Link copied to clipboard
class SaveForFutureUseController(saveForFutureUseInitialValue: Boolean) : InputController
Link copied to clipboard
data class SaveForFutureUseElement(    val identifier: IdentifierSpec,     val controller: SaveForFutureUseController,     val merchantName: String?) : FormElement

This is an element that will make elements (as specified by identifier) hidden when "save for future" use is unchecked

Link copied to clipboard
data class SaveForFutureUseSpec(val apiPath: IdentifierSpec = IdentifierSpec.SaveForFutureUse) : FormItemSpec

This is an element that will make elements (as specified by identifier) hidden when save for future use is unchecked

Link copied to clipboard
class SectionController(@StringRes val label: Int?, val sectionFieldErrorControllers: List<SectionFieldErrorController>) : Controller

This is the controller for a section with a static number of fields.

Link copied to clipboard
data class SectionElement(    val identifier: IdentifierSpec,     val fields: List<SectionFieldElement>,     val controller: SectionController) : FormElement
Link copied to clipboard
interface SectionFieldElement
Link copied to clipboard
interface SectionFieldErrorController : Controller

Any element in a section must have a controller that provides an error and have a type. This is used for a single field in a section or a section field that has other fields in it.

Link copied to clipboard
sealed class SectionMultiFieldElement : SectionFieldElement
Link copied to clipboard
sealed class SectionSingleFieldElement : SectionFieldElement

This is an element that is in a section and accepts user input.

Link copied to clipboard
class SimpleDropdownConfig(@StringRes val label: Int, items: List<DropdownItemSpec>) : DropdownConfig
Link copied to clipboard
data class SimpleDropdownElement(val identifier: IdentifierSpec, val controller: DropdownFieldController) : SectionSingleFieldElement
Link copied to clipboard
data class SimpleTextElement(val identifier: IdentifierSpec, val controller: TextFieldController) : SectionSingleFieldElement
Link copied to clipboard
class SimpleTextFieldConfig(    @StringRes val label: Int,     val capitalization: KeyboardCapitalization = KeyboardCapitalization.Words,     val keyboard: KeyboardType = KeyboardType.Text) : TextFieldConfig
Link copied to clipboard
class SimpleTextFieldController(    textFieldConfig: TextFieldConfig,     val showOptionalLabel: Boolean = false,     initialValue: String? = null) : TextFieldController, SectionFieldErrorController

This class will provide the onValueChanged and onFocusChanged functionality to the field's composable. These functions will update the observables as needed. It is responsible for exposing immutable observers for its data

Link copied to clipboard
data class SimpleTextSpec(    val apiPath: IdentifierSpec,     @StringRes val label: Int,     val capitalization: Capitalization = Capitalization.None,     val keyboardType: KeyboardType = KeyboardType.Ascii,     val showOptionalLabel: Boolean = false) : FormItemSpec
Link copied to clipboard
data class StaticTextElement(    val identifier: IdentifierSpec,     val stringResId: Int,     val controller: InputController? = null) : FormElement

This is an element that has static text because it takes no user input, it is not outputted from the list of form field values. If the stringResId contains a %s, the first one will be populated in the form with the merchantName parameter.

Link copied to clipboard
interface TextFieldConfig
Link copied to clipboard
Link copied to clipboard
sealed class TextFieldIcon
Link copied to clipboard
interface TextFieldState

This represents the different states a field can be in, in each of these cases there might be a reason to show the error in a different way. This interface separates how the state is implemented from what information is required by clients of the interface. This will allow the implementation to change without impacting the clients.

Link copied to clipboard

Functions

Link copied to clipboard
fun AffirmElementUI()
Link copied to clipboard
Link copied to clipboard
fun AnimatedIcons(icons: List<TextFieldIcon.Trailing>, loading: Boolean)
Link copied to clipboard
fun BsbElementUI(    enabled: Boolean,     element: BsbElement,     lastTextFieldIdentifier: IdentifierSpec?)
Link copied to clipboard
fun CardDetailsSectionElementUI(    enabled: Boolean,     controller: CardDetailsSectionController,     hiddenIdentifiers: List<IdentifierSpec>?)
Link copied to clipboard
fun H4Text(text: String, modifier: Modifier = Modifier)
Link copied to clipboard
fun H6Text(text: String, modifier: Modifier = Modifier)
Link copied to clipboard
fun Html(    html: String,     imageGetter: Map<String, EmbeddableImage>,     color: Color,     style: TextStyle,     modifier: Modifier = Modifier,     urlSpanStyle: SpanStyle = SpanStyle(textDecoration = TextDecoration.Underline))
Link copied to clipboard
fun MandateTextUI(element: MandateTextElement)
Link copied to clipboard
fun OTPElementUI(    enabled: Boolean,     element: OTPElement,     modifier: Modifier = Modifier,     colors: OTPElementColors = OTPElementColors( selectedBorder = MaterialTheme.colors.primary, placeholder = MaterialTheme.paymentsColors.placeholderText ))
Link copied to clipboard
fun PhoneNumberCollectionSection(    enabled: Boolean,     phoneNumberController: PhoneNumberController,     @StringRes sectionTitle: Int? = null,     requestFocusWhenShown: Boolean = false)
Link copied to clipboard
Link copied to clipboard
fun SectionCard(    modifier: Modifier = Modifier,     isSelected: Boolean = false,     border: BorderStroke = MaterialTheme.getBorderStroke(isSelected),     content: @Composable () -> Unit)

This is the layout for the section card.

Link copied to clipboard
fun SectionElementUI(    enabled: Boolean,     element: SectionElement,     hiddenIdentifiers: List<IdentifierSpec>,     lastTextFieldIdentifier: IdentifierSpec?)
Link copied to clipboard
fun SimpleDialogElementUI(    openDialog: MutableState<Boolean>,     titleText: String,     messageText: String,     confirmText: String,     dismissText: String,     onConfirmListener: () -> Unit = {},     onDismissListener: () -> Unit = {})
Link copied to clipboard
Link copied to clipboard
fun TextField(    textFieldController: TextFieldController,     enabled: Boolean,     imeAction: ImeAction,     modifier: Modifier = Modifier,     onTextStateChanged: (TextFieldState?) -> Unit = {},     nextFocusDirection: FocusDirection = FocusDirection.Next,     previousFocusDirection: FocusDirection = FocusDirection.Previous)

This is focused on converting an TextFieldController into what is displayed in a textField.

Link copied to clipboard
fun TextFieldColors(shouldShowError: Boolean = false): TextFieldColors
Link copied to clipboard
fun TextFieldSection(    textFieldController: TextFieldController,     modifier: Modifier = Modifier,     @StringRes sectionTitle: Int? = null,     imeAction: ImeAction,     enabled: Boolean,     onTextStateChanged: (TextFieldState?) -> Unit = {})

This is focused on converting an TextFieldController into what is displayed in a section with a single textField.

Properties

Link copied to clipboard
const val SAVE_FOR_FUTURE_CHECKBOX_TEST_TAG: String