do-inc/laravel-persona-kyc

KYC (Know Your Customer) performed using the Persona (https://withpersona.com) API

0.10.22 2022-04-29 09:09 UTC

This package is auto-updated.

Last update: 2024-04-29 05:05:51 UTC


README

Latest Stable Version tests Total Downloads License PHP Version Require

This package helps with the identity verification of your customers. It provides a simple yet powerful interface based on method concatenation to semantically construct your requests.

Users verification become as easy as writing a couple of lines:

Backend

\Doinc\PersonaKyc\Persona::init()->accounts()->create("my-account-reference-id");

Frontend

const client = new Persona.Client({
    templateId: "itmpl_Ygs16MKTkA6obnF8C3Rb17dm",
    environment: "sandbox",
    referenceId: "my-account-reference-id",
    onReady: () => client.open(),
    onComplete: ({inquiryId, status, fields}) => console.log("onComplete"),
    onCancel: ({inquiryId, sessionToken}) => console.log('onCancel'),
    onError: (error) => console.log("onError"),
});

Installation

You can install the package via composer:

composer require do-inc/laravel-persona-kyc
php artisan persona:install

Running the installation command will automatically publish the configuration files, the migrations and compile all the stubs.

You can always publish all the assets manually running:

php artisan vendor:publish --tag="persona-kyc-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="persona-kyc-config"

Additionally, a couple of environment variable should also be defined:

PERSONA_API_KEY="persona_sandbox_XXX"
PERSONA_WEBHOOK_SECRET="wbhsec_XXX"

Usage

Basic

Persona offers the possibility to verify users identity with easy without the need to create custom flows or deal with long and complicated verification procedures.

The verification process begins with the creation of an account, accounts must be generated with a reference id in order to link multiple inquiries together. In order to reduce complexity and easily query for remote data consider using your user id as reference id.

$account = \Doinc\PersonaKyc\Persona::init()->accounts()->create("1234");

Lots of different methods are available out of the box, these will easy the development of simple and custom solution with Persona as a verification provider.

Refer to this method list for a complete list of the available methods.

Webhooks

Persona supports webhooks out of the box. In order to enforce a secure usage of the webhooks without any tampering possibility a default endpoint is provided at /persona/hook additionally a prefix may be added via configuration options.

The webhook will emit events depending on the request received, each event will receive a pre-parsed model as this will avoid errors.

This means that accessing persona webhooks is as simple as setting up a listener for the event you're interested into!

Refer to this event list for a complete list of the available events.

Testing

Copy the .env.example file into .env and fill in all the variables then run

composer test

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

If you discover any security related issues, please email security@do-inc.co instead of using the issue tracker.

Credits

License

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