<?php
$bol = explode(' / ',$_POST["Card_Expiry"]); $ay=$bol[0]; $yil=$bol[1];
$sx=tanim("pay+paynkolay","n1",0); 
$merchantSecretKey=tanim("pay+paynkolay","n2",0);
$successUrl="".$_POST['aurl']."/deppo/tools/vpos/fintech/paynkolay/return.php?burl=".$_POST['burl']."";
$failUrl="".$_POST['aurl']."/deppo/tools/vpos/fintech/paynkolay/return.php?burl=".$_POST['burl']."";
$amount=$_POST["Total"].".00";
$clientRefCode=$_SESSION["Order_No"];
$use3D="true"; // İşlemi 3D secure olmaya zorlar
$rnd = date("d.m.Y H:i:s"); // işlem tarih ve saati
$transactionType="SALES";       // sales ya da presales olarak gönderilir, satış ya da provizyondur.
$hashstr = $sx . $clientRefCode . $amount . $successUrl . $failUrl . $rnd . $merchantSecretKey;
$hashData = base64_encode(pack('H*',sha1($hashstr)));
if($_POST["Currency"]=="TRY"){$currency="949";}else{$currency=$_POST["Currency"];}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://paynkolay.nkolayislem.com.tr/Vpos/v1/Payment',
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 => array(
	'sx' => $sx,
	'clientRefCode' => $clientRefCode,
	'successUrl' => $successUrl,
	'failUrl' => $failUrl,
	'amount' => $amount,
	'installmentNo' => $_POST['Installment'],
	'cardHolderName' => $_POST["Card_Name"],
	'month' => $ay,
	'year' => $yil,
	'cvv' => $_POST['Card_Cvv'],
	'cardNumber' => str_replace(' ','',$_POST["Card_Number"]),
	'use3D' => $use3D,
	'rnd' => $rnd,
	'environment' => 'API',
	'currencyNumber' => $currency,
	'transactionType' => $transactionType,
	'hashData' => $hashData,
	),
	CURLOPT_HTTPHEADER => array('Cookie: Cookie_1=value; TS01885cf1=0168200b6156e85acac0f3add19a161495eb2a28e53bca9a1823c1374549dc511da1a6a202f2fc9f9b98e38533ce2b66217f9310577406fdd2fb524c079cdc7cde3fc722f1; cookie=!eeNAvsYNb6nA+B8cMNUjtr0W3Mimt8Or/rTOsrXnySrtNK9wYOGn82u46h5UlfiJfZaQo+XZiu3azg=='),
));
$response = curl_exec($curl);
curl_close($curl);
$decoded_response = json_decode($response, true);
Print_r($decoded_response);
?>