Skip to main content

Element Events

Each element type supports a standard set of events that can be subscribed to in order to receive callbacks within your application.

ChangeEvent

Raised whenever the element's value is changed, upon each keypress and after pasting multiple characters into the element.

Schema

PropertyTypeDescription
isCompleteBooleanWhether this element satisfies the mask and validator, i.e. it is ready to be tokenized.
isEmptyBooleanWhether this element is empty.
isMaskSatisfiedBooleanWhether this element satisfies the length and format requirements of the mask, if defined. Defaults to true if this element does not have a mask.
isValidBooleanThe result of this element's validator, if defined. Defaults to true if this element does not have a validator.
detailsList<EventDetails>A list of EventDetails included with this event
binDetailsBinDetails?BinDetails object containing card BIN details when binLookup is enabled on CardNumberElement.
selectedNetworkString?The selected payment network for co-badged cards (e.g., "cartes-bancaires", "visa"). Only present when co-badge support is enabled.

EventDetails

PropertyTypeDescription
typeStringThe type of data represented by this detail object
messageStringThe content of this detail object

Usage

myElement.addChangeEventListener {
// handle event
}

FocusEvent

Raised whenever the element receives focus.

Schema

Empty

Usage

myElement.addFocusEventListener {
// handle event
}

BlurEvent

Raised whenever the element loses focus.

Schema

Empty

Usage

myElement.addBlurEventListener {
// handle event
}

BinDetails

When binLookup is enabled on a CardNumberElement, the element will automatically perform a BIN lookup and include the results in the binDetails property of the ChangeEvent. This provides detailed information about the card based on its BIN (Bank Identification Number).

BinDetails Properties

PropertyTypeDescription
brandString?The card brand (e.g., "visa", "mastercard")
fundingString?The funding type (e.g., "credit", "debit", "prepaid")
issuerString?The name of the issuing bank
segmentString?The card segment type
binRangeList<BinRange>?List of BIN ranges for the primary card brand
additionalList<AdditionalCardDetail>?List of additional card information for co-badged cards

AdditionalCardDetail Properties

PropertyTypeDescription
brandString?Additional card brand for co-badged cards
fundingString?Funding type for the additional brand
issuerString?Issuer for the additional brand
segmentString?Segment for the additional brand
binRangeList<BinRange>?BIN ranges for the additional brand

BinRange Properties

PropertyTypeDescription
binMinStringMinimum BIN value in the range
binMaxStringMaximum BIN value in the range

Enabling BIN Lookup

To enable BIN lookup on a CardNumberElement:

val cardNumberElement = findViewById<CardNumberElement>(R.id.card_number)
cardNumberElement.binLookup = true
cardNumberElement.setBasisTheoryElements(bt)

Usage Example

cardNumberElement.addChangeEventListener { event ->
event.binDetails?.let { binDetails ->
println("Card brand: ${binDetails.brand ?: "unknown"}")
println("Funding type: ${binDetails.funding ?: "unknown"}")
println("Issuer: ${binDetails.issuer ?: "unknown"}")

// Check for co-badged cards
binDetails.additional?.let { additional ->
if (additional.isNotEmpty()) {
println("Co-badged card detected")
additional.forEach { cardDetail ->
println("Additional brand: ${cardDetail.brand ?: "unknown"}")
}
}
}
}
}