<?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");
    $post = $_POST;
    ## API Entegrasyon Bilgileri - Mağaza paneline giriş yaparak BİLGİ sayfasından alabilirsiniz.
	$merchant_id = tanim("pay+paytr","n1",0);
	$merchant_key = tanim("pay+paytr","n2",0);
	$merchant_salt = tanim("pay+paytr","n3",0);
    $merchant_oid   = $_POST["transid"];
    $return_amount  = $_POST["Total"];
    //$reference_no  = "XXXXXX11111";
    $paytr_token=base64_encode(hash_hmac('sha256',$merchant_id.$merchant_oid.$return_amount.$merchant_salt,$merchant_key,true));
    $post_vals=array('merchant_id'=>$merchant_id,
        'merchant_oid'=>$merchant_oid,
        'return_amount'=>$return_amount,
        'paytr_token'=>$paytr_token);
    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/iade");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1) ;
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vals);
    curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 90);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 90);
    $result = @curl_exec($ch);
    if(curl_errno($ch)){
        echo curl_error($ch);
        curl_close($ch);
        exit;
    }
    curl_close($ch);
    $result=json_decode($result,1);
    if($result['status']=='success'){
    }else{
        echo $result['err_no']." - ".$result['err_msg'];
    }
?>