定制 fayda/fayda-php-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

fayda/fayda-php-sdk

最新稳定版本:v1.0.2

Composer 安装命令:

composer require fayda/fayda-php-sdk

包简介

PHP SDK for Fayda API

README 文档

README

❗This repository is work in progress. It is not ready yet and may change a lot.

Read the official specification

document Fayda Platform API Specification.

In order to receive the latest change notifications, please Watch this repository.

Latest Version PHP Version Build Status Total Downloads License

Requirements

Dependency Requirement
PHP >=7.1 <8.2 Recommend PHP8+
guzzlehttp/guzzle ^6.0 | ^7.0
firebase/php-jwt ^5.5

Install

Install package via Composer.

composer require "fayda/fayda-php-sdk"

Usage

Choose environment

Environment BaseUri
Production https://prod.fayda.et
Development https://auth-api.fayda.et(DEFAULT)
// Switch to the prod environment
FaydaApi::setBaseUri('https://prod.fayda.et');

Debug mode & logging

// Debug mode will record the logs of API to files in the directory "FaydaApi::getLogPath()" according to the minimum log level "FaydaApi::getLogLevel()".
FaydaApi::setDebugMode(true);

// Logging in your code
// FaydaApi::setLogPath('/tmp');
// FaydaApi::setLogLevel(Monolog\Logger::DEBUG);
FaydaApi::getLogger()->debug("I'm a debug message");

Examples

See the examples folder for more.

Example API - OTP Request Service

use Fayda\SDK\Api\Otp;
use Fayda\SDK\Auth;
use Fayda\SDK\Exceptions\BusinessException;
use Fayda\SDK\Exceptions\HttpException;
use Fayda\SDK\Exceptions\InvalidApiUriException;

// Set the base uri for your environment. Default is https://auth-api.fayda.et
//FaydaApi::setBaseUri('https://prod.fayda.et');

try {

    $api = new Otp();

    $transactionId = time(); // unique transaction id
    $individualId = ''; // your Fayda FIN/FCN
    
    $result = $api->requestNew($transactionId, $individualId);
    
    print "============ OTP Request Result ============\n";
    print json_encode($result) . "\n\n";
    
    $otp = readline("Enter OTP: ");
    
    print "============  eKyc ============\n";
    $dataKyc = new DataKyc();
    $authentication = $dataKyc->authenticate(
        $result['transactionID'], // transactionID from the previous request
        $individualId,
        $otp,
        [
            'otp' => false,
            'demo' => true,
            'bio' => false,
        ]
    );
    print json_encode($authentication) . "\n\n";
    
} catch (HttpException $e) {
    print $e->getMessage();
} catch (BusinessException $e) {
    print $e->getMessage();
} catch (InvalidApiUriException $e) {
    print $e->getMessage();
}

Using Docker

Set up docker environment.

  1. cp .env.example .env
  2. edit .env file with your credentials.
  3. docker-compose up -d

Run the examples inside docker. See the output on console to verify the results.

Request OTP and do kyc

docker-compose exec fayda php ./examples/Example.php

Run tests

Modify your API key in phpunit.xml first.

# Add your API configuration items into the environmental variable first     
        
export FAYDA_BASE_URL=https://dev.fayda.et

export FAYDA_VERSION=1.0
export FAYDA_ENV=prod

export FAYDA_SKIP_VERIFY_TLS=0
export FAYDA_DEBUG_MODE=1

composer test

License

MIT

Ethiopian National ID

统计信息

  • 总下载量: 453
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-12