Add PayPal webhook handler and marketing styles
- Implemented PayPal webhook for handling payment notifications, including signature verification and transaction updates. - Created invoice generation and license management for software upgrades upon successful payment. - Added comprehensive logging for debugging purposes. - Introduced new CSS styles for the marketing file management system, including layout, toolbar, breadcrumb navigation, search filters, and file management UI components.
This commit is contained in:
@@ -61,6 +61,7 @@ if (isset($criterias['sn']) && $criterias['sn'] != ''){
|
||||
e.sw_version as current_sw_version,
|
||||
e.hw_version,
|
||||
e.sw_version_license,
|
||||
e.sw_version_upgrade,
|
||||
e.rowID as equipment_rowid
|
||||
FROM equipment e
|
||||
JOIN products p ON e.productrowid = p.rowID
|
||||
@@ -77,6 +78,7 @@ if (isset($criterias['sn']) && $criterias['sn'] != ''){
|
||||
$current_sw_version = $equipment_data['current_sw_version'];
|
||||
$hw_version = $equipment_data['hw_version'];
|
||||
$sw_version_license = $equipment_data['sw_version_license'];
|
||||
$sw_version_upgrade = $equipment_data['sw_version_upgrade'];
|
||||
$equipment_rowid = $equipment_data['equipment_rowid'];
|
||||
|
||||
if (debug) {
|
||||
@@ -85,7 +87,8 @@ if (isset($criterias['sn']) && $criterias['sn'] != ''){
|
||||
'productcode' => $productcode,
|
||||
'current_sw_version_raw' => $current_sw_version,
|
||||
'hw_version' => $hw_version,
|
||||
'sw_version_license' => $sw_version_license
|
||||
'sw_version_license' => $sw_version_license,
|
||||
'sw_version_upgrade' => $sw_version_upgrade
|
||||
];
|
||||
}
|
||||
|
||||
@@ -119,6 +122,95 @@ if (isset($criterias['sn']) && $criterias['sn'] != ''){
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check if sw_version_upgrade is set - this overrides normal availability check
|
||||
if (!empty($sw_version_upgrade)) {
|
||||
if (debug) {
|
||||
$debug['sw_version_upgrade_check'] = [
|
||||
'sw_version_upgrade_id' => $sw_version_upgrade,
|
||||
'checking_override' => true
|
||||
];
|
||||
}
|
||||
|
||||
// Check if this version exists and is active
|
||||
$sql = 'SELECT
|
||||
psv.rowID as version_id,
|
||||
psv.version,
|
||||
psv.name,
|
||||
psv.description,
|
||||
psv.mandatory,
|
||||
psv.latest,
|
||||
psv.hw_version,
|
||||
psv.file_path,
|
||||
psv.status
|
||||
FROM products_software_versions psv
|
||||
WHERE psv.rowID = ?';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$sw_version_upgrade]);
|
||||
$upgrade_version = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($upgrade_version && $upgrade_version['status'] == 1) {
|
||||
// Valid override found - check if different from current version
|
||||
$normalized_upgrade_version = strtolower(ltrim($upgrade_version['version'], '0'));
|
||||
|
||||
if (debug) {
|
||||
$debug['sw_version_upgrade_check']['found_version'] = [
|
||||
'version' => $upgrade_version['version'],
|
||||
'name' => $upgrade_version['name'],
|
||||
'normalized' => $normalized_upgrade_version,
|
||||
'status' => $upgrade_version['status'],
|
||||
'is_different_from_current' => ($current_sw_version != $normalized_upgrade_version)
|
||||
];
|
||||
}
|
||||
|
||||
if (!$current_sw_version || $current_sw_version == '' || $normalized_upgrade_version != $current_sw_version) {
|
||||
// Override version is different from current (or no current) - return only this upgrade
|
||||
$output[] = [
|
||||
"productcode" => $productcode,
|
||||
"name" => $upgrade_version['name'] ?? '',
|
||||
"version" => $upgrade_version['version'],
|
||||
"version_id" => $upgrade_version['version_id'],
|
||||
"description" => $upgrade_version['description'] ?? '',
|
||||
"hw_version" => $upgrade_version['hw_version'] ?? '',
|
||||
"mandatory" => $upgrade_version['mandatory'] ?? '',
|
||||
"latest" => $upgrade_version['latest'] ?? '',
|
||||
"software" => $upgrade_version['file_path'] ?? '',
|
||||
"source" => '',
|
||||
"source_type" => '',
|
||||
"price" => '0.00',
|
||||
"currency" => '',
|
||||
"is_current" => false
|
||||
];
|
||||
|
||||
// Generate download token
|
||||
$download_token = create_download_url_token($criterias['sn'], $upgrade_version['version_id']);
|
||||
$download_url = 'https://'.$_SERVER['SERVER_NAME'].'/api.php/v2/software_download?token='.$download_token;
|
||||
$output[0]['source'] = $download_url;
|
||||
$output[0]['source_type'] = 'token_url';
|
||||
|
||||
if (debug) {
|
||||
$debug['sw_version_upgrade_check']['decision'] = 'Override version returned as only upgrade';
|
||||
$output[0]['_debug'] = $debug;
|
||||
}
|
||||
} else {
|
||||
// Override version is same as current - no upgrades
|
||||
if (debug) {
|
||||
$debug['sw_version_upgrade_check']['decision'] = 'Override version is same as current version - no upgrades';
|
||||
$output = ['message' => 'No upgrades available', 'debug' => $debug];
|
||||
}
|
||||
}
|
||||
|
||||
$messages = $output;
|
||||
echo json_encode($messages, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
} else {
|
||||
// Override version not found or inactive - fall back to standard check
|
||||
if (debug) {
|
||||
$debug['sw_version_upgrade_check']['found_version'] = $upgrade_version ? 'found but inactive' : 'not found';
|
||||
$debug['sw_version_upgrade_check']['decision'] = 'Falling back to standard check';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//GET ALL ACTIVE SOFTWARE ASSIGNMENTS for this product with matching HW version
|
||||
$sql = 'SELECT
|
||||
psv.rowID as version_id,
|
||||
|
||||
Reference in New Issue
Block a user