wedevbr/mati-laravel

Mati library for Laravel

v1.2.0 2021-04-22 05:32 UTC

README

Latest Version on Packagist Build Status Quality Score Total Downloads

Installation

You can install the package via composer:

composer require wedevbr/mati-laravel

After installed publish the config file:

php artisan vendor:publish --provider="WeDevBr\Mati\MatiServiceProvider"

Usage

Mati class can be accessed via facade, singleton or IoC container

// Using facade
use WeDevBr\Mati\MatiFacade;
$result = MatiFacade::createVerification();

// Using singleton
$result = $this->mati->createVerification();

// Using IoC container
use WeDevBr\Mati\Mati;
# ...
public function myFunction(Mati $mati) {
    $result = $mati->createVerification();
    # ...
}

A complete process looks like this:

$verification = MatiFacade::createVerification(['id' => 'localUserId'], 'flowId', '10.20.30.40', 'User-Agent String');

$document1 = new \WeDevBr\Mati\Inputs\DocumentPhoto;
$document1->setGroup(0)
    ->setType('national-id')
    ->setCountry('US')
    ->setRegion('CA')
    ->setPage('front')
    ->setFilePath('/tmp/doc001.jpg');

Mati::sendInputs($verification->identity, [$document1]);

// After the webhook notification, data can be acquired doing this:
$status = MatiFacade::retrieveResourceDataFromUrl($webhook_data->resource);

Configuration

The recommended way to configure is to set the environment variables MATI_CLIENT_ID and MATI_CLIENT_SECRET. This way no further step is required to authorize for the verification. Additionally, MATI_AUTH_URL and MATI_API_URL can be set for test purposes. If you don't want to use the environment to config, client ID and secret can be passed to the constructor of Mati class instead, and the constructor will deal with authorization. If you already have a valid access token, you can instantiate Mati without build parameters and call the method setAccessToken

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email contato@wedev.software instead of using the issue tracker.

Credits

License

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

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.