File size: 2,800 Bytes
628740b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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'];
    
    // Upload 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>