The change event is triggered when the value of the embed changes. The payload of this event contains keys specific to the embed you are using
Method Parameters
-
event
- mandatory
The name of the event, in this casechange
-
handler
- mandatory
handler(event) => void is a callback function that a merchant will provide that will be called when the event is fired. When called it will be passed an event object with the following properties:Field Sub-field Type Description embedType string The type of embed that emitted this event. In this case card empty boolean true if the embed is empty complete boolean true if the embed is well-formed and potentially complete. That is the merchant can use this to enable their pay button error json Any error that we surface to the customer while they are typing value json cardholder_name string Cardholder name entered by the customer on the embed scheme enum Card scheme - visa, mastercard, american_express
Handling a card embed change event
cardEmbed.on('change', function(event) {
if (event.complete) {
// enable payment button
} else if (event.error) {
// show validation to customer
}
});
Handler event object
{
complete: false,
brand: 'visa',
embedType: 'card',
empty: false,
error: {
cardNumber: "Enter the card number",
expiry: "Enter valid expiry date",
cvv: "",
name: "",
},,
value: { cardholder_name: "" },
}