From 5fe21dfb5570f98cf44284bfb50dd038d010e7de Mon Sep 17 00:00:00 2001 From: jouls Date: Thu, 7 Mar 2024 18:28:59 +0800 Subject: [PATCH] Create Notifs Added --- functions-test.php | 64 +++++++++++++++++++++++++++++++++++++++++--- users/update-kyc.php | 5 ++-- 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/functions-test.php b/functions-test.php index edc27b8..88f6604 100644 --- a/functions-test.php +++ b/functions-test.php @@ -207,7 +207,7 @@ function get_kyc_info($IDkyc) return $response; } -function reject_kyc($IDkyc, $IDuser) +function reject_kyc($IDkyc, $IDuser, $reason) { // First cURL request to reject KYC $curl = curl_init(); @@ -254,11 +254,39 @@ function reject_kyc($IDkyc, $IDuser) $response2 = curl_exec($curl2); curl_close($curl2); + $curl3 = curl_init(); + $postfields = '{ + "from_id":"6458dd6066139b3fee29a9cf", + "to_id":"' . $IDuser . '", + "title":"KYC Denied!!", + "message":"Your KYC got Rejected because ' . $reason . '.", + "status":"new" + }'; + + curl_setopt($curl3, CURLOPT_POSTFIELDS, $postfields); + curl_setopt_array($curl3, array( + CURLOPT_URL => 'https://testapi.obpay.online/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 eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MjE1NmU0ZTVhMTUwNjk2MTI3NGYyMCIsImlhdCI6MTY3OTkwNjU2OH0.1hDJwO760_p83FsQQwCduz0PIBBNFnMKYK3RvDqE9dA' + ), + )); + + $response3 = curl_exec($curl3); + curl_close($curl3); + // Return an array containing both responses - return array($response1, $response2); + return array($response1, $response2, $response3); } -function accept_kyc($IDkyc, $IDuser) +function accept_kyc($IDkyc, $IDuser, $reason) { $curl = curl_init(); $url = "https://testapi.obpay.online/api/kycs/update/$IDkyc"; @@ -301,7 +329,35 @@ function accept_kyc($IDkyc, $IDuser) $response2 = curl_exec($curl2); curl_close($curl2); - return array($response1, $response2); + $curl3 = curl_init(); + $postfields = '{ + "from_id":"6458dd6066139b3fee29a9cf", + "to_id":"' . $IDuser . '", + "title":"KYC Accepted!!", + "message":"Greetings!! ' . $reason . '.", + "status":"new" + }'; + + curl_setopt($curl3, CURLOPT_POSTFIELDS, $postfields); + curl_setopt_array($curl3, array( + CURLOPT_URL => 'https://testapi.obpay.online/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 eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MjE1NmU0ZTVhMTUwNjk2MTI3NGYyMCIsImlhdCI6MTY3OTkwNjU2OH0.1hDJwO760_p83FsQQwCduz0PIBBNFnMKYK3RvDqE9dA' + ), + )); + + $response3 = curl_exec($curl3); + curl_close($curl3); + + return array($response1, $response2, $response3); } diff --git a/users/update-kyc.php b/users/update-kyc.php index 0b7f301..5de96f8 100644 --- a/users/update-kyc.php +++ b/users/update-kyc.php @@ -12,8 +12,9 @@ if (isset($_GET['kycID'], $_GET['userID'], $_GET['isAccepted'])) { $reason = $_GET['reason']; if ($isAccepted) { + $reason = 'Congratulations, Your KYC got accepted!!'; // If isAccepted is true, call accept_kyc function - if (accept_kyc($kycID, $userID)) { + if (accept_kyc($kycID, $userID, $reason)) { // If accept_kyc is successful, redirect to users-kyc.php header('Location: users-kyc.php'); exit(); @@ -22,7 +23,7 @@ if (isset($_GET['kycID'], $_GET['userID'], $_GET['isAccepted'])) { } } else { // If isAccepted is false, call reject_kyc function - if (reject_kyc($kycID, $userID)) { + if (reject_kyc($kycID, $userID, $reason)) { // If reject_kyc is successful, redirect to users-kyc.php header('Location: users-kyc.php'); exit();