Skip to main content

Events

The iFrame produces event objects, each carrying properties pertinent to the specific message or event type. To associate one or more of these events with your iFrame instance, establish a connection on the iFrame object. This connection is created through the on() function, where you provide a callback function to handle the events.

deets.on('tokenize', (token) => {
// Modify to collect and send the token to your server
console.log(token);
})

Event List

The following is a table listing all the possible events to be passed through the on() function:

EventRaise Condition(s)
loadThe iFrame has loaded.
focusThe input in the iFrame gains focus.
blurThe input in the iFrame loses focus.
changeThe input value has changed. Raised only if the data between the most recent focus and blur events has changed.
cardTypeChangeThe possible card type entered by the user has changed.
errorAn error occurred during the invocation of a command.
validateThe validate command was invoked directly by the user or as part of the Tokenize command
tokenizeThe tokenize command was invoked
cvvFocusThe input in the CVV iFrame gains focus.
cvvBlurThe input in the CVV iFrame loses focus.
noticeRaised when the iFrame is loaded by providing an expiration date time stamp as yyyyMMddHHmmss in UTC (current time + 20 mins) and a second notice one minute before expiration. It also provides 3DS Fingerprinting event notifications.
expiredRaised when the IFrame has expired.
toggleMaskThe toggleMask command was invoked.
toggleCvvMaskThe toggleCvvMask command was invoked.

The sections below describe the object fields for some of the events.

Validate

The Validate event returns a different body depending on the validation result. You can find some examples here:

Valid:
{"isValid":true,"cardType":"masterCard","lastFour":"5454","firstSix":"545454"}

Invalid input data/failed validation:
{"isValid":false,"validator":"format"}

User did not supply any data:
{"isValid":false,"validator":"required"}

The following table presents all possible parameters in the body object.

FieldTypeDescription
isValidboolIndicates whether or not the input data is valid
cardTypestringThe type of credit card. Valid return values are 'masterCard', 'americanExpress', 'discover', 'visa', 'diners', or 'jcb'. See Card Type Validation Regexes below.
lastFourstringThe last four characters of the input data
firstSixstringThe first six characters of the input data
validatorstringIf isValid is false, this will list the validator(s) that failed
isCvvValidboolIndicates whether or not the CVV input data is valid

Tokenize

When the Tokenize event is called and all validations are successful, the event will return the token's body. Below is an example using a test card with the number 5454 5454 5454 5454 and the CVV 999.

{
"cardType": "masterCard"
"cvvIncluded": true
"firstSix": "545454"
"lastFour": "5454"
"referenceNumber": "23121917411368702449"
"token": "545454Wr2Z4Y5454" // This is the Token ID to include in the Backend API call
"tokenHMAC": "DGqYCCvGR4k+azJjHFfMDGzRxUqNTrOOQYy6Q/IgLSI="
}

The following table presents all possible parameters in the body object.

FieldTypeDescription
firstSixstringThe first six characters of the input data
lastFourstringThe last four characters of the input data
firstEightstringThe first eight characters of the input data. Returned only if useExtendedBIN is true in the iFrame configuration and the PAN is 16 characters or more.
cardTypestringThe type of credit card. Valid return values are 'masterCard', 'americanExpress', 'discover', 'visa', 'diners', or 'jcb'
characterCountintThe number of characters within the input data
tokenstringThe token generated from the provided data
referenceNumberlongThe reference number for the tokenization call
tokenHMACstringThe HMAC generated using the Token as the data and the Client Secret Key

Error

FieldTypeDescription
errorstringDescription of the error(s) that occurred during the execution of the invoked command
referenceNumberlongThe reference number for the invoked command

ToggleMask and ToggleCvvMask

FieldTypeDescription
inputMaskedboolThe toggled state of the input, indicating whether it is masked or not