diff --git a/buckaroo3.php b/buckaroo3.php index a02945c2..a0ec7be5 100644 --- a/buckaroo3.php +++ b/buckaroo3.php @@ -56,7 +56,7 @@ private function initializeModuleInfo() { $this->name = 'buckaroo3'; $this->tab = 'payments_gateways'; - $this->version = '4.2.0'; + $this->version = '4.2.1'; $this->author = 'Buckaroo'; $this->need_instance = 1; $this->bootstrap = true; @@ -84,7 +84,7 @@ private function initializeDisplayName() } elseif (isset($response->status) && $response->status > 0) { $this->displayName = (new RawPaymentMethodRepository())->getPaymentMethodsLabel($response->payment_method); } else { - $this->displayName = $this->l('Buckaroo Payments (v 4.2.0)'); + $this->displayName = $this->l('Buckaroo Payments (v 4.2.1)'); } } } diff --git a/config.xml b/config.xml index 47aafb5e..d7560f49 100644 --- a/config.xml +++ b/config.xml @@ -1,9 +1,9 @@ buckaroo3 - - - + + + diff --git a/library/checkout/billinkcheckout.php b/library/checkout/billinkcheckout.php index ab963570..327eaf25 100644 --- a/library/checkout/billinkcheckout.php +++ b/library/checkout/billinkcheckout.php @@ -18,6 +18,7 @@ include_once _PS_MODULE_DIR_ . 'buckaroo3/classes/CarrierHandler.php'; use Buckaroo\Resources\Constants\RecipientCategory; +use PrestaShop\Decimal\DecimalNumber; if (!defined('_PS_VERSION_')) { exit; @@ -100,7 +101,7 @@ public function getBillingAddress() ]; if (self::CUSTOMER_TYPE_B2C != $this->customerType - && $this->companyExists($this->invoice_address->company) ? $this->invoice_address->company : null) { + && $this->companyExists($this->invoice_address->company) ? $this->invoice_address->company : null) { $payload['recipient']['careOf'] = $this->invoice_address->company; $payload['recipient']['chamberOfCommerce'] = Tools::getValue('customerbillink-coc'); } @@ -108,7 +109,6 @@ public function getBillingAddress() return $payload; } - public function getRecipientCategory() { $category = self::CUSTOMER_TYPE_B2C; @@ -119,23 +119,6 @@ public function getRecipientCategory() return $category; } - protected function prepareProductArticles() - { - $articles = []; - foreach ($this->products as $item) { - $tmp = []; - $tmp['identifier'] = $item['id_product']; - $tmp['quantity'] = $item['quantity']; - $tmp['price'] = round($item['price_with_reduction'], 2); - $tmp['priceExcl'] = round($item['price_with_reduction_without_tax'], 2); - $tmp['vatPercentage'] = $item['rate']; - $tmp['description'] = $item['name']; - $articles[] = $tmp; - } - - return $articles; - } - public function getBirthDate() { return date( diff --git a/library/checkout/checkout.php b/library/checkout/checkout.php index f5be8943..99532b42 100644 --- a/library/checkout/checkout.php +++ b/library/checkout/checkout.php @@ -357,7 +357,7 @@ protected function prepareBuckarooFeeArticle() return [ 'identifier' => '0', 'quantity' => '1', - 'price' => round($buckarooFee['buckaroo_fee_tax_excl'], 2), + 'price' => round($buckarooFee['buckaroo_fee_tax_incl'], 2), 'vatPercentage' => '0', 'description' => 'buckaroo_fee', ]; @@ -370,7 +370,7 @@ protected function prepareProductArticles() $article = [ 'identifier' => $item['id_product'], 'quantity' => $item['quantity'], - 'price' => $item['price_wt']->toPrecision(2), + 'price' => round($item['price_wt'], 2), 'vatPercentage' => $item['rate'], 'description' => $item['name'], ]; diff --git a/upgrade/upgrade-4.2.1.php b/upgrade/upgrade-4.2.1.php index a51bc54b..efbdcd5e 100644 --- a/upgrade/upgrade-4.2.1.php +++ b/upgrade/upgrade-4.2.1.php @@ -41,20 +41,27 @@ function upgrade_module_4_2_1($object) Db::getInstance()->execute($createTableQuery); - // Move data from old table to new table - $moveDataQuery = 'INSERT INTO `' . _DB_PREFIX_ . 'bk_buckaroo_fee` (reference, id_cart, buckaroo_fee_tax_incl, buckaroo_fee_tax_excl, currency, created_at) - SELECT reference, id_cart, buckaroo_fee, buckaroo_fee, currency, created_at - FROM `' . _DB_PREFIX_ . 'buckaroo_fee`'; + // Check if the old table exists + $tableExists = Db::getInstance()->executeS('SHOW TABLES LIKE "' . _DB_PREFIX_ . 'buckaroo_fee"'); + if ($tableExists) { + // Move data from old table to new table + $moveDataQuery = 'INSERT INTO `' . _DB_PREFIX_ . 'bk_buckaroo_fee` (reference, id_cart, buckaroo_fee_tax_incl, buckaroo_fee_tax_excl, currency, created_at) + SELECT reference, id_cart, buckaroo_fee, buckaroo_fee, currency, created_at + FROM `' . _DB_PREFIX_ . 'buckaroo_fee`'; - Db::getInstance()->execute($moveDataQuery); + Db::getInstance()->execute($moveDataQuery); - // Delete the old table - $deleteOldTableQuery = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'buckaroo_fee`'; - Db::getInstance()->execute($deleteOldTableQuery); + // Delete the old table + $deleteOldTableQuery = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'buckaroo_fee`'; + Db::getInstance()->execute($deleteOldTableQuery); + } - // Example of additional existing operations - Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . 'bk_giftcards` - ADD is_custom INT(11) DEFAULT 0 NOT NULL;'); + // Check if the column 'is_custom' already exists in 'bk_giftcards' + $columnExists = Db::getInstance()->executeS('SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'bk_giftcards` LIKE "is_custom"'); + if (empty($columnExists)) { + Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . 'bk_giftcards` + ADD is_custom INT(11) DEFAULT 0 NOT NULL;'); + } Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'bk_payment_methods WHERE name = "tinka"');