A client represents the individual for whom you need to perform various KYC checks. A client is required to generate an SDK token. This must be done in your backend server.
To import our Web SDK, you need to include it in your target page as follows:
<!DOCTYPE html>
<html>
<head>
...
<!-- Importing the Javascript library -->
<script src="complycube.min.js"></script>
<!-- Importing the default CSS -->
<link rel="stylesheet" href="style.css" />
</head>
<body>
<!-- This is where the Web SDK will be mounted -->
<div id="complycube-mount"></div>
</body>
</html>
The links to complycube.min.js and style.css can be found in your developers portal.
Mount the SDK
With the SDK token you generated earlier, the Web SDK can be initialised in your frontend using the following Javascript code:
ComplyCube.mount({ token:'<YOUR_WEB_SDK_TOKEN>', containerId:'complycube-mount', stages: ['intro','documentCapture', { name:'faceCapture', options: { mode:'video' } },'completion' ],onComplete:function(data) {// Using the data attributes returned, request your// backend server to perform the necessary ComplyCube checksconsole.info('Capture complete'); },onModalClose:function() {// Handle the modal closure attempt },onError:function ({ type, message }) {if (type ==='token_expired') {// Request a new SDK token } else {// Handle other errorsconsole.err(message); } }});
The SDK mount parameters are described in the SDK Settings section below.
Your website's Referrer Policy header should be set to `strict-origin-when-cross-origin".
Referrer policy
To enable successful communication between the SDK and our servers, your web page's Referrer Policy header should be set to strict-origin-when-cross-origin. This ensures that the referrer information is securely transmitted during HTTP requests.
You can either do it programmatically or add it directly to the web page as follows:
<meta name="referrer" content="strict-origin-when-cross-origin">
Perform checks
Using the data returned by the SDK, via the onComplete callback, you can now instruct your backend server to run the appropriate checks using the create a check endpoint. For instance, use:
A number of settings can be updated at runtime as follows:
complycube =ComplyCube.mount({...})// Replace the SDK tokencomplycube.updateSettings({ token:"NEW_SDK_TOKEN" });...// Open the modalcomplycube.updateSettings({ isModalOpen:true });//Close the modalcomplycube.updateSettings({ isModalOpen:false });
Unmounting the SDK
If you are using the SDK within a Single Page Application (SPA), you can call unmount function to remove the SDK and reset its state.