-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuyNowProcess.php
87 lines (66 loc) · 2.33 KB
/
buyNowProcess.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
<?php
session_start();
include "connection.php";
if(isset($_SESSION["u"])){
$id = $_GET["id"];
$qty = $_GET["qty"];
$umail = $_SESSION["u"]["email"];
$array;
$order_id = uniqid();
$product_rs = Database::search("SELECT * FROM `product` WHERE `id`='".$id."'");
$product_data = $product_rs->fetch_assoc();
$city_rs = Database::search("SELECT * FROM `user_has_address` WHERE `user_email`='".$umail."'");
$city_num = $city_rs->num_rows;
if($city_num == 1){
$city_data = $city_rs->fetch_assoc();
$city_id = $city_data["city_city_id"];
$address = $city_data["line1"].", ".$city_data["line2"];
$district_rs = Database::search("SELECT * FROM `city` WHERE `city_id`='".$city_id."'");
$district_data = $district_rs->fetch_assoc();
$district_id = $district_data["district_district_id"];
$delivery = "0";
if($district_id == "2"){
$delivery = $product_data["delivery_fee_colombo"];
}else{
$delivery = $product_data["delivery_fee_other"];
}
$item = $product_data["title"];
$amount = ((int)$product_data["price"] * (int)$qty) + (int)$delivery;
$fname = $_SESSION["u"]["fname"];
$lname = $_SESSION["u"]["lname"];
$mobile = $_SESSION["u"]["mobile"];
$uaddress = $address;
$city = $district_data["city_name"];
$merchant_id = "1225162";
$merchant_secret = "MjQ4ODY5NjI5ODE4NjY2MTcyMDEyNDIzODMyNDIwNjg1ODc0MjI4";
$currency = "LKR";
$hash = strtoupper(
md5(
$merchant_id .
$order_id .
number_format($amount, 2, '.', '') .
$currency .
strtoupper(md5($merchant_secret))
)
);
$array["id"] = $order_id;
$array["item"] = $item;
$array["amount"] = $amount;
$array["fname"] = $fname;
$array["lname"] = $lname;
$array["mobile"] = $mobile;
$array["address"] = $uaddress;
$array["city"] = $city;
$array["umail"] = $umail;
$array["mid"] = $merchant_id;
$array["msecret"] = $merchant_secret;
$array["currency"] = $currency;
$array["hash"] = $hash;
echo json_encode($array);
}else{
echo ("2");
}
}else{
echo ("1");
}
?>