D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
probwael
/
public_html
/
Filename :
pay_verify.php
back
Copy
<? session_cache_expire(120); ini_set('session.gc_maxlifetime', 7200); @session_start(); include("conn.php"); $em=$_SESSION["em"]; $transid=$_SESSION['pay_transid']; //check if payment was successfull $result = array(); //The parameter after verify/ is the transaction reference to be verified $payrefrence=$_SESSION['payrefrence']; $url = 'https://api.paystack.co/transaction/verify/'.$payrefrence; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt( $ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_fe6c5a360615d1149111ebabcd7cf8f0d8a4dbef'] ); $request = curl_exec($ch); curl_close($ch); if ($request) { $result = json_decode($request, true); } if (array_key_exists('data', $result) && array_key_exists('status', $result['data']) && ($result['data']['status'] === 'success')) { //record payment status mysqli_query($conn,"update _dcart set pay_status='paid' where transid='$transid'"); $_SESSION['msg']="<br><font color=green><br> <b>Your payment was successful and your order is being processed. You shall be contacted shortly.</b><br></font>"; header("location: view_shopping_details?transid={$transid}"); } else{ $_SESSION['msg']="<br><font color=red><br><b>Your payment was not successful... contact support to make payment or try again!</b><br></font>"; //unset pay reference $_SESSION['payrefrence']=''; //--------------- header("location: view_shopping_details?transid={$transid}"); } ?>