From d72ae27518f4759e595d8ca058148db608f39404 Mon Sep 17 00:00:00 2001 From: stranac Date: Wed, 30 Jun 2021 12:00:45 +0200 Subject: [PATCH 1/5] Add support for 4-character currency codes --- upload/admin/model/extension/payment/coingate.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/upload/admin/model/extension/payment/coingate.php b/upload/admin/model/extension/payment/coingate.php index 4991ff5..fdd5bdb 100644 --- a/upload/admin/model/extension/payment/coingate.php +++ b/upload/admin/model/extension/payment/coingate.php @@ -12,6 +12,12 @@ public function install() { ) ENGINE=MyISAM DEFAULT COLLATE=utf8_general_ci; "); + // Modify the currency table to allow 4-character currency code + $this->db->query(" + ALTER TABLE `" . DB_PREFIX . "currency` + MODIFY `code` VARCHAR(3) NOT NULL; + "); + $this->load->model('setting/setting'); $defaults = array(); From 55f42527fa5ec3e3e48f895781982bb4fc9cd2e6 Mon Sep 17 00:00:00 2001 From: stranac Date: Wed, 30 Jun 2021 12:36:20 +0200 Subject: [PATCH 2/5] Modify code table SQL --- install.xml | 14 ++++++++++++++ upload/admin/model/extension/payment/coingate.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 install.xml diff --git a/install.xml b/install.xml new file mode 100644 index 0000000..5d71920 --- /dev/null +++ b/install.xml @@ -0,0 +1,14 @@ + + + CoinGate + coningate + 3.1.3 + Ivan + + + + request->post['code']) != 3)]]> + request->post['code']), array(3, 4)))]]> + + + diff --git a/upload/admin/model/extension/payment/coingate.php b/upload/admin/model/extension/payment/coingate.php index fdd5bdb..2f0c6e8 100644 --- a/upload/admin/model/extension/payment/coingate.php +++ b/upload/admin/model/extension/payment/coingate.php @@ -15,7 +15,7 @@ public function install() { // Modify the currency table to allow 4-character currency code $this->db->query(" ALTER TABLE `" . DB_PREFIX . "currency` - MODIFY `code` VARCHAR(3) NOT NULL; + MODIFY `code` VARCHAR(4) COLLATE utf8_general_ci NOT NULL; "); $this->load->model('setting/setting'); From afc1fa68fffb9602c5651f31dadf74c0849e1a39 Mon Sep 17 00:00:00 2001 From: stranac Date: Fri, 2 Jul 2021 18:07:59 +0200 Subject: [PATCH 3/5] Check code column size --- upload/admin/model/extension/payment/coingate.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/upload/admin/model/extension/payment/coingate.php b/upload/admin/model/extension/payment/coingate.php index 2f0c6e8..10e3872 100644 --- a/upload/admin/model/extension/payment/coingate.php +++ b/upload/admin/model/extension/payment/coingate.php @@ -13,10 +13,17 @@ public function install() { "); // Modify the currency table to allow 4-character currency code - $this->db->query(" - ALTER TABLE `" . DB_PREFIX . "currency` - MODIFY `code` VARCHAR(4) COLLATE utf8_general_ci NOT NULL; + $query = $this->db->query(" + SELECT character_maximum_length + FROM information_schema.columns + WHERE table_name = '" . DB_PREFIX . "currency' and column_name = 'code'; "); + if ((int)$query->row['character_maximum_length'] < 4) { + $this->db->query(" + ALTER TABLE `" . DB_PREFIX . "currency` + MODIFY `code` VARCHAR(4) COLLATE utf8_general_ci NOT NULL; + "); + } $this->load->model('setting/setting'); From 2de62d1f2927219a56950b83c67b5ae866e4ea87 Mon Sep 17 00:00:00 2001 From: stranac Date: Mon, 5 Jul 2021 11:20:14 +0200 Subject: [PATCH 4/5] Create consistent file structure for all versions of the plugin --- .../library/{coingate/coingate-php => vendor/coingate}/init.php | 0 .../{coingate/coingate-php => vendor/coingate}/lib/ApiError.php | 0 .../{coingate/coingate-php => vendor/coingate}/lib/CoinGate.php | 0 .../{coingate/coingate-php => vendor/coingate}/lib/Exception.php | 0 .../{coingate/coingate-php => vendor/coingate}/lib/Merchant.php | 0 .../coingate-php => vendor/coingate}/lib/Merchant/Order.php | 0 upload/system/library/{ => vendor}/coingate/version.php | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename upload/system/library/{coingate/coingate-php => vendor/coingate}/init.php (100%) mode change 100755 => 100644 rename upload/system/library/{coingate/coingate-php => vendor/coingate}/lib/ApiError.php (100%) mode change 100755 => 100644 rename upload/system/library/{coingate/coingate-php => vendor/coingate}/lib/CoinGate.php (100%) mode change 100755 => 100644 rename upload/system/library/{coingate/coingate-php => vendor/coingate}/lib/Exception.php (100%) mode change 100755 => 100644 rename upload/system/library/{coingate/coingate-php => vendor/coingate}/lib/Merchant.php (100%) mode change 100755 => 100644 rename upload/system/library/{coingate/coingate-php => vendor/coingate}/lib/Merchant/Order.php (100%) mode change 100755 => 100644 rename upload/system/library/{ => vendor}/coingate/version.php (100%) diff --git a/upload/system/library/coingate/coingate-php/init.php b/upload/system/library/vendor/coingate/init.php old mode 100755 new mode 100644 similarity index 100% rename from upload/system/library/coingate/coingate-php/init.php rename to upload/system/library/vendor/coingate/init.php diff --git a/upload/system/library/coingate/coingate-php/lib/ApiError.php b/upload/system/library/vendor/coingate/lib/ApiError.php old mode 100755 new mode 100644 similarity index 100% rename from upload/system/library/coingate/coingate-php/lib/ApiError.php rename to upload/system/library/vendor/coingate/lib/ApiError.php diff --git a/upload/system/library/coingate/coingate-php/lib/CoinGate.php b/upload/system/library/vendor/coingate/lib/CoinGate.php old mode 100755 new mode 100644 similarity index 100% rename from upload/system/library/coingate/coingate-php/lib/CoinGate.php rename to upload/system/library/vendor/coingate/lib/CoinGate.php diff --git a/upload/system/library/coingate/coingate-php/lib/Exception.php b/upload/system/library/vendor/coingate/lib/Exception.php old mode 100755 new mode 100644 similarity index 100% rename from upload/system/library/coingate/coingate-php/lib/Exception.php rename to upload/system/library/vendor/coingate/lib/Exception.php diff --git a/upload/system/library/coingate/coingate-php/lib/Merchant.php b/upload/system/library/vendor/coingate/lib/Merchant.php old mode 100755 new mode 100644 similarity index 100% rename from upload/system/library/coingate/coingate-php/lib/Merchant.php rename to upload/system/library/vendor/coingate/lib/Merchant.php diff --git a/upload/system/library/coingate/coingate-php/lib/Merchant/Order.php b/upload/system/library/vendor/coingate/lib/Merchant/Order.php old mode 100755 new mode 100644 similarity index 100% rename from upload/system/library/coingate/coingate-php/lib/Merchant/Order.php rename to upload/system/library/vendor/coingate/lib/Merchant/Order.php diff --git a/upload/system/library/coingate/version.php b/upload/system/library/vendor/coingate/version.php similarity index 100% rename from upload/system/library/coingate/version.php rename to upload/system/library/vendor/coingate/version.php From 42947783cadb1ff742145cae8581f40b2c85932e Mon Sep 17 00:00:00 2001 From: stranac Date: Mon, 5 Jul 2021 11:37:02 +0200 Subject: [PATCH 5/5] Fix errors after changing file structure --- upload/admin/controller/extension/payment/coingate.php | 2 +- upload/catalog/controller/extension/payment/coingate.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/upload/admin/controller/extension/payment/coingate.php b/upload/admin/controller/extension/payment/coingate.php index 95596ee..3a48c26 100644 --- a/upload/admin/controller/extension/payment/coingate.php +++ b/upload/admin/controller/extension/payment/coingate.php @@ -1,6 +1,6 @@ $this->url->link('extension/payment/coingate/callback', array('cg_token' => $token), true), 'success_url' => $this->url->link('extension/payment/coingate/success', array('cg_token' => $token), true), 'title' => $this->config->get('config_meta_title') . ' Order #' . $order_info['order_id'], - 'description' => join($description, ', '), + 'description' => join(', ', $description), 'token' => $token ));