added dynamic token and admin_Id

This commit is contained in:
jouls 2024-03-08 13:46:41 +08:00
parent f42b5a3bda
commit 47d4e50901
4 changed files with 38 additions and 18 deletions

View File

@ -158,7 +158,7 @@ function get_users()
return $response; return $response;
} }
function get_kyc() function get_kyc($bToken)
{ {
$curl = curl_init(); $curl = curl_init();
@ -172,7 +172,7 @@ function get_kyc()
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array( CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MmUzYTIzOTQwNTg5Y2UxM2Q4MjVlOSIsImlhdCI6MTY4MDc1MTI4M30.nk_GgSbyA8WuGYa9DgKJNvCVjl5GLHPAOt2rOujwUxs' 'Authorization: Bearer ' . $bToken . ''
), ),
)); ));
@ -182,7 +182,7 @@ function get_kyc()
return $response; return $response;
} }
function get_kyc_info($IDkyc) function get_kyc_info($IDkyc, $bToken)
{ {
$curl = curl_init(); $curl = curl_init();
//$url = "https://testapi.obpay.online/api/users/id/$email"; //$url = "https://testapi.obpay.online/api/users/id/$email";
@ -198,7 +198,7 @@ function get_kyc_info($IDkyc)
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array( CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MmUzYTIzOTQwNTg5Y2UxM2Q4MjVlOSIsImlhdCI6MTY4MDc1MTI4M30.nk_GgSbyA8WuGYa9DgKJNvCVjl5GLHPAOt2rOujwUxs' 'Authorization: Bearer ' . $bToken . ''
), ),
)); ));
@ -207,7 +207,8 @@ function get_kyc_info($IDkyc)
return $response; return $response;
} }
function reject_kyc($IDkyc, $IDuser, $reason) function reject_kyc($IDkyc, $IDuser, $reason, $bToken, $Admin_UserId)
{ {
// First cURL request to reject KYC // First cURL request to reject KYC
$curl = curl_init(); $curl = curl_init();
@ -224,7 +225,7 @@ function reject_kyc($IDkyc, $IDuser, $reason)
CURLOPT_POSTFIELDS => '{"status":"rejected"}', CURLOPT_POSTFIELDS => '{"status":"rejected"}',
CURLOPT_HTTPHEADER => array( CURLOPT_HTTPHEADER => array(
'Content-Type: application/json', 'Content-Type: application/json',
'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MjRkOTYyZmNiMWU0ZjgyNDU0NmM4OSIsImlhdCI6MTY4MDEzNzU2NH0.9EHOeaXkYS5mGYG-g-_tgRpw338JzxECLec9cU2zhys' 'Authorization: Bearer ' . $bToken . ''
), ),
)); ));
$response1 = curl_exec($curl); $response1 = curl_exec($curl);
@ -248,7 +249,7 @@ function reject_kyc($IDkyc, $IDuser, $reason)
CURLOPT_POSTFIELDS => $data, CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array( CURLOPT_HTTPHEADER => array(
'Content-Type: application/json', 'Content-Type: application/json',
'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MjRkOTYyZmNiMWU0ZjgyNDU0NmM4OSIsImlhdCI6MTY4MDEzNzU2NH0.9EHOeaXkYS5mGYG-g-_tgRpw338JzxECLec9cU2zhys' 'Authorization: Bearer ' . $bToken . ''
), ),
)); ));
$response2 = curl_exec($curl2); $response2 = curl_exec($curl2);
@ -256,7 +257,7 @@ function reject_kyc($IDkyc, $IDuser, $reason)
$curl3 = curl_init(); $curl3 = curl_init();
$postfields = '{ $postfields = '{
"from_id":"6458dd6066139b3fee29a9cf", "from_id":"' . $Admin_UserId . '",
"to_id":"' . $IDuser . '", "to_id":"' . $IDuser . '",
"title":"KYC Denied!!", "title":"KYC Denied!!",
"message":"Your KYC got Rejected because ' . $reason . '.", "message":"Your KYC got Rejected because ' . $reason . '.",
@ -275,7 +276,7 @@ function reject_kyc($IDkyc, $IDuser, $reason)
CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => array( CURLOPT_HTTPHEADER => array(
'Content-Type: application/json', 'Content-Type: application/json',
'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MjE1NmU0ZTVhMTUwNjk2MTI3NGYyMCIsImlhdCI6MTY3OTkwNjU2OH0.1hDJwO760_p83FsQQwCduz0PIBBNFnMKYK3RvDqE9dA' 'Authorization: Bearer ' . $bToken . ''
), ),
)); ));
@ -286,9 +287,10 @@ function reject_kyc($IDkyc, $IDuser, $reason)
return array($response1, $response2, $response3); return array($response1, $response2, $response3);
} }
function accept_kyc($IDkyc, $IDuser, $reason) function accept_kyc($IDkyc, $IDuser, $reason, $bToken, $Admin_UserId)
{ {
$curl = curl_init(); $curl = curl_init();
$url = "https://testapi.obpay.online/api/kycs/update/$IDkyc"; $url = "https://testapi.obpay.online/api/kycs/update/$IDkyc";
curl_setopt_array($curl, array( curl_setopt_array($curl, array(
CURLOPT_URL => $url, CURLOPT_URL => $url,
@ -302,7 +304,7 @@ function accept_kyc($IDkyc, $IDuser, $reason)
CURLOPT_POSTFIELDS => '{"status":"validated"}', CURLOPT_POSTFIELDS => '{"status":"validated"}',
CURLOPT_HTTPHEADER => array( CURLOPT_HTTPHEADER => array(
'Content-Type: application/json', 'Content-Type: application/json',
'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MjRkOTYyZmNiMWU0ZjgyNDU0NmM4OSIsImlhdCI6MTY4MDEzNzU2NH0.9EHOeaXkYS5mGYG-g-_tgRpw338JzxECLec9cU2zhys' 'Authorization: Bearer ' . $bToken . ''
), ),
)); ));
@ -323,7 +325,7 @@ function accept_kyc($IDkyc, $IDuser, $reason)
CURLOPT_POSTFIELDS => $data, CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array( CURLOPT_HTTPHEADER => array(
'Content-Type: application/json', 'Content-Type: application/json',
'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MjRkOTYyZmNiMWU0ZjgyNDU0NmM4OSIsImlhdCI6MTY4MDEzNzU2NH0.9EHOeaXkYS5mGYG-g-_tgRpw338JzxECLec9cU2zhys' 'Authorization: Bearer ' . $bToken . ''
), ),
)); ));
$response2 = curl_exec($curl2); $response2 = curl_exec($curl2);
@ -331,7 +333,7 @@ function accept_kyc($IDkyc, $IDuser, $reason)
$curl3 = curl_init(); $curl3 = curl_init();
$postfields = '{ $postfields = '{
"from_id":"6458dd6066139b3fee29a9cf", "from_id":"' . $Admin_UserId . '",
"to_id":"' . $IDuser . '", "to_id":"' . $IDuser . '",
"title":"KYC Accepted!!", "title":"KYC Accepted!!",
"message":"Greetings!! ' . $reason . '.", "message":"Greetings!! ' . $reason . '.",
@ -350,7 +352,7 @@ function accept_kyc($IDkyc, $IDuser, $reason)
CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => array( CURLOPT_HTTPHEADER => array(
'Content-Type: application/json', 'Content-Type: application/json',
'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MjE1NmU0ZTVhMTUwNjk2MTI3NGYyMCIsImlhdCI6MTY3OTkwNjU2OH0.1hDJwO760_p83FsQQwCduz0PIBBNFnMKYK3RvDqE9dA' 'Authorization: Bearer ' . $bToken . ''
), ),
)); ));

