<?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");
$pkadi=tanim("pay+paratika","n1",0);
$psifr=tanim("pay+paratika","n2",0);
$pkod=tanim("pay+paratika","n3",0);
$tutar=para($_POST["Total"]);
?> 
<html>
<head>
<title>Paratika Refund</title>
</head>
<body>
<?php
$url = 'https://vpos.paratika.com.tr/paratika/api/v2';
//$url = 'https://entegrasyon.paratika.com.tr/paratika/api/v2';
$data = array(
     'ACTION' => 'REFUND',
     'MERCHANTUSER' => $pkadi,
     'MERCHANTPASSWORD' => $psifr,
     'MERCHANT' => $pkod,
     'CURRENCY' => 'TRY',
     'AMOUNT' => $tutar,
     'PGTRANID' => $_POST["transid"],
     'REFLECTCOMMISSION' => 'No',
);
$options = array(
	'http' => array(
		'header' => "Content-type: application/x-www-form-urlencoded\r\n",
		'method' => 'POST',
		'content' => http_build_query($data)
	)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) {
	echo "An error occured!";
}
//echo http_build_query($data);
//var_dump(json_decode($result));
$resultObject = json_decode($result);
$sessionToken=$resultObject->{'sessionToken'};
if(empty($sessionToken)){
	echo "Error Code:" . $resultObject->{'errorCode'} . "<br>";
	echo "Error Message: " . $resultObject->{'errorMsg'} . "<br>";
	echo "Response Message: " . $resultObject->{'responseMsg'} . "<br>";
}
?>	
</body>
</html>