<?php
header('Content-Type: text/html; charset=utf-8');
$user=tanim("pay+ozanpos","n1",0);
$pass=tanim("pay+ozanpos","n2",0);
$referenceNo = "00-".date("YmdHis")."-00";
$tutar = para($_POST["Total"])*100;
$number = str_replace(' ','',$_POST["Card_Number"]);
$bol = explode(' / ',$_POST["Card_Expiry"]); $ay=$bol[0]; $yil=$bol[1];
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.ozan.com/api/v3/purchase',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "apiKey": "'.$user.'",
    "providerKey": "'.$pass.'",
    "amount": "'.ceil($tutar).'",
    "currency": "'.$_POST["Currency"].'",
    "number": "'.$number.'",
    "expiryMonth": "'.$ay.'",
    "expiryYear": "'.$yil.'",
    "cvv": "'.$_POST["Card_Cvv"].'",
    "referenceNo": "'.$referenceNo.'",
    "description": "VPos",
    "is3d": true,
    "only3d": true,
    "isPreAuth": false,
    "installment": '.$_POST["Installment"].',
    "billingFirstName": "'.$_POST["Card_Name"].'",
    "billingLastName": "'.$_POST["Card_Surname"].'",
    "email": "user@eposta.com",
    "billingPhone": "Phone",
    "billingAddress1": "Adress",
    "billingCountry": "TR",
    "billingCity": "Türkiye",
    "billingPostcode": "34413",
    "basketItems": [
        {
            "name": "VPos",
            "description": "VPos",
            "category": "VPos",
            "extraField": "",
            "quantity": 1,
            "unitPrice": '.$tutar.'
        }
    ],
    "returnUrl": "'.$_POST["aurl"].'/deppo/tools/vpos/fintech/ozanpos/return.php?burl='.$_POST["burl"].'",
    "customerIp": "89.184.22.134",
    "customerUserAgent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36",
    "browserInfo": {
        "language": "en-US",
        "colorDepth": 24,
        "screenHeight": 900,
        "screenWidth": 1440,
        "screenTZ": "-180",
        "javaEnabled": false,
        "acceptHeader": "/"
    }
}',
  CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
));
$response = curl_exec($curl);
curl_close($curl);
$decoded = json_decode($response,true);
//Print_r($decoded);
$code = $decoded["code"];
$message = $decoded["message"];
$form3d = $decoded["form3d"];
//echo "".$message." {".$code."}";
//Print_r($decoded);
if($code=="283"){
	header('Location: '.$form3d);
}else{
	$burl=$_POST['burl'].'err/'.$code.'/'.v3e($message);
	header('Location: '.$burl);
}
?>