<?php 


include("tools/header.php");?>
<?php
$data = array("merchant_id" => "493668a1-078d-4f3e-93ff-49061ba7e12e", "authority" => "A00000000000000000000000000270903953", "amount" => "8424000");
$data = array("merchant_id" => "493668a1-078d-4f3e-93ff-49061ba7e12e");
$jsonData = json_encode($data);
$ch = curl_init('https://api.zarinpal.com/pg/v4/payment/unVerified.json');
curl_setopt($ch, CURLOPT_USERAGENT, 'ZarinPal Rest Api v4');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($jsonData)
));

$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result, true);

 

if ($result['data']['code'] == 100) { 
        
        $auths = $result['data']["authorities"];
         for($i=0;$i<sizeof($auths);$i++){
		 	$temp=$auths[$i];
			 
			 
			 $auth = $temp["authority"];
			 $amount = $temp["amount"];
			 $cburl = $temp["callback_url"];
			 $refurl = $temp["referer"];
			 $purdate = $temp["date"];
 
			 if(($cburl=="https://www.lajeh.ir/chsta.php") && ($refurl=="https://www.lajeh.ir/")){

				 
				 $purdate = str_replace('-', '', $purdate);
				 $purdate = str_replace(':', '', $purdate);
				 $purdate = str_replace(' ', '', $purdate);
  	 
		 	 $queries -> updateFactor("EXEC dbo.handleUnverifiedAuth @t_auth =  ".$auth.", @t_amount = ".$amount.", @dateof = ".$purdate);
				 
			 }
			 
			 
		 
		 }
        
        
}

?>