-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckoutform.php
156 lines (133 loc) · 6.34 KB
/
checkoutform.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
require_once('config.php');
if(isset($_POST['gönder']))
{
$installment=$_POST['installment'];
$cardHolderName=$_POST['cardHolderName'];
$cardNumber=$_POST['cardNumber'];
$expireMonth=$_POST['expireMonth'];
$expireYear=$_POST['expireYear'];
$cvc=$_POST['cvc'];
$registerCardEnabled=$_POST['registerCardEnabled'];
//Payment
$rprice=$_POST['request_price'];
$paidPrice=$_POST['paidPrice'];
$currency=$_POST['currency'];
$enabledInstallments=$_POST['enabledInstallments'];
$rbasketId=$_POST['request_basketId'];
$rpaymentGroup=$_POST['request_paymentGroup'];
$rlocale=$_POST['request_locale'];
//BasketItm1
$request_basketItems1_id=$_POST['request_basketItems1_id'];
$request_basketItems1_price=$_POST['request_basketItems1_price'];
$request_basketItems1_name=$_POST['request_basketItems1_name'];
$request_basketItems1_itemType=$_POST['request_basketItems1_itemType'];
$request_basketItems1_category1=$_POST['request_basketItems1_category1'];
$request_basketItems1_category2=$_POST['request_basketItems1_category2'];
//BasketItm2
$request_basketItems2_id=$_POST['request_basketItems2_id'];
$request_basketItems2_price=$_POST['request_basketItems2_price'];
$request_basketItems2_name=$_POST['request_basketItems2_name'];
$request_basketItems2_itemType=$_POST['request_basketItems2_itemType'];
$request_basketItems2_category1=$_POST['request_basketItems2_category1'];
$request_basketItems2_category2=$_POST['request_basketItems2_category2'];
//Buyer
$request_buyer_id=$_POST['request_buyer_id'];
$request_buyer_name=$_POST['request_buyer_name'];
$request_buyer_surname=$_POST['request_buyer_surname'];
$request_buyer_identityNumber=$_POST['request_buyer_identityNumber'];
$request_buyer_email=$_POST['request_buyer_email'];
$request_buyer_gsmNumber=$_POST['request_buyer_gsmNumber'];
$request_buyer_registrationDate=$_POST['request_buyer_registrationDate'];
$request_buyer_lastLoginDate=$_POST['request_buyer_lastLoginDate'];
$request_buyer_registrationAddress=$_POST['request_buyer_registrationAddress'];
$request_buyer_country=$_POST['request_buyer_country'];
$request_buyer_zipCode=$_POST['request_buyer_zipCode'];
$request_buyer_ip=$_POST['request_buyer_ip'];
$request_buyer_city=$_POST['request_buyer_city'];
//ShippingAdres
$request_shippingAddress_address=$_POST['request_shippingAddress_address'];
$request_shippingAddress_zipCode=$_POST['request_shippingAddress_zipCode'];
$request_shippingAddress_contactName=$_POST['request_shippingAddress_contactName'];
$request_shippingAddress_city=$_POST['request_shippingAddress_city'];
$request_shippingAddress_country=$_POST['request_shippingAddress_country'];
//BillingAdres
$request_billingAddress_address=$_POST['request_billingAddress_address'];
$request_billingAddress_zipCode=$_POST['request_billingAddress_zipCode'];
$request_billingAddress_contactName=$_POST['request_billingAddress_contactName'];
$request_billingAddress_city=$_POST['request_billingAddress_city'];
$request_billingAddress_country=$_POST['request_billingAddress_country'];
//hidden
$request_conversationId=$_POST['request_conversationId'];
$totalprice=$request_basketItems2_price+$request_basketItems1_price;
# create request class
# create request class
$request = new \Iyzipay\Request\CreateCheckoutFormInitializeRequest();
$request->setLocale(\Iyzipay\Model\Locale::TR);
$request->setConversationId($request_conversationId);
$request->setPrice($totalprice);
$request->setPaidPrice($totalprice);
$request->setCurrency(\Iyzipay\Model\Currency::TL);
$request->setBasketId($rbasketId);
$request->setPaymentGroup(\Iyzipay\Model\PaymentGroup::PRODUCT);
$request->setCallbackUrl("http://localhost:8888/iyzico/checksonuc.php");
$request->setEnabledInstallments(array($installment));
$buyer = new \Iyzipay\Model\Buyer();
$buyer->setId($request_buyer_id);
$buyer->setName($request_buyer_name);
$buyer->setSurname($request_buyer_surname);
$buyer->setGsmNumber($request_buyer_gsmNumber);
$buyer->setEmail($request_buyer_email);
$buyer->setIdentityNumber($request_buyer_identityNumber);
$buyer->setLastLoginDate($request_buyer_lastLoginDate);
$buyer->setRegistrationDate($request_buyer_registrationDate);
$buyer->setRegistrationAddress($request_buyer_registrationAddress);
$buyer->setIp($request_buyer_ip);
$buyer->setCity($request_buyer_city);
$buyer->setCountry($request_buyer_country);
$buyer->setZipCode($request_buyer_zipCode);
$request->setBuyer($buyer);
$shippingAddress = new \Iyzipay\Model\Address();
$shippingAddress->setContactName($request_shippingAddress_contactName);
$shippingAddress->setCity($request_shippingAddress_city);
$shippingAddress->setCountry($request_shippingAddress_country);
$shippingAddress->setAddress($request_shippingAddress_address);
$shippingAddress->setZipCode($request_shippingAddress_zipCode);
$request->setShippingAddress($shippingAddress);
$billingAddress = new \Iyzipay\Model\Address();
$billingAddress->setContactName($request_billingAddress_contactName);
$billingAddress->setCity($request_shippingAddress_city);
$billingAddress->setCountry($request_billingAddress_country);
$billingAddress->setAddress($request_shippingAddress_address);
$billingAddress->setZipCode($request_shippingAddress_zipCode);
$request->setBillingAddress($billingAddress);
$basketItems = array();
$firstBasketItem = new \Iyzipay\Model\BasketItem();
$firstBasketItem->setId($request_basketItems1_id);
$firstBasketItem->setName($request_basketItems1_name);
$firstBasketItem->setCategory1($request_basketItems1_category1);
$firstBasketItem->setCategory2($request_basketItems1_category2);
$firstBasketItem->setItemType(\Iyzipay\Model\BasketItemType::PHYSICAL);
$firstBasketItem->setPrice($request_basketItems1_price);
$basketItems[0] = $firstBasketItem;
$secondBasketItem = new \Iyzipay\Model\BasketItem();
$secondBasketItem->setId($request_basketItems2_id);
$secondBasketItem->setName($request_basketItems2_name);
$secondBasketItem->setCategory1($request_basketItems2_category1);
$secondBasketItem->setCategory2($request_basketItems2_category2);
$secondBasketItem->setItemType(\Iyzipay\Model\BasketItemType::VIRTUAL);
$secondBasketItem->setPrice($request_basketItems2_price);
$basketItems[1] = $secondBasketItem;
$request->setBasketItems($basketItems);
# make request
$checkoutFormInitialize = \Iyzipay\Model\CheckoutFormInitialize::create($request, Config::options());
# print result
echo "<pre>";
print_r($checkoutFormInitialize);
?>
<html>
<body>
<div id="iyzipay-checkout-form" class="responsive"></div>
</body>
</html>
<?php } ?>