|
|
<?php |
|
|
ini_set('display_errors', 1); |
|
|
ini_set('display_startup_errors', 1); |
|
|
error_reporting(E_ALL); |
|
|
|
|
|
session_start(); |
|
|
if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) { |
|
|
header('Location: ../../index.php'); |
|
|
exit; |
|
|
} |
|
|
|
|
|
|
|
|
$username = $_SESSION['username']; |
|
|
$email = $_SESSION['email']; |
|
|
$tier = $_SESSION['tier']; |
|
|
$package = $_SESSION['package']; |
|
|
$balance = $_SESSION['balance']; |
|
|
$total_deposits = $_SESSION['total_deposits']; |
|
|
$total_withdrawals = $_SESSION['total_withdrawals']; |
|
|
$rewards = $_SESSION['rewards']; |
|
|
$user_id = $_SESSION['user_id']; |
|
|
$currency = $_SESSION['currency'] ?? 'KES'; |
|
|
|
|
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
|
|
require_once '../api/mpesa_service.php'; |
|
|
require_once '../api/main_account.php'; |
|
|
|
|
|
$amount = $_POST['amount']; |
|
|
$payment_method = $_POST['payment_method']; |
|
|
$phone_number = $_POST['phone_number']; |
|
|
|
|
|
|
|
|
if (empty($amount) || empty($phone_number)) { |
|
|
$error = "Please fill all required fields"; |
|
|
} elseif ($amount < 500) { |
|
|
$error = "Minimum recharge amount is 500 " . $currency; |
|
|
} else { |
|
|
if ($payment_method === 'M-Pesa') { |
|
|
|
|
|
$mpesaService = new MpesaService(); |
|
|
$result = $mpesaService->initiateSTKPush($phone_number, $amount, $user_id); |
|
|
|
|
|
if (isset($result['success'])) { |
|
|
$success = "M-Pesa prompt sent to your phone! Please enter your PIN to complete payment."; |
|
|
|
|
|
|
|
|
$mainAccount = new MainAccount(); |
|
|
$mainAccount->recordPendingTransaction($user_id, $amount, $phone_number, $result['CheckoutRequestID']); |
|
|
|
|
|
|
|
|
$success .= " Check your phone for the M-Pesa prompt. Transaction ID: " . $result['CheckoutRequestID']; |
|
|
|
|
|
} else { |
|
|
$error = "Payment initiation failed: " . ($result['message'] ?? 'Please try again later.'); |
|
|
|
|
|
|
|
|
error_log("M-Pesa Error: " . print_r($result, true)); |
|
|
} |
|
|
} elseif ($payment_method === 'Manual') { |
|
|
|
|
|
$_SESSION['payment_amount'] = $amount; |
|
|
$_SESSION['payment_phone'] = $phone_number; |
|
|
header('Location: ../api/manual_payment.php'); |
|
|
exit; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
require_once '../../db.php'; |
|
|
$db = new Database(); |
|
|
$conn = $db->getConnection(); |
|
|
$currency_rates = []; |
|
|
try { |
|
|
$stmt = $conn->prepare("SELECT target_currency, exchange_rate FROM currency_rates"); |
|
|
$stmt->execute(); |
|
|
$currency_rates = $stmt->fetchAll(PDO::FETCH_KEY_PAIR); |
|
|
} catch (PDOException $e) { |
|
|
error_log("Currency rates error: " . $e->getMessage()); |
|
|
} |
|
|
?> |
|
|
<!DOCTYPE html> |
|
|
<html lang="en"> |
|
|
<head> |
|
|
<meta charset="UTF-8"> |
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
|
<title>Recharge | Japanese Motors</title> |
|
|
<script src="https://cdn.tailwindcss.com"></script> |
|
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700;800&display=swap" rel="stylesheet"> |
|
|
<script src="https://unpkg.com/feather-icons"></script> |
|
|
<style> |
|
|
:root { |
|
|
--bg: |
|
|
--card: |
|
|
--card-2: |
|
|
--accent: |
|
|
--muted: rgba(255,255,255,0.6); |
|
|
font-family: 'Poppins', system-ui, Arial; |
|
|
} |
|
|
|
|
|
body { |
|
|
background: var(--bg); |
|
|
font-family: 'Poppins', sans-serif; |
|
|
transition: all 0.3s ease; |
|
|
min-height: 100vh; |
|
|
} |
|
|
|
|
|
.sidebar { |
|
|
width: 250px; |
|
|
height: 100vh; |
|
|
background: |
|
|
color: |
|
|
position: fixed; |
|
|
top: 0; |
|
|
left: -250px; |
|
|
transition: all 0.3s ease; |
|
|
z-index: 1000; |
|
|
overflow-y: auto; |
|
|
} |
|
|
|
|
|
.sidebar.active { |
|
|
left: 0; |
|
|
} |
|
|
|
|
|
|
|
|
margin-left: 0; |
|
|
transition: all 0.3s ease; |
|
|
width: 100%; |
|
|
} |
|
|
|
|
|
.sidebar.active ~ |
|
|
margin-left: 250px; |
|
|
width: calc(100% - 250px); |
|
|
} |
|
|
|
|
|
header { |
|
|
background: |
|
|
color: white; |
|
|
padding: 15px 20px; |
|
|
display: flex; |
|
|
justify-content: space-between; |
|
|
align-items: center; |
|
|
position: relative; |
|
|
z-index: 900; |
|
|
transition: all 0.3s ease; |
|
|
} |
|
|
|
|
|
.menu-toggle { |
|
|
background: transparent; |
|
|
border: none; |
|
|
color: white; |
|
|
font-size: 1.5rem; |
|
|
cursor: pointer; |
|
|
} |
|
|
|
|
|
.logo-section { |
|
|
padding: 15px; |
|
|
border-bottom: 1px solid |
|
|
display: flex; |
|
|
align-items: center; |
|
|
gap: 10px; |
|
|
} |
|
|
|
|
|
.brand { |
|
|
font-size: 1.2rem; |
|
|
font-weight: 700; |
|
|
color: |
|
|
} |
|
|
|
|
|
.subtitle { |
|
|
font-size: 0.75rem; |
|
|
color: |
|
|
} |
|
|
|
|
|
.menu { |
|
|
list-style: none; |
|
|
padding: 0; |
|
|
margin: 0; |
|
|
} |
|
|
|
|
|
.menu li a { |
|
|
display: flex; |
|
|
align-items: center; |
|
|
padding: 12px 20px; |
|
|
color: white; |
|
|
text-decoration: none; |
|
|
transition: background 0.3s; |
|
|
} |
|
|
|
|
|
.menu li a:hover { |
|
|
background: |
|
|
} |
|
|
|
|
|
.menu li a i { |
|
|
margin-right: 12px; |
|
|
} |
|
|
|
|
|
.user-footer { |
|
|
padding: 15px; |
|
|
background: |
|
|
display: flex; |
|
|
align-items: center; |
|
|
gap: 10px; |
|
|
position: sticky; |
|
|
bottom: 0; |
|
|
} |
|
|
|
|
|
.avatar { |
|
|
width: 35px; |
|
|
height: 35px; |
|
|
background: |
|
|
border-radius: 50%; |
|
|
display: flex; |
|
|
align-items: center; |
|
|
justify-content: center; |
|
|
font-weight: bold; |
|
|
color: white; |
|
|
} |
|
|
|
|
|
.card { |
|
|
background: var(--card); |
|
|
border-radius: 12px; |
|
|
padding: 26px; |
|
|
color: white; |
|
|
box-shadow: 0 6px 0 rgba(0,0,0,0.08) inset; |
|
|
} |
|
|
|
|
|
.btn { |
|
|
padding: 14px 24px; |
|
|
border-radius: 10px; |
|
|
background: var(--accent); |
|
|
color: |
|
|
font-weight: 700; |
|
|
border: none; |
|
|
cursor: pointer; |
|
|
width: 100%; |
|
|
transition: all 0.3s ease; |
|
|
} |
|
|
|
|
|
.btn:hover { |
|
|
background: |
|
|
} |
|
|
|
|
|
.form-group { |
|
|
margin: 12px 0; |
|
|
} |
|
|
|
|
|
label { |
|
|
display: block; |
|
|
margin-bottom: 8px; |
|
|
color: rgba(255,255,255,0.85); |
|
|
} |
|
|
|
|
|
input, select { |
|
|
width: 100%; |
|
|
padding: 14px; |
|
|
border-radius: 10px; |
|
|
border: 1px solid rgba(255,255,255,0.1); |
|
|
background: rgba(255,255,255,0.1); |
|
|
color: white; |
|
|
box-sizing: border-box; |
|
|
} |
|
|
|
|
|
input:focus, select:focus { |
|
|
outline: none; |
|
|
border-color: var(--accent); |
|
|
} |
|
|
|
|
|
.payment-option { |
|
|
border: 2px solid transparent; |
|
|
border-radius: 10px; |
|
|
transition: all 0.3s ease; |
|
|
cursor: pointer; |
|
|
padding: 16px; |
|
|
} |
|
|
|
|
|
.payment-option.selected { |
|
|
border-color: var(--accent); |
|
|
background: rgba(239, 223, 45, 0.1); |
|
|
} |
|
|
|
|
|
.recharge-package { |
|
|
transition: all 0.3s ease; |
|
|
cursor: pointer; |
|
|
} |
|
|
|
|
|
.recharge-package:hover { |
|
|
transform: translateY(-2px); |
|
|
} |
|
|
|
|
|
@media (max-width: 768px) { |
|
|
.sidebar.active ~ |
|
|
margin-left: 0; |
|
|
width: 100%; |
|
|
} |
|
|
|
|
|
.sidebar.active { |
|
|
width: 100%; |
|
|
z-index: 1001; |
|
|
} |
|
|
|
|
|
|
|
|
display: block; |
|
|
position: absolute; |
|
|
right: 20px; |
|
|
top: 20px; |
|
|
} |
|
|
} |
|
|
</style> |
|
|
</head> |
|
|
<body> |
|
|
<!-- Sidebar --> |
|
|
<aside class="sidebar" id="sidebar"> |
|
|
<button id="menu-toggle-close" class="menu-toggle" style="display: none;"> |
|
|
<i data-feather="x"></i> |
|
|
</button> |
|
|
<div class="logo-section"> |
|
|
<i data-feather="zap" class="text-yellow-400"></i> |
|
|
<div> |
|
|
<h2 class="brand">JMOTORS</h2> |
|
|
<p class="subtitle">Marketing Platform</p> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<ul class="menu"> |
|
|
<li><a href="index.php"><i data-feather="home"></i> Dashboard</a></li> |
|
|
<li><a href="meta-uploads.php"><i data-feather="upload"></i> Meta Uploads</a></li> |
|
|
<li><a href="transactions.php"><i data-feather="repeat"></i> Transactions</a></li> |
|
|
<li><a href="transfer.php"><i data-feather="send"></i> Transfer</a></li> |
|
|
<li><a href="daily-product.php"><i data-feather="shopping-bag"></i> Daily Product</a></li> |
|
|
<li><a href="withdraw.php"><i data-feather="dollar-sign"></i> Withdraw</a></li> |
|
|
<li><a href="packages.php"><i data-feather="package"></i> Packages</a></li> |
|
|
<li><a href="loan.php"><i data-feather="credit-card"></i> Loan</a></li> |
|
|
<li><a href="recharge.php"><i data-feather="battery-charging"></i> Recharge</a></li> |
|
|
<li><a href="agent-approval.php"><i data-feather="user-check"></i> Agent Approval</a></li> |
|
|
<li><a href="access-token.php"><i data-feather="key"></i> Access Token</a></li> |
|
|
<li><a href="agent-claim.php"><i data-feather="tag"></i> Agent Claim</a></li> |
|
|
<li><a href="team.php"><i data-feather="users"></i> Team</a></li> |
|
|
</ul> |
|
|
|
|
|
<ul class="menu bottom"> |
|
|
<li><a href="profile.php"><i data-feather="user"></i> Profile</a></li> |
|
|
<li><a href="settings.php"><i data-feather="settings"></i> Settings</a></li> |
|
|
<li><a href="whatsapp-channel.php"><i data-feather="message-square"></i> Whatsapp Channel</a></li> |
|
|
<li><a href="customer-care.php"><i data-feather="headphones"></i> Customer Care</a></li> |
|
|
</ul> |
|
|
|
|
|
<div class="user-footer"> |
|
|
<div class="avatar"><?php echo substr($username, 0, 2); ?></div> |
|
|
<div> |
|
|
<h4><?php echo $username; ?></h4> |
|
|
<p><?php echo $tier; ?> - Marketer</p> |
|
|
</div> |
|
|
</div> |
|
|
</aside> |
|
|
|
|
|
<!-- Main Content --> |
|
|
<div id="content"> |
|
|
<header class="bg-gray-800 text-white p-4"> |
|
|
<div class="flex items-center"> |
|
|
<button class="menu-toggle" id="menu-toggle"> |
|
|
<i data-feather="menu"></i> |
|
|
</button> |
|
|
<div class="ml-4 font-bold text-xl">Jmotors</div> |
|
|
</div> |
|
|
<nav class="flex items-center space-x-6"> |
|
|
<a href="transfer.php" class="hover:text-yellow-300">Transfer</a> |
|
|
<a href="loan.php" class="hover:text-yellow-300">Loans</a> |
|
|
<a href="dailyproduct.php" class="hover:text-yellow-300">New Product</a> |
|
|
<div class="w-9 h-9 rounded-full bg-gradient-to-r from-yellow-300 to-orange-400 flex items-center justify-center font-bold"><?php echo substr($username, 0, 2); ?></div> |
|
|
</nav> |
|
|
</header> |
|
|
|
|
|
<main class="p-4"> |
|
|
<div class="max-w-2xl mx-auto"> |
|
|
<?php if (isset($error)): ?> |
|
|
<div class="bg-red-500 text-white p-4 rounded-lg mb-4 flex items-center"> |
|
|
<i data-feather="alert-circle" class="mr-2"></i> |
|
|
<?php echo $error; ?> |
|
|
</div> |
|
|
<?php endif; ?> |
|
|
|
|
|
<?php if (isset($success)): ?> |
|
|
<div class="bg-green-500 text-white p-4 rounded-lg mb-4"> |
|
|
<div class="flex items-center"> |
|
|
<i data-feather="check-circle" class="mr-2"></i> |
|
|
<?php echo $success; ?> |
|
|
</div> |
|
|
<div class="mt-2 text-sm"> |
|
|
<p>Check your phone for M-Pesa prompt. Enter your PIN to complete payment.</p> |
|
|
</div> |
|
|
</div> |
|
|
<?php endif; ?> |
|
|
|
|
|
<!-- Quick Deposit Section --> |
|
|
<div class="card mb-6"> |
|
|
<h2 class="text-xl font-bold mb-6 flex items-center gap-2"> |
|
|
<i data-feather="zap" class="text-yellow-400"></i> Quick Deposit |
|
|
</h2> |
|
|
|
|
|
<form method="POST" action="" id="depositForm"> |
|
|
<div class="form-group"> |
|
|
<label>Amount (<?php echo $currency; ?>)</label> |
|
|
<input type="number" name="amount" placeholder="Enter amount" required min="500" |
|
|
class="bg-gray-800 border border-gray-700"> |
|
|
<div class="text-xs text-gray-400 mt-1"> |
|
|
Minimum amount: 500 <?php echo $currency; ?> |
|
|
<?php |
|
|
if ($currency !== 'KES') { |
|
|
$kes_amount = $currency_rates[$currency] ? 500 / $currency_rates[$currency] : 500; |
|
|
echo ' (' . number_format($kes_amount, 2) . ' KES)'; |
|
|
} |
|
|
?> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div class="form-group"> |
|
|
<label>Payment Method</label> |
|
|
<div class="grid grid-cols-2 gap-4"> |
|
|
<div class="payment-option p-4 rounded-lg text-center cursor-pointer" data-method="M-Pesa"> |
|
|
<i data-feather="smartphone" class="text-2xl mb-2 text-green-400"></i> |
|
|
<p>M-Pesa STK Push</p> |
|
|
<small class="text-gray-400">Instant • Automatic</small> |
|
|
</div> |
|
|
<div class="payment-option p-4 rounded-lg text-center cursor-pointer" data-method="Manual"> |
|
|
<i data-feather="user-check" class="text-2xl mb-2 text-blue-400"></i> |
|
|
<p>Manual Verification</p> |
|
|
<small class="text-gray-400">Admin • Secure</small> |
|
|
</div> |
|
|
</div> |
|
|
<input type="hidden" name="payment_method" id="paymentMethod" value="M-Pesa" required> |
|
|
</div> |
|
|
|
|
|
<div class="form-group"> |
|
|
<label>Your M-Pesa Phone Number</label> |
|
|
<input type="tel" name="phone_number" placeholder="2547XXXXXXXX" required |
|
|
pattern="254[0-9]{9}" class="bg-gray-800 border border-gray-700"> |
|
|
</div> |
|
|
|
|
|
<button type="submit" class="btn mt-6 bg-yellow-500 hover:bg-yellow-600 transition"> |
|
|
<i data-feather="credit-card" class="mr-2"></i> |
|
|
<span id="submitText">Initiate M-Pesa Payment</span> |
|
|
</button> |
|
|
</form> |
|
|
</div> |
|
|
|
|
|
<!-- Payment Methods Info --> |
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> |
|
|
<!-- M-Pesa STK Push Method --> |
|
|
<div class="card"> |
|
|
<h3 class="text-lg font-bold mb-4 flex items-center gap-2"> |
|
|
<i data-feather="smartphone" class="text-green-400"></i> M-Pesa STK Push |
|
|
</h3> |
|
|
<ul class="space-y-2 text-sm"> |
|
|
<li class="flex items-center gap-2"> |
|
|
<i data-feather="check" class="text-green-400 w-4 h-4"></i> |
|
|
Instant payment processing |
|
|
</li> |
|
|
<li class="flex items-center gap-2"> |
|
|
<i data-feather="check" class="text-green-400 w-4 h-4"></i> |
|
|
Automatic balance update |
|
|
</li> |
|
|
<li class="flex items-center gap-2"> |
|
|
<i data-feather="check" class="text-green-400 w-4 h-4"></i> |
|
|
Receipt sent to your phone |
|
|
</li> |
|
|
</ul> |
|
|
</div> |
|
|
|
|
|
<!-- Manual Verification Method --> |
|
|
<div class="card"> |
|
|
<h3 class="text-lg font-bold mb-4 flex items-center gap-2"> |
|
|
<i data-feather="user-check" class="text-blue-400"></i> Manual Verification |
|
|
</h3> |
|
|
<ul class="space-y-2 text-sm"> |
|
|
<li class="flex items-center gap-2"> |
|
|
<i data-feather="check" class="text-blue-400 w-4 h-4"></i> |
|
|
Upload payment screenshot |
|
|
</li> |
|
|
<li class="flex items-center gap-2"> |
|
|
<i data-feather="check" class="text-blue-400 w-4 h-4"></i> |
|
|
Admin verification required |
|
|
</li> |
|
|
<li class="flex items-center gap-2"> |
|
|
<i data-feather="check" class="text-blue-400 w-4 h-4"></i> |
|
|
24/7 support available |
|
|
</li> |
|
|
</ul> |
|
|
<div class="mt-4 p-3 bg-blue-900 bg-opacity-20 rounded-lg"> |
|
|
<p class="text-sm"><strong>Send to:</strong> Paybill 542542</p> |
|
|
<p class="text-sm"><strong>Account:</strong> 00106664176150</p> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<!-- Package Bonuses --> |
|
|
<div class="card mt-6"> |
|
|
<h3 class="text-lg font-bold mb-4">Bonus Packages</h3> |
|
|
<div class="grid grid-cols-2 md:grid-cols-3 gap-4"> |
|
|
<?php |
|
|
$packages = [ |
|
|
500 => 5, |
|
|
1000 => 15, |
|
|
2000 => 40, |
|
|
5000 => 120, |
|
|
10000 => 300, |
|
|
20000 => 700 |
|
|
]; |
|
|
|
|
|
foreach ($packages as $amount => $bonus): |
|
|
$display_amount = $currency === 'KES' ? $amount : number_format($amount * ($currency_rates[$currency] ?? 1), 2); |
|
|
?> |
|
|
<div class="bg-gray-800 p-4 rounded-lg text-center cursor-pointer hover:bg-gray-700 transition recharge-package" |
|
|
data-amount="<?php echo $amount; ?>"> |
|
|
<div class="font-bold text-yellow-400"><?php echo $display_amount; ?> <?php echo $currency; ?></div> |
|
|
<div class="text-xs mt-1 text-green-400">+<?php echo $bonus; ?> Bonus</div> |
|
|
</div> |
|
|
<?php endforeach; ?> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<!-- Currency Converter --> |
|
|
<div class="card mt-6"> |
|
|
<h3 class="text-lg font-bold mb-4">Currency Converter</h3> |
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm"> |
|
|
<?php foreach ($currency_rates as $curr => $rate): ?> |
|
|
<?php if ($curr !== 'KES'): ?> |
|
|
<div class="text-center"> |
|
|
<span class="font-bold">1 <?php echo $curr; ?> =</span> |
|
|
<span class="text-yellow-400"><?php echo number_format(1/$rate, 2); ?> KES</span> |
|
|
</div> |
|
|
<?php endif; ?> |
|
|
<?php endforeach; ?> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</main> |
|
|
</div> |
|
|
|
|
|
<script> |
|
|
feather.replace(); |
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
const toggleBtn = document.getElementById('menu-toggle'); |
|
|
const closeBtn = document.getElementById('menu-toggle-close'); |
|
|
const sidebar = document.getElementById('sidebar'); |
|
|
const content = document.getElementById('content'); |
|
|
|
|
|
// Toggle sidebar |
|
|
toggleBtn.addEventListener('click', function() { |
|
|
sidebar.classList.add('active'); |
|
|
if (window.innerWidth <= 768) { |
|
|
closeBtn.style.display = 'block'; |
|
|
} |
|
|
}); |
|
|
|
|
|
// Close sidebar |
|
|
closeBtn.addEventListener('click', function() { |
|
|
sidebar.classList.remove('active'); |
|
|
closeBtn.style.display = 'none'; |
|
|
}); |
|
|
|
|
|
// Close sidebar when clicking outside on mobile |
|
|
document.addEventListener('click', function(event) { |
|
|
if (window.innerWidth <= 768 && sidebar.classList.contains('active')) { |
|
|
if (!sidebar.contains(event.target) && event.target !== toggleBtn) { |
|
|
sidebar.classList.remove('active'); |
|
|
closeBtn.style.display = 'none'; |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
// Package selection |
|
|
document.querySelectorAll('.recharge-package').forEach(package => { |
|
|
package.addEventListener('click', function() { |
|
|
const amount = this.getAttribute('data-amount'); |
|
|
document.querySelector('input[name="amount"]').value = amount; |
|
|
}); |
|
|
}); |
|
|
|
|
|
// Payment method selection |
|
|
document.querySelectorAll('.payment-option').forEach(option => { |
|
|
option.addEventListener('click', function() { |
|
|
// Remove selected class from all options |
|
|
document.querySelectorAll('.payment-option').forEach(opt => { |
|
|
opt.classList.remove('selected'); |
|
|
}); |
|
|
|
|
|
// Add selected class to clicked option |
|
|
this.classList.add('selected'); |
|
|
|
|
|
// Update hidden input |
|
|
const method = this.getAttribute('data-method'); |
|
|
document.getElementById('paymentMethod').value = method; |
|
|
|
|
|
// Update submit button text |
|
|
const submitText = document.getElementById('submitText'); |
|
|
if (method === 'M-Pesa') { |
|
|
submitText.textContent = 'Initiate M-Pesa Payment'; |
|
|
} else { |
|
|
submitText.textContent = 'Proceed to Manual Payment'; |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
// Set first payment option as selected by default |
|
|
document.querySelector('.payment-option').classList.add('selected'); |
|
|
|
|
|
// Form validation |
|
|
document.getElementById('depositForm').addEventListener('submit', function(e) { |
|
|
const amount = document.querySelector('input[name="amount"]').value; |
|
|
const phone = document.querySelector('input[name="phone_number"]').value; |
|
|
|
|
|
if (amount < 500) { |
|
|
e.preventDefault(); |
|
|
alert('Minimum recharge amount is 500 ' + '<?php echo $currency; ?>'); |
|
|
return false; |
|
|
} |
|
|
|
|
|
if (!phone.match(/^254[0-9]{9}$/)) { |
|
|
e.preventDefault(); |
|
|
alert('Please enter a valid M-Pesa phone number in the format 2547XXXXXXXX'); |
|
|
return false; |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
// Handle window resize |
|
|
window.addEventListener('resize', function() { |
|
|
const sidebar = document.getElementById('sidebar'); |
|
|
const closeBtn = document.getElementById('menu-toggle-close'); |
|
|
|
|
|
if (window.innerWidth > 768) { |
|
|
sidebar.classList.remove('active'); |
|
|
closeBtn.style.display = 'none'; |
|
|
} |
|
|
}); |
|
|
</script> |
|
|
</body> |
|
|
</html> |