-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpayment.php
285 lines (255 loc) · 14.1 KB
/
payment.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<?php
ob_start();
session_start();
if(isset($_SESSION['user_session_token']) && !empty($_SESSION['user_session_token']))
{
$login_user = $_SESSION['user_session_token'];
include("connect.php");
$userInfo = mysqli_query($con, "select username, email from users where id=".$login_user);
$userRow = mysqli_fetch_assoc($userInfo);
$tid = $_REQUEST['tid'];
$unitCharge = mysqli_query($con, "select routes.charge from routes INNER JOIN bookings ON routes.busnum = bookings.busnum where transactionid='$tid'");
$row = mysqli_fetch_assoc($unitCharge);
$totalSeats = mysqli_query($con, "select count(*) as total from bookings where transactionid='$tid' and status = 'booked'");
$trow = mysqli_fetch_assoc($totalSeats);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="payment.css">
<title>Payment Options</title>
</head>
<body>
<div class="container">
<br>
<div class="row">
<div class="col-xs-12 col-md-4">
<div class="panel panel-default credit-card-box">
<div class="panel-heading display-table" >
<div class="row display-tr" style="text-align:center;" >
<h3 class="panel-title display-td"> Payment Details</h3>
<div class="display-td" >
<img class="img-responsive pull-right" src="images/bus-png.png" height="150" width="150">
</div>
</div>
</div>
<div class="panel-body">
<!-- Display errors returned by createToken -->
<div class="payment-status" style="color: red;"></div>
<!-- Payment form -->
<form role="form" action="stripe_payment.php" method="POST" name="cardpayment" id="payment-form">
<input type="hidden" name="tid" value="<?php echo $_REQUEST['tid']; ?>" />
<input type="hidden" name="username" value="<?php echo $userRow['username']; ?>" />
<div class="row">
<div class="col-xs-12">
<div class="form-group">
<label for="couponCode">CARD HOLDER NAME</label>
<input type="text" class="form-control" name="holdername" placeholder="Enter Card Holder Name" autofocus required id="name" />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="form-group">
<label for="couponCode">EMAIL</label>
<input value="<?php echo $userRow['email']; ?>" type="email" class="form-control" name="email" placeholder="Email" id="email" required />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="form-group">
<label for="cardNumber">CARD NUMBER</label>
<div class="input-group">
<input type="text" class="form-control" name="card_number" placeholder="Valid Card Number" autocomplete="cc-number" id="card_number" maxlength="16" data-stripe="number" required />
<span class="input-group-addon"><i class="fa fa-credit-card"></i></span>
</div>
</div>
</div>
</div>
<div class="sidebyside">
<div class="block">
<div class="form-group">
<label for="cardExpiry"><span class="visible-xs-inline">MON</span></label>
<select name="card_exp_month" id="card_exp_month" class="form-control" data-stripe="exp_month" required>
<option>MON</option>
<option value="01">01 ( JAN )</option>
<option value="02">02 ( FEB )</option>
<option value="03">03 ( MAR )</option>
<option value="04">04 ( APR )</option>
<option value="05">05 ( MAY )</option>
<option value="06">06 ( JUN )</option>
<option value="07">07 ( JUL )</option>
<option value="08">08 ( AUG )</option>
<option value="09">09 ( SEP )</option>
<option value="10">10 ( OCT )</option>
<option value="11">11 ( NOV )</option>
<option value="12">12 ( DEC )</option>
</select>
</div>
</div>
<div class="block">
<div class="form-group">
<label for="cardExpiry"><span class="visible-xs-inline">YEAR</span></label>
<select name="card_exp_year" id="card_exp_year" class="form-control" data-stripe="exp_year">
<option>Year</option>
<option value="20">2020</option>
<option value="21">2021</option>
<option value="22">2022</option>
<option value="23">2023</option>
<option value="24">2024</option>
<option value="25">2025</option>
<option value="26">2026</option>
<option value="27">2027</option>
<option value="28">2028</option>
<option value="29">2029</option>
<option value="30">2030</option>
<option value="31">2031</option>
<option value="32">2032</option>
<option value="33">2033</option>
<option value="34">2034</option>
<option value="35">2035</option>
</select>
</div>
</div>
<div class="block">
<div class="form-group">
<label for="cardCVC">CV CODE</label>
<input type="password" class="form-control" name="card_cvc" placeholder="CVC" autocomplete="cc-csc" id="card_cvc" required />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<button class="subscribe btn btn-success btn-lg btn-block submit" type="submit" id="payBtn">PAY NOW ( Rs.<?php echo $row['charge'] * $trow['total'];?> )</button>
</div>
</div>
</form>
</div>
</div>
<!-- CREDIT CARD FORM ENDS HERE -->
</div>
<hr />
<!-- <div class="col-xs-12 col-md-4">
<h2>Test Card Number Details</h2>
<p>To test the payment process, you need test card details. Use any of the following test card numbers - </p>
<ul>
<li>A valid future expiration date.</li>
<li>Any random CVC number</li>
</ul>
<table class="" style="text-align:center;" cellspacing="0" cellpadding="10" width="100%" border='1'>
<tr>
<th>Card Number</th>
<th>Brand Name</th>
</tr>
<tr>
<td>4242424242424242</td>
<td>Visa</td>
</tr>
<tr>
<td>4000056655665556</td>
<td>Visa (debit)</td>
</tr>
<tr>
<td>5555555555554444</td>
<td>Mastercard</td>
</tr>
<tr>
<td>5200828282828210</td>
<td>Mastercard (debit)</td>
</tr>
<tr>
<td>378282246310005</td>
<td>American Express</td>
</tr>
<tr>
<td>6011111111111117</td>
<td>Discover</td>
</tr>
<tr>
<td>6200000000000005</td>
<td>UnionPay</td>
</tr>
</table>
</div>-->
</div>
</div>
<script src="https://js.stripe.com/v2/"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script>
// Set your publishable key
Stripe.setPublishableKey('pk_test_B6cJ6r3MAZkwZdSvfHLVUffG');
/*$(function() {
var $form = $('#payment-form');
$form.submit(function(event) {
// Disable the submit button to prevent repeated clicks:
$form.find('.submit').prop('disabled', true);
// Request a token from Stripe:
Stripe.card.createToken($form, stripeResponseHandler);
// Prevent the form from being submitted:
return false;
});
});
function stripeResponseHandler(status, response) {
// Grab the form:
var $form = $('#payment-form');
if (response.error) { // Problem!
// Show the errors on the form:
$form.find('.payment-status').text(response.error.message);
$form.find('.submit').prop('disabled', false); // Re-enable submission
} else { // Token was created!
// Get the token ID:
var token = response.id;
// Insert the token ID into the form so it gets submitted to the server:
$form.append($('<input type="hidden" name="stripeToken">').val(token));
// Submit the form:
$form.get(0).submit();
}
};*/
// Callback to handle the response from stripe
function stripeResponseHandler(status, response) {
if (response.error) {
// Enable the submit button
$('#payBtn').removeAttr("disabled");
// Display the errors on the form
$(".payment-status").html('<p>'+response.error.message+'</p>');
} else {
var form$ = $("#payment-form");
// Get token id
var token = response.id;
// Insert the token into the form
form$.append("<input type='hidden' name='stripeToken' value='" + token + "' />");
// Submit form to the server
form$.get(0).submit();
}
}
$(document).ready(function() {
// On form submit
$("#payment-form").submit(function() {
// Disable the submit button to prevent repeated clicks
$('#payBtn').attr("disabled", "disabled");
// Create single-use token to charge the user
Stripe.createToken({
number: $('#card_number').val(),
exp_month: $('#card_exp_month').val(),
exp_year: $('#card_exp_year').val(),
cvc: $('#card_cvc').val()
}, stripeResponseHandler);
// Submit from callback
return false;
});
});
</script>
</body>
</html>
<?php
mysqli_close($con);
}
else
{
header("location: login.php");
}
?>
<?php ob_end_flush(); ?>