Esenda
Recurring Payments

Tokenisation Flow Events

Handle postMessage events during the card tokenisation flow

This page lists events sent from the embedded tokenisation iframe to the parent application, allowing your app to respond to key moments such as tokenisation completion.

Tokenisation Flow Completion Event

When the tokenisation journey inside the iframe is completed, the iframe sends a postMessage event to the parent.

The event is sent after a short delay (approximately 3 seconds) to allow the tokenisation status page to render inside the iframe.

Event Properties

PropertyValueTypeDescription
typeTOKENISATION_FLOW_COMPLETEDStringIndicates the tokenisation journey has finished and the iframe can be closed
tokenisedCardIde.g. c3e7f8a9-1234-5678-9012-3456789abcdeUUIDThe unique identifier for the tokenised card

Event Listener Example

window.addEventListener("message", (event) => {
  if (event.data?.type === "TOKENISATION_FLOW_COMPLETED") {
    const { tokenisedCardId } = event.data;
    console.log(`Tokenisation completed for card: ${tokenisedCardId}`);

    // Close the iframe
    const iframe = document.getElementById("tokenisation-iframe");
    if (iframe) {
      iframe.remove();
    }
  }
});

Example Flow

  1. The user completes the tokenisation inside the iframe.
  2. The iframe waits ~3 seconds to allow the status page to render.
  3. The iframe sends TOKENISATION_FLOW_COMPLETED to the parent via window.parent.postMessage.
  4. The parent app receives the event and closes the iframe or performs post-tokenisation actions.

Notes

  • The parent app is responsible for closing the iframe — the iframe does not remove itself.
  • The payload currently contains tokenisedCardId. Additional metadata may be included in future versions.

On this page