Skip to main content

Overview

Communication between CFS/Pages and third-party POS systems (Clover, PAX) is implemented via JavaScript iframe events using window.postMessage() Event Model:
export enum IframeMessageTypes {
  buttonClick = "buttonClick",
  inputFocus = "inputFocus",
  inputBlur = "inputBlur",
  formSubmitted = "formSubmitted",
  userActivity = "userActivity",
  setWindowClass = "setWindowClass",
  scanCompleted = "scanCompleted",
  scanCancelled = "scanCancelled",
  init = "init",
}

interface IframeMessageData<T> {
  type: IframeMessageTypes;
  data: T;
}
Events are exchanged with:
window.postMessage(params, "*");

Output Events (Sent by CFS → External System)

init

Description
Triggered on CFS application initialization.
Post Message Example
window.postMessage(
  {
    type: "init",
    data: {
      projectName: "cfs",
    },
  },
  "*"
);
Parameters
FieldDescription
projectNameStatic string “cfs” – identifies the source project

buttonClick

Description
Emitted when a button is clicked in CFS. Used to request external scanner usage (e.g., Check-In UI).
Post Message Example
window.postMessage(
  {
    type: "buttonClick",
    data: {
      targetId: "scan",
      buttonId: "scan",
    },
  },
  "*"
);
Parameters
FieldDescription
targetIdHTML element ID of the clicked button (e.g., “scan”)
buttonIdDeprecated. Legacy support only (use targetId instead).

inputFocus

Description
Emitted when an input field in CFS gains focus. Can notify the external POS to prepare for login/check-in actions.
Post Message Example
window.postMessage(
  {
    type: "inputFocus",
    data: {
      targetId: "search",
      inputId: "search",
    },
  },
  "*"
);
Parameters
FieldDescription
targetIdHTML element ID of the input field (e.g., “search”)
inputIdDeprecated. Legacy support only (use targetId instead).

inputBlur

Description
Emitted when an input field in CFS loses focus.
Post Message Example
window.postMessage(
  {
    type: "inputBlur",
    data: {
      targetId: "search",
      inputId: "search",
    },
  },
  "*"
);
Parameters
FieldDescription
targetIdHTML element ID of the input field (e.g., “search”)
inputIdDeprecated. Legacy support only (use targetId instead).

Input Events (Received by CFS ← External System)

formSubmitted

Description
Instructs CFS to close the current iframe window (e.g., after external form submit in CFS Template iframe).
Parameters
No additional parameters.

userActivity

Description
Used to prolong user activity inside the iframe (prevent “Are you still here?” prompts).
Parameters
No additional parameters.

setWindowClass

Description
Previously used to set CSS class on iframe window.
Currently considered deprecated.

scanCompleted

Description
Delivers the result of an external scan (barcode, QR, username, email). Used for login/check-in.
Example Payload
{
  type: "scanCompleted",
  data: "user@example.com"
}

Parameters
FieldDescription
dataString value representing scan result (username, code, email)

scanCancelled

Description
Indicates cancellation of a scan request. Typically results in:
  • Showing a toast message to the user.
  • Resending cancellation notice to the external system.
Parameters
No additional parameters.