Documentation

Iframe Integration Code Reference (H5)

Overview

This document provides comprehensive guidance on handling codes returned by the AAI KYC iFrame integration. Codes are categorized into two types:

  • Frontend-triggered codes: Require immediate client-side handling
  • Backend-return codes: Require server-side verification via API

Code Reference Table

Code

Category

Trigger Condition

When It Occurs

Recommended Action

Implementation Priority

SUCCESS

Success

KYC verification flow completed and submitted successfully

User completes all verification steps successfully

Redirect to success page or next step in your flow

Required

CAMERA_ISSUE

Frontend Triggered

Camera unavailable or inaccessible
and Fallback is close

  • Camera in use by another app
  • No camera hardware
  • Camera driver issues

Display error message

High Priority

BROWSER_ISSUE

Frontend Triggered

Browser not supported or compatibility issues
and Fallback is close

  • Outdated browser version
  • Browser lacks required features (WebRTC, MediaDevices API,WASM,Worker)• Required APIs disabled

Display error message: "Your browser is not compatible. Please use Chrome, Safari, Firefox, or Edge (latest versions)."

High Priority

RESELECT_REGION

Frontend Triggered

The user clicked the "Reselect Region" prompt for a document from an unsupported region.

  • User clicks "Reselect Region" button

Redirect to region selection page

High Priority

RESELECT_DOC_TYPE

Frontend Triggered

The user clicked the "Reselect Document" prompt for an unsupported document type.

  • User clicks "Reselect Document" button

Redirect to document type selection page or re-initialize iFrame with step: 'document_type_selection'

High Priority

All Other Backend Codes

Backend Return

The complete set of backend status codes for all KYC data submissions.

  • When the backend returns a final state for the KYC process to the frontend.

Call Get Result API to retrieve detailed verification status and reason

Required


Integration Example

window.addEventListener('message', (event) => {
  const { type, code } = event.data;
  
  if (type === 'complete') {
    switch (code) {
      case 'SUCCESS':
        console.log('Document Verification complete successfully.');
        handleSuccess();
        break;
      
      // Frontend-triggered codes
      case 'CAMERA_ISSUE': // It is only sent when the downgrade process is closed.
        handleCameraIssue();
        break;
      
      case 'BROWSER_ISSUE': // It is only sent when the downgrade process is closed.
        handleBrowserIssue();
        break;
      
      case 'RESELECT_REGION':
        handleReselectRegion();
        break;
      
      case 'RESELECT_DOC_TYPE':
        handleReselectDocType();
        break;
      
      // All other codes - Backend-proxied
      default:
        console.info('Refer to the corresponding {errorCode}:', code);
        handleBackendCode(code, event.data.transactionId);
        break;
    }
  }
  
  if (type === 'copy') {
    console.log(event.data.shortUrl);
  }
});