PaymentCardDetailsForm

class PaymentCardDetailsForm @JvmOverloads constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : ConstraintLayout, CardValidCallback

Convenience multi-field form for collecting card details from a user. Card fields are separated into multiple input fields, and the control has a "card" style background.


Important:

User-entered card details are intentionally restricted for PCI compliance


Styling/Branding

This class can be styled in the following ways:

  1. Override color resource values

  2. Set styles programmatically

Override color resource values

This class can be styled by overriding the following color resource values:

olopay_paymentcarddetailsform_edittext_textcolor
olopay_paymentcarddetailsform_edittext_disabledtextcolor
olopay_paymentcarddetailsform_background
olopay_paymentcarddetailsform_disabledbackground
olopay_paymentcarddetailsform_errorcolor
olopay_paymentcarddetailsform_bordercolor

In addition, since this form uses an instance of [PaymentCardDetailsMultiLineView] under the hood, many of the fields can be styled by following style documentation for [PaymentCardDetailsMultiLineView].

Note that values specifically called out here will take precedence over similar values for customizing the same attributes on PaymentCardDetailsMultiLineView. For example, olopay_paymentcarddetailsmultilineview_edittext_textcolor won't have an effect on this form because of olopay_paymentcarddetailsform_edittext_textcolor

Set styles programmatically

A number of methods exist that allow you to style PaymentCardDetailsForm. Methods exist for changing the background style (color, border, radius, etc), the text colors, error text colors, hint text colors, font, and font size.

Constructors

PaymentCardDetailsForm
Link copied to clipboard
fun PaymentCardDetailsForm(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0)

Creates a new instance of PaymentCardDetailsForm

Properties

cardBrand
Link copied to clipboard
val cardBrand: CardBrand

The detected card brand based on the currently entered card number

formValidCallback
Link copied to clipboard
var formValidCallback: FormValidCallback? = null

Callback to be notified when the card transitions to valid and invalid states

isValid
Link copied to clipboard
val isValid: Boolean

true if all fields are complete and valid, otherwise false

paymentMethodParams
Link copied to clipboard
val paymentMethodParams: IPaymentMethodParams?

Get an IPaymentMethodParams instance that can be used to create an IPaymentMethod instance. If the form is not valid this will return null.

Functions

clearFields
Link copied to clipboard
fun clearFields()

Clears all text fields in the control

dismissKeyboard
Link copied to clipboard
fun dismissKeyboard()

Dismisses the keyboard, if visible, and removes focus from input fields in this control

isEnabled
Link copied to clipboard
open override fun isEnabled(): Boolean

True if the form is enabled and can accept user input, false otherwise

requestFocus
Link copied to clipboard
fun requestFocus(field: CardField, showKeyboard: Boolean)

Moves focus to the specified input field

setCardBackgroundColor
Link copied to clipboard
fun setCardBackgroundColor(color: Int)

Sets the border color for this view

@RequiresApi(value = 27)
fun setCardBackgroundColor(colorHex: String)

Sets the border color for this view IMPORTANT: This method requires API level 27 or higher

setCardBorderColor
Link copied to clipboard
fun setCardBorderColor(color: Int)

Sets the border color for this view

@RequiresApi(value = 27)
fun setCardBorderColor(colorHex: String)

Sets the border color for this view IMPORTANT: This method requires API level 27 or higher

setCardBorderRadius
Link copied to clipboard
fun setCardBorderRadius(radius: Float)

Sets the card corner radius for this view

setCardBorderWidth
Link copied to clipboard
fun setCardBorderWidth(widthPx: Int)

Sets the border width for this view.

setCardElevation
Link copied to clipboard
fun setCardElevation(elevationPx: Float)

Sets the elevation of the card background

setCardPadding
Link copied to clipboard
fun setCardPadding(startPx: Int?, topPx: Int?, endPx: Int?, bottomPx: Int?)

Sets the padding for the area immediately surrounding the card input fields.

setCountry
Link copied to clipboard
fun setCountry(countryCode: String)

Sets the two letter country code for this form

setCursorColor
Link copied to clipboard
@RequiresApi(value = 29)
fun setCursorColor(color: Int)
@RequiresApi(value = 29)
fun setCursorColor(colorHex: String)

Sets the color for the cursor, selection handles, and text selection highlight IMPORTANT: This method requires API Level 29 or higher

setEnabled
Link copied to clipboard
open override fun setEnabled(enabled: Boolean)

Enables or disables the control

setErrorFont
Link copied to clipboard
fun setErrorFont(font: Typeface)

Sets the error font for error messages

setErrorPadding
Link copied to clipboard
fun setErrorPadding(startPx: Int?, topPx: Int?, endPx: Int?, bottomPx: Int?)

Sets the padding for the error message displayed below the card input fields.

setErrorTextColor
Link copied to clipboard
fun setErrorTextColor(color: Int)

Sets the error text color for all input fields and error messages

@RequiresApi(value = 27)
fun setErrorTextColor(colorHex: String)

Sets the error text color for all input fields and error messages IMPORTANT: This method requires API level 27 or higher

setErrorTextSize
Link copied to clipboard
fun setErrorTextSize(size: Float)

Sets the text size for error messages

setFieldDividerColor
Link copied to clipboard
fun setFieldDividerColor(color: Int)

Sets the color for the field dividers

@RequiresApi(value = 27)
fun setFieldDividerColor(colorHex: String)

Sets the color for the field dividers IMPORTANT: This method requires API level 27 or higher

setFieldDividerWidth
Link copied to clipboard
fun setFieldDividerWidth(widthPx: Int)

Sets the width of the field dividers

setFocusedHintTextColor
Link copied to clipboard
fun setFocusedHintTextColor(color: Int)

Sets the hint text color for when a field has focus. Note that setHintTextColor overrides this value, so this method must be called after calling setHintTextColor.

@RequiresApi(value = 27)
fun setFocusedHintTextColor(colorHex: String)

Sets the hint text color for when a field has focus. Note that setHintTextColor overrides this value, so this method must be called after calling setHintTextColor. IMPORTANT: This method requires API level 27 or higher

setFont
Link copied to clipboard
fun setFont(font: Typeface)

Sets the font for all input fields

setHintText
Link copied to clipboard
fun setHintText(field: CardField, hint: String)

Sets the hint text for the specified field

setHintTextColor
Link copied to clipboard
fun setHintTextColor(color: Int)

Sets the hint text color for all input fields

@RequiresApi(value = 27)
fun setHintTextColor(colorHex: String)

Sets the hint text color for all input fields IMPORTANT: This method requires API level 27 or higher

setTextColor
Link copied to clipboard
fun setTextColor(color: Int)

Sets the text color for all input fields

@RequiresApi(value = 27)
fun setTextColor(colorHex: String)

Sets the text color for all input fields IMPORTANT: This method requires API level 27 or higher

setTextSize
Link copied to clipboard
fun setTextSize(size: Float)

Sets the text size for all input fields