Javascript Library
The Dojah platform has a smooth widget that enables your users to authorize access to their accounts. This widget works effortlessly across various browsers and devices of all sizes.
How to Generate Widget
Using the Dojah CDN-hosted Javascript client library, you can install the Dojah widget into your application by simply adding a script tag to your HTML document and insert basic configuration parameters.
Step 1: Add the Client Javascript Library
Add the script tag before the end of the closing body tag of your desired HTML page where you desire to give users the ability to authorize access to a financial institution.
❗️Adding the async attribute can cause the inline code to return undefined because the library may not be available at that moment. So avoid the use of async and defer for now.
Adding the async attribute can cause the inline code to return undefined because the library may not be available at that moment. So avoid the use of async and defer for now.
Step 2: Configure the Javascript Client Library
At this stage, you can now create a Dojah widget object by passing in your public key in javascript object representing your preferred configuration options.
Parameter | Type | Description | |
---|---|---|---|
type | string | Widget Type: Values are ‘custom’, ‘verification’, ‘identification’, ‘verification’, ‘liveness’ | |
app_id | string | Application Id, Get it from your dojah application dashboard here | |
p_key | string | Public Key, Get it from your dojah application dashboard here | |
reference_id | string | Reference ID, It can be passed to keep track of the verification steps (Started, Ongoing, Successful). NB: reference_id character length must be greater than 10 | |
widget_id | string | Widget ID, Get it from your Easy Onboard application dashboard here | |
user_data | object | Automatically update the user data page, and thus skip the page | |
gov_data | object | Automatically update the government data page, and thus skip the page | |
metadata | object | Your application’s metadata to be passed back to you via webhook, onSuccess, or onError | |
onSuccess | function | This is called when your user has successfully completed enrollment with their preferred institution. The sample response data below is passed to the widget | |
onError | function | This is called when your user was unable to successfully complete enrollment. | |
onClose | function | This is called when the widget is closed. |
Typescript implementation
If you want to use typescript on some classes that are not available now or in the future, you could look at extending the global ‘window’ interface. You can follow below steps to guide you: With typescript, you need to extend the global Window interface with additional properties. Create a new folder “types” Add a file “index.d.ts” Put below code inside your “index.d.ts” file
set your compilerOptions “typeRoots” property to path of your type folder E.g [”./src/types”] Use the extended window property anywhere like this:
Step 3: Handle a Successful Verification
On successful enrollment, the onSuccess callback function that you supplied is called by the client library. We then return the connected account code to your server.
Kindly use the overall status (response.status (Boolean, i.e true or false)) to ascertain if the request failed or succeeded.
📘 Webhook Notifications
Webhook Notifications
You can receive the same data below (also passed to onSuccess and onError) via a webhook call.
Register your url for webhook calls here and ensure
kyc.widget
is theservice
you are subscribed to.In Config object Kindly set webhook object value to true (Boolean)
Example : webhook : true
The Sample response data after successful verification
Was this page helpful?