Skip to content

Commit

Permalink
Merge pull request #116 from yoomoney/release/v2.2.2
Browse files Browse the repository at this point in the history
* Оптимизация под новые версии Opencart
  • Loading branch information
SaShaSpi authored Dec 7, 2021
2 parents 057c7b1 + cc5d003 commit 85dc603
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v2.2.2 от 07.12.2021
* Оптимизация под новые версии Opencart

### v2.2.1 от 24.11.2021
* Обновлен SDK до версии 2.2.2

Expand Down
2 changes: 1 addition & 1 deletion src/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modification>
<name>YooMoney for Opencart 3.x</name>
<code>YooMoney</code>
<version>2.2.1</version>
<version>2.2.2</version>
<author>YooMoney</author>
<link>https://github.com/yoomoney/cms-opencart3</link>
<!-- Вставка кнопки в историю заказов-->
Expand Down
2 changes: 1 addition & 1 deletion src/upload/admin/controller/extension/payment/yoomoney.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class ControllerExtensionPaymentYoomoney extends Controller
{
const MODULE_NAME = 'yoomoney';
const MODULE_VERSION = '2.2.1';
const MODULE_VERSION = '2.2.2';

const WIDGET_INSTALL_STATUS_SUCCESS = true;
const WIDGET_INSTALL_STATUS_FAIL = false;
Expand Down
23 changes: 20 additions & 3 deletions src/upload/admin/model/extension/payment/yoomoney.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ModelExtensionPaymentYoomoney extends Model
/**
* string
*/
const MODULE_VERSION = '2.2.1';
const MODULE_VERSION = '2.2.2';
const YOOMONEY_EVENT_SECOND_RECEIPT_CODE = 'yoomoney_second_receipt_trigger';

private $kassaModel;
Expand All @@ -19,6 +19,14 @@ class ModelExtensionPaymentYoomoney extends Model
public function install()
{
$this->log('info', 'install yoomoney module');
if ($this->checkExistTable(DB_PREFIX.'yoomoney_payment', 'captured_at')) {
$this->db->query('
ALTER TABLE `' . DB_PREFIX . 'yoomoney_payment` MODIFY `captured_at` DATETIME NULL DEFAULT NULL;');
}
if ($this->checkExistTable(DB_PREFIX.'yoomoney_refunds', 'authorized_at')) {
$this->db->query('
ALTER TABLE `' . DB_PREFIX . 'yoomoney_refunds` MODIFY `authorized_at` DATETIME NULL DEFAULT NULL;');
}
$this->db->query('
CREATE TABLE IF NOT EXISTS `'.DB_PREFIX.'yoomoney_payment` (
`order_id` INTEGER NOT NULL,
Expand All @@ -29,7 +37,7 @@ public function install()
`payment_method_id` CHAR(36) NOT NULL,
`paid` ENUM(\'Y\', \'N\') NOT NULL,
`created_at` DATETIME NOT NULL,
`captured_at` DATETIME NOT NULL DEFAULT \'0000-00-00 00:00:00\',
`captured_at` DATETIME NULL DEFAULT NULL,
`receipt` TEXT DEFAULT NULL,
CONSTRAINT `'.DB_PREFIX.'yoomoney_payment_pk` PRIMARY KEY (`order_id`),
Expand All @@ -45,7 +53,7 @@ public function install()
`amount` DECIMAL(11, 2) NOT NULL,
`currency` CHAR(3) NOT NULL,
`created_at` DATETIME NOT NULL,
`authorized_at` DATETIME NOT NULL DEFAULT \'0000-00-00 00:00:00\',
`authorized_at` DATETIME NULL DEFAULT NULL,
INDEX `'.DB_PREFIX.'yoomoney_refunds_idx_order_id` (`order_id`),
INDEX `'.DB_PREFIX.'yoomoney_refunds_idx_payment_id` (`payment_id`),
CONSTRAINT `'.DB_PREFIX.'yoomoney_refunds_pk` PRIMARY KEY (`refund_id`)
Expand Down Expand Up @@ -745,4 +753,13 @@ private function getMapFileName()
{
return 'opencart-3.map';
}

private function checkExistTable($tableName, $columnName)
{
try {
return $this->db->query("SELECT $columnName FROM $tableName LIMIT 1;");
} catch (Exception $e) {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<td class="text-center">{{ payment.status }}</td>
<td class="text-center">{{ payment.created_at }}</td>
<td class="text-center">
{% if payment.captured_at == '0000-00-00 00:00:00' %}
{% if payment.captured_at == null %}
не подтверждён
{% else %}
{{ payment.captured_at }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class ControllerExtensionPaymentYoomoney extends Controller
{
const MODULE_NAME = 'yoomoney';
const MODULE_VERSION = '2.2.1';
const MODULE_VERSION = '2.2.2';

/**
* @var ModelExtensionPaymentYoomoney
Expand Down
2 changes: 1 addition & 1 deletion src/upload/catalog/model/extension/payment/yoomoney.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class ModelExtensionPaymentYoomoney extends Model
{
const MODULE_VERSION = '2.2.1';
const MODULE_VERSION = '2.2.2';

private $kassaModel;
private $walletModel;
Expand Down
Binary file modified yoomoney.oc3x.ocmod.zip
Binary file not shown.

0 comments on commit 85dc603

Please sign in to comment.