qgen-cfm-controller
v1.0.15
Published
The CFM Integration SDK provides a simple and effective way for merchants to integrate CFM (Customer Facing Module) functionalities directly into their websites. This SDK allows for initiating the application process, handling session IDs, embedding the C
Downloads
95
Readme
CFM Integration SDK
The CFM Integration SDK provides a simple and effective way for merchants to integrate CFM (Customer Facing Module) functionalities directly into their websites. This SDK allows for initiating the application process, handling session IDs, embedding the CFM application iframe, and registering event listeners for application completion.
SDK Functions Overview
StartApplication
Initiates the application process by posting applicant data to a specified endpoint and handling the session ID.
Parameters:
- data: ApplicantData - The applicant's information.
- endpoint: string - The endpoint URL to start the application.
- handleResponse: Function - A function to extract the session ID from the response.
Example Usage:
const handleResponse = (response) => response.data.data.sessionID; // Define how to extract the session ID from your response
await StartApplication(applicantData, endpoint, handleResponse);
HandleSessionID
Processes the session ID to retrieve an access token, storing both the token and session ID in localStorage for future use.
Parameters:
- sessionID: string - The session ID obtained from starting the application.
Example Usage:
await HandleSessionID(sessionID);
CreateIFrame
Generates and appends an iframe element to the specified container, embedding the CFM application interface within the web page.
Parameters:
- divId: string - The ID of the container div where the iframe should be appended.
- className: string - The class name for the iframe, for styling purposes.
- tokenData: string (optional) - The token to use in the iframe's source URL. Defaults to localStorage if not provided.
- sessionData: string (optional) - The session data to use in the iframe's source URL. Defaults to localStorage if not provided.
Example Usage:
CreateIFrame("containerDivId", "iframeClassName", tokenData, sessionData);
RegisterListener
Registers an event listener for the CFM application iframe to handle completion events and other messages from the CFM system.
Parameters:
- callback: Function - The function to call when an event is received.
Example Usage:
RegisterListener((eventData) => {
console.log("Application completion event received:", eventData);
});
Event list
- steps_completed_event
{
"source": "cfm-event-listener",
"type": "steps_completed_event",
"payload": {
"acceptanceInfo": {
"deviceIP": "188.250.179.30",
"deviceInfo": "Mozilla/5.0",
"id": "65f177550e67c2013b8f7a0e",
"timestamp": "2024-03-13 09:52:21.622 +0000 UTC",
"version": "v1"
},
"caseID": "65f17753067871cd768cc6b0",
"caseTypeID": "65153aacb4c7fdf640dd74f8",
"entityID": "65f17753067871cd768cc6b2",
"journeyID": "65f177530e67c2013b8f7a0d",
"locale": "EN",
"merchantID": "5ede17951111fc24d89bba7b",
"referenceID": "65f17753b1f30e6fb81d4747",
"riskLevelID": "65153b157e9b10a3031e985d",
"sessionID": "65f17753390ffd4984b8bf75",
"steps": [] // array of steps, it depends cfm process
}
}
Example Workflow 1
Start an Application: Use the
StartApplication
function with applicant data and a custom handler to process the response and extract a session ID.Embed the CFM Iframe: Use the
CreateIFrame
function to embed the CFM application into your website, providing a seamless experience for users.Register for Completion Events: Use the
RegisterListener
function to handle events indicating the completion of the CFM application process.
Example Workflow 2
Handle the Session ID: Use the
HandleSessionID
function with the obtained session ID to get and store the access token.Embed the CFM Iframe: Use the
CreateIFrame
function to embed the CFM application, passing as argument the token and session_id obtained.Register for Completion Events: Use the
RegisterListener
function to handle events indicating the completion of the CFM application process.