Learn about customisation options for the card expiry date component.
val cardExpiryDateComponentConfig = CardExpiryDateComponentConfig(
label = String,
validations = CardExpiryDateValidations,
style = CardExpiryDateStyle?,
formatOptions = ExpiryDateFormat,
numberOfMonthExpired = Int?,
showTrailingIcon = Boolean,
showTooltip = Boolean,
showHintIcon = Boolean,
hintIcon = Int,
showValidIcon = Boolean,
validIcon = Int,
invalidIcon = Int,
showInvalidIcon = Boolean,
tooltipData = TooltipData,
dynamicCardImageComponent = DynamicCardImageComponent?,
displayRequiredIcon = Boolean?,
placeholder = String,
isRequired = Boolean
)| Property | Description |
|---|---|
labelString | The input label's text. Defaults to `"Expiry Date". |
placeholderString | The placeholder text showing the expected format (e.g., MM/YY). |
formatOptionsExpiryDateFormat | The date format pattern. Defaults to SHORT_SLASH. |
numberOfMonthExpiredInt? | The grace period for expired cards, in months. |
isRequiredBoolean | Whether the expiry date field is required for submission. Defaults to true. Can't be overriden. |
showTrailingIconBoolean | Whether to show a calendar icon. Defaults to true. |
showValidIconBoolean | Whether to show a checkmark when valid. Defaults to true. |
showInvalidIconBoolean | Whether to show an error icon when invalid. Defaults to true. |
validIconInt | The valid state icon resource. |
invalidIconInt | The invalid state icon resource. |
hintIconInt | The hint icon resource. |
showHintIconBoolean | Whether to display a hint icon. Defaults to false. |
styleCardExpiryDateStyle? | Custom styling configuration. |
validationsCardExpiryDateValidations | Custom validation messages. |
data class CardExpiryDateComponentConfig(
val onChange: ((ExpiryDateInputEvent) -> Unit)? = null,
val onFocus: ((ExpiryDateFocusEvent) -> Unit)? = null,
val onBlur: ((ExpiryDateFocusEvent) -> Unit)? = null,
val onValidationPassed: ((List<ValidationResult>) -> Unit)? = null,
val onValidationFailed: ((List<ValidationResult>) -> Unit)? = null,
val onMonthChanged: ((Int) -> Unit)? = null,
val onYearChanged: ((Int) -> Unit)? = null,
val onFormatChange: ((ExpiryFormatEvent) -> Unit)? = null
)| Callback | Description |
|---|---|
onChange: (ExpiryDateInputEvent) -> Unit | Event handler for when the expiry date value changes. |
onFocus: (ExpiryDateFocusEvent) -> Unit | Event handler for when the input receives focus. |
onBlur: (ExpiryDateFocusEvent) -> Unit | Event handler for when the input loses focus. |
onValidationPassed: (List<ValidationResult>) -> Unit | Event handler for when the validation passes. |
onValidationFailed: (List<ValidationResult>) -> Unit | Event handler for when the validation fails. |
onMonthChanged: (Int) -> Unit | Event handler for when a month's value changes |
onYearChanged: (Int) -> Unit | Event handler for when a year's value changes. |
onFormatChange: (ExpiryFormatEvent) -> Unit | Event handler for when the date format changes. |
For more information about callbacks, see Events.
import com.pxp.checkout.components.cardexpirydate.CardExpiryDateValidations
val config = CardExpiryDateComponentConfig(
label = "Card Expiry Date",
formatOptions = ExpiryDateFormat.LONG_SLASH,
numberOfMonthExpired = 6, // 6-month grace period
showTrailingIcon = true,
showValidIcon = true,
showInvalidIcon = true,
validations = CardExpiryDateValidations(
required = "Expiry date is required",
invalidFormat = "Please enter numbers only",
invalidMonth = "Month must be between 01-12",
invalidFormatPattern = "Please use MM/YYYY format",
expired = "Card has expired, please use a valid card"
),
style = customExpiryDateStyle
)
val cardExpiryDateComponent = checkout.createComponent<CardExpiryDateComponent, CardExpiryDateComponentConfig>(
type = ComponentType.CARD_EXPIRY_DATE,
config = config
)