Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bp 3481 update test release v4.2.1 #168

Merged
merged 19 commits into from
Jun 20, 2024
Merged
4 changes: 2 additions & 2 deletions buckaroo3.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)');
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>buckaroo3</name>
<displayName><![CDATA[Buckaroo Payments (v 4.2.0)]]></displayName>
<version><![CDATA[4.2.0]]></version>
<description><![CDATA[Buckaroo Payment module. Compatible with PrestaShop version 1.7.x + 8.1.4]]></description>
<displayName><![CDATA[Buckaroo Payments (v 4.2.1)]]></displayName>
<version><![CDATA[4.2.1]]></version>
<description><![CDATA[Buckaroo Payment module. Compatible with PrestaShop version 1.7.x + 8.1.6]]></description>
<author><![CDATA[Buckaroo]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[Are you sure you want to delete Buckaroo Payments module?]]></confirmUninstall>
Expand Down
21 changes: 2 additions & 19 deletions library/checkout/billinkcheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -100,15 +101,14 @@ 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');
}

return $payload;
}


public function getRecipientCategory()
{
$category = self::CUSTOMER_TYPE_B2C;
Expand All @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions library/checkout/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,12 @@ protected function prepareBuckarooFeeArticle()
return [];
}

$buckarooFeeData['buckaroo_fee_tax'] = $buckarooFee['buckaroo_fee_tax_incl'] - $buckarooFee['buckaroo_fee_tax_excl'];

return [
'identifier' => '0',
'quantity' => '1',
'price' => round($buckarooFee['buckaroo_fee_tax_excl'], 2),
'price' => round($buckarooFeeData['buckaroo_fee_tax'], 2),
'vatPercentage' => '0',
'description' => 'buckaroo_fee',
];
Expand All @@ -370,7 +372,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'],
];
Expand Down
29 changes: 18 additions & 11 deletions upgrade/upgrade-4.2.1.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"');

Expand Down
Loading