-
Notifications
You must be signed in to change notification settings - Fork 1
/
seller-payments.php
255 lines (214 loc) · 7.68 KB
/
seller-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
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
<?php
session_start();
?>
<!DOCTYPE HTML>
<html>
<head>
<title>FullCashback Seller Payments - Get Full Cashback!</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 15% auto; /* 15% from the top and centered */
padding: 20px;
border: 1px solid #888;
width: 80%; /* Could be more or less, depending on screen size */
}
/* The Close Button */
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
</style>
</head>
<body>
<?php
if (!isset($_COOKIE['seller-email'])) {
header('location:seller-login.php');
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<header class="p-3 mb-3 border-bottom">
<div class="container">
<div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start">
<a href="/" class="d-flex align-items-center mb-2 mb-lg-0 text-dark text-decoration-none">
<svg class="bi me-2" width="40" height="32" role="img" aria-label="Bootstrap"><use xlink:href="#bootstrap"></use></svg>
</a>
<ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">
<li><a href="index.php" class="nav-link px-2 link-secondary">Home</a></li>
<li><a href="home.php" class="nav-link px-2 link-dark">Products</a></li>
</ul>
<form method="GET" action="search.php" class="col-12 col-lg-auto mb-3 mb-lg-0 me-lg-3">
<input name="name" type="search" class="form-control" placeholder="Search..." aria-label="Search">
</form>
<?php
if (isset($_COOKIE['seller-email'])) {
?>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
<?php echo $_COOKIE['seller-email']; ?>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
<li><a class="dropdown-item" onclick="deleteCookie();">Log Out</a></li>
<li><a class="dropdown-item" href="seller-dashboard.php">Edit Account Details</a></li>
<li><a class="dropdown-item" href="home.php">Products</a></li>
<li><a class="dropdown-item" href="seller-applications.php">Product Applications</a></li>
</ul>
</div>
<!-- Make a modal where the user can edit their account details (PayPal username and Email Verifying button) when they click on Edit Details -->
<?php } ?>
</div>
</div>
</header>
<main>
<section class="py-5 text-center container">
<div class="row py-lg-5">
<div class="col-lg-6 col-md-8 mx-auto">
<h1 class="fw-light">My Payments</h1>
<br>
</div>
</div>
</section>
<div class="album py-5 bg-light">
<div class="container">
<table class="table table-hover table-striped">
<thead>
<tr>
<th scope="col">Buyer Email</th>
<th scope="col">Product Name</th>
<th scope="col">Payment</th>
<th scope="col">Purchase Verified</th>
<th scope="col">Payment Received</th>
</tr>
</thead>
<tbody>
<?php
$selleremail = $_COOKIE['seller-email'];
$productids = array();
$purchaseverified = array();
$paymentids = array();
$paymentreceived = array();
$buyeremails = array();
$buyerusername = array();
$servername = "localhost";
$username = "root";
$password = "PASSWORD";
$dbname = "fullcashback";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM payments WHERE selleremail='$selleremail'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
array_push($productids, $row['productid']);
$purchaseverified[$row['productid']] = $row['purchaseverified'];
$paymentids[$row['productid']] = $row['id'];
$paymentreceived[$row['productid']] = $row['paymentreceived'];
$buyeremails[$row['productid']] = $row['useremail'];
$buyerusername[$row['productid']] = $row['buyerpaypalusername'];
}
} else {
echo "No pending payments. Go to the product applications page to request cashback for a product.";
}
//$conn->close();
// Create connection
$conn_ = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn_->connect_error) {
die("Connection failed: " . $conn_->connect_error);
}
$arrayLength = count($productids);
$i = 0;
while ($i < $arrayLength) {
$sql_ = "SELECT * FROM products WHERE id='$productids[$i]'";
$result_ = $conn_->query($sql_);
if ($result_->num_rows > 0) {
while($row_ = $result_->fetch_assoc()) {
?>
<tr>
<td><?php echo substr($buyeremails[$row_['id']], 0, 5)."*****"; ?></td>
<td><?php echo $row_['name']; ?></td>
<td>£<?php echo $row_['price']; ?></td>
<?php if ($purchaseverified[$row_['id']] == "false") { ?>
<form method="POST" action="verify-purchase.php">
<input type="hidden" name="paymentid" value="<?php echo $paymentids[$row_['id']] ?>">
<td><button type="submit" class="btn btn-primary">Verify Purchase</button></td>
</form>
<?php } else {?>
<td>true</td>
<?php } ?>
<?php if ($paymentreceived[$row_['id']] == "false") { ?>
<td><a href="https://paypal.me/<?php echo $buyerusername[$row_['id']] ?>/<?php echo $row_['price'] ?>"><button type="submit" class="btn btn-primary">Pay Cashback</button></a></td>
<?php } else {?>
<td>true</td>
<?php } ?>
</tr>
<?php
}
}
$i++;
}
$conn->close();
$conn_->close();
?>
</tbody>
</table>
</div>
</div>
</main>
<script>
function deleteCookie() {
document.cookie = "email=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
document.cookie = "password=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
location.reload();
}
</script>
</body>
</html>