alexstewartja/php-didit
最新稳定版本:1.1.0
Composer 安装命令:
composer require alexstewartja/php-didit
包简介
PHP SDK for Didit's identity verification (KYC) and authentication (CIAM) solutions
README 文档
README
PHP Didit
PHP SDK for Didit's identity verification (KYC) and authentication (CIAM) solutions
Features
- ✅ Verification
- ⏳ Auth
- ⏳ Data
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_topath is supplied, an instance ofPsr\Http\Message\StreamInterfacewill be returned, allowing for further processing.
Testing
-
Navigate to the
tests/assetsdirectory and copycredentials.json.exampletocredentials.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_idandclient_secretfields, respectively. -
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 didit@alexstewartja.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-13