DocuPass Quick Start Guide
This guide demonstrates the use of ID Analyzer client libraries, if you prefer to proceed without client library or if client library is not available for your language, please continue to
DocuPass API Reference.
Installing Client Library (SDK)
It is recommended to install ID Analyzer client library with package managers.
composer require idanalyzer/id-analyzer-php-sdk
Install-Package IDAnalyzer
Alternatively, you may download the client library and include it in your project manually:
Create DocuPass Session
You need to generate a DocuPass session for every user you want to verify or every document you want to sign through the DocuPass web app, every DocuPass session comes with a unique URL and reference code.
Import ID Analyzer Client Library
To start, import ID Analyzer client library into your project.
// Use composer autoload
require("vendor/autoload.php");
// Or manually load DocuPass class
// require("../src/DocuPass.php");
use IDAnalyzer\DocuPass;
const IDAnalyzer = require("idanalyzer");
Initialize DocuPass API
The very first step is to initialize DocuPass object with your API Key, you will also need to specify your company name to be displayed in the DocuPass app. Finally, you can also set whether you want to use US or EU API server.
$docupass = new DocuPass("API Key", "My Company Inc.", "US");
DocuPass docupass = new DocuPass("Your API Key", "My Company Inc.", "US");
let DocuPass = new IDAnalyzer.DocuPass("Your API Key","Your Company Name Inc.","US");
docupass = idanalyzer.DocuPass("Your API Key", "Your Company Name Inc.", "US")
Configure DocuPass Options
DocuPass by default only ask users to take photo of their ID documents and does not perform additional check on the document, you could fine-tune its parameters for a more robust identity verification procedure.
To make sure the document is owned by your user, we will enable biometric face verification. Once enabled, DocuPass will ask your user to take a selfie photo and verify the photo against the document. In the example, we will also set the minimum confidence score required to 0.5.
$docupass->enableFaceVerification(true, 1, 0.5);
docupass.EnableFaceVerification(true, 1, 0.5);
DocuPass.enableFaceVerification(true, 1, 0.5);
docupass.enable_face_verification(True, 1, 0.5)
To stop users from submitting fake documents, you can enable document authentication and set a threshold to reject documents below a certain score. In this example, we will use the "quick" authentication module and reject any documents that falls below a score of 0.3.
$docupass->enableAuthentication(true, "quick", 0.3);
docupass.SetCallbackURL("https://www.your-website.com/docupass_callback.php");
DocuPass.enableAuthentication(true, "quick", 0.3);
docupass.enable_authentication(True, "quick", 0.3)
We will also reject documents that have already expired.
$docupass->checkExpiry(true);
docupass.CheckExpiry(true);
DocuPass.checkExpiry(true);
docupass.check_expiry(True)
We will give each user 2 attempts to verify themselves, just in case they failed the first attempt due to a badly taken photo.
$docupass->setMaxAttempt(2);
docupass.SetMaxAttempt(2);
DocuPass.setMaxAttempt(2);
docupass.set_max_attempt(2)
Now we need to set an identifier to identify the specific person that we are going to verify, this value is usually set to a user ID within your own database and can be used to identify your user when you receive verification results from DocuPass.
$docupass->setCustomID("5678");
docupass.SetCustomID("5678");
DocuPass.setCustomID("5678");
docupass.set_custom_id("5678")
If you want to get user to sign a legal document such as rental contract.
$docupass->signContract("Template ID", "PDF");
docupass.SignContract("Template ID", "PDF");
DocuPass.signContract("Template ID", "PDF");
docupass.sign_contract("Template ID", "PDF")
Finally, we will configure where to redirect the user once they are done with verification, and where the verification should be sent to on your server. Webhook.site is a good tool to test the callback data.
// Set a callback URL where verification results will be sent
$docupass->setCallbackURL("https://www.your-website.com/docupass_callback.php");
// We want to redirect user back to your website when they are done with verification
$docupass->setRedirectionURL("https://www.your-website.com/verification_succeeded.php", "https://www.your-website.com/verification_failed.php");
// Set a callback URL where verification results will be sent
docupass.SetCallbackURL("https://www.your-website.com/docupass_callback.php");
// We want to redirect user back to your website when they are done with verification
docupass.SetRedirectionURL("https://www.your-website.com/verification_succeeded.php", "https://www.your-website.com/verification_failed.php");
// Set a callback URL where verification results will be sent
DocuPass.setCallbackURL("https://www.your-website.com/docupass_callback.php");
// We want to redirect user back to your website when they are done with verification
DocuPass.setRedirectionURL("https://www.your-website.com/verification_succeeded.html","https://www.your-website.com/verification_failed.html");
# Set a callback URL where verification results will be sent
docupass.set_callback_url("https://www.your-website.com/docupass_callback.php")
# We want to redirect user back to your website when they are done with verification
docupass.set_redirection_url("https://www.your-website.com/verification_succeeded.html",
"https://www.your-website.com/verification_failed.html")
You can perform on-the-fly phone verification and make it easier for users to start identity verification by sending the verification link to your user's mobile number.
// Send verification link to user's mobile phone
$docupass->smsVerificationLink("+1333444555");
// Or if you want user to enter and verify their own phone number during verification
//$docupass->enablePhoneVerification(true);
// Send verification link to user's mobile phone
docupass.SMSVerificationLink("+1333444555");
// Or if you want user to enter and verify their own phone number during verification
//docupass.EnablePhoneVerification(true);
// Send verification link to user's mobile phone
DocuPass.smsVerificationLink("+1333444555");
// Or if you want user to enter and verify their own phone number during verification
//DocuPass.enablePhoneVerification(true);
# Send verification link to user's mobile phone
docupass.sms_verification_link("+1333444555")
# Or if you want user to enter and verify their own phone number during verification
#docupass.enable_phone_verification(True)
Creating DocuPass Identity Verification Session
Now we can create the DocuPass Identity Verification session using the desired module.
// Create a session using DocuPass Standard Mobile module
$result = $docupass->createMobile();
// Create a session using DocuPass Live Mobile module
$result = $docupass->createLiveMobile();
// Create a session using DocuPass Iframe module
$result = $docupass->createIframe();
// Create a session using DocuPass Redirection module
$result = $docupass->createRedirection();
// Create a session using DocuPass Standard Mobile module
JObject result = await docupass.CreateMobile();
// Create a session using DocuPass Live Mobile module
JObject result = await docupass.CreateLiveMobile();
// Create a session using DocuPass Iframe module
JObject result = await docupass.CreateIframe();
// Create a session using DocuPass Redirection module
JObject result = await docupass.CreateRedirection();
// Create a session using DocuPass Standard Mobile module
let result = await DocuPass.createMobile();
// Create a session using DocuPass Live Mobile module
let result = await DocuPass.createLiveMobile();
// Create a session using DocuPass Iframe module
let result = await DocuPass.createIframe();
// Create a session using DocuPass Redirection module
let result = await DocuPass.createRedirection();
# Create a session using DocuPass Standard Mobile module
response = docupass.create_mobile()
# Create a session using DocuPass Live Mobile module
response = docupass.create_live_mobile()
# Create a session using DocuPass Iframe module
response = docupass.create_iframe()
# Create a session using DocuPass Redirection module
response = docupass.create_redirection()
Creating DocuPass Signature Session
A signature session allows your user to review and sign legal document without going through identity verification.
$result = $docupass->createSignature("Template ID", "PDF");
JObject result = await docupass.CreateSignature("Template ID", "PDF");
let result = await DocuPass.createSignature("Template ID", "PDF");
response = docupass.create_signature("Template ID", "PDF")
Parsing Response and distributing URL
Check out session creation response for different session data returned by DocuPass. Once the DocuPass session is created, you have to distribute it to your user or embed it into your website or app, please refer to the user distribution section in DocuPass API reference.
if($result['error']){
// Something went wrong
echo("Error Code: {$result['error']['code']}<br/>Error Message: {$result['error']['message']}");
}else{
echo("Scan the QR Code below to verify your identity: <br/>");
echo("<img src=\"{$result['qrcode']}\"><br/>");
echo("Or open your mobile browser and type in: ");
echo("<a href=\"{$result['url']}\">{$result['url']}</a>");
}
Console.WriteLine("Scan the QR Code below to verify your identity: ");
Console.WriteLine((string)result["qrcode"]);
Console.WriteLine("Or open your mobile browser and type in: ");
Console.WriteLine((string)result["url"]);
console.log("Scan the QR Code below to verify your identity: ");
console.log(response['qrcode']);
console.log("Or open your mobile browser and type in: ");
console.log(response['url']);
print("Scan the QR Code below to verify your identity: ")
print(response['qrcode'])
print("Or open your mobile browser and type in: ")
print(response['url'])
Processing Callback
You need to write a webhook/callback script on your server to receive and process DocuPass verification, this script is generally required if you want to process the results automatically without human intervention. The verification results will be sent in application/json
format to the callbackurl
you have set when creating the verification session.
First, we need to decode the JSON payload received in request body.
// Get raw post body
$input_raw = file_get_contents('php://input');
// Parse JSON into associative array
$data = json_decode($input_raw, true);
// Not available in current language
// Not available in current language
# Not available in current language
Next, validate the result against DocuPass API to prevent someone attempting to submit fake verification results.
// Initialize DocuPass with your credentials and company name
$docupass = new DocuPass("Your API Key", "My Company Inc.", "US");
// Validate result with DocuPass API Server
$validation = $docupass->validate($data['reference'], $data['hash']);
// Not available in current language
// Not available in current language
# Not available in current language
Check the validation results, if it is ok, we can proceed to check if user succeeded of failed the verification.
if($validation){
// Get custom ID passed when creating DocuPass session
$customerID = $data['customid'];
if($data['success'] === true){
// User has completed verification successfully
echo("{$data['firstName']} {$data['lastName']} has completed identity verification.");
}else{
// User did not pass identity verification
echo("User failed DocuPass: Reason: {$data['failreason']}. Fail Code: {$data['failcode']}.");
}
}else{
echo("Could not validate the authenticity of this request");
}
// Not available in current language
// Not available in current language
# Not available in current language
You can check the full JSON data returned by DocuPass in DocuPass API Reference.
Full Demo Code
You may view or download full code examples from GitHub.
You may view or download full code examples from GitHub.
You may view or download full code examples from GitHub.
You may view or download full code examples from GitHub.
Client Library Reference
To read the complete list of methods and parameters for ID Analyzer Client library, visit the link below: