Home

Document Upload SDK

Overview

The Highnote Document Upload SDK lets you collect identity verification documents from account holders when a card product application enters manual review.

Prerequisites

  1. A Highnote account
  2. A server-side integration using an API key
  3. Document upload session ID
  4. An HTML selector for injecting a DOM element

Installation

The Highnote Document Upload SDK follows semver and can be installed using the following:

  • JavaScript package manager: npm, yarn, or pnpm
  • Content Delivery Network (CDN) via traditional <script> tag or ECMAScript module.
JSDelivr Script Tag

Install by package manager

The Document Upload SDK supports the following JavaScript package managers: npm, yarn, and pnpm.

npm
yarn
pnpm

Install by CDN

To ensure stability and avoid potential issues caused by updates, replace @latest with a specific version number such as @1.0.0.

You can install Document Upload SDK directly from a content delivery network (CDN) such as JSDelivr.

The SDK supports both traditional script tags and ECMAScript module imports. ESM imports require modern browsers. To support older browsers, use the traditional script tag approach with appropriate polyfills.

Script tag

To install the Document Upload SDK by <script> tag, add the following to your HTML file:

Script tag for Document Upload SDK

ESM import

To install the Document Upload SDK by ESM module, add the following to your HTML file:

ESM import for Document Upload SDK

Usage

To use the Document Upload SDK, you must fetch a document upload session ID and set up elements for each field as follows:

  1. Prepare your HTML
  2. Fetch document upload session ID
  3. Fetch a client token
  4. Initialize document upload.

Prepare your HTML

To prepare your HTML, you must provide an element to which to append the HTMLDivElement. The document upload library uses the HTMLDivElement to render the appropriate document upload widget. You can style the content inside the widget by passing any combination of styling options.

The following code sample shows an example how you can prepare your HTML for the Document Upload SDK:

Prepare HTML

Fetch document upload session ID

If an account holder's card product application status is IN_REVIEW , they must provide specific documents for Customer Identification Program (CIP) verification. To use the Document Upload SDK for document collection, you must use a document upload session ID to start a secure document upload session.

Use the following query to retrieve a card product application and fetch your document upload session ID:

Fetch a client token

To get a client token from your server for the Document Upload SDK, use the generateDocumentUploadClientToken mutation.

Refer to the following guidelines when generating a payment card client token:

  • Provide the documentUploadSessionId of the payment card you are rendering.
  • The client token is only valid for 10 minutes, but can be used multiple times.
  • Once a token expires, you must generate a new one to render payment card details.

Use the following mutation to generate a document upload client token:

Initialize document upload

You can initialize the Document Upload SDK by calling an initializeDocumentUploadSdk function. This returns a Promise containing a reference to the documentUpload instance, which includes helper methods to enact on the SDK such as unmount and endSession.

The following code sample is an example of an initializeDocumentUploadSdk function:

Initialize Document Upload

Error handling

The following error types are supported for the Document Upload SDK:

ErrorDescription
InvalidCredentialErrorThe provided client token is invalid or expired. Use the requestId in the payload for support and debugging.
DocumentUploadRequestErrorRepresents errors encountered when communicating with the Highnote API. Use the requestId in the payload for support and debugging.
DocumentUploadConfigurationErrorAn invalid configuration is provided at runtime. Example messages include:
Invalid client token.
Invalid Document Upload Session ID.
Invalid environment. Please provide test or live.
GenericDocumentUploadErrorAll unknown and unexpected errors.

The following code sample provides examples of document upload errors:

Error Examples

Styling options

The following styling options are available for use in elements for your document upload widget:

HTML ElementidDescription
<div>document-upload-componentThe selector provided during initialization of the SDK.
<div>inner-document-upload-componentThe <div> that is rendered by the SDK.
<div>reloaded-document-upload-componentThe <div> that contains documents required and documents uploaded. This <div> reloaded on each new upload.
<div>stagnant-document-upload-componentThe <div> that contains all elements that are not reloaded.
<input>file-upload-componentThe file selector for uploads.
<select>document-typeThe list of documents to be uploaded.
<button>document-upload-buttonButton to upload required documents.
<h4>All section headings.
<p>All informational text.

Using the live environment

By default, the card viewer library makes requests against the test environment. When you are ready to switch to the live environment, set the environment configuration option using the following function call:

Live Environment

Lifecycle

When the Document Upload SDK initializes, it automatically renders the required document upload widget and closes the sessions once all requirements are met. You are required to handle onSuccess and onError behavior as you wish. The rendered widget contains two sections:

  1. Documents uploaded: Includes documents already uploaded
  2. Documents required: Includes a drop-down of the required documents and a method for uploading them

The widget guides the user through the document upload process with reloaded components triggered by an upload event on subsequent steps. When no more documents are left to be uploaded, the SDK will end the document upload session and submit uploads for review.

Documents uploaded.png

Interactions

The Document Upload SDK supports the following interactions:

  • Allows account holder to upload documentation
  • Unmount the SDK
  • End the document upload session

Upload document

Once the SDK is initialized, the document upload widget provides the applicant with a list of uploaded documents and a dropdown menu with outstanding, required documents.

The account holder can pick a document to upload and click on the Upload button. The applicant must be able to successfully upload all required documents until no document type options remain to select from the dropdown.

Unmount SDK

The Document Upload SDK provides a call-back function for you to unmount the SDK. This allows you to decouple it with the client-token for a fresh start at any time.

End session

Warning: This action will submit any uploaded documents for review.

The Document Upload SDK provides a call-back function for you to end a document session at any time.

Provide Feedback

Was this content helpful?