feat: Add software licenses management page and update payment handling
- Introduced a new licenses management page with functionality to create, update, and view software licenses. - Updated payment return handling in softwaretool.php to check payment status from the database and display appropriate modals for success, pending, and failure states. - Enhanced webhook_mollie.php to log webhook calls, handle payment status updates directly in the database, and generate invoices based on payment status. - Improved CSS styles for better alignment of buttons and modal components. - Added JavaScript for modal interactions and bulk license creation functionality.
This commit is contained in:
@@ -18,24 +18,73 @@ $bearertoken = createCommunicationToken($_SESSION['userkey']);
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// PAYMENT RETURN DETECTION
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
$payment_return = isset($_GET['payment_id']) ? $_GET['payment_id'] : null;
|
||||
$payment_return = isset($_GET['order_id']) ? $_GET['order_id'] : null;
|
||||
$payment_return_status = isset($_GET['payment_return']) ? $_GET['payment_return'] : null;
|
||||
|
||||
template_header('Softwaretool', 'softwaretool','view');
|
||||
|
||||
// Show payment return message if returning from payment
|
||||
$view = '';
|
||||
$payment_modal = '';
|
||||
if ($payment_return && $payment_return_status) {
|
||||
$view = '
|
||||
<div class="content-title">
|
||||
<div style="background: #d4edda; border: 1px solid #c3e6cb; color: #155724; padding: 15px; border-radius: 6px; margin-bottom: 20px;">
|
||||
<i class="fa-solid fa-check-circle"></i>
|
||||
<strong>Payment Successful!</strong>
|
||||
<p style="margin: 10px 0 0 0;">Your payment has been processed. Please reconnect your device to apply the software upgrade.</p>
|
||||
<p style="margin: 5px 0 0 0; font-size: 12px; color: #666;">Payment ID: '.htmlspecialchars($payment_return).'</p>
|
||||
</div>
|
||||
</div>';
|
||||
} else {
|
||||
$view = '';
|
||||
// Check actual payment status in database
|
||||
$pdo = dbConnect($dbname);
|
||||
$sql = 'SELECT payment_status FROM transactions WHERE txn_id = ?';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$payment_return]);
|
||||
$transaction = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($transaction) {
|
||||
if ($transaction['payment_status'] == 1) {
|
||||
// Payment confirmed as paid
|
||||
$payment_modal = '
|
||||
<div id="paymentModal" class="modal" style="display: flex; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center;">
|
||||
<div class="modal-content" style="background: white; border-radius: 12px; max-width: 500px; margin: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); position: relative;">
|
||||
<span class="close" onclick="closePaymentModal()" style="position: absolute; top: 15px; right: 20px; font-size: 28px; font-weight: bold; color: #999; cursor: pointer;">×</span>
|
||||
<div style="text-align: center; padding: 40px 30px;">
|
||||
<i class="fa-solid fa-check-circle" style="font-size: 64px; color: #28a745; margin-bottom: 20px;"></i>
|
||||
<h2 style="color: #155724; margin-bottom: 15px;">Payment Successful!</h2>
|
||||
<p style="margin-bottom: 10px; color: #333;">Your payment has been processed. Please reconnect your device to apply the software upgrade.</p>
|
||||
<p style="font-size: 12px; color: #666; margin-bottom: 25px;">Order ID: '.htmlspecialchars($payment_return).'</p>
|
||||
<button onclick="closePaymentModal()" class="btn" style="padding: 12px 30px;">Continue</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
} else if ($transaction['payment_status'] == 0 || $transaction['payment_status'] == 101) {
|
||||
// Payment pending
|
||||
$payment_modal = '
|
||||
<div id="paymentModal" class="modal" style="display: flex; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center;">
|
||||
<div class="modal-content" style="background: white; border-radius: 12px; max-width: 500px; margin: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.3);">
|
||||
<div style="text-align: center; padding: 40px 30px;">
|
||||
<i class="fa-solid fa-clock" style="font-size: 64px; color: #ffc107; margin-bottom: 20px;"></i>
|
||||
<h2 style="color: #856404; margin-bottom: 15px;">Payment Processing...</h2>
|
||||
<p style="margin-bottom: 10px; color: #333;">Your payment is being processed. This page will update automatically when confirmed.</p>
|
||||
<p style="font-size: 12px; color: #666; margin-bottom: 25px;">Order ID: '.htmlspecialchars($payment_return).'</p>
|
||||
<i class="fa-solid fa-spinner fa-spin" style="font-size: 32px; color: #ffc107;"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// Auto-refresh every 3 seconds to check payment status
|
||||
setTimeout(function() { location.reload(); }, 3000);
|
||||
</script>';
|
||||
} else {
|
||||
// Payment failed/cancelled
|
||||
$payment_modal = '
|
||||
<div id="paymentModal" class="modal" style="display: flex; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center;">
|
||||
<div class="modal-content" style="background: white; border-radius: 12px; max-width: 500px; margin: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); position: relative;">
|
||||
<span class="close" onclick="closePaymentModal()" style="position: absolute; top: 15px; right: 20px; font-size: 28px; font-weight: bold; color: #999; cursor: pointer;">×</span>
|
||||
<div style="text-align: center; padding: 40px 30px;">
|
||||
<i class="fa-solid fa-exclamation-circle" style="font-size: 64px; color: #dc3545; margin-bottom: 20px;"></i>
|
||||
<h2 style="color: #721c24; margin-bottom: 15px;">Payment Failed</h2>
|
||||
<p style="margin-bottom: 10px; color: #333;">Your payment could not be processed. Please try again.</p>
|
||||
<p style="font-size: 12px; color: #666; margin-bottom: 25px;">Order ID: '.htmlspecialchars($payment_return).'</p>
|
||||
<button onclick="closePaymentModal()" class="btn" style="padding: 12px 30px;">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$view .= '
|
||||
@@ -90,7 +139,7 @@ $view .= '<div class="content-block">
|
||||
|
||||
<div id="softwareOptions" style="margin-top: 20px; display:none;">
|
||||
<h3 style="margin-bottom: 20px; color: #333;">'.$softwaretool_select_upgrade.'</h3>
|
||||
<div id="softwareOptionsGrid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;">
|
||||
<div id="softwareOptionsGrid" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; justify-content: center; max-width: 1200px; margin: 0 auto;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -144,6 +193,9 @@ $view .= '</div>';
|
||||
//OUTPUT
|
||||
echo $view;
|
||||
|
||||
// Output payment modal if exists
|
||||
echo $payment_modal;
|
||||
|
||||
|
||||
echo '
|
||||
<script src="assets/upload.js?'.script_version.'"></script>
|
||||
@@ -169,12 +221,29 @@ echo '
|
||||
}
|
||||
};
|
||||
|
||||
// Payment modal functions
|
||||
window.closePaymentModal = function() {
|
||||
const modal = document.getElementById("paymentModal");
|
||||
if (modal) {
|
||||
modal.style.display = "none";
|
||||
// Clean URL by removing payment_return and order_id parameters
|
||||
const url = new URL(window.location);
|
||||
url.searchParams.delete("payment_return");
|
||||
url.searchParams.delete("order_id");
|
||||
window.history.replaceState({}, document.title, url);
|
||||
}
|
||||
};
|
||||
|
||||
// Close modal on background click
|
||||
document.addEventListener("click", function(e) {
|
||||
const modal = document.getElementById("helpModal");
|
||||
if (modal && e.target === modal) {
|
||||
const helpModal = document.getElementById("helpModal");
|
||||
if (helpModal && e.target === helpModal) {
|
||||
closeInstructions();
|
||||
}
|
||||
const paymentModal = document.getElementById("paymentModal");
|
||||
if (paymentModal && e.target === paymentModal) {
|
||||
closePaymentModal();
|
||||
}
|
||||
});
|
||||
</script>';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user