Initiate Verification
1. Creating a Metric instance
The Metric() constructor is used to create a Metric instance
const metric = new window.Metric({
client_id: "your_public_key",
client_secret: "your_secret_key",
});
Parameters
client_id: An API encrypted public key string. For example, AIzaSyDaGmWKa4JsXZ-HjGw7ISLn_3namBGewQeclient_secret: An API encrypted secret key string. For example, AIzaSyDaGmWKa4JsXZ-HjGw7ISLn_3namBGewQeinfo
2. Triggering a verification procedure
The verifyFingerprint() method on the Metric object is called with two arguments: payload, callback, This creates an iframe element that loads the verification process from the Metric API. Once the verification process is complete, the iframe is removed from the DOM and the callback function is called with the results of the verification process.
const metric = new window.Metric({
client_id: "your_public_key",
client_secret: "your_private_key",
});
metric.verifyFingerprint(payload, callback);
Parameters
payload: An object that contains the data required to perform the verification. The object has the following properties: id_number:A string representing the card number of the user's ID.purpose:A string representing the purpose of the verification.reference_id (optional):A string representing the reference ID for the verification.branch (optional):An optional string that can be used to track the branch that is tied to this verification.
callback: A function that takes a single argument results. The function will be called when the verification is complete, and results will contain an object with the following properties: status:A string representing the status of the verification.
Full Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Page Title</title>
</head>
<body>
<button onclick="verifyUser()">Verify Me</button>
<script type="text/javascript" src="https://sdk.dev.metric.africa/v1"></script>
<script>
const verifyUser = () => {
const metric = new window.Metric({
client_id: "XXXXXXXXXX",
client_secret: "XXXXXXXXXX",
});
metric.verifyFingerprint(
{
id_number: "GHA-000000000-0",
reference_id: "0300000000",
purpose: "state your purpose",
branch_name: "Accra",
},
(results) => {
console.log(results.status);
},
);
};
</script>
</body>
</html>