-
Notifications
You must be signed in to change notification settings - Fork 1
/
payNowProcess.php
54 lines (44 loc) · 1.41 KB
/
payNowProcess.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
<?php
session_start();
require "connection.php";
if (isset($_SESSION["u"])) {
$pid = $_GET["id"];
$umail = $_SESSION["u"]["email"];
$order_id = uniqid();
$product_rs = Database::search("SELECT * FROM `product` WHERE `id`='" . $pid . "'");
$product_data = $product_rs->fetch_assoc();
$item = $product_data["title"];
$amount = (int)$product_data["price"];
$fname = $_SESSION["u"]["fname"];
$lname = $_SESSION["u"]["lname"];
$mobile = $_SESSION["u"]["username"];
$merchant_id = "1227443"; // Replace with your actual merchant ID
$merchant_secret = "MzI5NTI0NTQzMzMzNjU2MDUwMDQxOTcxNzk0Njg1MzQ5MzIwMDE2NA=="; // Replace with your actual merchant secret
$currency = "LKR";
$hash = strtoupper(
md5(
$merchant_id .
$order_id .
number_format($amount, 2, '.', '') .
$currency .
strtoupper(md5($merchant_secret))
)
);
$array = [
"id" => $order_id,
"item" => $item,
"amount" => $amount,
"fname" => $fname,
"lname" => $lname,
"mobile" => $mobile,
"umail" => $umail,
"address" => "", // Empty as no physical delivery
"city" => "", // Empty as no physical delivery
"hash" => $hash,
"currency" => $currency
];
echo json_encode($array);
} else {
echo json_encode(["error" => "User not logged in"]);
}
?>