File: /home/durgeshpandey215/www/zeeroprice.skilladders.com/cashfree-response.php
<?php require_once "application_top.php";
require "protect.php";
$orderId = (isset($_REQUEST['order_id'])&&($_REQUEST['order_id']))? $_REQUEST['order_id'] : "";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.cashfree.com/pg/orders/$orderId",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
"x-client-id: TEST362983010987cf24fea23cf6df389263",
"x-client-secret: TEST3484cc1ff3ee2571e561ce17bc0b7c6ff31143fd",
'x-api-version: 2021-05-21'
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if(!$err) {
$result = json_decode($response, true);
if($result["order_status"] == 'PAID'){
$_SESSION["msg"] = "Payment successful!";
//update transaction table and register table
$customeridfrompg = $result["customer_details"]["customer_id"];
$db->where('userid',$customeridfrompg);
$rowu = $db->getOne('register');
$db->where('transactionid',$orderId);
$rowpack = $db->getOne('transactions');
$dbwallet = $rowu['points'];
$newwallet = $dbwallet + $rowpack['credited'];
$updatedata = array('points'=>$newwallet,
'isPaid'=>1
);
$db->where('userid',$customeridfrompg);
$db->update('register',$updatedata);
//update in transaction table
$updatedata = array(
'isPaid'=> 1,
'postedon'=> date('Y-m-d H:i:s')
);
$db->where('transactionid',$orderId);
$db->update('transactions',$updatedata);
} else {
$_SESSION["msg"] = "Order has not been paid!";
}
} else {
$_SESSION["msg"] = $err;
}
header('location:'.HTTP_SERVER."wallet.php");exit;
?>