承接 onfido/onfido-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

onfido/onfido-php

Composer 安装命令:

composer require onfido/onfido-php

包简介

The Onfido Public API (v3.6)

README 文档

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 8.1 and later.

Latest release Build Status

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 instructions 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 `Region::EU`, `Region::US`, and `Region::CA`

$onfidoApi = new Onfido\Api\DefaultApi(
              new \GuzzleHttp\Client([
                  'timeout'  => 30,
                  'connect_timeout' => 30,
                  'read_timeout' => 30
              ]), $configuration);

You can also authenticate using OAuth2 client credentials instead of an API token:

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

$configuration = Onfido\Configuration::getDefaultConfiguration();
$configuration->setOAuthCredentials($_ENV['ONFIDO_OAUTH_CLIENT_ID'], $_ENV['ONFIDO_OAUTH_CLIENT_SECRET']);
$configuration->setRegion(Onfido\Region::EU);   // Supports `Region::EU`, `Region::US`, and `Region::CA`

$onfidoApi = new Onfido\Api\DefaultApi(
              new \GuzzleHttp\Client([
                  'timeout'  => 30,
                  'connect_timeout' => 30,
                  'read_timeout' => 30
              ]), $configuration);

The client will automatically exchange credentials for an access token and refresh it when it expires.

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. The library allows easy decoding of the payload and verification of its signature before returning it as an object for user convenience:

try {
  $verifier = new Onfido\WebhookEventVerifier(getenv('ONFIDO_WEBHOOK_SECRET_TOKEN'));

  $signature = 'a0...760e';

  $event = $verifier->readPayload('{"payload":{"r...3"}}', $signature);
} catch (Onfido\OnfidoInvalidSignatureError $ex) {
  // Invalid webhook signature
}

Recommendations

Do not use square bracket syntax

Except for accessing Task object's outputs, avoid using the square bracket syntax (i.e. []) to access undefined properties to prevent breaking changes when these fields appear.

Contributing

This library is automatically generated using OpenAPI Generator (version: 7.16.0); therefore, all contributions (except test files) should target the Onfido OpenAPI specification repository instead of this repository. Please follow the contribution guidelines provided in the OpenAPI specification repository.

For contributions to the tests instead, please follow the steps below:

  1. Fork the repository
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Make your changes
  4. Commit your changes (git commit -am 'Add detailed description of the feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

Versioning policy

Versioning helps manage changes and ensures compatibility across different versions of the library.

Semantic Versioning policy is used for library versioning, following the guidelines and limitations outlined below:

  • MAJOR versions (x.0.0) may:
    • target a new API version
    • include non-backward compatible change
  • MINOR versions (0.x.0) may:
    • add a new functionality, non-mandatory parameter or property
    • deprecate an old functionality
    • include non-backward compatible change to a functionality which is:
      • labelled as alpha or beta
      • completely broken and not usable
  • PATCH version (0.0.x) will:
    • fix a bug
    • include backward compatible changes only

More documentation

Additional 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 includes support documentation.

onfido/onfido-php 适用场景与选型建议

onfido/onfido-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 195.94k 次下载、GitHub Stars 达 20, 最近一次更新时间为 2024 年 05 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「rest」 「api」 「sdk」 「openapi」 「openapitools」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 onfido/onfido-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 onfido/onfido-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 onfido/onfido-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 195.94k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 11
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 20
  • Watchers: 22
  • Forks: 28
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-28