This repository was archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayments.php
76 lines (72 loc) · 2.58 KB
/
payments.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
<?php
use \Sizzle\Bacon\Database\RecruitingToken;
use \Stripe\{
Charge,
Stripe
};
date_default_timezone_set('America/Chicago');
if (!logged_in()) {
login_then_redirect_back_here();
}
define('TITLE', 'S!zzle - Payments');
require __DIR__.'/header.php';
?>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/s/dt/jszip-2.5.0,pdfmake-0.1.18,dt-1.10.10,b-1.1.0,b-flash-1.1.0,b-html5-1.1.0,b-print-1.1.0/datatables.min.css"/>
<link rel="stylesheet" type="text/css" href="/css/datatables.min.css"/>
</head>
<body id="payments-listing">
<div>
<?php require __DIR__.'/navbar.php';?>
</div>
<div class="row" id="datatable-div">
<div class="col-sm-offset-2 col-sm-8">
<h2>Payments</h2>
<?php if (isset($_SESSION['stripe_id'])) { ?>
<table id="responsive-table" class="table table-striped table-hover">
<thead>
<th>Payment</th>
<th>Status</th>
<th>Method</th>
<th>Invoice</th>
<th>Date & Time</th>
</thead>
<tbody>
<?php
try {
Stripe::setApiKey(STRIPE_SECRET_KEY);
$success = 'true';
$data = Charge::all(array('customer'=>$_SESSION['stripe_id']));
$payments = json_decode(ltrim($data, 'Stripe\Collection JSON: '))->data;
foreach ($payments as $payment) {
echo '<tr>';
echo "<td>$".money_format('%i', $payment->amount/100)."</td>";
echo "<td>{$payment->status}</td>";
echo "<td>{$payment->source->brand} ending in {$payment->source->last4}</td>";
echo "<td><a href=\"/invoice?id={$payment->invoice}\" target=_blank>invoice details</a></td>";
echo "<td>".date('d/m/Y g:i a', $payment->created)."</td>";
echo '</tr>';
}
} catch (Exception $e) {
//ignore Stripe errors
}?>
</tbody>
</table>
<?php } else { ?>
No payments yet.
<?php }?>
</div>
</div>
<?php require __DIR__.'/footer.php';?>
<script type="text/javascript" src="https://cdn.datatables.net/s/dt/jszip-2.5.0,pdfmake-0.1.18,dt-1.10.10,b-1.1.0,b-flash-1.1.0,b-html5-1.1.0,b-print-1.1.0/datatables.min.js"></script>
<script>
$(document).ready(function() {
var table = $('#responsive-table').DataTable({
dom: 'B<"clear">lfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf','print'
]
});
});
</script>
</body>
</html>