<?php
//error_reporting(E_ALL);
$bol = explode(' / ',$_POST["Card_Expiry"]); $ay=$bol[0]; $yil=$bol[1];
$pkadi=tanim("pay+iyzipay","n1",0);
$psifr=tanim("pay+iyzipay","n2",0);
//$pkod=tanim("pay+iyzipay","n3",0);
require_once('IyzipayBootstrap.php');
require_once('samples/config.php');
if($_POST["Installment"]==0 or $_POST["Installment"]==""){
	$taksit="1";
}else{
	$taksit=$_POST["Installment"];
}
$_SESSION["burl"]=$_POST["burl"];
$request = new \Iyzipay\Request\CreatePaymentRequest();
$request->setLocale(\Iyzipay\Model\Locale::TR);
$request->setConversationId($_SESSION["Order_No"]);
$request->setPrice(para($_POST["Total"]));
$request->setPaidPrice(para($_POST["Total"]));
$request->setCurrency(\Iyzipay\Model\Currency::TL);
$request->setInstallment($taksit);
$request->setBasketId($_SESSION["Order_No"]);
$request->setPaymentChannel(\Iyzipay\Model\PaymentChannel::WEB);
$request->setPaymentGroup(\Iyzipay\Model\PaymentGroup::PRODUCT);
$request->setCallbackUrl("".$weburl."/deppo/tools/vpos/fintech/iyzipay/samples/create_threeds_payment.php?burl=".$_POST["burl"]."");
$paymentCard = new \Iyzipay\Model\PaymentCard();
$paymentCard->setCardHolderName("".$_POST["Card_Name"]." ".$_POST["Card_Surname"]."");
$paymentCard->setCardNumber(str_replace(' ','',$_POST["Card_Number"]));
$paymentCard->setExpireMonth($ay);
$paymentCard->setExpireYear($yil);
$paymentCard->setCvc($_POST["Card_Cvv"]);
$paymentCard->setRegisterCard(0);
$request->setPaymentCard($paymentCard);
$buyer = new \Iyzipay\Model\Buyer();
$buyer->setId("CID-".rand(1000,9999)."");
$buyer->setName($_POST["Card_Name"]);
$buyer->setSurname($_POST["Card_Surname"]);
$buyer->setGsmNumber($_POST["gsm"]);
$buyer->setEmail($_POST["email"]);
$buyer->setIdentityNumber("74300864791");
$buyer->setLastLoginDate("2015-10-05 12:43:35");
$buyer->setRegistrationDate("2013-04-21 15:12:09");
$buyer->setRegistrationAddress($_POST["uye_adres"]);
$buyer->setIp("85.34.78.112");
$buyer->setCity("Istanbul");
$buyer->setCountry("Turkey");
$buyer->setZipCode("34732");
$request->setBuyer($buyer);
$shippingAddress = new \Iyzipay\Model\Address();
$shippingAddress->setContactName($_POST["Card_Name"]);
$shippingAddress->setCity($_POST["uye_sehir"]);
$shippingAddress->setCountry("Turkey");
$shippingAddress->setAddress($_POST["uye_adres"]);
$shippingAddress->setZipCode("34742");
$request->setShippingAddress($shippingAddress);
$billingAddress = new \Iyzipay\Model\Address();
$billingAddress->setContactName($_POST["Card_Name"]);
$billingAddress->setCity($_POST["uye_sehir"]);
$billingAddress->setCountry("Turkey");
$billingAddress->setAddress($_POST["uye_adres"]);
$billingAddress->setZipCode("34742");
$request->setBillingAddress($billingAddress);
$basketItems = array();
$firstBasketItem = new \Iyzipay\Model\BasketItem();
$firstBasketItem->setId("0001");
$firstBasketItem->setName("urun-1");
$firstBasketItem->setCategory1("cat");
$firstBasketItem->setCategory2("cat2");
$firstBasketItem->setItemType(\Iyzipay\Model\BasketItemType::PHYSICAL);
$firstBasketItem->setPrice(para($_POST["Total"]));
$basketItems[0] = $firstBasketItem;
$request->setBasketItems($basketItems);
$threedsInitialize = \Iyzipay\Model\ThreedsInitialize::create($request, Config::options());
//print_r($threedsInitialize);
?>