andrevalentin / laravel-onfido
A Laravel wrapper for the Onfido PHP client
Installs: 169 756
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 2
Open Issues: 1
Requires
- php: ^7.1.3 || ^8.0
- illuminate/support: ^8.0
- onfido/api-php-client: ^5.2 || ^6.0
Requires (Dev)
- graham-campbell/testbench: ^5.5
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-10-17 21:05:44 UTC
README
The Laravel wrapper for the Onfido PHP API Client.
Installation
Install using composer:
composer require andrevalentin/laravel-onfido
In app.php in your Laravel application add the Service Provider under the providers array:
'providers' => [
...,
AndreValentin\Onfido\OnfidoServiceProvider::class,
],
Also add the Class Alias under the aliases array:
'aliases' => [
...,
'Onfido' => AndreValentin\Onfido\Facades\Onfido::class,
],
Add a onfido.php config file in your config directory with the following content:
<?php
return [
"api_key" => env("ONFIDO_API_KEY", "api_testing.default"),
];
Configuration
Remember to add your Onfido API key to your .env
file.
ONFIDO_API_KEY=api_sandbox.ABC...
Usage
I would always encourage anyone to use the official PHP package as reference, and this is simply a Laravel wrapper. However, I will provide an example on how to create an applicant.
Remeber to import the Onfido Facade, by adding use Onfido;
at the top of your file.
To create an applicant and send a check:
$applicant = Onfido::createApplicant([
'first_name' => 'John',
'last_name' => 'Doe',
'email' => 'johndoe@example.org',
]);
$onfido_check = Onfido::createCheck([
'applicant_id' => $applicant['id'],
'report_names' => ['right_to_work'],
'applicant_provides_data' => true,
]);
The above is all that is required to create an applicant and send the applicant a right to work check via Onfido.
You can then consult the results of the check as an array:
$applicant['id']
$onfido_check['id']
$onfido_check['status']
$onfido_check['form_uri']
To see all possible return data check the official PHP package documentation over at https://github.com/onfido/api-php-client