-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcheckout.php
70 lines (55 loc) · 2.02 KB
/
checkout.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
<?php
ob_start();
include 'header.php';
include 'partials/_categories_nav.php';
// $userId = getUserId($user);
// echo $userId;
// if(!isset($_SESSION['login'])){
// // header('location:index.php');
// echo "<script>location.href='".$URL."/login.php';</script>";
// }
error_reporting(0);
// mysqli_report(5);
?>
<?php
$secretkey = ""; /* enter secret key here */
$orderId = $_POST["orderId"];
$orderAmount = $_POST["orderAmount"];
$referenceId = $_POST["referenceId"];
$txStatus = $_POST["txStatus"];
$paymentMode = $_POST["paymentMode"];
$txMsg = $_POST["txMsg"];
$txTime = $_POST["txTime"];
$signature = $_POST["signature"];
$data = $orderId.$orderAmount.$referenceId.$txStatus.$paymentMode.$txMsg.$txTime;
$hash_hmac = hash_hmac('sha256', $data, $secretkey, true) ;
$computedSignature = base64_encode($hash_hmac);
if ($signature == $computedSignature) {
if($txStatus == "SUCCESS") {
// $userId = getUserId($user);
// $product_ids = $Cart->getCartIds($Cart->getData($userId,'cart'));
// $Cart->placeOrder($userId, $product_ids);
placeOrders($Cart, $user);
} else {
header('refresh:3; url=cart.php');
?>
<!-- main sections starts -->
<main class="w-full mt-12 sm:mt-0">
<!-- row -->
<div class="flex flex-col items-center justify-center sm:w-4/6 sm:mt-4 m-auto mb-7 bg-white shadow rounded p-6 pb-12">
<img draggable="false" class="w-1/2 h-60 object-contain" src="assets/images/transaction-error.gif" alt="Transaction Error">
<h1 class="text-2xl font-semibold">Transaction Failed</h1>
<p class="mt-4 text-lg text-gray-800">Redirecting to cart in 0<span id="timer">3</span> sec</p>
</div>
<!-- row -->
</main>
<!-- main sections starts -->
<?php
}
} else {
// header('refresh:3; url=cart.php');
?>
<?php
}
include 'partials/_footer.php';
?>