Merge branch 'development'
This commit is contained in:
@@ -49,6 +49,9 @@ if(isset($get_content) && $get_content!=''){
|
||||
elseif ($v[0] == 'equipmentid') {
|
||||
//build up search
|
||||
$clause .= ' AND e.rowID = :'.$v[0];
|
||||
|
||||
//UPDATE VERSION STATUS
|
||||
$sw_version_latest_update = 1;
|
||||
}
|
||||
elseif ($v[0] == 'servicedate') {
|
||||
//build up service coverage
|
||||
@@ -69,6 +72,7 @@ if(isset($get_content) && $get_content!=''){
|
||||
elseif ($v[0] == 'h_equipmentid') {
|
||||
//build up search
|
||||
$clause .= ' AND h.equipmentid = :'.$v[0];
|
||||
|
||||
}
|
||||
elseif ($v[0] == 'status') {
|
||||
//Update status based on status
|
||||
|
||||
88
api/v2/get/payment.php
Normal file
88
api/v2/get/payment.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
defined($security_key) or exit;
|
||||
|
||||
//------------------------------------------
|
||||
// Payment Status Retrieval
|
||||
//------------------------------------------
|
||||
// This endpoint retrieves payment details for verification
|
||||
|
||||
//Connect to DB
|
||||
$pdo = dbConnect($dbname);
|
||||
|
||||
//NEW ARRAY
|
||||
$criterias = [];
|
||||
|
||||
//Check for $_GET variables
|
||||
if(isset($get_content) && $get_content!=''){
|
||||
$requests = explode("&", $get_content);
|
||||
foreach ($requests as $y){
|
||||
$v = explode("=", $y);
|
||||
$criterias[$v[0]] = $v[1];
|
||||
}
|
||||
}
|
||||
|
||||
// Validate payment_id
|
||||
if (empty($criterias['payment_id'])) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['error' => 'Missing required parameter: payment_id'], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
$payment_id = $criterias['payment_id'];
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// STEP 1: Fetch transaction
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
$sql = 'SELECT * FROM transactions WHERE txn_id = ?';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$payment_id]);
|
||||
$transaction = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$transaction) {
|
||||
http_response_code(404);
|
||||
echo json_encode(['error' => 'Payment not found'], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// STEP 2: Fetch transaction item
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
$sql = 'SELECT * FROM transactions_items WHERE txn_id = ? LIMIT 1';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$payment_id]);
|
||||
$item = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$item) {
|
||||
http_response_code(404);
|
||||
echo json_encode(['error' => 'Payment item not found'], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// STEP 3: Parse item_options JSON
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
$item_options = [];
|
||||
if (!empty($item['item_options'])) {
|
||||
$item_options = json_decode($item['item_options'], true);
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// STEP 4: Return payment details
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
$messages = json_encode([
|
||||
'payment_id' => $transaction['txn_id'],
|
||||
'payment_status' => $transaction['payment_status'],
|
||||
'payment_amount' => $transaction['payment_amount'],
|
||||
'currency' => 'EUR', // Default currency
|
||||
'serial_number' => $item_options['serial_number'] ?? null,
|
||||
'equipment_id' => $item_options['equipment_id'] ?? null,
|
||||
'hw_version' => $item_options['hw_version'] ?? null,
|
||||
'version_id' => $item['item_id'],
|
||||
'payer_email' => $transaction['payer_email'],
|
||||
'customer_name' => trim(($transaction['first_name'] ?? '') . ' ' . ($transaction['last_name'] ?? '')),
|
||||
'created' => $transaction['created']
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
echo $messages;
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
defined($security_key) or exit;
|
||||
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
//------------------------------------------
|
||||
// Products Software Licenses
|
||||
//------------------------------------------
|
||||
@@ -12,7 +14,7 @@ $pdo = dbConnect($dbname);
|
||||
if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} else {$soldto_search = '-%';}
|
||||
|
||||
//default whereclause
|
||||
list($whereclause,$condition) = getWhereclauselvl2("software_licenses",$permission,$partner,'get');
|
||||
list($whereclause,$condition) = getWhereclauselvl2("products_software_licenses",$permission,$partner,'get');
|
||||
|
||||
//NEW ARRAY
|
||||
$criterias = [];
|
||||
@@ -52,12 +54,20 @@ if(isset($criterias['totals']) && $criterias['totals'] ==''){
|
||||
$sql = 'SELECT count(*) as count FROM products_software_licenses '.$whereclause.'';
|
||||
}
|
||||
elseif (isset($criterias['list']) && $criterias['list'] =='') {
|
||||
//SQL for list
|
||||
$sql = 'SELECT l.*, u.username, v.name as version_name FROM products_software_licenses l LEFT JOIN users u ON l.user_id = u.id LEFT JOIN products_software_versions v ON l.version_id = v.rowID '.$whereclause.' ORDER BY l.created DESC';
|
||||
//SQL for list
|
||||
$sql = 'SELECT l.*, v.name as version_name, v.version, e.serialnumber as assigned_serial
|
||||
FROM products_software_licenses l
|
||||
LEFT JOIN products_software_versions v ON l.version_id = v.rowID
|
||||
LEFT JOIN equipment e ON l.license_key = e.sw_version_license
|
||||
'.$whereclause.' ORDER BY l.created DESC';
|
||||
}
|
||||
else {
|
||||
//SQL for paged
|
||||
$sql = 'SELECT l.*, u.username, v.name as version_name FROM products_software_licenses l LEFT JOIN users u ON l.user_id = u.id LEFT JOIN products_software_versions v ON l.version_id = v.rowID '.$whereclause.' ORDER BY l.created DESC LIMIT :page,:num_licenses';
|
||||
//SQL for paged
|
||||
$sql = 'SELECT l.*, v.name as version_name, v.version, e.serialnumber as assigned_serial
|
||||
FROM products_software_licenses l
|
||||
LEFT JOIN products_software_versions v ON l.version_id = v.rowID
|
||||
LEFT JOIN equipment e ON l.license_key = e.sw_version_license
|
||||
'.$whereclause.' ORDER BY l.created DESC LIMIT :page,:num_licenses';
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
@@ -245,16 +245,16 @@ if (isset($criterias['sn']) && $criterias['sn'] != ''){
|
||||
//Check if there's a valid license for this upgrade
|
||||
if ($final_price > 0 && $sw_version_license) {
|
||||
//Check if the license is valid
|
||||
$sql = 'SELECT status, start_at, expires_at
|
||||
$sql = 'SELECT status, starts_at, expires_at
|
||||
FROM products_software_licenses
|
||||
WHERE license_key = ? AND equipment_id = ?';
|
||||
WHERE license_key = ?';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$sw_version_license, $equipment_rowid]);
|
||||
$stmt->execute([$sw_version_license]);
|
||||
$license = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($license && $license['status'] == 1) {
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$start_at = $license['start_at'];
|
||||
$start_at = $license['starts_at'];
|
||||
$expires_at = $license['expires_at'];
|
||||
|
||||
//Check if license is within valid date range
|
||||
|
||||
@@ -281,16 +281,16 @@ if (isset($criterias['sn']) && $criterias['sn'] != ''){
|
||||
$license_applied = false;
|
||||
if ($final_price > 0 && $sw_version_license) {
|
||||
//Check if the license is valid
|
||||
$sql = 'SELECT status, start_at, expires_at
|
||||
$sql = 'SELECT status, starts_at, expires_at
|
||||
FROM products_software_licenses
|
||||
WHERE license_key = ? AND equipment_id = ?';
|
||||
WHERE license_key = ?';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$sw_version_license, $equipment_rowid]);
|
||||
$stmt->execute([$sw_version_license]);
|
||||
$license = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($license && $license['status'] == 1) {
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$start_at = $license['start_at'];
|
||||
$start_at = $license['starts_at'];
|
||||
$expires_at = $license['expires_at'];
|
||||
|
||||
//Check if license is within valid date range
|
||||
|
||||
Reference in New Issue
Block a user