Merge pull request 'louie-kyc' (#1) from louie-kyc into main
Reviewed-on: #1
This commit is contained in:
commit
e195709d20
|
@ -21,7 +21,7 @@ $user_id = $_SESSION['user_id'];
|
|||
});
|
||||
</script>
|
||||
|
||||
<body class="dt-example dt-example-bootstrap" >
|
||||
<body class="dt-example dt-example-bootstrap">
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
|
@ -38,6 +38,7 @@ $user_id = $_SESSION['user_id'];
|
|||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a href="#">Transactions</a></li>
|
||||
<li><a href="/users/users-test.php">Users</a></li>
|
||||
<li><a href="/users/users-kyc.php">KYC</a></li>
|
||||
<!-- <li class="dropdown">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Loan
|
||||
<span class="caret"></span></a>
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
function validate_user($id, $pwd)
|
||||
{
|
||||
$curl = curl_init();
|
||||
$url = "172.17.0.3:3000/api/users/id/$id";
|
||||
$url = "https://testapi.obanana.io/api/users/id/$id";
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt_array(
|
||||
$curl,
|
||||
array(
|
||||
//CURLOPT_URL => '172.17.0.3:3000/api/users/id/648058013436143c807101e4',
|
||||
//CURLOPT_URL => 'https://testapi.obanana.io/api/users/id/648058013436143c807101e4',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
|
@ -34,11 +34,11 @@ function validate_user($id, $pwd)
|
|||
function get_user_info($email)
|
||||
{
|
||||
$curl = curl_init();
|
||||
//$url = "172.17.0.3:3000/api/users/id/$email";
|
||||
$url = "172.17.0.3:3000/api/users/$email";
|
||||
//$url = "https://testapi.obanana.io/api/users/id/$email";
|
||||
$url = "https://testapi.obanana.io/api/users/$email";
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt_array($curl, array(
|
||||
//CURLOPT_URL => '172.17.0.3:3000/api/users/egalang@premiummegastructures.com',
|
||||
//CURLOPT_URL => 'https://testapi.obanana.io/api/users/egalang@premiummegastructures.com',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
|
@ -57,10 +57,11 @@ function get_user_info($email)
|
|||
return $response;
|
||||
}
|
||||
|
||||
|
||||
function get_user_info2($email)
|
||||
{
|
||||
$curl = curl_init();
|
||||
$url = "http://172.17.0.3:3000/api/users/id/$email";
|
||||
$url = "https://testapi.obanana.io/api/users/id/$email";
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt_array($curl, array(
|
||||
//CURLOPT_URL => 'https://api.obananapay.com/api/users/egalang@premiummegastructures.com',
|
||||
|
@ -85,10 +86,10 @@ function get_user_info2($email)
|
|||
function activate_account($user_id)
|
||||
{
|
||||
$curl = curl_init();
|
||||
$url = "172.17.0.3:3000/api/users/$user_id/sub";
|
||||
$url = "https://testapi.obanana.io/api/users/$user_id/sub";
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt_array($curl, array(
|
||||
//CURLOPT_URL => '172.17.0.3:3000/api/users/645a0c93008258b5e9a2cd20/sub',
|
||||
//CURLOPT_URL => 'https://testapi.obanana.io/api/users/645a0c93008258b5e9a2cd20/sub',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
|
@ -112,7 +113,7 @@ function get_transactions()
|
|||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => '172.17.0.3:3000/api/transactions/',
|
||||
CURLOPT_URL => 'https://testapi.obanana.io/api/transactions/',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
|
@ -136,7 +137,7 @@ function get_users()
|
|||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => '172.17.0.3:3000/api/users/',
|
||||
CURLOPT_URL => 'https://testapi.obanana.io/api/users/',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
|
@ -149,6 +150,240 @@ function get_users()
|
|||
),
|
||||
));
|
||||
|
||||
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
return $response;
|
||||
}
|
||||
|
||||
function get_kyc($bToken)
|
||||
{
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'https://testapi.obanana.io/api/kycs/',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Authorization: Bearer ' . $bToken . ''
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
return $response;
|
||||
}
|
||||
|
||||
function get_kyc_info($IDkyc, $bToken)
|
||||
{
|
||||
$curl = curl_init();
|
||||
//$url = "https://testapi.obanana.io/api/users/id/$email";
|
||||
$url = "https://testapi.obanana.io/api/kycs/$IDkyc";
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt_array($curl, array(
|
||||
//CURLOPT_URL => 'https://testapi.obanana.io/api/users/egalang@premiummegastructures.com',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Authorization: Bearer ' . $bToken . ''
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
return $response;
|
||||
}
|
||||
|
||||
function reject_kyc($IDkyc, $IDuser, $reason, $bToken, $Admin_UserId)
|
||||
|
||||
{
|
||||
// First cURL request to reject KYC
|
||||
$curl = curl_init();
|
||||
$url = "https://testapi.obanana.io/api/kycs/update/$IDkyc";
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'PATCH',
|
||||
CURLOPT_POSTFIELDS => '{"status":"rejected"}',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $bToken . ''
|
||||
),
|
||||
));
|
||||
$response1 = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
// Second cURL request to update user's KYC status
|
||||
$response1 = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$curl2 = curl_init();
|
||||
$url2 = "https://testapi.obanana.io/api/users/$IDuser/sub";
|
||||
$data = '{"kycStatus":"new", "kycRef":"' . $IDkyc . '"}';
|
||||
curl_setopt_array($curl2, array(
|
||||
CURLOPT_URL => $url2,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'PATCH',
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $bToken . ''
|
||||
),
|
||||
));
|
||||
$response2 = curl_exec($curl2);
|
||||
curl_close($curl2);
|
||||
|
||||
$curl3 = curl_init();
|
||||
$postfields = '{
|
||||
"from_id":"' . $Admin_UserId . '",
|
||||
"to_id":"' . $IDuser . '",
|
||||
"title":"KYC Application Denied.",
|
||||
"message":"Your KYC Application was rejected due to the following reason/s: ' . $reason . '.",
|
||||
"status":"new"
|
||||
}';
|
||||
|
||||
curl_setopt($curl3, CURLOPT_POSTFIELDS, $postfields);
|
||||
curl_setopt_array($curl3, array(
|
||||
CURLOPT_URL => 'https://testapi.obanana.io/api/notifications/create',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $bToken . ''
|
||||
),
|
||||
));
|
||||
|
||||
$response3 = curl_exec($curl3);
|
||||
curl_close($curl3);
|
||||
|
||||
// Return an array containing both responses
|
||||
return array($response1, $response2, $response3);
|
||||
}
|
||||
|
||||
function accept_kyc($IDkyc, $IDuser, $reason, $bToken, $Admin_UserId)
|
||||
{
|
||||
$curl = curl_init();
|
||||
|
||||
$url = "https://testapi.obanana.io/api/kycs/update/$IDkyc";
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'PATCH',
|
||||
CURLOPT_POSTFIELDS => '{"status":"validated"}',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $bToken . ''
|
||||
),
|
||||
));
|
||||
|
||||
$response1 = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$curl2 = curl_init();
|
||||
$url2 = "https://testapi.obanana.io/api/users/$IDuser/sub";
|
||||
$data = '{"kycStatus":"validated", "kycRef":"' . $IDkyc . '"}';
|
||||
curl_setopt_array($curl2, array(
|
||||
CURLOPT_URL => $url2,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'PATCH',
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $bToken . ''
|
||||
),
|
||||
));
|
||||
$response2 = curl_exec($curl2);
|
||||
curl_close($curl2);
|
||||
|
||||
$curl3 = curl_init();
|
||||
$postfields = '{
|
||||
"from_id":"' . $Admin_UserId . '",
|
||||
"to_id":"' . $IDuser . '",
|
||||
"title":"KYC Application Accepted.",
|
||||
"message":"Congratulations! ' . $reason . '.",
|
||||
"status":"new"
|
||||
}';
|
||||
|
||||
curl_setopt($curl3, CURLOPT_POSTFIELDS, $postfields);
|
||||
curl_setopt_array($curl3, array(
|
||||
CURLOPT_URL => 'https://testapi.obanana.io/api/notifications/create',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $bToken . ''
|
||||
),
|
||||
));
|
||||
|
||||
$response3 = curl_exec($curl3);
|
||||
curl_close($curl3);
|
||||
|
||||
return array($response1, $response2, $response3);
|
||||
}
|
||||
|
||||
|
||||
function delete_kyc_info($IDuser)
|
||||
{
|
||||
$curl = curl_init();
|
||||
|
||||
// Append the $refNum to the API URL for deletion
|
||||
$url = "https://testapi.obanana.io/api/kycs/$IDuser/delete";
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'DELETE',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MmUzYTIzOTQwNTg5Y2UxM2Q4MjVlOSIsImlhdCI6MTY4MDc1MTI4M30.nk_GgSbyA8WuGYa9DgKJNvCVjl5GLHPAOt2rOujwUxs'
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
@ -161,7 +396,7 @@ function user_login($email, $password)
|
|||
$postfields = '{"users":"' . $email . '", "password":"' . $password . '"}';
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => '172.17.0.3:3000/api/auth/login',
|
||||
CURLOPT_URL => 'https://testapi.obanana.io/api/auth/login',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
|
@ -184,12 +419,12 @@ function user_login($email, $password)
|
|||
function user_balance($user_id, $token)
|
||||
{
|
||||
$curl = curl_init();
|
||||
$url = "172.17.0.3:3000/api/users/id/$user_id";
|
||||
$url = "https://testapi.obanana.io/api/users/id/$user_id";
|
||||
$httpheader = "Authorization: Bearer $token";
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array($httpheader));
|
||||
curl_setopt_array($curl, array(
|
||||
//CURLOPT_URL => '172.17.0.3:3000/api/users/id/6458dd6066139b3fee29a9cf',
|
||||
//CURLOPT_URL => 'https://testapi.obanana.io/api/users/id/6458dd6066139b3fee29a9cf',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
|
@ -233,7 +468,7 @@ function cash_in($user_id, $amount, $notes, $refno)
|
|||
}';
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => '172.17.0.3:3000/api/transactions/create',
|
||||
CURLOPT_URL => 'https://testapi.obanana.io/api/transactions/create',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
|
@ -267,7 +502,7 @@ function cash_out($user_id, $amount, $notes, $refno)
|
|||
}';
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => '172.17.0.3:3000/api/transactions/create',
|
||||
CURLOPT_URL => 'https://testapi.obanana.io/api/transactions/create',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
|
@ -300,7 +535,7 @@ function create_notification($to_id, $amount)
|
|||
';
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => '172.17.0.3:3000/api/notifications/create',
|
||||
CURLOPT_URL => 'https://testapi.obanana.io/api/notifications/create',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
|
@ -333,7 +568,7 @@ function create_notification_co($from_id, $amount)
|
|||
';
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => '172.17.0.3:3000/api/notifications/create',
|
||||
CURLOPT_URL => 'https://testapi.obanana.io/api/notifications/create',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
|
@ -378,8 +613,8 @@ function sendSMSotp($phone, $otp)
|
|||
function getUserById($id)
|
||||
{
|
||||
$curl = curl_init();
|
||||
$url = "172.17.0.3:3000/api/users/id/".$id;
|
||||
curl_setopt($curl,CURLOPT_URL,$url);
|
||||
$url = "https://testapi.obanana.io/api/users/id/" . $id;
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt_array($curl, array(
|
||||
//CURLOPT_URL => 'https://api.obpay.online/api/users/id/6458dd6066139b3fee29a9cf',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
session_start();
|
||||
$email = $_POST['email'];
|
||||
$pwd = $_POST['pwd'];
|
||||
$data = '{ "users":"'.$email.'", "password":"'.$pwd.'" }';
|
||||
$data = '{ "users":"' . $email . '", "password":"' . $pwd . '" }';
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl,CURLOPT_POSTFIELDS,$data);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => '172.17.0.4:3000/api/auth/login',
|
||||
CURLOPT_URL => 'https://testapi.obanana.io/api/auth/login',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
|
@ -23,14 +23,14 @@ $response = curl_exec($curl);
|
|||
|
||||
curl_close($curl);
|
||||
$array = json_decode($response, true);
|
||||
if($array['token']!=null){
|
||||
if($array['user']['type']!='admin'){
|
||||
if ($array['token'] != null) {
|
||||
if ($array['user']['type'] != 'admin') {
|
||||
header("Location: /login/?msg=1");
|
||||
} else {
|
||||
$_SESSION['token']=$array['token'];
|
||||
$_SESSION['user_id']=$array['user']['_id'];
|
||||
$_SESSION['user_type']=$array['user']['type'];
|
||||
header("Location: /admin-test.php".$_SESSION['url']);
|
||||
$_SESSION['token'] = $array['token'];
|
||||
$_SESSION['user_id'] = $array['user']['_id'];
|
||||
$_SESSION['user_type'] = $array['user']['type'];
|
||||
header("Location: /admin-test.php" . $_SESSION['url']);
|
||||
}
|
||||
} else {
|
||||
header("Location: /login/?msg=2");
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
include '../functions-test.php';
|
||||
|
||||
if (isset($_GET['kycID'])) {
|
||||
$kycID = $_GET['kycID'];
|
||||
|
||||
// Delete KYC info
|
||||
$response = delete_kyc_info($kycID);
|
||||
|
||||
// Check if deletion was successful
|
||||
if ($response) {
|
||||
// Redirect back to users-kyc.php
|
||||
header("Location: users-kyc.php");
|
||||
exit();
|
||||
} else {
|
||||
// Handle error (if needed)
|
||||
echo "Error deleting KYC info.";
|
||||
}
|
||||
} else {
|
||||
// Handle case where userID is not provided
|
||||
echo "Invalid request.";
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
|
||||
body {
|
||||
justify-content: space-between;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.mainContainer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding-left: 10rem;
|
||||
padding-right: 10rem;
|
||||
}
|
||||
|
||||
.section {
|
||||
width: 45%;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.section h2 {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
margin-bottom: 20px;
|
||||
padding-top: 0px;
|
||||
}
|
||||
|
||||
form {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.image-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 48%;
|
||||
height: auto;
|
||||
max-height: 200px;
|
||||
object-fit: cover;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.checkboxFormContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.checkbox-container {
|
||||
margin-bottom: 10px;
|
||||
/* Adjust the margin as needed */
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
.kycImg , .selfieImg{
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
transition: 0.3s;
|
||||
|
||||
}
|
||||
|
||||
.kycImg:hover , .selfieImg:hover{
|
||||
box-shadow: 5px 10px 5px lightblue;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.imgModal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
padding-top: 100px;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
background-color: rgb(0,0,0);
|
||||
background-color: rgba(0,0,0,0.9);
|
||||
}
|
||||
|
||||
|
||||
.imgModal-content {
|
||||
margin: auto;
|
||||
display: block;
|
||||
width: 80%;
|
||||
height: auto;
|
||||
max-width: 700px;
|
||||
}
|
||||
|
||||
|
||||
.imgModal-content, #caption {
|
||||
-webkit-animation-name: zoom;
|
||||
-webkit-animation-duration: 0.6s;
|
||||
animation-name: zoom;
|
||||
animation-duration: 0.6s;
|
||||
}
|
||||
|
||||
@-webkit-keyframes zoom {
|
||||
from {-webkit-transform:scale(0)}
|
||||
to {-webkit-transform:scale(1)}
|
||||
}
|
||||
|
||||
@keyframes zoom {
|
||||
from {transform:scale(0)}
|
||||
to {transform:scale(1)}
|
||||
}
|
||||
|
||||
|
||||
.closeImg {
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
right: 35px;
|
||||
color: #f1f1f1;
|
||||
font-size: 40px;
|
||||
font-weight: bold;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
.closeImg:hover,
|
||||
.closeImg:focus {
|
||||
color: #bbb;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 700px){
|
||||
.imgModal-content {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,253 @@
|
|||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['token'])) {
|
||||
header("Location: /login/");
|
||||
exit();
|
||||
}
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$BearerToken = $_SESSION['token'];
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<?php include '../header.php'; ?>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="edit-kyc.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-brand">
|
||||
<header> VERIFY YOUR KYCs </header>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</nav>
|
||||
<div class="mainContainer">
|
||||
<div class="section form-container">
|
||||
<?php
|
||||
//gets the pass parameter kycID and assigned to local variable $IDkyc
|
||||
$IDkyc = isset($_GET['kycID']) ? $_GET['kycID'] : '';
|
||||
include '../functions-test.php';
|
||||
//calls the get_kyc_info function insdie the functions-test.php that retrieves all the kyc data
|
||||
$response = get_kyc_info($IDkyc, $BearerToken);
|
||||
$array = json_decode($response, true);
|
||||
|
||||
if (!empty($array['userRef']['address1'] && $array['userRef']['city'] && $array['userRef']['province'] && $array['userRef']['zip'] || $array['userRef']['country'])) {
|
||||
$CurrentUserAddress = '' . $array['userRef']['address1'] . ', ' . $array['userRef']['city'] . ', ' . $array['userRef']['province'] . ', ' . $array['userRef']['country'] . ' ' . $array['userRef']['zip'];
|
||||
} else {
|
||||
$CurrentUserAddress = "";
|
||||
}
|
||||
// Check if the decoding was successful
|
||||
if ($array !== null) {
|
||||
?>
|
||||
<h2>User Selfie:</h2>
|
||||
<div class="image-container">
|
||||
<?php
|
||||
// Display selfie image
|
||||
if (!empty($array['selfie'])) {
|
||||
echo '<img src="' . $array['selfie'] . '" alt="Selfie Image" id="kycImg" class="selfieImg" onclick="trigger(\'kycImg\', \'Selfie Image\');">';
|
||||
} else {
|
||||
echo '<p>No selfie available.</p>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div id="myModal" class="imgModal">
|
||||
<span class="closeImg" onclick="closeModal()">×</span>
|
||||
<img class="imgModal-content" id="img01" style="max-width: 100%; max-height: 80vh; width: auto; height: auto; margin: auto; display: block;">
|
||||
|
||||
</div>
|
||||
<!-- Displays all the information retrieved by get_kyc_info() related to userInfo -->
|
||||
<h3>User Information</h3>
|
||||
<div class="form-container">
|
||||
<fieldset disabled>
|
||||
<form>
|
||||
<label for="fullName">Full Name:</label>
|
||||
<input class="form-control" type="text" id="fullName" name="fullName" value="<?php echo $array['userRef']['fName'] . ' ' . $array['userRef']['lName']; ?>" readonly>
|
||||
|
||||
<label for="email">Email:</label>
|
||||
<input class="form-control" type="text" id="email" name="email" value="<?php echo $array['userRef']['email']; ?>" readonly>
|
||||
|
||||
<label for="address">Address:</label>
|
||||
<input class="form-control" type="text" id="address" name="address" value="<?php echo $CurrentUserAddress; ?>" readonly>
|
||||
|
||||
|
||||
<label for="additionalStatus">KYC Status:</label>
|
||||
<input class="form-control" type="text" id="additionalStatus" name="additionalStatus" value="<?php echo $array['status']; ?>" readonly>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
echo 'Failed to decode JSON response.';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<!-- Displays all the information related to kycInfo -->
|
||||
<div class="section form-container">
|
||||
<h2>ID Images:</h2>
|
||||
<div class="image-container">
|
||||
<?php
|
||||
if (!empty($array['images'])) {
|
||||
foreach ($array['images'] as $image) {
|
||||
|
||||
$img = $image['link'];
|
||||
echo '<img src="' . $img . '" alt="KYC Image" id="' . $img . '" class="kycImg" onclick="trigger(\'' . $img . '\', \'KYC Image\');">';
|
||||
}
|
||||
} else {
|
||||
echo '<p>No images available.</p>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div id="myModal" class="imgModal">
|
||||
<span class="closeImg">×</span>
|
||||
<img class="imgModal-content" id="img01">
|
||||
</div>
|
||||
<h3>KYC Information</h3>
|
||||
<div class="form-container">
|
||||
<form>
|
||||
<fieldset disabled>
|
||||
<label for="additionalFullName">Full Name:</label>
|
||||
<input class="form-control" type="text" id="additionalFullName" name="additionalFullName" value="<?php echo $array['full_name']; ?>" readonly>
|
||||
|
||||
<label for="idNum">ID Number:</label>
|
||||
<input class="form-control" type="text" id="idNum" name="idNum" value="<?php echo $array['id_num']; ?>" readonly>
|
||||
|
||||
<label for="dob">Date of Birth:</label>
|
||||
<input class="form-control" type="text" id="dob" name="dob" value="<?php echo $array['date_of_birth']; ?>" readonly>
|
||||
|
||||
<label for="address">ID Address:</label>
|
||||
<input class="form-control" type="text" id="kyc_address" name="KycAddress" value="<?php echo $array['address']; ?>" readonly>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Display section for confirmation or validation of information via checkbox -->
|
||||
<div class="section form-container">
|
||||
<h2>Confirm KYC Details</h2>
|
||||
<div class="checkboxFormContainer">
|
||||
<form id="checkboxForm">
|
||||
<div class="checkbox-container">
|
||||
<label for="checkbox1" class="checkbox-label">Full Name
|
||||
<input type="checkbox" id="checkbox1" name="checkbox1">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox-container">
|
||||
<label for="checkbox2" class="checkbox-label">ID Number
|
||||
<input type="checkbox" id="checkbox2" name="checkbox2">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox-container">
|
||||
<label for="checkbox3" class="checkbox-label">Date of Birth
|
||||
<input type="checkbox" id="checkbox3" name="checkbox3">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox-container">
|
||||
<label for="checkbox4" class="checkbox-label">Address
|
||||
<input type="checkbox" id="checkbox4" name="checkbox4">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-container">
|
||||
<h3>Change the status?</h3>
|
||||
|
||||
<button type="button" class="btn btn-danger" id="rejectButton" onclick="openRejectDialog();">Reject</button>
|
||||
<button type="button" class="btn btn-success" id="acceptButton" onclick="handleKycAction('<?php echo $IDkyc; ?>', '<?php echo $array['userRef']['_id']; ?>', true);" disabled>Accept</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Scripts for modal boxes and image hovering -->
|
||||
<script type="text/javascript">
|
||||
function handleCheckboxChange() {
|
||||
// Check the status of checkboxes and enable/disable the "Accept" button
|
||||
var areAllChecked = document.querySelectorAll('#checkboxForm input[type="checkbox"]:checked').length === 4;
|
||||
document.getElementById('acceptButton').disabled = !areAllChecked;
|
||||
}
|
||||
|
||||
// Attach the handleCheckboxChange function to each checkbox's onchange event
|
||||
var checkboxes = document.querySelectorAll('#checkboxForm input[type="checkbox"]');
|
||||
checkboxes.forEach(function(checkbox) {
|
||||
checkbox.addEventListener('change', handleCheckboxChange);
|
||||
});
|
||||
|
||||
function openRejectDialog() {
|
||||
$('#rejectModal').modal('show');
|
||||
}
|
||||
|
||||
function handleKycAction(kycID, userID, isAccepted, reason) {
|
||||
if (isAccepted) {
|
||||
// Handle the logic for accept
|
||||
// You may call acceptFunction or perform other actions
|
||||
window.location.href = 'update-kyc.php?kycID=' + kycID + '&userID=' + userID + '&isAccepted=true';
|
||||
} else {
|
||||
// Handle the logic for reject
|
||||
// Redirect to update-kyc.php with the additional parameter
|
||||
window.location.href = 'update-kyc.php?kycID=' + kycID + '&userID=' + userID + '&isAccepted=false&reason=' + encodeURIComponent(reason);
|
||||
}
|
||||
}
|
||||
|
||||
function handleRejectWithReason() {
|
||||
var reason = document.getElementById('rejectReason').value;
|
||||
if (reason.trim() !== "") {
|
||||
// User entered a non-empty reason
|
||||
var kycID = '<?php echo $IDkyc; ?>';
|
||||
var userID = '<?php echo $array['userRef']['_id']; ?>';
|
||||
handleKycAction(kycID, userID, false, reason);
|
||||
$('#rejectModal').modal('hide');
|
||||
} else {
|
||||
// User entered an empty reason
|
||||
alert("Please provide a valid reason for rejection.");
|
||||
}
|
||||
};
|
||||
|
||||
var modal = document.getElementById("myModal");
|
||||
|
||||
function trigger(var1, caption) {
|
||||
var modalImg = document.getElementById("img01");
|
||||
|
||||
modal.style.display = "block";
|
||||
modalImg.src = document.getElementById(var1).src;
|
||||
captionText.innerHTML = caption;
|
||||
}
|
||||
|
||||
// Close the modal when clicking outside the image or x button
|
||||
window.onclick = function(event) {
|
||||
if (event.target == modal || event.target.classList.contains('closeImg')) {
|
||||
modal.style.display = "none";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<!-- Creating a modal dialog box using Bootstrap framework in HTML. -->
|
||||
<div class="modal fade" id="rejectModal" tabindex="-1" role="dialog" aria-labelledby="rejectModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="rejectModalLabel"><strong>Confirm Rejection? State your reason</strong></h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<label for="rejectReason">Enter your reasons here:</label>
|
||||
<textarea class="form-control" id="rejectReason" placeholder="E.g. ID is expired.." required></textarea>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-danger" onclick="handleRejectWithReason();">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,3 +1,2 @@
|
|||
<?php
|
||||
header("location: users-test.php");
|
||||
?>
|
||||
header("location: users-test.php");
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['token'])) {
|
||||
$_SESSION['url'] = "users/";
|
||||
header("Location: /login/");
|
||||
exit();
|
||||
}
|
||||
$user_id = $_SESSION['user_id'];
|
||||
// update-kyc.php
|
||||
|
||||
// Include functions-test.php
|
||||
include '../functions-test.php';
|
||||
|
||||
// Check if the user ID and isAccepted parameters are set in the URL parameters
|
||||
if (isset($_GET['kycID'], $_GET['userID'], $_GET['isAccepted'])) {
|
||||
$kycID = $_GET['kycID'];
|
||||
$userID = $_GET['userID'];
|
||||
$isAccepted = ($_GET['isAccepted'] === 'true');
|
||||
$reason = $_GET['reason'];
|
||||
$BearerToken = $_SESSION['token'];
|
||||
|
||||
if ($isAccepted) {
|
||||
$reason = 'Your KYC Application got approved';
|
||||
// If isAccepted is true, call accept_kyc function
|
||||
if (accept_kyc($kycID, $userID, $reason, $BearerToken, $user_id)) {
|
||||
// If accept_kyc is successful, redirect to users-kyc.php
|
||||
header('Location: users-kyc.php');
|
||||
exit();
|
||||
} else {
|
||||
echo 'Failed to accept KYC.';
|
||||
}
|
||||
} else {
|
||||
// If isAccepted is false, call reject_kyc function
|
||||
if (reject_kyc($kycID, $userID, $reason, $BearerToken, $user_id)) {
|
||||
// If reject_kyc is successful, redirect to users-kyc.php
|
||||
header('Location: users-kyc.php');
|
||||
exit();
|
||||
} else {
|
||||
echo 'Failed to reject KYC.';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo 'Invalid parameters.';
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['token'])) {
|
||||
$_SESSION['url'] = "users/";
|
||||
header("Location: /login/");
|
||||
exit();
|
||||
}
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$BearerToken = $_SESSION['token'];
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<?php include '../header.php'; ?>
|
||||
<script type="text/javascript" class="init">
|
||||
$(document).ready(function() {
|
||||
$('#example').DataTable({
|
||||
// dom: 'Bfrtip',
|
||||
// buttons: [
|
||||
// 'csv'
|
||||
// ],
|
||||
responsive: true
|
||||
});
|
||||
});
|
||||
|
||||
function confirmDelete(kycID) {
|
||||
if (confirm("Are you sure you want to delete this KYC record?")) {
|
||||
window.location.href = 'delete-kyc.php?kycID=' + kycID;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<body class="dt-example dt-example-bootstrap">
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="#">oBananaPay</a>
|
||||
</div>
|
||||
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="/admin-test.php">Transactions</a></li>
|
||||
<li><a href="users-test.php">Users</a></li>
|
||||
<li class="active"><a href="#">KYC</a></li>
|
||||
<!-- <li class="dropdown">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Loan
|
||||
<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/loan/">Applications</a></li>
|
||||
<li><a href="/loan/transfer.php">Batch Transfer</a></li>
|
||||
<li><a href="/loan/payment.php">Payments</a></li>
|
||||
</ul>
|
||||
</li> -->
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li><a href="/logout.php">Logout <span class="glyphicon glyphicon-log-out" aria-hidden="true"></span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container">
|
||||
<h1>Know-Your-Customer</h1>
|
||||
<?php
|
||||
include '../functions-test.php';
|
||||
$response = get_kyc($BearerToken);
|
||||
$array = json_decode($response, true);
|
||||
?>
|
||||
<table id="example" class="table table-bordered display responsive nowrap" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width='1'>User ID</th>
|
||||
<th>KYC ID</th>
|
||||
<th>Name</th>
|
||||
<th>Status</th>
|
||||
<th> Action </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($array as $x => $val) {
|
||||
echo "<tr>";
|
||||
echo "<td>" . $val['userRef'] . "</td>";
|
||||
echo "<td>" . $val['_id'] . "</td>";
|
||||
echo "<td>" . $val['full_name'] . "</td>";
|
||||
echo "<td>" . $val['status'] . "</td> ";
|
||||
echo "<td>" .
|
||||
"<button class='btn btn-info' onclick=location.href='edit-kyc.php?kycID=" . $val['_id'] . "'>Edit</button>" .
|
||||
"<button class='btn btn-default' onclick='confirmDelete(\"" . $val['_id'] . "\")'>Delete</button>" .
|
||||
"</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -39,6 +39,7 @@ $user_id = $_SESSION['user_id'];
|
|||
<ul class="nav navbar-nav">
|
||||
<li><a href="/admin-test.php">Transactions</a></li>
|
||||
<li class="active"><a href="#">Users</a></li>
|
||||
<li><a href="users-kyc.php">KYC</a></li>
|
||||
<!-- <li class="dropdown">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Loan
|
||||
<span class="caret"></span></a>
|
||||
|
@ -87,8 +88,8 @@ $user_id = $_SESSION['user_id'];
|
|||
echo "<td>" . $val['type'] . "</td>";
|
||||
echo "<td>" . $val['status'] . "</td>";
|
||||
$json = getUserById($val['_id']);
|
||||
$balance = json_decode($json,true);
|
||||
echo "<td>".$balance['balance']."</td>";
|
||||
$balance = json_decode($json, true);
|
||||
echo "<td>" . $balance['balance'] . "</td>";
|
||||
echo "<td>" . substr($val['createdAt'], 0, 10) . "</td>";
|
||||
echo "<td>" . substr($val['createdAt'], 11, 8) . "</td>";
|
||||
echo "</tr>";
|
||||
|
|
Loading…
Reference in New Issue