| <?php |
| session_start(); |
| if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) { |
| header('Location: ../../index.php'); |
| exit; |
| } |
|
|
| if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
| require_once '../../db.php'; |
| require_once 'main_account.php'; |
| |
| $mpesa_code = $_POST['mpesa_code']; |
| $screenshot = $_FILES['screenshot']; |
| |
| |
| $target_dir = "../uploads/payments/"; |
| $filename = time() . '_' . basename($screenshot["name"]); |
| $target_file = $target_dir . $filename; |
| |
| if (move_uploaded_file($screenshot["tmp_name"], $target_file)) { |
| $mainAccount = new MainAccount(); |
| $result = $mainAccount->submitManualPayment( |
| $_SESSION['user_id'], |
| $_SESSION['payment_amount'], |
| $_SESSION['payment_phone'], |
| $mpesa_code, |
| $filename |
| ); |
| |
| if ($result['success']) { |
| $success = "Payment submitted for verification! We'll update your balance within 1 hour."; |
| unset($_SESSION['payment_amount'], $_SESSION['payment_phone']); |
| } else { |
| $error = $result['error']; |
| } |
| } else { |
| $error = "Failed to upload screenshot"; |
| } |
| } |
| ?> |
|
|
| <!-- Manual Payment HTML Form --> |
| <div class="card"> |
| <h2 class="text-xl font-bold mb-6">Manual Payment Verification</h2> |
| |
| <form method="POST" action="" enctype="multipart/form-data"> |
| <div class="form-group"> |
| <label>Amount</label> |
| <input type="text" value="KES <?php echo number_format($_SESSION['payment_amount']); ?>" disabled> |
| </div> |
| |
| <div class="form-group"> |
| <label>M-Pesa Transaction Code</label> |
| <input type="text" name="mpesa_code" placeholder="e.g., LGR1234567" required> |
| </div> |
| |
| <div class="form-group"> |
| <label>Payment Screenshot</label> |
| <input type="file" name="screenshot" accept="image/*" required> |
| <small class="text-gray-400">Upload screenshot of M-Pesa confirmation</small> |
| </div> |
| |
| <div class="bg-blue-900 bg-opacity-20 p-4 rounded-lg mb-4"> |
| <h4 class="font-bold mb-2">Payment Instructions:</h4> |
| <ol class="list-decimal list-inside text-sm space-y-1"> |
| <li>Send KES <?php echo number_format($_SESSION['payment_amount']); ?> to <strong>0756709823</strong></li> |
| <li>Take screenshot of M-Pesa confirmation</li> |
| <li>Enter transaction code above</li> |
| <li>Upload the screenshot</li> |
| <li>Submit for verification</li> |
| </ol> |
| </div> |
| |
| <button type="submit" class="btn bg-blue-500 hover:bg-blue-600">Submit for Verification</button> |
| </form> |
| </div> |