1. Go to this page and download the library: Download fayda/fayda-php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fayda / fayda-php-sdk example snippets
// 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");
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();
}
shell
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.