onfido / api-php-client
The Onfido API
Requires
- php: ^7.3 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ~2.12
- phpunit/phpunit: ^7.4
- squizlabs/php_codesniffer: ~2.6
- dev-master
- 6.8.0
- 6.7.0
- 6.6.0
- 6.5.0
- 6.4.0
- 6.3.0
- 6.2.0
- 6.1.0
- 6.0.0
- 5.2.1
- 5.2.0
- 5.1.0
- 5.0.2
- 5.0.1
- 5.0.0
- 4.3.0
- 4.2.0
- 4.1.3
- 4.1.2
- 4.1.0
- 4.0.1
- 4.0.0
- 3.1.0
- 3.0.0
- 2.1.0
- 2.0.0
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
- dev-release-upgrade
- dev-add-support-section-readme
- dev-feature/add-new-minor-version-3.6
- dev-version-6.6.0
- dev-version-6.5.0
- dev-version-3.5
- dev-feature/DMF-842-add-new-minor-version-3.5
- dev-version-6.3.0
- dev-version-4.1.3
- dev-version-4.1.2
- dev-version-4.1.1
This package is auto-updated.
Last update: 2024-04-25 08:12:09 UTC
README
The official PHP library for integrating with the Onfido API.
Documentation can be found at https://documentation.onfido.com.
This version uses Onfido API v3.6. Refer to our API versioning guide for details of which client library versions use which versions of the API.
Installation & Usage
Requirements
PHP 7.4 and later. Should also work with PHP 8.0.
Installation
Composer
To install the bindings via Composer, add the following to composer.json
:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/onfido/onfido-php.git" } ], "require": { "onfido/onfido-php": "*@dev" } }
Then run composer install
Manual Installation
Download the files and include autoload.php
:
<?php require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');
Getting Started
Please follow the installation procedure and then run the following:
<?php require_once(__DIR__ . '/vendor/autoload.php'); $configuration = Onfido\Configuration::getDefaultConfiguration(); $configuration->setApiToken($_ENV['ONFIDO_API_TOKEN']); $configuration->setRegion(Onfido\Region::EU); // Supports `EU`, `US` and `CA` $onfidoApi = new Onfido\Api\DefaultApi( new \GuzzleHttp\Client([ 'timeout' => 30, 'connect_timeout' => 30, 'read_timeout' => 30 ]), $configuration);
Making a call to the API
try { $applicant = $onfidoApi->createApplicant( new Onfido\Model\ApplicantBuilder( [ 'first_name' => 'First', 'last_name' => 'Last' ]) ); // To access the information use the getter for the desired property on the object, for example: $applicant->getFirstName(); // ... } catch (Onfido\ApiException $ex) { // Handle API exception echo 'Caught exception: ', $ex->getMessage(), "\n"; }
Webhook event verification
Webhook events payload needs to be verified before it can be accessed. Library allows to easily decode the payload and verify its signature before returning it as an object for user convenience:
try { $verifier = new Onfido\WebhookEventVerifier('_ABC123abc...3ABC123_'); $signature = 'a0...760e'; $event = $verifier->readPayload('{"payload":{"r...3"}}', $signature); } catch (Onfido\OnfidoInvalidSignatureError $ex) { // Invalid webhook signature }
Contributing
This library is automatically generated using OpenAPI Generator - version: 7.4.0; therefore all the contributions, except tests files, should target Onfido OpenAPI specification repository instead of this repository.
For contributions to the tests instead, please follow the steps below:
- Fork repository
- Create your feature branch (
git checkout -b my-new-feature
) - Make your changes
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
More documentation
More documentation and code examples can be found at https://documentation.onfido.com.
Support
Should you encounter any technical issues during integration, please contact Onfido's Customer Support team via the Customer Experience Portal which also include support documentation.