Skip to content

PHP SDK for Didit's identity verification (KYC) and authentication (CIAM) solutions

License

Notifications You must be signed in to change notification settings

alexstewartja/php-didit

Repository files navigation

PHP SDK for Didit KYC/CIAM by alexstewartja on GitHub

PHP Didit

Latest Stable Version Total Downloads License

Tests Status Static Analysis

PHP Version Required

Buy Me A Coffee

PHP SDK for Didit's identity verification (KYC) and authentication (CIAM) solutions

Features

Installation

You can install the package via composer:

composer require alexstewartja/php-didit

Usage

Get Access Token

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...

Create a Verification Session

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 a Verification Session

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);

Update a Verification Session Status

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...
}

Generate a Verification PDF Report

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 of Psr\Http\Message\StreamInterface will be returned, allowing for further processing.

Testing

  1. Navigate to the tests/assets directory and copy credentials.json.example to credentials.json:

    cp tests/assets/credentials.json.example tests/assets/credentials.json
  2. Open tests/assets/credentials.json. Enter your Client ID and Client Secret into the client_id and client_secret fields, respectively.

  3. Run the test suite:

    composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

A Lando file is included in the repo to get up and running quickly:

lando start

Please see CONTRIBUTING for more details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

PHP SDK for Didit's identity verification (KYC) and authentication (CIAM) solutions

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages