Frontend Integration
Last updated
Last updated
Generate your access tokens before proceeding:
Generate AccessTokensOptionally, generate KYC sessionId
as well.
You'll need to generate a Widget URL and insert it into a DOM element. Additionally, you can monitor events triggered by the widget on your webpage to showcase either success or failure. Once the user completes the KYC process successfully, you'll receive an idToken
, which can be utilised to request the user's data/credentials from the KYC server.
The Widget URL has three query params:
kycAccessToken
: KYC Access Token
ssiAccessToken
: SSI Access Token
sessionId
: KYC Session Id
The final Widget URL format would look something like this:
https://verify.hypersign.id ?kycAccessToken=${kycAccessToken}&ssiAccessToken=${ssiAccessToken}&sessionId=${sessionId}
You can invoke the Hypersign KYC widget through popup from your page
const widgetUrl = `https://verify.hypersign.id
?kycAccessToken=${kycAccessToken}&ssiAccessToken=${ssiAccessToken}&sessionId=${sessionId}`
window.open(widgetUrl, 'Popup Window', 'width=850,height=900');
You can listen to events thrown by the widget to get the result of verification.
window.addEventListener('message', function (event) {
if (event.origin === 'https://verify.hypersign.id') {
console.log('Received message from popup:', event.data);
// make sure to parse the data before use
const data = JSON.parse(event.data)
// we send these 3 vaules:
// status = success / fail,
// message = a simple message (if any)
const { status, message} = data;
if (status === 'success') {
console.log('Successfully finished the KYC')
}
else if (status === 'fail') {
console.log('Failed to finish KYC')
}
}
});
You can only obtain status of verification through events. But in order to get user data, developers need to configure the webhook on their KYC dashboard.
Webhook