-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_sale.php
More file actions
59 lines (51 loc) · 1.52 KB
/
create_sale.php
File metadata and controls
59 lines (51 loc) · 1.52 KB
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
<?php
// This example creates sale(without charging) with using 'sale' endpoint
$sale_items[]= array(
"name" => "TEST URUN",
"photo" => "",
"quantity" => 1,
"unit_price" => 10,
);
$sale_data = array(
"merchant_name" => "Example Store",
);
$data = array(
"order_id" => date("YmdHis"),
"secure_option" => false,
"return_url" => "http://www.example.com/?is=ok",
"cancel_url" => "http://www.example.com/?is=fail",
"installment" => 1,
"amount" => 10,
"currency" => "TRY",
"customer_first_name" => "John",
"customer_last_name" => "Doe",
"customer_email" => "john@doe.com",
"billing_country" => "TR",
"billing_state" => "TR",
"billing_city" => "ISTANBUL",
"billing_zipcode" => "34000",
"billing_address" => "Adresim",
"customer_ip_address" => "1.1.1.1",
"items" => $sale_items,
"sale_data" => $sale_data,
);
//echo "<pre>". json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://sandbox.paytrek.com/api/v2/sale/");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
array(
"Content-Type: application/json",
"Authorization: Basic " . base64_encode("TOKEN"),
)
);
$response = curl_exec($ch);
curl_close($ch);
echo "<pre>";
print_r($response);