SecurityCodeTextField
A PCI-compliant XML view component for entering card security codes (CVV). This component provides a secure input field that handles card security codes with automatic formatting and validation.
The component supports customizable security code lengths (typically 3 or 4 digits) and provides real-time feedback through events for validation and input state changes.
Example:
<com.mercadopago.sdk.android.coremethods.ui.components.textfield.securitycode.xml.SecurityCodeTextField
android:id="@+id/securityCodeField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:securityCodeSize="3"
app:cursorColor="@color/primary"
app:readOnly="false" />
// Configure the security code field
securityCodeField.apply {
onEvent = { event ->
when (event) {
is SecurityCodeTextFieldEvent.OnInputFilled -> {
if (event.isFilled) {
// Handle complete input
}
}
}
}
securityCodeSize = 3
textStyle = TextStyle(
color = Color.Black,
fontSize = 16.sp
)
}
Parameters
The context in which the view is running
The attributes of the XML tag that is inflating the view
The default style to apply to this view
See also
Properties
The brush used to paint the text cursor. This allows customization of the cursor's appearance.
Configuration for the software keyboard. This includes options like keyboard type and IME actions.
Callback for handling security code field events. This callback is triggered for various events like focus changes, input completion, and length changes.
The maximum number of digits allowed in the security code. This value determines the length of the security code input (typically 3 for most cards, 4 for American Express).
The state holder for the security code input field. This property manages the input value and ensures PCI compliance.
Visual transformation to be applied to the security code input. This can be used to mask or format the input display.