bdelespierre/onfido-api-php-client

The Onfido API is used to submit check requests.

5.2.1 2021-12-01 16:45 UTC

README

The Onfido API is used to submit check requests.

This PHP package is automatically generated by the OpenAPI Generator project:

  • API version: 3.0.0
  • Package version: 5.2.0
  • Build package: org.openapitools.codegen.languages.PhpClientCodegen

Requirements

  • PHP 7.1 and later
  • Guzzle/psr7 1.7 and later

Installation & Usage

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/onfido/api-php-client.git"
    }
  ],
  "require": {
    "onfido/api-php-client": "^5.2.0"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

    require_once('/path/to/onfido-php/vendor/autoload.php');

Tests

To run the unit tests:

composer install
./vendor/bin/phpunit

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: Token
$config = Onfido\Configuration::getDefaultConfiguration();
$config->setApiKey('Authorization', 'token=' . 'YOUR API KEY');
$config->setApiKeyPrefix('Authorization', 'Token');

// Limit the at-rest region, if needed (optional, see https://documentation.onfido.com/#regions)
// $config->setHost($config->getHostFromSettings(1, array("region" => "us")));

$apiInstance = new Onfido\Api\DefaultApi(null, $config);

// Setting applicant details

$applicantDetails = new Onfido\Model\Applicant();

$applicantDetails->setFirstName('Jane');
$applicantDetails->setLastName('Doe');
$applicantDetails->setDob('1990-01-31');

$address = new \Onfido\Model\Address();
$address->setBuildingNumber('100');
$address->setStreet('Main Street');
$address->setTown('London');
$address->setPostcode('SW4 6EH');
$address->setCountry('GBR');

$applicantDetails->setAddress($address);

// Setting check details

$checkData = new Onfido\Model\Check();
$checkData->setReportNames(array('identity_standard'));

// Create an applicant and then a check with an Identity report

try {
    $applicantResult = $apiInstance->createApplicant($applicantDetails);
    $applicantId = $applicantResult->getId();
    print_r("Applicant ID: ".$applicantId);
    $checkData->setApplicantId($applicantId);
    $checkResult = $apiInstance->createCheck($checkData);
    print_r($checkResult);
} catch (Exception $e) {
    print_r($e->getResponseBody());
}

?>

Documentation for API Endpoints

All URIs are relative to https://api.onfido.com/v3

Documentation For Models

Documentation For Authorization

Token

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Author