-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransactions.php
67 lines (59 loc) · 1.36 KB
/
transactions.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
$account_id = $_GET['account_id'];
include('common.php');
require_once('AuthDb.php');
$auth_token = AuthDb::getInstance()->getAuthToken();
$url = $ASTRA_URL . '/v2/keyspaces/' . $KEYSPACE . '/' . $TABLE . '/' . $account_id;
$request = curl_init($url);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'X-Cassandra-Token: ' . $auth_token
));
$response = curl_exec($request);
// echo $response;
$decoded = json_decode($response);
$transaction_count = $decoded->{'count'};
$transactions = $decoded->{'data'};
echo '
<html>
<head>
<style>
table, th, td {
text-align: center;
border: 1px solid black;
padding: 5px;
}
</style>
</head>
<body>
<h2>Transactions for account id: ' . $account_id . '</h2>
<p>Transaction count: ' . $transaction_count . '</p>
<table>
<tr>
<th>Transaction ID</th>
<th>Transaction status</th>
<th>Amount</th>
<th>Medium</th>
<th>Merchant ID</th>
<th>Category</th>
</tr>
';
foreach ($transactions as $transaction) {
echo '
<tr>
<td>' . $transaction->transaction_id . '</td>
<td>' . $transaction->tx_status . '</td>
<td>' . $transaction->amount . '</td>
<td>' . $transaction->medium . '</td>
<td>' . $transaction->merchant_id . '</td>
<td>' . $transaction->category . '</td>
</tr>
';
}
echo '
</table>
</body>
</html>
';
?>