PaymentCardDetailsForm

class PaymentCardDetailsForm @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : 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

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

Creates a new instance of PaymentCardDetailsForm

Properties

Link copied to clipboard

The detected card brand based on the currently entered card number

Link copied to clipboard

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

Link copied to clipboard

true if all fields are complete and valid, otherwise false

Link copied to clipboard

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

Functions

Link copied to clipboard

Clears all text fields in the control

Link copied to clipboard

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

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

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

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

Moves focus to the specified input field

Link copied to clipboard
@RequiresApi(value = 27)
fun setCardBackgroundColor(colorHex: String)

Sets the border color for this view

Link copied to clipboard
@RequiresApi(value = 27)
fun setCardBorderColor(colorHex: String)

Sets the border color for this view

Link copied to clipboard

Sets the card corner radius for this view

Link copied to clipboard
fun setCardBorderWidth(widthPx: Int)

Sets the border width for this view.

Link copied to clipboard
fun setCardElevation(elevationPx: Float)

Sets the elevation of the card background

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.

Link copied to clipboard
fun setCountry(countryCode: String)

Sets the two letter country code for this form

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

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

Enables or disables the control

Link copied to clipboard

Sets the error font for error messages

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.

Link copied to clipboard
@RequiresApi(value = 27)
fun setErrorTextColor(colorHex: String)

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

Link copied to clipboard

Sets the text size for error messages

Link copied to clipboard
@RequiresApi(value = 27)
fun setFieldDividerColor(colorHex: String)

Sets the color for the field dividers

Link copied to clipboard

Sets the width of the field dividers

Link copied to clipboard
@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.

Link copied to clipboard
fun setFont(font: Typeface)

Sets the font for all input fields

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

Sets the hint text for the specified field

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

Sets the hint text color for all input fields

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

Sets the text color for all input fields

Link copied to clipboard
fun setTextSize(size: Float)

Sets the text size for all input fields