<?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;
	}
    //İşlem Bilgileri
    /*
    Bu bilgiler bir önceki sayfadan alınmaktadır.Ancak bu bilgilerin
    session'dan alınması sistemin daha güvenli olmasını sağlıyacaktır.
    */
    $xid = $POST['XID'];
    $instnumber = $POST['instalment'];
    $amount = $POST['amount'];
    $currencycode = $POST['currency'];
    $custName = $POST['custName'];
    $trantype = $POST['tranType'];
    $vftCode = $POST['vftCode'];
  $openANewWindow = $POST['openANewWindow'];
  
  
    //Eğer ki kredi kartı bilgileri üye işyeri sayfasında alınacak ise
    if(array_key_exists("ccdata", $POST)) {
		$ccdataisexist = true;
        $ccno = $POST['ccno'];
        $expdate = $POST['expdate'];
        $cvc = $POST['cvv'];
    }
    else
        $ccdataisexist = false;
    $posnetOOS = new PosnetOOS;
    //$posnetOOS->SetDebugLevel(1);
    $posnetOOS->SetPosnetID(POSNETID);
    $posnetOOS->SetMid(MID);
    $posnetOOS->SetTid(TID);
    //XML Servisi için
    $posnetOOS->SetURL(XML_SERVICE_URL);
    $posnetOOS->SetUsername(USERNAME);
    $posnetOOS->SetPassword(PASSWORD);
    if($ccdataisexist)
    {
        //Eğer ki kredi kartı bilgileri üye işyeri sayfasında alınacak ise
        if(!$posnetOOS->CreateTranRequestDatas($custName,
                                        $amount,
                                        $currencycode,
                                        $instnumber,
                                        $xid,
                                        $trantype,
                                        $ccno,
                                        $expdate,
                                        $cvc
                                        ))
        {
            echo("PosnetData'lari olusturulamadi.<br>".
                        "Data1 = ".$posnetOOS->GetData1()."<br>".
                        "Data2 = ".$posnetOOS->GetData2()."<br>".
                        "XML Response Data = ".$posnetOOS->GetResponseXMLData()
                );
            echo("Error Code : ".$posnetOOS->GetResponseCode());
            echo("<br>");
            echo("Error Text : ".$posnetOOS->GetResponseText());
        }
    }
    else
    {
        //Kart Bilgilerinin OOS sisteminde girilmesi isteniyor ise
        if(!$posnetOOS->CreateTranRequestDatas($custName,
                                        $amount,
                                        $currencycode,
                                        $instnumber,
                                        $xid,
                                        $trantype
                                        ))
        {
            echo("<html>");
            echo("PosnetData'lari olusturulamadi.<br>".
                       "Data1 = ".$posnetOOS->GetData1()."<br>".
                       "Data2 = ".$posnetOOS->GetData2()."<br>".
                       "XML Response Data = ".$posnetOOS->GetResponseXMLData()
                );
            echo("Error Code : ".$posnetOOS->GetResponseCode());
            echo("<br>");
            echo("Error Text : ".$posnetOOS->GetResponseText());
            echo("</html>");
            return;
        }
    }
?>
<html>
<head>
<title>3-D Secure veya Ortak Ödeme Sayfası</title>
<meta charset="UTF-8" />
<META HTTP-EQUIV="expires" CONTENT="0">
<META HTTP-EQUIV="cache-control" CONTENT="no-cache">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<script language="JavaScript" src="https://www.posnet.ykb.com/3DSWebService/scriptler/posnet.js"></script>
<script language="JavaScript" type="text/JavaScript">
function submitFormEx(Form, OpenNewWindowFlag, WindowName) {
    	submitForm(Form, OpenNewWindowFlag, WindowName)
    	Form.submit();
}
</script>
</head>
<body onLoad="document.formName.submit();">
<!-- target="YKBWindow"-->
<form name="formName" method="post" action="<? echo OOS_TDS_SERVICE_URL; ?>" style="display:none;">
  <div align="center"> 
    <table width="44%" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF">
      <tr bordercolor="#0099FF"> 
        <td height="28" bordercolor="#CCCCCC"><font size="2" face="Geneva, Arial, Helvetica, sans-serif">Sipariş Numarası :</font></td>
        <td height="28" bordercolor="#CCCCCC"><font size="2" face="Geneva, Arial, Helvetica, sans-serif">&nbsp;<? echo $xid; ?></font></td>
      </tr>
      <tr bordercolor="#0099FF">
        <td height="28" bordercolor="#CCCCCC"><font size="2" face="Geneva, Arial, Helvetica, sans-serif">Toplam tutar (x100) :</font></td>
        <td height="28" bordercolor="#CCCCCC"><font size="2" face="Geneva, Arial, Helvetica, sans-serif">&nbsp;<? echo $amount; ?></font></td>
      </tr>
      <tr BORDERCOLOR="#0099ff">
        <td height="28" bordercolor="#CCCCCC"><font size="2" face="Geneva, Arial, Helvetica, sans-serif">Para Birimi  :</font></td>
        <td height="28" bordercolor="#CCCCCC"><font size="2" face="Geneva, Arial, Helvetica, sans-serif">&nbsp;<? echo $currencycode; ?></font></td>
      </tr>
      <tr bordercolor="#0099FF">
        <td width="46%" height="28" bordercolor="#CCCCCC"><font size="2" face="Geneva, Arial, Helvetica, sans-serif">Taksit sayısı :</font></td>
        <td width="54%" height="28" bordercolor="#CCCCCC"><font size="2" face="Geneva, Arial, Helvetica, sans-serif">&nbsp;<? echo $instnumber; ?></font></td>
      </tr>
    </table>
    <p> <font size="2">
      <input name="posnetData" type="hidden" id="posnetData" value="<? echo $posnetOOS->GetData1(); ?>">
      <input name="posnetData2" type="hidden" id="posnetData2" value="<? echo $posnetOOS->GetData2(); ?>">
      <input name="mid" type="hidden" id="mid" value="<? echo MID; ?>">
      <input name="posnetID" type="hidden" id="posnetID" value="<? echo POSNETID; ?>">
      <input name="digest" type="hidden" id="sign" value="<? echo $posnetOOS->GetSign(); ?>">
      <input name="vftCode" type="hidden" id="vftCode" value="<? echo $vftCode; ?>">
      <input name="merchantReturnURL" type="hidden" id="merchantReturnURL" value="<?php echo uri("full")?>/provizyon.php?burl=<?php echo $_GET["burl"]?>">
      <!-- <input name="koiCode" type="hidden" id="koiCode" value="2"> -->
      
      <!-- Static Parameters -->
      <input name="lang" type="hidden" id="lang" value="tr">
      <input name="url" type="hidden" id="url" value="">
      <input name="openANewWindow" type="hidden" id="openANewWindow" value="0">
      </font></p>
		<p><A HREF="javascript:formName.submit()" onClick="submitFormEx(formName, <? echo $openANewWindow; ?>, 'YKBWindow');this.disabled=true;"><FONT FACE="Geneva, Arial, Helvetica, sans-serif"><STRONG>Ödeme Yap</STRONG></FONT></A> 
      </p>
  </div>
</form>
</body>
</html>