90 lines
2.3 KiB
PHP
90 lines
2.3 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Controllers;
|
|
|
|
use CodeIgniter\API\ResponseTrait;
|
|
use Firebase\JWT\JWT;
|
|
|
|
class DigiFiBVN extends BaseController
|
|
{
|
|
use ResponseTrait;
|
|
|
|
var $request;
|
|
|
|
function __construct()
|
|
{
|
|
$this->request = \Config\Services::request();
|
|
}
|
|
|
|
|
|
public function completeBVNVerify(){
|
|
|
|
$data = $this->request->getPost();
|
|
if ($data['bvn'] != '' && $data['verification_id'] !='' && $data['otp'] !='') {
|
|
|
|
$final_out = $data;
|
|
|
|
$key = getenv('JWT_SECRET');
|
|
$iat = time(); // current timestamp value
|
|
$exp = $iat + 3600;
|
|
|
|
$payload = array(
|
|
"iss" => "Issuer of the JWT",
|
|
"aud" => "Audience that the JWT",
|
|
"sub" => "Subject of the JWT",
|
|
"iat" => $iat, //Time the JWT issued at
|
|
"exp" => $exp, // Expiration time of token
|
|
"user_detail" => $final_out,
|
|
);
|
|
|
|
$token = JWT::encode($payload, $key, 'HS256');
|
|
|
|
$response = [
|
|
'message' => 'Account Verified',
|
|
'call_return' => '100',
|
|
"uid" => "3119b744-42ad-4834-bb83-b737588754ca",
|
|
"firstname"=>'Firstname',
|
|
"lastname"=>'lastname',
|
|
"last_login"=> "2024-04-26 13:35:19.750027",
|
|
"token" =>$token
|
|
];
|
|
|
|
return $this->respond($response, 200);
|
|
} else {
|
|
$response = [
|
|
'message' => 'Invalid account found',
|
|
'call_return' => '100',
|
|
'token' => ''
|
|
];
|
|
return $this->fail($response, 409);
|
|
}
|
|
}
|
|
public function startBVNVerify()
|
|
{
|
|
$data = $this->request->getPost();
|
|
|
|
if ($data['bvn'] != '') {
|
|
|
|
$response = [
|
|
'message' => 'Verification text sent to user',
|
|
'call_return' => '100',
|
|
'verification_id' => 'e99c9c7555c97807b86b750cfe6323d15b2b09e561022205dc679534825f2acf'
|
|
];
|
|
|
|
return $this->respond($response, 200);
|
|
} else {
|
|
$response = [
|
|
'message' => 'Failure',
|
|
'call_return' => '100',
|
|
'token' => ''
|
|
];
|
|
return $this->fail($response, 409);
|
|
}
|
|
|
|
|
|
//return json_encode( $response );
|
|
|
|
}
|
|
}
|