-
Notifications
You must be signed in to change notification settings - Fork 4
/
bookpass.php
121 lines (104 loc) · 4.24 KB
/
bookpass.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
require ('./db/conn.php');
require ('./config.php');
require ('razorpay-php/Razorpay.php');
session_start();
if(!isset($_SESSION['uidorPhone'])){
header('Location: index.php');
die("Sorry! You're not logged In.");
}
use Razorpay\Api\Api;
use Razorpay\Api\Errors\SignatureVerificationError;
$success = true;
$error = "Payment Failed";
if (empty($_POST['razorpay_payment_id']) === false){
$api = new Api($RazorpayKeyId, $RazorpayKeySecret);
try {
$attributes = array(
'razorpay_order_id' => $_SESSION['razorpay_order_id'],
'razorpay_payment_id' => $_POST['razorpay_payment_id'],
'razorpay_signature' => $_POST['razorpay_signature']
);
$api->utility->verifyPaymentSignature($attributes);
} catch(SignatureVerificationError $e) {
$success = false;
$error = 'Razorpay Error : ' . $e->getMessage();
}
}
if ($success === true){
if($_POST['source'] && $_POST['destination'] && $_POST['via'] && $_POST['class'] && $_POST['duration']){
$uid = $_SESSION['uidorPhone'];
$source = $_POST['source'];
$destination = $_POST['destination'];
$via = $_POST['via'];
$class = (int)$_POST['class'];
$duration = (int)$_POST['duration'];
$valid_from = date("Y-m-d H:i:s");
$valid_to = $duration == '1' ? date('Y-m-d', strtotime("+1 months", strtotime(strftime("%Y%m%d%H%M%S")))) : date('Y-m-d', strtotime("+3 months", strtotime(strftime("%Y%m%d%H%M%S"))));
$currentTime = strftime("%Y%m%d%H%M%S");
$uniqueTicketNo = 'RM'.$currentTime.$_SESSION['uidorPhone'];
$amount = $_SESSION['amount'];
$sql1 = "INSERT INTO passbooking (uid, source, destination, via, class, duration, valid_from, valid_to, fare, booking_time) VALUES ('$uid', '$source', '$destination', '$via', '$class', '$duration', '$valid_from', '$valid_to', '$amount', '$valid_from')";
$conn->query($sql1);
$sql = "INSERT INTO passgeneration (uid, ticket_no, source, destination, via, class, duration, valid_from, valid_to, fare, booking_time, barcode) VALUES ('$uid', '$uniqueTicketNo', '$source', '$destination', '$via', '$class', '$duration', '$valid_from', '$valid_to', '$amount', '$valid_from', '$uniqueTicketNo')";
if ($conn->query($sql) === TRUE) {
$queryResult = true;
} else {
$error = "Error: " . $sql . "<br>" . $conn->error;
$queryResult = true;
}
} else {
header('Location: index.php');
die("Sorry! Please enter all your details properly.");
}
} else{
$queryResult = false;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pass Confirmation</title>
<link rel="shortcut icon" href="assets/favicon.png">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="loader" id="loader">
<div class="spinner-border text-success" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div class="d-none" id="main">
<nav id="navbar" class="navbar navbar-expand-lg navbar-dark">
<div class="container">
<a class="navbar-brand" href="index.php">RailMumbai</a>
</div>
</nav>
<div class="container my-2">
<a href="./index.php" class="btn btn-primary mt-3 d-inline-flex align-items-center justify-content-center">
<svg width="24" height="24" fill-rule="evenodd" clip-rule="evenodd" fill="#fff"><path d="M2.117 12l7.527 6.235-.644.765-9-7.521 9-7.479.645.764-7.529 6.236h21.884v1h-21.883z"/></svg>
Back
</a>
<h1 class="text-center my-3">Pass</h1>
<div class="jumbotron text-light <?php echo $queryResult ? 'bg-success' : 'bg-danger' ?>">
<div class="text-center">
<img class="mx-auto" src="<?php echo $queryResult ? './assets/success.gif' : './assets/fail.gif' ?>" alt="">
<h2 class="mt-4">
<?php echo $queryResult ? 'Pass Booking Success' : 'Pass Booking Failed' ?>
</h2>
</div>
<div class="my-2 text-center">
<a href="pass.php?id=<?php echo $uniqueTicketNo ?>" class="btn btn-primary mt-4">Show Ticket</a>
</div>
</div>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/main.js"></script>
</body>
</html>