obananapay_admin/users/update-kyc.php

45 lines
1.4 KiB
PHP

<?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 = 'Congratulations, Your KYC got accepted!!';
// 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.';
}