<?php
$merchant_id = tanim("pay+paytr","n1",0);
$merchant_key = tanim("pay+paytr","n2",0);
$merchant_salt = tanim("pay+paytr","n3",0);
$bol = explode(' / ',$_POST["Card_Expiry"]); $ay=$bol[0]; $yil=$bol[1];
$installment = (empty($_POST["Installment"]) || $_POST["Installment"] == "1") ? 0 : (int)$_POST["Installment"];
$merchant_ok_url="https:".$_POST["burl"]."ok";
$merchant_fail_url="https:".$_POST["burl"]."err";
$user_basket = htmlentities(json_encode(array(array("Hizmet", "1", 1))));
srand(time(null));
$merchant_oid = str_replace("OID-","",$_SESSION["Order_No"]);
$test_mode=tanim("pay+paytr", "n6", 0) != "" ? tanim("pay+paytr", "n6", 0) : 0; // test mode 1
$non_3d="0";
$client_lang = "tr";
$non3d_test_failed="0";
if(isset($_SERVER["HTTP_CLIENT_IP"])){
	$ip = $_SERVER["HTTP_CLIENT_IP"];
} elseif( isset( $_SERVER["HTTP_X_FORWARDED_FOR"])){
	$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else {
	$ip = $_SERVER["REMOTE_ADDR"];
}
$user_ip = $ip;
$email = $_POST["email"];
$payment_amount = para($_POST["Total"]); 		//15.00
if($_POST["Currency"]=="TRY"){$currency="TL";}else{$currency=$_POST["Currency"];}
//$currency=$_POST["Currency"];
$payment_type = "card";
//$card_type = "bonus"; // Alabileceği değerler; advantage, axess, combo, bonus, cardfinans, maximum, paraf, world, saglamkart
$installment_count = $installment;
$post_url = "https://www.paytr.com/odeme";
$hash_str = $merchant_id . $user_ip . $merchant_oid . $email . $payment_amount . $payment_type . $installment_count. $currency. $test_mode. $non_3d;
$token = base64_encode(hash_hmac('sha256',$hash_str.$merchant_salt,$merchant_key,true));
?>
<form action="<?php echo $post_url;?>" method="post" id="paytr" style="display:none">
  Kart Sahibi Adı: <input type="text" name="cc_owner" value="<?php echo $_POST["Card_Name"];?>"><br>
  Kart Numarası: <input type="text" name="card_number" value="<?php echo str_replace(' ','',$_POST["Card_Number"])?>"><br>
  Kart Son Kullanma Ay: <input type="text" name="expiry_month" value="<?php echo $ay;?>" ><br>
  Kart Son Kullanma Yıl: <input type="text" name="expiry_year" value="<?php echo substr($yil,-2);?>"><br>
  Kart Güvenlik Kodu: <input type="text" name="cvv" value="<?php echo $_POST["Card_Cvv"];?>"><br>
  <input type="hidden" name="merchant_id" value="<?php echo $merchant_id;?>">
  <input type="hidden" name="user_ip" value="<?php echo $user_ip;?>">
  <input type="hidden" name="merchant_oid" value="<?php echo $merchant_oid;?>">
  <input type="hidden" name="email" value="<?php echo $email;?>">
  <input type="hidden" name="payment_type" value="<?php echo $payment_type;?>">
  <input type="hidden" name="payment_amount" value="<?php echo $payment_amount;?>">
  <input type="hidden" name="currency" value="<?php echo $currency;?>">
  <input type="hidden" name="test_mode" value="<?php echo $test_mode;?>">
  <input type="hidden" name="non_3d" value="<?php echo $non_3d;?>">
  <input type="hidden" name="merchant_ok_url" value="<?php echo $merchant_ok_url;?>">
  <input type="hidden" name="merchant_fail_url" value="<?php echo $merchant_fail_url;?>">
  <input type="hidden" name="user_name" value="<?php echo $_SESSION["User_Name"]?>">
  <input type="hidden" name="user_address" value="User Adress">
  <input type="hidden" name="user_phone" value="<?php echo $_POST["gsm"]?>">
  <input type="hidden" name="user_basket" value="<?php echo $user_basket; ?>">
  <input type="hidden" name="debug_on" value="1">
  <input type="hidden" name="client_lang" value="<?php echo $client_lang; ?>">
  <input type="hidden" name="paytr_token" value="<?php echo $token; ?>">
  <input type="hidden" name="non3d_test_failed" value="<?php echo $non3d_test_failed; ?>">
  <input type="hidden" name="no_installment" value="0">
  <input type="hidden" name="max_installment" value="0">
  <input type="hidden" name="lang" value="<?php echo $client_lang; ?>">
  <input type="hidden" name="installment_count" value="<?php echo $installment_count; ?>">
  <input type="hidden" name="card_type" value="<?php echo $card_type; ?>">
  <input type="submit" value="Submit">
</form>
<SCRIPT LANGUAGE="Javascript">
	document.getElementById('paytr').submit();
</SCRIPT>