<?php
	header('Content-type: text/html; charset=utf-8');
	$path="../../../../";
	include("".$path."deppo/tools/script/cevir.php");
	$path2="config/"; include("".$path."config/map.php");
	include("".$path."deppo/tools/script/fonksiyon".$ver.".php");
	$sql = mysqli_query($conn, "select * from genel where ne='banka' and s1=".$_SESSION["Order_Bank_Id"]." and s2=1"); $rsb = mysqli_fetch_assoc($sql);
?>
	<table style="display:none;">
		<?php
			$postParams = array();
			foreach ($_POST as $key => $value){
				array_push($postParams, $key);				
				echo "<tr><td>" . $key ."</td><td>" . $value . "</td></tr>";
			}
			
			natcasesort($postParams);		
			
			$hashval = "";					
			foreach ($postParams as $param){				
				$paramValue = $_POST[$param];
				$escapedParamValue = str_replace("|", "\\|", str_replace("\\", "\\\\", $paramValue));	
					
				$lowerParam = strtolower($param);
				if($lowerParam != "hash" && $lowerParam != "encoding" )	{
					$hashval = $hashval . $escapedParamValue . "|";
				}
			}
			
			$storeKey = $rsb["n5"];
			$escapedStoreKey = str_replace("|", "\\|", str_replace("\\", "\\\\", $storeKey));	
			$hashval = $hashval . $escapedStoreKey;
			
			$calculatedHashValue = hash('sha512', $hashval);  
			$actualHash = base64_encode (pack('H*',$calculatedHashValue));
			
			$retrievedHash = $_POST["HASH"];
			$mdStatus = $_POST["mdStatus"];
			$ErrMsg = $_POST["ErrMsg"];
			if($mdStatus == 1 || $mdStatus == 2 || $mdStatus == 3 || $mdStatus == 4){
				//echo "<h5>3D Islemi basarili</h5><br/>";
				for($i=0;$i<6;$i++){
					$param = $odemeparametreleri[$i];
					//echo "<tr><td>".$param."</td><td>".$_POST[$param]."</td></tr>";
				}
				$response = $_POST["Response"];
				if($response == "Approved"){
					echo "<script>window.location.href=\"".$_GET["burl"]."ok/".$_POST["TransId"]."\"</script>";
					//echo "Ödeme Islemi Basarili";
				}else{
					echo "<script>window.location.href=\"".$_GET["burl"]."err/".base64_encode($ErrMsg)."\"</script>";
					//echo "Ödeme Islemi Basarisiz. Hata = ".$ErrMsg;
				}
				
			}else{
					echo "<script>window.location.href='".$_GET["burl"]."err/".base64_encode($ErrMsg)."'</script>";
					//echo "<h5>3D Islemi basarisiz</h5>";
			}
		?>
	</table>