View File

@ -1,3 +1,12 @@
<?php
session_start();
if (!isset($_SESSION['token'])) {
header("Location: /login/");
exit();
}
$user_id = $_SESSION['user_id'];
$BearerToken = $_SESSION['token'];
?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@ -25,7 +34,7 @@
$IDkyc = isset($_GET['kycID']) ? $_GET['kycID'] : ''; $IDkyc = isset($_GET['kycID']) ? $_GET['kycID'] : '';
include '../functions-test.php'; include '../functions-test.php';
//calls the get_kyc_info function insdie the functions-test.php that retrieves all the kyc data //calls the get_kyc_info function insdie the functions-test.php that retrieves all the kyc data
$response = get_kyc_info($IDkyc); $response = get_kyc_info($IDkyc, $BearerToken);
$array = json_decode($response, true); $array = json_decode($response, true);
// Check if the decoding was successful // Check if the decoding was successful

View File

@ -1,4 +1,11 @@
<?php <?php
session_start();
if (!isset($_SESSION['token'])) {
$_SESSION['url'] = "users/";
header("Location: /login/");
exit();
}
$user_id = $_SESSION['user_id'];
// update-kyc.php // update-kyc.php
// Include functions-test.php // Include functions-test.php
@ -10,11 +17,12 @@ if (isset($_GET['kycID'], $_GET['userID'], $_GET['isAccepted'])) {
$userID = $_GET['userID']; $userID = $_GET['userID'];
$isAccepted = ($_GET['isAccepted'] === 'true'); $isAccepted = ($_GET['isAccepted'] === 'true');
$reason = $_GET['reason']; $reason = $_GET['reason'];
$BearerToken = $_SESSION['token'];
if ($isAccepted) { if ($isAccepted) {
$reason = 'Congratulations, Your KYC got accepted!!'; $reason = 'Congratulations, Your KYC got accepted!!';
// If isAccepted is true, call accept_kyc function // If isAccepted is true, call accept_kyc function
if (accept_kyc($kycID, $userID, $reason)) { if (accept_kyc($kycID, $userID, $reason, $BearerToken, $user_id)) {
// If accept_kyc is successful, redirect to users-kyc.php // If accept_kyc is successful, redirect to users-kyc.php
header('Location: users-kyc.php'); header('Location: users-kyc.php');
exit(); exit();
@ -23,7 +31,7 @@ if (isset($_GET['kycID'], $_GET['userID'], $_GET['isAccepted'])) {
} }
} else { } else {
// If isAccepted is false, call reject_kyc function // If isAccepted is false, call reject_kyc function
if (reject_kyc($kycID, $userID, $reason)) { if (reject_kyc($kycID, $userID, $reason, $BearerToken, $user_id)) {
// If reject_kyc is successful, redirect to users-kyc.php // If reject_kyc is successful, redirect to users-kyc.php
header('Location: users-kyc.php'); header('Location: users-kyc.php');
exit(); exit();

View File

@ -6,6 +6,7 @@ if (!isset($_SESSION['token'])) {
exit(); exit();
} }
$user_id = $_SESSION['user_id']; $user_id = $_SESSION['user_id'];
$BearerToken = $_SESSION['token'];
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@ -67,7 +68,7 @@ $user_id = $_SESSION['user_id'];
<h1>Know-Your-Customer</h1> <h1>Know-Your-Customer</h1>
<?php <?php
include '../functions-test.php'; include '../functions-test.php';
$response = get_kyc(); $response = get_kyc($BearerToken);
$array = json_decode($response, true); $array = json_decode($response, true);
?> ?>
<table id="example" class="table table-bordered display responsive nowrap" style="width:100%"> <table id="example" class="table table-bordered display responsive nowrap" style="width:100%">