-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckoutProcess.php
More file actions
98 lines (64 loc) · 2.36 KB
/
checkoutProcess.php
File metadata and controls
98 lines (64 loc) · 2.36 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
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
<?php
session_start();
include "connection.php";
if(isset($_SESSION["u"])){
$mail = $_SESSION["u"]["email"];
$fname = $_SESSION["u"]["fname"];
$lname = $_SESSION["u"]["lname"];
$mobile = $_SESSION["u"]["mobile"];
$address_rs = Database::search("SELECT * FROM `users_has_address` INNER JOIN `city` ON `users_has_address`.`city_city_id` = `city`.`city_id` INNER JOIN
`district` ON `city`.`district_district_id` = `district`.`district_id` WHERE `users_email` = '".$mail."' ");
$address_data = $address_rs->fetch_assoc();
$address = $address_data["address_line_1"]." , ".$address_data["address_line_2"];
$city = $address_data["city_name"];
$order_id = uniqid();
$items = "";
$product_total = 0;
$delivery_total = 0;
$cart_rs = Database::search("SELECT * FROM `cart` INNER JOIN `product` ON `cart`.`cart_product_id` = `product`.`id`
WHERE `cart_users_email` = '".$mail."' ");
$cart_num = $cart_rs->num_rows;
for($x = 0; $x < $cart_num; $x++){
$cart_data = $cart_rs->fetch_assoc();
$unit_price = $cart_data["price"];
$cart_qty = $cart_data["cart_qty"];
$product_total += $unit_price * $cart_qty;
if($address_data["city_id"] == 1){
$delivery_total += $cart_data["delivery_fee_Kandy"];
}else{
$delivery_total += $cart_data["delivery_fee_other"];
}
$items .= $cart_data["title"].", ";
}
$amount = $product_total + $delivery_total;
$merchant_id = "1227161";
$merchant_secret = "MjUyNzUxNTU2MTk0NTA2Mjk2NzM5MjQyMzQyMTQxOTI2ODU2Njg=";
$currency = "LKR";
$hash = strtoupper(
md5(
$merchant_id .
$order_id .
number_format($amount, 2, '.', '') .
$currency .
strtoupper(md5($merchant_secret))
)
);
$array;
$array["email"] = $mail;
$array["fname"] = $fname;
$array["lname"] = $lname;
$array["mobile"] = $mobile;
$array["address"] = $address;
$array["city"] = $city;
$array["order_id"] = $order_id;
$array["items"] = $items;
$array["amount"] = $amount;
$array["merchant_id"] = $merchant_id;
$array["merchant_secret"] = $merchant_secret;
$array["currency"] = $currency;
$array["hash"] = $hash;
echo json_encode($array);
}else{
echo("You have to login first");
}
?>