Skip to main content

SDK Events

Payment elements expose events through paymentElement.on(eventName, handler).

Event names

EventWhen it fires
readyIframe reports ready.
changeUser input or validation state changed.
focusElement gained focus.
blurElement lost focus.
escapeEscape key.
clickTriggeredClick on a payment control.
completeDoThisCompletion step in multi-step flows.
confirmTriggeredConfirm action initiated from the form.
oneClickConfirmTriggeredOne-click confirm path.

Handlers receive an optional event data object (e.g. fields such as elementType and event-specific payloads for ready, focus, blur, clickTriggered, confirmTriggered).

Usage

const paymentElement = elements.create("payment", {});
paymentElement.mount("#payment-form");

paymentElement.on("ready", (event) => {
console.log("ready", event);
});

paymentElement.on("change", (event) => {
if (event && event.complete) {
document.getElementById("pay-button").disabled = false;
}
});

paymentElement.on("focus", () => {
document.getElementById("payment-form").classList.add("focused");
});

paymentElement.on("blur", () => {
document.getElementById("payment-form").classList.remove("focused");
});

Removing listeners

Pass null or undefined as the handler to remove the listener for that event:

paymentElement.on("change", null);

Server-side events (webhooks)

The table above lists in-browser SDK events (ready, change, etc.). For server-side payment lifecycle notifications, use Webhooks: event_type values such as payment_succeeded, payment_failed, payment_processing, and refund_succeeded (snake_case). Verify the TensorRail-Signature header, which carries t=<timestamp>,v1=<hex>: v1 is HMAC-SHA512(your_signing_secret, "<t>.<raw_request_body>") — the timestamp and a dot are prefixed to the body before hashing. Full recipe in Webhooks. Do not confuse these with iframe/SDK event names.