MOON
Server: Apache
System: Linux smtp.modiva.org 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64
User: rtbrisc (1005)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/rtbrisc/public_html/admin/main/helpdesk/payment/data.php
<?php
header("Access-Control-Allow-Origin: *");
session_start();
require('../../worker/workers/server/customer.php'); //$cus
require('../../worker/workers/server/issues.php'); //$iss

$ref = $_GET['reference'];
//$amount = $_GET['amount'];
$cid = $_GET['cid'];
$tid = $_GET['tid'];
$spid = $_GET['spid'];
$rid = $_GET['rid'];
$rtid = $_GET['rtid'];
$did = $_GET['did'];
$dif = $_GET['dif'];
$dbid = $_GET['dbid'];
$bdi = $_GET['bdi'];
$dm = $_GET['dm'];
$des = $_GET['des'];
$stt = $_GET['stt'];
$sut = $_GET['sut'];
$pix = $_GET['pix'];
$cn = $_GET['cn'];
$cno = $_GET['cno'];
$ce = $_GET['ce'];
$sul = $_GET['sul'];
$cen = $_GET['cen'];


$verify = Verify($ref);

	
$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'];
$purpose = "Helpdesk Request";

//echo $tid;

$issue = mysqli_query($iss, "INSERT INTO tblhelpdeskrequest (TicketID, CustomerID, SupportPlanID, RequestID, RequestTypeID, DeviceTypeID, DeviceTypeInfo, DeviceBrandID, DeviceBrandInfo, DeviceModel, Description, SupportTimeType, SupportTime, Picture, StatusFlag, TrackStatus, AssignStatus, Payment, PaymentStatus, Center) 
 VALUES ('$tid', '$cid', $spid, $rid, $rtid, $did, '$dif', $dbid, '$bdi', '$dm', '$des', '$stt', '$sut', '$pix', 0, 0, 0, 'Applicable', 'Paid', $cen)");

$supportinfo = mysqli_query($iss, "INSERT INTO tblsupportinfo (TicketID, SupportName, SupportNumber, SupportEmail, SupportLocation)
 VALUES ('$tid', '$cn', '$cno', '$ce', '$sul')");

$paymentData = mysqli_query($cus, "INSERT INTO tblpaydata (CustomerID, PaymentID, Email, Amount, PaymentChannel, PaymentDate, PaymentStatus) VALUES ('$cid', '$ref', '$email', '$amount', '$channel', '$trans_date', '$status')");

	//==============================================================================
	if($issue && $supportinfo && $paymentData){
		if($status == "success"){
			// $_SESSION['req_suc'] = "Thank you for contactiong QIS. Your Issue / Purchase ID is " . $tid . ". We will contact you soon";
			// echo json_encode("success");
// 			header("Location: mailer/?rid=1&tid=$tid");
            echo json_encode("success");
		}else{
			//$_SESSION['req_err'] = "There was a problem logging your request!!!";
			echo json_encode("fail");
		}
	}else{
		echo json_encode("record not saved");;
	}

 
 function Verify($ref){
	$sk = "sk_test_172b35565efc03cee6cea658bb414c2e1c52f05c";
	$result = array();
    $url = "https://api.paystack.co/transaction/verify/" . $ref;

   $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;
 }
?>