feat: Enhance software tool with country selection and tax calculation
- Added a helper function to generate country select options in software tool. - Updated user info modal and payment modal to use country dropdowns instead of text inputs. - Implemented tax calculation based on selected country in payment modal. - Improved software options loading behavior in debug mode. - Enhanced description formatting in payment modal. - Added log modal for equipment updates with a link to view logs. - Introduced a new countries settings file with tax rates for various countries. - Minor adjustments to various PHP files for better handling of equipment and payment processes.
This commit is contained in:
@@ -22,6 +22,24 @@ $payment_return = isset($_GET['order_id']) ? $_GET['order_id'] : null;
|
||||
$payment_return_status = isset($_GET['payment_return']) ? $_GET['payment_return'] : null;
|
||||
$paypal_token = isset($_GET['token']) ? $_GET['token'] : null; // PayPal returns with ?token=
|
||||
|
||||
// Handle payment cancellation - mark order as cancelled
|
||||
if ($payment_return && $payment_return_status === 'cancelled') {
|
||||
try {
|
||||
$pdo = dbConnect($dbname);
|
||||
$sql = 'UPDATE transactions SET payment_status = 999 WHERE txn_id = ?';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$payment_return]);
|
||||
|
||||
if (debug) {
|
||||
debuglog("Payment cancelled - Order ID: {$payment_return} marked as cancelled (999)");
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
if (debug) {
|
||||
debuglog("Error marking order as cancelled: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle PayPal return - capture the order directly
|
||||
if ($paypal_token && $payment_return) {
|
||||
try {
|
||||
@@ -134,8 +152,23 @@ if ($payment_return && $payment_return_status) {
|
||||
// Auto-refresh every 3 seconds to check payment status
|
||||
setTimeout(function() { location.reload(); }, 3000);
|
||||
</script>';
|
||||
} else if ($transaction['payment_status'] == 999) {
|
||||
// Payment 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-times-circle" style="font-size: 64px; color: #ffc107; margin-bottom: 20px;"></i>
|
||||
<h2 style="color: #856404; margin-bottom: 15px;">Payment Cancelled</h2>
|
||||
<p style="margin-bottom: 10px; color: #333;">You cancelled the payment. The order has been cancelled.</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>';
|
||||
} else {
|
||||
// Payment failed/cancelled
|
||||
// Payment failed/expired
|
||||
$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;">
|
||||
@@ -297,6 +330,9 @@ echo '
|
||||
var TRANS_USER_INFO_REQUIRED = "'.($user_information_required ?? 'User Information Required').'";
|
||||
var TRANS_USER_INFO_DESCRIPTION = "'.($user_information_description ?? 'Please provide your information to continue with software updates').'";
|
||||
var TRANS_CONTINUE = "'.($general_continue ?? 'Continue').'";
|
||||
|
||||
// Countries data
|
||||
var COUNTRIES = '.json_encode($countries ?? []).';
|
||||
|
||||
var port, textEncoder, writableStreamClosed, writer, historyIndex = -1;
|
||||
const lineHistory = [];
|
||||
|
||||
Reference in New Issue
Block a user