Learn about customisation options for the card CVC component.
val cardCvcComponentConfig = CardCvcComponentConfig(
label = String,
placeholder = String,
cardBrand = CardBrand?,
validations = CardCvcValidations,
style = CardCvcStyle?,
showTrailingIcon = Boolean,
showTooltip = Boolean,
showLabel = Boolean,
showErrorMessage = Boolean,
visibilityOnIcon = Int,
visibilityOffIcon = Int,
tooltipData = TooltipData,
applyMask = Boolean,
showMaskToggle = Boolean,
showHintIcon = Boolean,
hintIcon = Int,
showValidIcon = Boolean,
validIcon = Int,
invalidIcon = Int,
showInvalidIcon = Boolean,
displayRequiredIcon = Boolean?,
guideText = String?,
dynamicCardImageComponent = DynamicCardImageComponent?
)| Property | Description |
|---|---|
labelString | The input label's text. Defaults to "CVC". |
placeholderString | The placeholder text for the field. Defaults to an empty string. |
cardBrandCardBrand? | The current card brand to determine CVC requirements. This affects validation length. |
validationsCardCvcValidations | Custom validation error messages for CVC validation. |
styleCardCvcStyle? | Custom styling configuration for the component. |
showTrailingIconBoolean | Whether to show the trailing icon. Defaults to true. |
showTooltipBoolean | Whether to show the tooltip icon. Defaults to false. |
showLabelBoolean | Whether to show the label. Defaults to true. |
showErrorMessageBoolean | Whether to show error messages. Defaults to true. |
visibilityOnIconInt | The resource ID for the visibility on icon (when CVC is visible). |
visibilityOffIconInt | The resource ID for the visibility off icon (when CVC is masked). |
tooltipDataTooltipData | Tooltip configuration data with card images and text. |
applyMaskBoolean | Whether to mask the CVC by default. Defaults to false. |
showMaskToggleBoolean | Whether to show the mask toggle button (eye icon). Defaults to false. |
showHintIconBoolean | Whether to show the hint icon. Defaults to false. |
hintIconInt | Custom hint icon resource. Defaults to a generic CVC icon. |
showValidIconBoolean | Whether to show the validation icon when the CVC is valid. Defaults to true. |
validIconInt | The valid icon resource. |
invalidIconInt | The invalid icon resource. |
showInvalidIconBoolean | Whether to show the invalid icon when the CVC is invalid. Defaults to true. |
displayRequiredIconBoolean? | Whether to display the required icon when the field is required. |
guideTextString? | Helper text to display below the input field. |
dynamicCardImageComponentDynamicCardImageComponent? | Component to display dynamic card images. See Dynamic card image. |
data class CardCvcComponentConfig(
val onChange: ((CvcInputEvent) -> Unit)? = null,
val onFocus: ((CvcFocusEvent) -> Unit)? = null,
val onValidationPassed: ((List<ValidationResult>) -> Unit)? = null,
val onValidationFailed: ((List<ValidationResult>) -> Unit)? = null,
val onMaskingChange: ((SecurityCheckEvent) -> Unit)? = null
)| Callback | Description |
|---|---|
onChange: (CvcInputEvent) -> Unit | Event handler for when the CVC value changes. |
onFocus: (CvcFocusEvent) -> Unit | Event handler for when the input receives focus. |
onValidationPassed: (List<ValidationResult>) -> Unit | Event handler for when validation passes. |
onValidationFailed: (List<ValidationResult>) -> Unit | Event handler for when validation fails. |
onMaskingChange: (Boolean) -> Unit | Event handler for when the masking state changes. |
For more information about callbacks, see Events.
import com.pxp.checkout.components.cardcvc.CardCvcValidations
val config = CardCvcComponentConfig(
label = "Security Code",
cardBrand = CardBrand.AMEX,
applyMask = true,
showMaskToggle = true,
showTrailingIcon = true,
showValidIcon = true,
showInvalidIcon = true,
validations = CardCvcValidations(
required = "Security code is required",
invalidFormat = "Please enter only numbers",
invalidLength = "Security code is incomplete",
exceededMaxLength = "Security code is too long"
),
style = customCvcStyle
)
val cardCvcComponent = checkout.createComponent<CardCvcComponent, CardCvcComponentConfig>(
type = ComponentType.CARD_CVC,
config = config
)