|
|
<?php |
|
|
session_start(); |
|
|
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) { |
|
|
header('Location: login.php'); |
|
|
exit; |
|
|
} |
|
|
|
|
|
require_once '../../db.php'; |
|
|
require_once '../api/main_account.php'; |
|
|
|
|
|
$mainAccount = new MainAccount(); |
|
|
$pendingPayments = $mainAccount->getPendingPayments(); |
|
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
|
|
$payment_id = $_POST['payment_id']; |
|
|
$action = $_POST['action']; |
|
|
$notes = $_POST['notes'] ?? ''; |
|
|
|
|
|
if ($action === 'verify') { |
|
|
$result = $mainAccount->verifyPayment($payment_id, $_SESSION['admin_id'], $notes); |
|
|
} else { |
|
|
$result = $mainAccount->rejectPayment($payment_id, $_SESSION['admin_id'], $notes); |
|
|
} |
|
|
|
|
|
if ($result['success']) { |
|
|
$message = $action === 'verify' ? "Payment verified successfully!" : "Payment rejected!"; |
|
|
} else { |
|
|
$error = $result['error']; |
|
|
} |
|
|
} |
|
|
?> |
|
|
|
|
|
<!-- Admin Payment Verification Interface --> |
|
|
<div class="container mx-auto p-6"> |
|
|
<h1 class="text-2xl font-bold mb-6">Payment Verification</h1> |
|
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-6"> |
|
|
<?php foreach ($pendingPayments as $payment): ?> |
|
|
<div class="bg-white rounded-lg shadow p-6"> |
|
|
<div class="flex justify-between items-center mb-4"> |
|
|
<h3 class="font-bold">Payment #<?php echo $payment['id']; ?></h3> |
|
|
<span class="bg-yellow-100 text-yellow-800 px-2 py-1 rounded text-sm">Pending</span> |
|
|
</div> |
|
|
|
|
|
<div class="space-y-2"> |
|
|
<p><strong>User:</strong> <?php echo $payment['username']; ?></p> |
|
|
<p><strong>Amount:</strong> KES <?php echo number_format($payment['amount']); ?></p> |
|
|
<p><strong>Phone:</strong> <?php echo $payment['phone_number']; ?></p> |
|
|
<p><strong>M-Pesa Code:</strong> <?php echo $payment['mpesa_code']; ?></p> |
|
|
<p><strong>Submitted:</strong> <?php echo date('M j, Y H:i', strtotime($payment['created_at'])); ?></p> |
|
|
</div> |
|
|
|
|
|
<?php if ($payment['screenshot']): ?> |
|
|
<div class="mt-4"> |
|
|
<img src="../uploads/payments/<?php echo $payment['screenshot']; ?>" |
|
|
alt="Payment Proof" class="rounded border max-w-full"> |
|
|
</div> |
|
|
<?php endif; ?> |
|
|
|
|
|
<form method="POST" class="mt-4 space-y-2"> |
|
|
<input type="hidden" name="payment_id" value="<?php echo $payment['id']; ?>"> |
|
|
<textarea name="notes" placeholder="Verification notes..." class="w-full p-2 border rounded"></textarea> |
|
|
<div class="flex gap-2"> |
|
|
<button type="submit" name="action" value="verify" |
|
|
class="flex-1 bg-green-500 text-white p-2 rounded hover:bg-green-600"> |
|
|
Verify |
|
|
</button> |
|
|
<button type="submit" name="action" value="reject" |
|
|
class="flex-1 bg-red-500 text-white p-2 rounded hover:bg-red-600"> |
|
|
Reject |
|
|
</button> |
|
|
</div> |
|
|
</form> |
|
|
</div> |
|
|
<?php endforeach; ?> |
|
|
</div> |
|
|
</div> |