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
}

CopyEvent​

Raised whenever the element's value is copied to the clipboard. This event is available on all element types (TextElement, CardNumberElement, CardExpirationDateElement, CardVerificationCodeElement) when the enableCopy option is set to true.

Schema​

Empty

Enabling Copy​

To enable the copy functionality on an element, set enableCopy to true. This displays a copy icon that users can tap to copy the element's value to the clipboard:

val cardNumberElement = findViewById<CardNumberElement>(R.id.card_number)
cardNumberElement.enableCopy = true
cardNumberElement.copyIconColor = Color.BLUE // Optional: customize the copy icon color

You can also trigger a copy programmatically using the performCopy() method:

val success = cardNumberElement.performCopy() // Returns true if copy was performed, false if enableCopy is disabled

Usage​

cardNumberElement.addCopyEventListener {
// handle event - triggered when value is copied to clipboard
println("Card number copied to clipboard")
showCopiedConfirmation()
}

Example with TextElement​

val textElement = findViewById<TextElement>(R.id.text_element)
textElement.enableCopy = true

textElement.addCopyEventListener {
Toast.makeText(context, "Value copied!", Toast.LENGTH_SHORT).show()
}

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"}")
}
}
}
}
}