❗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.
Dependency | Requirement |
---|---|
PHP | >=7.1 <8.2 Recommend PHP8+ |
guzzlehttp/guzzle | ^6.0 | ^7.0 |
firebase/php-jwt | ^5.5 |
Install package via Composer.
composer require "fayda/fayda-php-sdk"
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 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");
See the examples folder for more.
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();
}
Set up docker environment.
cp .env.example .env
- edit
.env
file with your credentials. docker-compose up -d
Run the examples inside docker. See the output on console to verify the results.
docker-compose exec fayda php ./examples/Example.php
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