From 80f075e57b7a46348f5290cbce7a83b96d5aa3a3 Mon Sep 17 00:00:00 2001 From: stranac Date: Wed, 30 Jun 2021 11:43:04 +0200 Subject: [PATCH 1/3] Fix rounding (switch to 8 decimals) --- catalog/controller/extension/payment/coingate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalog/controller/extension/payment/coingate.php b/catalog/controller/extension/payment/coingate.php index 42a2298..16905c5 100755 --- a/catalog/controller/extension/payment/coingate.php +++ b/catalog/controller/extension/payment/coingate.php @@ -50,7 +50,7 @@ public function confirm() $order = \CoinGate\Merchant\Order::createOrFail(array( 'order_id' => $order['order_id'], - 'price_amount' => number_format($order['total'] * $this->currency->getvalue($order['currency_code']), 2, '.', ''), + 'price_amount' => number_format($order['total'] * $this->currency->getvalue($order['currency_code']), 8, '.', ''), 'price_currency' => $order['currency_code'], 'receive_currency' => $this->config->get('coingate_receive_currency'), 'cancel_url' => $this->url->link('extension/payment/coingate/cancel', '', $this->config->get('config_secure')), From d963e63c568a7886b5e5d10587d80e54221b9ea5 Mon Sep 17 00:00:00 2001 From: stranac Date: Wed, 30 Jun 2021 12:48:11 +0200 Subject: [PATCH 2/3] Add support for 4-character currency codes --- admin/controller/extension/payment/coingate.php | 5 +++++ admin/model/extension/payment/coingate.php | 11 +++++++++++ install.xml | 14 ++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 admin/model/extension/payment/coingate.php create mode 100644 install.xml diff --git a/admin/controller/extension/payment/coingate.php b/admin/controller/extension/payment/coingate.php index 9480653..53cdc1b 100755 --- a/admin/controller/extension/payment/coingate.php +++ b/admin/controller/extension/payment/coingate.php @@ -178,4 +178,9 @@ private function validate() return !$this->error; } + + public function install() { + $this->load->model('extension/payment/coingate'); + $this->model_extension_payment_coingate->install(); + } } diff --git a/admin/model/extension/payment/coingate.php b/admin/model/extension/payment/coingate.php new file mode 100644 index 0000000..ebacb82 --- /dev/null +++ b/admin/model/extension/payment/coingate.php @@ -0,0 +1,11 @@ +db->query(" + ALTER TABLE `" . DB_PREFIX . "currency` + MODIFY `code` VARCHAR(4) COLLATE utf8_general_ci NOT NULL; + "); + } +} 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)))]]> + + + From 17e8bc5833807722d97114876366f80862f803bf Mon Sep 17 00:00:00 2001 From: stranac Date: Fri, 2 Jul 2021 18:11:11 +0200 Subject: [PATCH 3/3] Check code column size --- admin/model/extension/payment/coingate.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/admin/model/extension/payment/coingate.php b/admin/model/extension/payment/coingate.php index ebacb82..c4123f2 100644 --- a/admin/model/extension/payment/coingate.php +++ b/admin/model/extension/payment/coingate.php @@ -3,9 +3,16 @@ class ModelExtensionPaymentCoingate extends Model { 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; + "); + } } }