Web SDK integration guide
Last updated
Last updated
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.
The response will contain an id
(the Client ID). It is required for the next step.
SDK Tokens enable clients to securely send personal data from your web application's frontend to ComplyCube.
To learn more about our SDK Token endpoint.
You must generate a new token each time you initialise the ComplyCube Web SDK.
To import our Web SDK, you need to include it in your target page as follows:
The links to complycube.min.js
and style.css
can be found in your developers portal.
With the SDK token you generated earlier, the Web SDK can be initialised in your frontend using the following Javascript code:
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".
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">
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:
documentCapture.documentId
to run a document check
documentCapture.documentId
and faceCapture.livePhotoId
to run an identity check
documentCapture.documentId
and faceCapture.liveVideoId
to run an enhanced identity check
poaCapture.documentId
to run a proof of address check
If you have set up webhooks as described in our webhooks guide, you will be notified once a check completes.
To retrieve the check results, you can perform a get check request.
A number of settings can be updated at runtime as follows:
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.
Attribute | Description |
---|---|
token
Your client's SDK token. This is a required attribute.
language
The UI language. Valid values include:
en
ar
de
es
fr
hi
hk
id
it
ja
ko
nl
no
pl
pt
sv
th
vi
zh
Default value: en
containerId
A string containing the ID of the container element that the Web SDK will mount to.
This must be an empty element.
Default value: complycube-mount
useModal
This defines whether the UI screens load into a modal or not.
Default value: true
disableClientAnalytics
This defines whether we track client analytics or not.
Default value: false
stages
This is the array of verification stages your clients will go through. Stages can be provided as string values which include : intro
, userConsentCapture
faceCapture
, documentCapture
, poaCapture
, and completion
.
Stages can be also provided as objects to enable customisations, as explained on the customisations page.
Default value: ['intro', 'faceCapture, 'documentCapture', 'completion']
onComplete
This callback function executes after the client completes the SDK flow. You could then use a function to trigger a check creation on your backend server.
Depending on the stages provided, data
may include the following attributes:
documentCapture
documentId
: the uploaded identity document unique reference generated by ComplyCube.
documentType:
the type of document uploaded.
faceCapture
liveVideoId
: the captured video unique reference number generated by ComplyCube, OR;
livePhotoId
: the captured photo unique reference number generated by ComplyCube.
poaCapture
documentId
: the uploaded ID document unique reference generated by ComplyCube.
documentType:
the type of document uploaded.
onModalClose
This callback executes when your client tries to close the modal. You can then decide whether to close the modal or not by toggling the isModalOpen
attribute using the updateSettings
method, as shown below.
onError
This callback executes when an error occurs. The error object has two attributes:
type
: this can be either:
exception
token_expired
: indicates the SDK token provided has expired. When this occurs, a new SDK toke must be provided, as shown below.
message
: a descriptive message of the error that has occurred.
onExit
This callback executes when your client exits the SDK verification flow prior to completion. The callback returns the exit reason, e.g., USER_CONSENT_NOT_GRANTED
.