<?php
    /**
     * @package posnet oostest
     */
    //Include POSNETOOS Class
    require_once('posnet_oos_config.php');
	require_once('Posnet_Modules/Posnet_OOS/posnet_oos.php');
	
	$POST;
	if ((floatval(phpversion()) >= 5) && ((ini_get('register_long_arrays') == '0') || (ini_get('register_long_arrays') == ''))){
		$POST =& $_POST;
	} else {
		$POST =& $HTTP_POST_VARS;
	}
    
	$posnetOOS = new PosnetOOS();
    //$posnetOOS->SetDebugLevel(1);
    $merchantPacket = $POST['MerchantPacket'];
    $bankPacket = $POST['BankPacket'];
    $sign = $POST['Sign'];
    $posnetOOS->SetMid(MID);
    $posnetOOS->SetTid(TID);
    // bunu sonradan ekledim böyle bir fonksiyon normalde yok 
    $posnetOOS->createMacdata($_POST['Xid'],$_POST['Amount'],'TL');
    //XML Servisi için
    $posnetOOS->SetURL(XML_SERVICE_URL);
    $posnetOOS->SetUsername(USERNAME);
    $posnetOOS->SetPassword(PASSWORD);
    $posnetOOS->SetKey(ENCKEY);
	if (array_key_exists("WPAmount", $POST))
    $posnetOOS->SetPointAmount($POST['WPAmount']);
    
    if(!$posnetOOS->ConnectAndDoTDSTransaction($merchantPacket,
        $bankPacket,
        $sign
         ))
    {
        // echo("İşlem gerçekleştirilemedi.<br>");
        // echo("Hata : ".$posnetOOS->GetLastErrorMessage());
    }
if($posnetOOS->GetApprovedCode()==1){
	echo "<script>window.location.href=\"".$_GET["burl"]."ok\"</script>";
}else{
	echo "<script>window.location.href=\"".$_GET["burl"]."err//".$posnetOOS->GetResponseCode()."\"</script>";
}
?>