Update admin/model/payment/hutko.php
This commit is contained in:
@@ -3,10 +3,7 @@ namespace Opencart\Admin\Model\Extension\Hutko\Payment;
|
|||||||
|
|
||||||
class Hutko extends \Opencart\System\Engine\Model {
|
class Hutko extends \Opencart\System\Engine\Model {
|
||||||
public function install(): void {
|
public function install(): void {
|
||||||
// Drop old table if exists (Clean start for new architecture if needed)
|
|
||||||
// $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "hutko_order`");
|
// $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "hutko_order`");
|
||||||
|
|
||||||
// Create new Transaction Table
|
|
||||||
$this->db->query("
|
$this->db->query("
|
||||||
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "hutko_transaction` (
|
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "hutko_transaction` (
|
||||||
`hutko_transaction_id` INT(11) NOT NULL AUTO_INCREMENT,
|
`hutko_transaction_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
@@ -19,14 +16,13 @@ class Hutko extends \Opencart\System\Engine\Model {
|
|||||||
`payload` MEDIUMTEXT,
|
`payload` MEDIUMTEXT,
|
||||||
`date_added` DATETIME NOT NULL,
|
`date_added` DATETIME NOT NULL,
|
||||||
PRIMARY KEY (`hutko_transaction_id`),
|
PRIMARY KEY (`hutko_transaction_id`),
|
||||||
KEY `idx_order_id` (`order_id`),
|
KEY `idx_order_id` (`order_id`)
|
||||||
KEY `idx_hutko_ref` (`hutko_ref`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uninstall(): void {
|
public function uninstall(): void {
|
||||||
// Optional: $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "hutko_transaction`");
|
// Optional drop
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTransactions(int $order_id): array {
|
public function getTransactions(int $order_id): array {
|
||||||
@@ -34,9 +30,23 @@ class Hutko extends \Opencart\System\Engine\Model {
|
|||||||
return $query->rows;
|
return $query->rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper for history (OC4 compatibility)
|
|
||||||
public function addOrderHistory(int $order_id, int $order_status_id, string $comment = '', bool $notify = false): void {
|
public function addOrderHistory(int $order_id, int $order_status_id, string $comment = '', bool $notify = false): void {
|
||||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "order_history` SET `order_id` = '" . (int)$order_id . "', `order_status_id` = '" . (int)$order_status_id . "', `notify` = '" . (int)$notify . "', `comment` = '" . $this->db->escape($comment) . "', `date_added` = NOW()");
|
$this->db->query("INSERT INTO `" . DB_PREFIX . "order_history` SET `order_id` = '" . (int)$order_id . "', `order_status_id` = '" . (int)$order_status_id . "', `notify` = '" . (int)$notify . "', `comment` = '" . $this->db->escape($comment) . "', `date_added` = NOW()");
|
||||||
$this->db->query("UPDATE `" . DB_PREFIX . "order` SET `order_status_id` = '" . (int)$order_status_id . "', `date_modified` = NOW() WHERE `order_id` = '" . (int)$order_id . "'");
|
$this->db->query("UPDATE `" . DB_PREFIX . "order` SET `order_status_id` = '" . (int)$order_status_id . "', `date_modified` = NOW() WHERE `order_id` = '" . (int)$order_id . "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MIRRORED FROM CATALOG MODEL for logging admin actions
|
||||||
|
public function logTransaction($order_id, $hutko_ref, $type, $status, $amount, $currency, $payload_data = []) {
|
||||||
|
$json = json_encode($payload_data, JSON_UNESCAPED_UNICODE);
|
||||||
|
$this->db->query("INSERT INTO `" . DB_PREFIX . "hutko_transaction` SET
|
||||||
|
`order_id` = '" . (int)$order_id . "',
|
||||||
|
`hutko_ref` = '" . $this->db->escape($hutko_ref) . "',
|
||||||
|
`type` = '" . $this->db->escape($type) . "',
|
||||||
|
`status` = '" . $this->db->escape($status) . "',
|
||||||
|
`amount` = '" . (float)$amount . "',
|
||||||
|
`currency` = '" . $this->db->escape($currency) . "',
|
||||||
|
`payload` = '" . $this->db->escape($json) . "',
|
||||||
|
`date_added` = NOW()
|
||||||
|
");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user