This topic provides examples on how to call ID Verification - KYC (Global) SDK for Node.js. KYC is short for Know Your Customer.
Prerequisites
Node.js 8.0 or later is installed.
Authentication is configured by using credentials provided by Alibaba Cloud. For more information, see Configure credentials.
Install the SDK
For more information about the source code of the SDK, see Alibaba Cloud Cloudauth-intl SDK for NodeJS.
We recommend that you use npm to manage dependency packages.
npm install @alicloud/openapi-client
npm install @alicloud/cloudauth-intl20220809@1.2.1
npm install @alicloud/credentials
Call examples
Call the Initialize operation
const {Config} = require("@alicloud/openapi-client");
const CloudAuth = require("@alicloud/cloudauth-intl20220809");
const Client = CloudAuth.default;
async function main(){
// Build client
const cred = new Credential();
const config = new Config({
credential: cred,
endpoint: "cloudauth-intl.cn-hongkong.aliyuncs.com"
});
const client = new Client(config);
// Build request
const request = new CloudAuth.InitializeRequest({
productCode: "KYC_GLOBAL",
metaInfo : "{\"apdidT****.0.0\"}",
merchantBizId : "***",
merchantUserId : "***",
docType : "01560001",
docScanMode : "auto",
returnUrl : "https://***",
productFlow : "DOC_FACE",
callbackUrl: "https://www.aliyun.com",
callbackToken: "NY4******"
});
// Invoke API
const response = await client.initialize(request);
// Get result
console.log(response.body.requestId);
console.log(response.body.result.transactionId);
console.log(response.body.result.transactionUrl);
}
main().then(function (response) {});
Call the CheckResult operation
const {Config} = require("@alicloud/openapi-client");
const CloudAuth = require("@alicloud/cloudauth-intl20220809");
const Client = CloudAuth.default;
async function main(){
// Build client
const cred = new Credential();
const config = new Config({
credential: cred,
endpoint: "cloudauth-intl.cn-hongkong.aliyuncs.com"
});
const client = new Client(config);
// Build request
const request = new CloudAuth.CheckResultRequest({
merchantBizId: "XXXX",
transactionId: "hks99********8f902",
isReturnImage: "Y"
});
// Invoke API
const response = await client.checkResult(request);
// Get result
console.log(response.body.requestId);
console.log(response.body.result.passed);
console.log(response.body.result.subCode);
console.log(response.body.result.extFaceInfo);
console.log(response.body.result.extIdInfo);
}
main().then(function (response) {});