PHP SDK for Didit's identity verification (KYC) and authentication (CIAM) solutions
- ✅ Verification
- ⏳ Auth
- ⏳ Data
You can install the package via composer:
composer require alexstewartja/php-didit
Supply the Client ID and Client Secret of your application, from the Didit console:
// Replace these example credentials with your own...
$client_id = 'AcL8JK38FqNPmx20qrd3-b';
$client_secret = 'QuajPJsV0sKiQ3M33fd4RK2rVofEmHXLolKW_ZeyeNL';
$token_info = Didit::getAccessToken($client_id, $client_secret);
$access_token = $token_info->getAccessToken();
// Store your access token securely...
After obtaining a valid client access token, you can then create a new verification session:
$access_token = 'eyJhbGciOiAiUlMyNTYiLCAidHlwIjogIkpXVCJ9...'; // Retrieved from secure storage
$vendor_data = 'c4afad98-e044-4a5f-b68f-5ffaaaefe6a0'; // Commonly, a unique id/uuid of the user in your application
$callback = 'https://verify.didit.me/'; // URL to redirect your user after they complete verification
$features = VerificationFeatures::OCR_FACE; // Optional verification features to enable
$session = Didit::createVerificationSession($access_token, $vendor_data, $callback);
$session_id = $session->getSessionId();
// Store your session ID for future reference, commonly as part of your user record...
$session_url = $session->getSessionUrl();
// Redirect your user to the verification URL...
Retrieve the results of a verification session by supplying its session_id
:
$access_token = 'eyJhbGciOiAiUlMyNTYiLCAidHlwIjogIkpXVCJ9...'; // Retrieved from secure storage
$session_id = 'e8933296-fa3b-4a7a-9c99-b132d34b19fc'; // Retrieved from user record
$session = Didit::getVerificationSession($access_token, $session_id);
You may approve or decline a verification, by updating its status to Approved
or Declined
respectively:
$access_token = 'eyJhbGciOiAiUlMyNTYiLCAidHlwIjogIkpXVCJ9...'; // Retrieved from secure storage
$session_id = 'e8933296-fa3b-4a7a-9c99-b132d34b19fc'; // Retrieved from user record
$new_status = VerificationStatus::DECLINED;
$comment = 'User is from a country that is no longer supported'; // Optional comment/reason for review
$declined = Didit::updateVerificationSessionStatus($access_token, $session_id, $new_status, $comment);
if ($declined) {
// Status update was successful...
}
You can generate a PDF for sessions that are either In Review
, Declined
or Approved
:
$access_token = 'eyJhbGciOiAiUlMyNTYiLCAidHlwIjogIkpXVCJ9...'; // Retrieved from secure storage
$session_id = 'e8933296-fa3b-4a7a-9c99-b132d34b19fc'; // Retrieved from user record
$save_to = './session_pdf_downloads/session.pdf'; // Optional file path to store generated PDF
$generated = Didit::generateVerificationSessionPdf($access_token, $session_id, $save_to);
if ($generated) {
// PDF generated and stored successfully...
}
ℹ️ If no
$save_to
path is supplied, an instance ofPsr\Http\Message\StreamInterface
will be returned, allowing for further processing.
-
Navigate to the
tests/assets
directory and copycredentials.json.example
tocredentials.json
:cp tests/assets/credentials.json.example tests/assets/credentials.json
-
Open
tests/assets/credentials.json
. Enter your Client ID and Client Secret into theclient_id
andclient_secret
fields, respectively. -
Run the test suite:
composer test
Please see CHANGELOG for more information on what has changed recently.
A Lando file is included in the repo to get up and running quickly:
lando start
Please see CONTRIBUTING for more details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.