File: /home/rtbrisc/public_html/admin/main/payment/pay/data.php
<?php
session_start();
header("Access-Control-Allow-Origin: *");
require('../../worker/workers/server/customer.php');
require('../../worker/workers/server/issues.php');
require('../../worker/workers/server/utilities.php');
$tid = $_GET['reference'];
$cid = $_GET['cid'];
$pid = $_GET['pid'];
$verify = Verify($tid);
$transaction_no = $verify['data']['reference'];
$status = $verify['data']['status'];
$amount = $verify['data']['amount'];
$trans_date = $verify['data']['transaction_date'];
$channel = $verify['data']['channel'];
$email = $verify['data']['customer']['email'];
$sql = mysqli_query($cus, "INSERT INTO tblpaydata (CustomerID, PaymentID, Email, Amount, PaymentChannel, PaymentStatus) VALUES ('$cid', '$tid', '$email', '$amount', '$channel', '$status')");
$sql2 = mysqli_query($iss, "UPDATE tblpaymentticket SET TransactionID = '$tid', PaymentStatus = 2, PaymentMethod = '$channel' WHERE PaymentID = '$pid'");
// $sql3 = mysqli_query($iss, "UPDATE tblhelpdeskupdate SET PaymentStatus = 'Fully Paid' WHERE PaymentID");
// //==============================================================================
if($sql && $sql2)
{
echo json_encode("success");
}
else
{
echo json_encode("record not saved");;
}
function Verify($tid)
{
$sk = "sk_test_172b35565efc03cee6cea658bb414c2e1c52f05c";
$result = array();
$url = "https://api.paystack.co/transaction/verify/" . $tid;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = array('Authorization: Bearer ' . $sk, 'Content-Type: application/json');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$request = curl_exec ($ch);
//$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
if ($request) {
$result = json_decode($request, true);
}
//Use the $result array to get redirect URL
return $result;
}
?>