From a1a5624065cbca18f601359dd31a31a0971c854a Mon Sep 17 00:00:00 2001 From: "v.carkaxhija" Date: Thu, 14 Nov 2024 23:59:48 +0100 Subject: [PATCH 1/2] refactor buckaroo fee --- Block/Adminhtml/Sales/Totals.php | 19 +- Block/Cart/BuckarooConfig.php | 50 ++- Helper/Data.php | 5 + Helper/PaymentFee.php | 257 ++-------------- Model/ConfigProvider/Account.php | 3 + Model/ConfigProvider/BuckarooFee.php | 37 +-- Model/Method/AbstractMethod.php | 94 ++++-- Model/Total/Quote/BuckarooAlreadyPay.php | 1 - Model/Total/Quote/BuckarooFee.php | 185 +++-------- Model/Total/Quote/BuckarooFeeHyva.php | 175 ++--------- Model/Total/Quote/Tax/BuckarooFee.php | 209 +++++++++---- Service/BuckarooFee/Calculate.php | 94 ++++++ Service/BuckarooFee/Result.php | 90 ++++++ Service/BuckarooFee/Types/FixedAmount.php | 60 ++++ Service/BuckarooFee/Types/Percentage.php | 74 +++++ Service/Sales/Pdf/BuckarooFee.php | 99 +++--- Service/Tax/TaxCalculate.php | 80 +++++ etc/adminhtml/system.xml | 3 - etc/adminhtml/system/account.xml | 8 +- etc/adminhtml/system/tax.xml | 48 --- etc/di.xml | 6 + .../sales/order/creditmemo/buckaroo_fee.phtml | 2 +- .../templates/sales/order/total.phtml | 2 +- view/frontend/web/js/model/buckaroo-fee.js | 56 ---- .../view/checkout/cart/totals/buckaroo_fee.js | 12 +- .../js/view/checkout/summary/already-paid.js | 3 - .../view/checkout/summary/remaining-amount.js | 3 - view/frontend/web/js/view/summary/totals.js | 287 ++++++++---------- .../template/cart/totals/buckaroo_fee.html | 24 -- .../web/template/summary/buckaroo_fee.html | 41 +-- 30 files changed, 963 insertions(+), 1064 deletions(-) mode change 100644 => 100755 Model/Total/Quote/BuckarooFee.php mode change 100644 => 100755 Model/Total/Quote/Tax/BuckarooFee.php create mode 100755 Service/BuckarooFee/Calculate.php create mode 100755 Service/BuckarooFee/Result.php create mode 100755 Service/BuckarooFee/Types/FixedAmount.php create mode 100755 Service/BuckarooFee/Types/Percentage.php create mode 100755 Service/Tax/TaxCalculate.php mode change 100644 => 100755 etc/adminhtml/system/account.xml delete mode 100644 etc/adminhtml/system/tax.xml delete mode 100644 view/frontend/web/js/model/buckaroo-fee.js diff --git a/Block/Adminhtml/Sales/Totals.php b/Block/Adminhtml/Sales/Totals.php index ec4787963..b8e8926bd 100644 --- a/Block/Adminhtml/Sales/Totals.php +++ b/Block/Adminhtml/Sales/Totals.php @@ -55,15 +55,9 @@ public function __construct( public function initTotals() { $parent = $this->getParentBlock(); - /** - * @noinspection PhpUndefinedMethodInspection - */ $source = $parent->getSource(); $totals = $this->getTotalsForCreditmemo($source); foreach ($totals as $total) { - /** - * @noinspection PhpUndefinedMethodInspection - */ $this->getParentBlock()->addTotalBefore(new \Magento\Framework\DataObject($total), 'grand_total'); } return $this; @@ -72,12 +66,9 @@ public function initTotals() public function getTotals() { $parent = $this->getParentBlock(); - /** - * @noinspection PhpUndefinedMethodInspection - */ $source = $parent->getSource(); - + return $this->getTotalsForCreditmemo($source); } @@ -92,7 +83,7 @@ public function getCurrentCurrencySymbol() } /** - * For credit memo display the fees from invoice/order, + * For credit memo display the fees from invoice/order, * check if invoice has that fee and set selected * * @param mixed $source @@ -107,7 +98,7 @@ protected function getTotalsForCreditmemo($source) $invoice = $source->getInvoice(); $salesModel = ($invoice != null? $invoice : $order); $saleTotals = $this->helper->getTotals($salesModel); - + $saleTotals = array_map(function($saleTotal) use($creditTotals) { if (in_array($saleTotal['code'],['buckaroo_fee', 'buckaroo_fee_excl'] )) { $saleTotal['block_name'] = "buckaroo_fee"; @@ -116,12 +107,12 @@ protected function getTotalsForCreditmemo($source) return $saleTotal; }, $saleTotals); - + return array_merge( $this->getTotalsByCode($creditTotals, 'buckaroo_already_paid'), $this->getTotalsExceptCode($saleTotals, 'buckaroo_already_paid') ); - + } return $this->helper->getTotals($source); } diff --git a/Block/Cart/BuckarooConfig.php b/Block/Cart/BuckarooConfig.php index 20be07519..416e29e35 100644 --- a/Block/Cart/BuckarooConfig.php +++ b/Block/Cart/BuckarooConfig.php @@ -1,11 +1,32 @@ configProviderFactory->get('buckaroo_fee'); - return $this->jsonEncoder->encode($configProvider->getConfig()); + return $this->jsonEncoder->serialize($configProvider->getConfig()); } } diff --git a/Helper/Data.php b/Helper/Data.php index 2b3de3220..68ba02557 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -261,6 +261,11 @@ public function getOriginalTransactionKey($orderId) return $this->groupTransaction->getGroupTransactionOriginalTransactionKey($orderId); } + public function getAlreadyPaid() + { + return $this->groupTransaction->getAlreadyPaid($this->getOrderId()); + } + public function getOrderId() { $orderId = $this->_checkoutSession->getQuote()->getReservedOrderId(); diff --git a/Helper/PaymentFee.php b/Helper/PaymentFee.php index b6e266ffa..e6c2a35bf 100644 --- a/Helper/PaymentFee.php +++ b/Helper/PaymentFee.php @@ -1,5 +1,4 @@ displaySalesBothPrices(); - $displayIncludeTaxPrice = $this->displaySalesIncludeTaxPrice(); - } elseif ($dataObject instanceof \Magento\Quote\Model\Quote\Address\Total) { - $displayBothPrices = $this->displayCartBothPrices(); - $displayIncludeTaxPrice = $this->displayCartIncludeTaxPrice(); - } + $taxClassId = $this->configProviderAccount->getBuckarooFeeTaxClass(); $label = $this->getBuckarooPaymentFeeLabel($dataObject); - /** - * Buckaroo fee for order totals - */ - if ($displayBothPrices || $displayIncludeTaxPrice) { - if ($displayBothPrices) { - /** - * @noinspection PhpUndefinedMethodInspection - */ - $this->addTotalToTotals( - $totals, - 'buckaroo_fee_excl', - $dataObject->getBuckarooFee(), - $dataObject->getBaseBuckarooFee(), - $label . __(' (Excl. Tax)'), - false, - true - ); - } - /** - * @noinspection PhpUndefinedMethodInspection - */ + $fee = $dataObject->getBuckarooFee(); + $feeTaxAmount = $dataObject->getBuckarooFeeTaxAmount(); + $baseFee = $dataObject->getBaseBuckarooFee(); + $baseFeeTaxAmount = $dataObject->getBuckarooFeeBaseTaxAmount(); + + // Check the setting to determine if the fee should include tax + if ($taxClassId && $this->buckarooPaymentCalculationInclTax()) { + // Add the fee with tax included $this->addTotalToTotals( $totals, - ($dataObject instanceof \Magento\Sales\Model\Order\Creditmemo) ? 'buckaroo_fee' : 'buckaroo_fee_incl', - $dataObject->getBuckarooFee() + $dataObject->getBuckarooFeeTaxAmount(), - $dataObject->getBaseBuckarooFee() + $dataObject->getBuckarooFeeBaseTaxAmount(), - $label . __(' (Incl. Tax)'), - ($dataObject instanceof \Magento\Sales\Model\Order\Creditmemo) ? 'buckaroo_fee' : false, - false, - [ - 'incl_tax' => true, - 'fee_with_tax' => $dataObject->getBuckarooFee() + $dataObject->getBuckarooFeeTaxAmount() - ] + 'buckaroo_fee_incl', + $fee + $feeTaxAmount, + $baseFee + $baseFeeTaxAmount, + $label . __(' (Incl. Tax)') ); } else { - /** - * @noinspection PhpUndefinedMethodInspection - */ + // Add the fee without tax $this->addTotalToTotals( $totals, 'buckaroo_fee', - $dataObject->getBuckarooFee(), - $dataObject->getBaseBuckarooFee(), - $label, - ($dataObject instanceof \Magento\Sales\Model\Order\Creditmemo) ? 'buckaroo_fee' : false, - false, - [ - 'incl_tax' => false, - 'fee_with_tax' => $dataObject->getBuckarooFee() + $dataObject->getBuckarooFeeTaxAmount() - ] + $fee, + $baseFee, + $label . __(' (Excl. Tax)') ); } $this->addAlreadyPayedTotals($dataObject, $totals); - //Set public object data - /** - * @noinspection PhpUndefinedMethodInspection - */ - $this->buckarooFee = $dataObject->getBuckarooFee(); - /** - * @noinspection PhpUndefinedMethodInspection - */ - $this->buckarooFeeTax = $dataObject->getBuckarooFeeTaxAmount(); + $this->buckarooFee = $fee; + $this->buckarooFeeTax = $feeTaxAmount; return $totals; } + + public function buckarooPaymentCalculationInclTax($store = null) + { + $configValue = $this->configProviderBuckarooFee->getPaymentFeeTax($store); + + return $configValue == DisplayType::DISPLAY_TYPE_INCLUDING_TAX; + } public function addAlreadyPayedTotals($dataObject, &$totals) { $order_id = $this->getOrderIncrementId($dataObject); $alreadyPayed = $this->groupTransaction->getAlreadyPaid($order_id); - + if (!$dataObject instanceof \Magento\Sales\Model\Order\Creditmemo && $alreadyPayed > 0) { unset($totals['buckaroo_fee']); $this->addTotalToTotals( @@ -178,7 +136,7 @@ public function addAlreadyPayedTotals($dataObject, &$totals) __('Paid with Giftcard / Voucher') ); return; - } + } if ($order_id !== null && $alreadyPayed > 0) { @@ -264,6 +222,7 @@ public function getOrderIncrementId($dataObject) return $dataObject->getOrder()->getIncrementId(); } } + /** * @return mixed */ @@ -310,9 +269,6 @@ public function getBuckarooPaymentFeeLabel($dataObject) * If a method is found, and the method has a config provider, try to get the label from config */ if ($method && $this->configProviderMethodFactory->has($method)) { - /** - * @noinspection PhpUndefinedMethodInspection - */ $label = $this->configProviderMethodFactory->get($method)->getPaymentFeeLabel(); } @@ -333,161 +289,6 @@ public function getBuckarooPaymentFeeLabel($dataObject) return $label; } - /** - * @param \Magento\Framework\DataObject $dataObject - * - * @return array - */ - public function getBuckarooPaymentFeeTotal($dataObject) - { - $totals = []; - - /** - * @noinspection PhpUndefinedMethodInspection - */ - $this->addTotalToTotals( - $totals, - 'buckaroo_fee', - $dataObject->getBuckarooFee() + $dataObject->getBuckarooFeeTaxAmount(), - $dataObject->getBaseBuckarooFee() + $dataObject->getBuckarooFeeBaseTaxAmount(), - $this->getBuckarooPaymentFeeLabel($dataObject) - ); - - return $totals; - } - - /** - * Check if the fee calculation has to be done with taxes - * - * @param \Magento\Store\Model\Store|int|null $store - * - * @return bool - */ - public function buckarooPaymentCalculationInclTax($store = null) - { - /** - * @noinspection PhpUndefinedMethodInspection - */ - $configValue = $this->configProviderBuckarooFee->getPaymentFeeTax($store); - - return $configValue == DisplayType::DISPLAY_TYPE_INCLUDING_TAX; - } - - /** - * Check if the fee calculation has to be done without taxes - * - * @param \Magento\Store\Model\Store|int|null $store - * - * @return bool - */ - public function buckarooPaymentFeeCalculationExclTax($store = null) - { - /** - * @noinspection PhpUndefinedMethodInspection - */ - $configValue = $this->configProviderBuckarooFee->getPaymentFeeTax($store); - - return $configValue == DisplayType::DISPLAY_TYPE_EXCLUDING_TAX; - } - - /** - * Check ability to display prices including tax for buckaroo fee in shopping cart - * - * @param \Magento\Store\Model\Store|int|null $store - * @return bool - */ - public function displayCartIncludeTaxPrice($store = null) - { - /** - * @noinspection PhpUndefinedMethodInspection - */ - $configValue = $this->configProviderBuckarooFee->getPriceDisplayCart($store); - - return $configValue == DisplayType::DISPLAY_TYPE_BOTH || - $configValue == DisplayType::DISPLAY_TYPE_INCLUDING_TAX; - } - - /** - * Check ability to display prices excluding tax for buckaroo fee in shopping cart - * - * @param \Magento\Store\Model\Store|int|null $store - * @return bool - */ - public function displayCartExcludeTaxPrice($store = null) - { - /** - * @noinspection PhpUndefinedMethodInspection - */ - $configValue = $this->configProviderBuckarooFee->getPriceDisplayCart($store); - - return $configValue == DisplayType::DISPLAY_TYPE_EXCLUDING_TAX; - } - - /** - * Check ability to display both prices for buckaroo fee in shopping cart - * - * @param \Magento\Store\Model\Store|int|null $store - * @return bool - */ - public function displayCartBothPrices($store = null) - { - /** - * @noinspection PhpUndefinedMethodInspection - */ - $configValue = $this->configProviderBuckarooFee->getPriceDisplayCart($store); - - return $configValue == DisplayType::DISPLAY_TYPE_BOTH; - } - - /** - * Check ability to display prices including tax for buckaroo fee in backend sales - * - * @param \Magento\Store\Model\Store|int|null $store - * @return bool - */ - public function displaySalesIncludeTaxPrice($store = null) - { - /** - * @noinspection PhpUndefinedMethodInspection - */ - $configValue = $this->configProviderBuckarooFee->getPriceDisplaySales($store); - - return $configValue == DisplayType::DISPLAY_TYPE_BOTH || - $configValue == DisplayType::DISPLAY_TYPE_INCLUDING_TAX; - } - - /** - * Check ability to display prices excluding tax for buckaroo fee in backend sales - * - * @param \Magento\Store\Model\Store|int|null $store - * @return bool - */ - public function displaySalesExcludeTaxPrice($store = null) - { - /** - * @noinspection PhpUndefinedMethodInspection - */ - $configValue = $this->configProviderBuckarooFee->getPriceDisplaySales($store); - - return $configValue == DisplayType::DISPLAY_TYPE_EXCLUDING_TAX; - } - - /** - * Check ability to display both prices for buckaroo fee in backend sales - * - * @param \Magento\Store\Model\Store|int|null $store - * @return bool - */ - public function displaySalesBothPrices($store = null) - { - /** - * @noinspection PhpUndefinedMethodInspection - */ - $configValue = $this->configProviderBuckarooFee->getPriceDisplaySales($store); - - return $configValue == DisplayType::DISPLAY_TYPE_BOTH; - } - /** * Add total into array totals * diff --git a/Model/ConfigProvider/Account.php b/Model/ConfigProvider/Account.php index 7fc5a46bb..0c75bb5c7 100644 --- a/Model/ConfigProvider/Account.php +++ b/Model/ConfigProvider/Account.php @@ -48,6 +48,7 @@ * @method mixed getPaymentFeeLabel() * @method mixed getCreateOrderBeforeTransaction() * @method mixed getCustomerAdditionalInfo() + * @method mixed getBuckarooFeeTaxClass() */ class Account extends AbstractConfigProvider { @@ -86,6 +87,7 @@ class Account extends AbstractConfigProvider const XPATH_ACCOUNT_IDIN_MODE = 'buckaroo_magento2/account/idin_mode'; const XPATH_ACCOUNT_IDIN_CATEGORY = 'buckaroo_magento2/account/idin_category'; const XPATH_ACCOUNT_ADVANCED_EXPORT_GIFTCARDS = 'buckaroo_magento2/account/advanced_export_giftcards'; + const XPATH_ACCOUNT_BUCKAROO_FEE_TAX_CLASS = 'buckaroo_magento2/account/buckaroo_fee_tax_class'; /** * @var MethodFactory @@ -143,6 +145,7 @@ public function getConfig($store = null) 'cart_keep_alive' => $this->getCartKeepAlive($store),//can be changed from cli/db only 'selection_type' => $this->getSelectionType($store), 'customer_additional_info' => $this->getCustomerAdditionalInfo($store), + 'buckaroo_fee_tax_class' => $this->getBuckarooFeeTaxClass($store), 'idin' => $this->getIdin($store), 'idin_mode' => $this->getIdinMode($store), 'idin_category' => $this->getIdinCategory($store), diff --git a/Model/ConfigProvider/BuckarooFee.php b/Model/ConfigProvider/BuckarooFee.php index 1aebe86d5..5411167a3 100644 --- a/Model/ConfigProvider/BuckarooFee.php +++ b/Model/ConfigProvider/BuckarooFee.php @@ -20,8 +20,6 @@ namespace Buckaroo\Magento2\Model\ConfigProvider; -use \Buckaroo\Magento2\Model\Config\Source\Display\Type as DisplayType; - /** * @method int getPriceDisplayCart() * @method int getPriceDisplaySales() @@ -36,19 +34,15 @@ class BuckarooFee extends AbstractConfigProvider const XPATH_BUCKAROOFEE_TAX_CLASS = 'tax/classes/buckaroo_fee_tax_class'; /** - * Calculation fee tax settings - */ - const XPATH_BUCKAROOFEE_PAYMENT_FEE_TAX = 'tax/calculation/buckaroo_fee'; - - /** - * Shopping cart display settings - */ - const XPATH_BUCKAROOFEE_PRICE_DISPLAY_CART = 'tax/cart_display/buckaroo_fee'; - - /** - * Sales display settings + * Retrieve the tax class for Buckaroo fee + * + * @param null $store + * @return int|string */ - const XPATH_BUCKAROOFEE_PRICE_DISPLAY_SALES = 'tax/sales_display/buckaroo_fee'; + public function getBuckarooFeeTaxClass($store = null) + { + return $this->scopeConfig->getValue(self::XPATH_BUCKAROOFEE_TAX_CLASS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store); + } /** * Retrieve associated array of checkout configuration @@ -61,20 +55,7 @@ public function getConfig($store = null) { return [ 'buckarooFee' => [ - 'calculation' => [ - 'buckarooPaymentFeeInclTax' => - $this->getPaymentFeeTax() == DisplayType::DISPLAY_TYPE_INCLUDING_TAX, - ], - 'cart' => [ - 'displayBuckarooFeeBothPrices' => $this->getPriceDisplayCart() == DisplayType::DISPLAY_TYPE_BOTH, - 'displayBuckarooFeeInclTax' => $this->getPriceDisplayCart() == DisplayType::DISPLAY_TYPE_BOTH - || $this->getPriceDisplayCart() == DisplayType::DISPLAY_TYPE_INCLUDING_TAX, - ], - 'sales' => [ - 'displayBuckarooFeeBothPrices' => $this->getPriceDisplaySales() == DisplayType::DISPLAY_TYPE_BOTH, - 'displayBuckarooFeeInclTax' => $this->getPriceDisplaySales() == DisplayType::DISPLAY_TYPE_BOTH - || $this->getPriceDisplaySales() == DisplayType::DISPLAY_TYPE_INCLUDING_TAX, - ], + 'tax_class_id' => $this->getBuckarooFeeTaxClass($store), ], ]; } diff --git a/Model/Method/AbstractMethod.php b/Model/Method/AbstractMethod.php index 5427c5bca..1f3a5f2ec 100644 --- a/Model/Method/AbstractMethod.php +++ b/Model/Method/AbstractMethod.php @@ -21,7 +21,27 @@ namespace Buckaroo\Magento2\Model\Method; +use Buckaroo\Magento2\Gateway\GatewayInterface; +use Buckaroo\Magento2\Gateway\Http\TransactionBuilderFactory; +use Buckaroo\Magento2\Model\ConfigProvider\BuckarooFee; +use Buckaroo\Magento2\Model\ConfigProvider\Factory; use Buckaroo\Magento2\Model\ConfigProvider\Refund as RefundConfigProvider; +use Buckaroo\Magento2\Model\RefundFieldsFactory; +use Buckaroo\Magento2\Model\ValidatorFactory; +use Magento\Framework\Api\AttributeValueFactory; +use Magento\Framework\Api\ExtensionAttributesFactory; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\Data\Collection\AbstractDb; +use Magento\Framework\Event\ManagerInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Model\Context; +use Magento\Framework\Model\ResourceModel\AbstractResource; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; +use Magento\Payment\Helper\Data; +use Magento\Payment\Model\Method\Logger; +use Magento\Quote\Model\QuoteFactory; use Magento\Tax\Model\Config; use Magento\Sales\Model\Order; use Magento\Framework\Phrase; @@ -226,37 +246,41 @@ abstract class AbstractMethod extends \Magento\Payment\Model\Method\AbstractMeth protected $_code; /** - * @var EventManager + * @var ManagerInterface */ private $eventManager; /** - * @param \Magento\Framework\ObjectManagerInterface $objectManager - * @param \Magento\Framework\Model\Context $context - * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory - * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory - * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Payment\Model\Method\Logger $logger + * @param ObjectManagerInterface $objectManager + * @param Context $context + * @param Registry $registry + * @param ExtensionAttributesFactory $extensionFactory + * @param AttributeValueFactory $customAttributeFactory + * @param Data $paymentData + * @param ScopeConfigInterface $scopeConfig + * @param Logger $logger * @param \Magento\Developer\Helper\Data $developmentHelper - * @param \Magento\Quote\Model\QuoteFactory $quoteFactory - * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection - * @param \Buckaroo\Magento2\Gateway\GatewayInterface $gateway - * @param \Buckaroo\Magento2\Gateway\Http\TransactionBuilderFactory $transactionBuilderFactory - * @param \Buckaroo\Magento2\Model\ValidatorFactory $validatorFactory - * @param \Buckaroo\Magento2\Helper\Data $helper - * @param \Magento\Framework\App\RequestInterface $request - * @param \Buckaroo\Magento2\Model\RefundFieldsFactory $refundFieldsFactory - * @param \Buckaroo\Magento2\Model\ConfigProvider\Factory $configProviderFactory - * @param \Buckaroo\Magento2\Model\ConfigProvider\Method\Factory $configProviderMethodFactory - * @param \Magento\Framework\Pricing\Helper\Data $priceHelper + * @param QuoteFactory $quoteFactory + * @param Config $taxConfig + * @param Calculation $taxCalculation + * @param BuckarooFee $configProviderBuckarooFee + * @param BuckarooLog $buckarooLog + * @param SoftwareData $softwareData + * @param AddressFactory $addressFactory + * @param ManagerInterface $eventManager + * @param AbstractResource|null $resource + * @param AbstractDb|null $resourceCollection + * @param GatewayInterface|null $gateway + * @param TransactionBuilderFactory|null $transactionBuilderFactory + * @param ValidatorFactory|null $validatorFactory + * @param \Buckaroo\Magento2\Helper\Data|null $helper + * @param RequestInterface|null $request + * @param RefundFieldsFactory|null $refundFieldsFactory + * @param Factory|null $configProviderFactory + * @param \Buckaroo\Magento2\Model\ConfigProvider\Method\Factory|null $configProviderMethodFactory + * @param \Magento\Framework\Pricing\Helper\Data|null $priceHelper * @param array $data * - * @param GroupTransaction $groupTransaction - * - * @throws \Buckaroo\Magento2\Exception */ public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, @@ -275,7 +299,7 @@ public function __construct( BuckarooLog $buckarooLog, SoftwareData $softwareData, AddressFactory $addressFactory, - \Magento\Framework\Event\ManagerInterface $eventManager, + ManagerInterface $eventManager, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, \Buckaroo\Magento2\Gateway\GatewayInterface $gateway = null, @@ -666,6 +690,7 @@ public function getRemoteAddress($ipToLong = false, $alternativeHeaders = []) /** * @return string * @throws \Buckaroo\Magento2\Exception + * @throws LocalizedException */ public function getTitle() { @@ -685,19 +710,24 @@ public function getTitle() } $paymentFee = trim($this->configProviderMethodFactory->get($this->buckarooPaymentMethodCode)->getPaymentFee()); - if (!$paymentFee || (float) $paymentFee < 0.01) { - return $title; - } - if (strpos($paymentFee, '%') === false) { - $title .= ' + ' . $this->priceHelper->currency(number_format($paymentFee, 2), true, false); - } else { - $title .= ' + ' . $paymentFee; + if(!$this->helper->getAlreadyPaid()){ + if (!$paymentFee || (float) $paymentFee < 0.01) { + return $title; + } + + if (strpos($paymentFee, '%') === false) { + $title .= ' + ' . $this->priceHelper->currency(number_format($paymentFee, 2), true, false); + } else { + $title .= ' + ' . $paymentFee; + } } return $title; } + + /** * @return bool|string */ diff --git a/Model/Total/Quote/BuckarooAlreadyPay.php b/Model/Total/Quote/BuckarooAlreadyPay.php index 9efb45f73..b11157117 100644 --- a/Model/Total/Quote/BuckarooAlreadyPay.php +++ b/Model/Total/Quote/BuckarooAlreadyPay.php @@ -104,7 +104,6 @@ public function fetch(Quote $quote, Total $total) } } } catch (\Exception $e) { - // $this->logger->error($e->getMessage()); } } diff --git a/Model/Total/Quote/BuckarooFee.php b/Model/Total/Quote/BuckarooFee.php old mode 100644 new mode 100755 index 57ef22de3..88cfa8f21 --- a/Model/Total/Quote/BuckarooFee.php +++ b/Model/Total/Quote/BuckarooFee.php @@ -17,116 +17,77 @@ * @copyright Copyright (c) Buckaroo B.V. * @license https://tldrlegal.com/license/mit-license */ + namespace Buckaroo\Magento2\Model\Total\Quote; -use Buckaroo\Magento2\Exception; -use Magento\Catalog\Helper\Data; -use Buckaroo\Magento2\Logging\Log; use Buckaroo\Magento2\Helper\PaymentGroupTransaction; +use Buckaroo\Magento2\Service\BuckarooFee\Calculate; +use Magento\Framework\Phrase; use Magento\Framework\Pricing\PriceCurrencyInterface; +use Magento\Quote\Api\Data\ShippingAssignmentInterface; +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\Quote\Address\Total; use Magento\Quote\Model\Quote\Address\Total\AbstractTotal; -use Magento\Tax\Model\Calculation as TaxModelCalculation; -use Buckaroo\Magento2\Model\ConfigProvider\Method\Factory; -use Buckaroo\Magento2\Model\Config\Source\TaxClass\Calculation; -use Buckaroo\Magento2\Model\ConfigProvider\Account as ConfigProviderAccount; -use Buckaroo\Magento2\Model\ConfigProvider\BuckarooFee as ConfigProviderBuckarooFee; +use Psr\Log\LoggerInterface; class BuckarooFee extends AbstractTotal { - /** - * @var ConfigProviderAccount - */ - protected $configProviderAccount; - - /** - * @var ConfigProviderBuckarooFee - */ - protected $configProviderBuckarooFee; - - /** - * @var Factory - */ - protected $configProviderMethodFactory; - /** * @var PriceCurrencyInterface */ public $priceCurrency; - /** - * @var Data - */ - public $catalogHelper; - /** * @var PaymentGroupTransaction */ public $groupTransaction; /** - * @var Calculation + * @var Calculate */ - protected $taxCalculation; + protected $calculate; - /** - * @var Log $logging - */ - protected $logging; + protected $logger; /** - * @param ConfigProviderAccount $configProviderAccount - * @param ConfigProviderBuckarooFee $configProviderBuckarooFee - * @param Factory $configProviderMethodFactory * @param PriceCurrencyInterface $priceCurrency - * @param Data $catalogHelper * @param PaymentGroupTransaction $groupTransaction - * @param Log $logging - * @param TaxModelCalculation $taxCalculation + * @param Calculate $calculate */ public function __construct( - ConfigProviderAccount $configProviderAccount, - ConfigProviderBuckarooFee $configProviderBuckarooFee, - Factory $configProviderMethodFactory, PriceCurrencyInterface $priceCurrency, - Data $catalogHelper, PaymentGroupTransaction $groupTransaction, - Log $logging, - TaxModelCalculation $taxCalculation + Calculate $calculate, + LoggerInterface $logger ) { $this->setCode('buckaroo_fee'); - $this->configProviderAccount = $configProviderAccount; - $this->configProviderBuckarooFee = $configProviderBuckarooFee; - $this->configProviderMethodFactory = $configProviderMethodFactory; $this->priceCurrency = $priceCurrency; - $this->catalogHelper = $catalogHelper; - $this->groupTransaction = $groupTransaction; - $this->logging = $logging; - $this->taxCalculation = $taxCalculation; + $this->calculate = $calculate; + $this->logger = $logger; } /** * Collect grand total address amount * - * @param \Magento\Quote\Model\Quote $quote - * @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment - * @param \Magento\Quote\Model\Quote\Address\Total $total - * @return $this + * @param Quote $quote + * @param ShippingAssignmentInterface $shippingAssignment + * @param Total $total * - * @throws \Buckaroo\Magento2\Exception - * @throws Exception + * @return $this */ public function collect( - \Magento\Quote\Model\Quote $quote, - \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment, - \Magento\Quote\Model\Quote\Address\Total $total + Quote $quote, + ShippingAssignmentInterface $shippingAssignment, + Total $total ) { parent::collect($quote, $shippingAssignment, $total); if (!$shippingAssignment->getItems()) { return $this; } + /** * @noinspection PhpUndefinedMethodInspection */ @@ -143,49 +104,39 @@ public function collect( return $this; } - $paymentMethod = $quote->getPayment()->getMethod(); - if (!$paymentMethod || strpos($paymentMethod, 'buckaroo_magento2_') !== 0) { - return $this; - } - - $methodInstance = $quote->getPayment()->getMethodInstance(); - if (!$methodInstance instanceof \Buckaroo\Magento2\Model\Method\AbstractMethod) { - return $this; - } + $result = $this->calculate->calculatePaymentFee($quote, $total); - // Calculate the base payment fee using the getBaseFee method - $basePaymentFee = $this->getBaseFee($methodInstance, $quote, $total); - if ($basePaymentFee < 0.01) { + if ($result === null || $result->getAmount() < 0.01){ return $this; } - - $paymentFee = $this->priceCurrency->convert($basePaymentFee, $quote->getStore()); + $amount = $this->priceCurrency->convert($result->getRoundedAmount()); /** * @noinspection PhpUndefinedMethodInspection */ - $quote->setBuckarooFee($paymentFee); + $quote->setBuckarooFee($amount); /** * @noinspection PhpUndefinedMethodInspection */ - $quote->setBaseBuckarooFee($basePaymentFee); + $quote->setBaseBuckarooFee($result->getRoundedAmount()); /** * @noinspection PhpUndefinedMethodInspection */ - $total->setBuckarooFee($paymentFee); + $total->setBuckarooFee($amount); /** * @noinspection PhpUndefinedMethodInspection */ - $total->setBaseBuckarooFee($basePaymentFee); + $total->setBaseBuckarooFee($result->getRoundedAmount()); /** * @noinspection PhpUndefinedMethodInspection */ - $total->setBaseGrandTotal($total->getBaseGrandTotal() + $basePaymentFee); + $total->setGrandTotal($total->getGrandTotal() + $amount); + /** * @noinspection PhpUndefinedMethodInspection */ - $total->setGrandTotal($total->getGrandTotal() + $paymentFee); + $total->setBaseGrandTotal($total->getBaseGrandTotal() + $result->getRoundedAmount()); return $this; } @@ -193,11 +144,11 @@ public function collect( /** * Add buckaroo fee information to address * - * @param \Magento\Quote\Model\Quote $quote - * @param \Magento\Quote\Model\Quote\Address\Total $total + * @param Quote $quote + * @param Total $total * @return array */ - public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total) + public function fetch(Quote $quote, Total $total) { /** * @noinspection PhpUndefinedMethodInspection @@ -214,72 +165,10 @@ public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Qu ]; } - /** - * @param \Buckaroo\Magento2\Model\Method\AbstractMethod $methodInstance - * @param \Magento\Quote\Model\Quote $quote - * @param \Magento\Quote\Model\Quote\Address\Total $total - * - * @return bool|false|float - * @throws \Buckaroo\Magento2\Exception - */ - public function getBaseFee( - \Buckaroo\Magento2\Model\Method\AbstractMethod $methodInstance, - \Magento\Quote\Model\Quote $quote, - \Magento\Quote\Model\Quote\Address\Total $total - ) { - $buckarooPaymentMethodCode = $methodInstance->buckarooPaymentMethodCode; - if (!$this->configProviderMethodFactory->has($buckarooPaymentMethodCode)) { - return false; - } - - $configProvider = $this->configProviderMethodFactory->get($buckarooPaymentMethodCode); - $basePaymentFeeRaw = trim($configProvider->getPaymentFee($quote->getStore())); - - $inclTax= $this->configProviderBuckarooFee->getPaymentFeeTax() == - Calculation::DISPLAY_TYPE_INCLUDING_TAX; - - // Determine if the fee is a percentage or fixed amount - $isPercentage = strpos($basePaymentFeeRaw, '%') !== false; - - if ($isPercentage) { - $subtotal = $total->getData('base_subtotal_incl_tax'); - if (!$subtotal) { - $subtotal = $total->getTotalAmount('subtotal'); - } - $percentage = (float) rtrim($basePaymentFeeRaw, '%'); - $basePaymentFee = ($percentage / 100) * $subtotal; - } else { - $basePaymentFee = (float) $basePaymentFeeRaw; - } - - if (!$inclTax) { - $shippingAddress = $quote->getShippingAddress() ?: $quote->getBillingAddress(); - $billingAddress = $quote->getBillingAddress(); - $customerTaxClassId = $quote->getCustomerTaxClassId(); - $storeId = $quote->getStoreId(); - $taxClassId = $this->configProviderBuckarooFee->getTaxClass(); - if (!$taxClassId) { - $taxClassId = 0; - } - - $taxRate = $this->taxCalculation->getRate( - $this->taxCalculation->getRateRequest( - $shippingAddress, - $billingAddress, - $customerTaxClassId, - $storeId - )->setProductClassId($taxClassId) - ); - $basePaymentFee = $basePaymentFee * (1 + $taxRate / 100); - } - - return $basePaymentFee; - } - /** * Get Buckaroo label * - * @return \Magento\Framework\Phrase + * @return Phrase */ public function getLabel() { diff --git a/Model/Total/Quote/BuckarooFeeHyva.php b/Model/Total/Quote/BuckarooFeeHyva.php index 036ef0164..f407ef911 100644 --- a/Model/Total/Quote/BuckarooFeeHyva.php +++ b/Model/Total/Quote/BuckarooFeeHyva.php @@ -21,55 +21,31 @@ use Buckaroo\Magento2\Exception; use Buckaroo\Magento2\Helper\PaymentGroupTransaction; -use Buckaroo\Magento2\Logging\Log; -use Buckaroo\Magento2\Model\Config\Source\TaxClass\Calculation; -use Buckaroo\Magento2\Model\ConfigProvider\Account as ConfigProviderAccount; -use Buckaroo\Magento2\Model\ConfigProvider\BuckarooFee as ConfigProviderBuckarooFee; -use Buckaroo\Magento2\Model\ConfigProvider\Method\Factory; +use Buckaroo\Magento2\Service\BuckarooFee\Calculate; use Buckaroo\Magento2\Service\HyvaCheckoutConfig; -use Magento\Catalog\Helper\Data; +use Magento\Framework\Phrase; use Magento\Framework\Pricing\PriceCurrencyInterface; +use Magento\Quote\Api\Data\ShippingAssignmentInterface; use Magento\Quote\Model\Quote; use Magento\Quote\Model\Quote\Address\Total; -use Magento\Tax\Model\Calculation as TaxModelCalculation; +use Magento\Quote\Model\Quote\Address\Total\AbstractTotal; -class BuckarooFeeHyva extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal +class BuckarooFeeHyva extends AbstractTotal { - /** @var ConfigProviderAccount */ - protected $configProviderAccount; - - /** @var ConfigProviderBuckarooFee */ - protected $configProviderBuckarooFee; - - /** - * @var Factory - */ - protected $configProviderMethodFactory; - /** * @var PriceCurrencyInterface */ public $priceCurrency; - /** - * @var Data - */ - public $catalogHelper; - /** * @var PaymentGroupTransaction */ public $groupTransaction; /** - * @var Calculation - */ - protected $taxCalculation; - - /** - * @var Log $logging + * @var Calculate */ - protected $logging; + protected $calculate; /** * @var HyvaCheckoutConfig @@ -77,56 +53,39 @@ class BuckarooFeeHyva extends \Magento\Quote\Model\Quote\Address\Total\AbstractT protected $configProvider; /** - * @param ConfigProviderAccount $configProviderAccount - * @param ConfigProviderBuckarooFee $configProviderBuckarooFee - * @param Factory $configProviderMethodFactory * @param PriceCurrencyInterface $priceCurrency - * @param Data $catalogHelper * @param PaymentGroupTransaction $groupTransaction - * @param Log $logging - * @param TaxModelCalculation $taxCalculation * @param HyvaCheckoutConfig $configProvider + * @param Calculate $calculate */ public function __construct( - ConfigProviderAccount $configProviderAccount, - ConfigProviderBuckarooFee $configProviderBuckarooFee, - Factory $configProviderMethodFactory, PriceCurrencyInterface $priceCurrency, - Data $catalogHelper, PaymentGroupTransaction $groupTransaction, - Log $logging, - TaxModelCalculation $taxCalculation, HyvaCheckoutConfig $configProvider, + Calculate $calculate ) { $this->setCode('buckaroo_fee_hyva'); - $this->configProviderAccount = $configProviderAccount; - $this->configProviderBuckarooFee = $configProviderBuckarooFee; - $this->configProviderMethodFactory = $configProviderMethodFactory; $this->priceCurrency = $priceCurrency; - $this->catalogHelper = $catalogHelper; - $this->groupTransaction = $groupTransaction; - $this->logging = $logging; - $this->taxCalculation = $taxCalculation; $this->configProvider = $configProvider; + $this->calculate = $calculate; } /** * Collect grand total address amount * - * @param \Magento\Quote\Model\Quote $quote - * @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment - * @param \Magento\Quote\Model\Quote\Address\Total $total + * @param Quote $quote + * @param ShippingAssignmentInterface $shippingAssignment + * @param Total $total * @return $this * - * @throws \LogicException * @throws Exception */ public function collect( - \Magento\Quote\Model\Quote $quote, - \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment, - \Magento\Quote\Model\Quote\Address\Total $total + Quote $quote, + ShippingAssignmentInterface $shippingAssignment, + Total $total ) { if (!$this->configProvider->isHyvaCheckoutEnabled()) { return $this; @@ -155,39 +114,26 @@ public function collect( return $this; } - // Ensure payment method is set correctly - $paymentMethod = $quote->getPayment()->getMethod(); - if (!$paymentMethod || strpos($paymentMethod, 'buckaroo_magento2_') !== 0) { - return $this; - } - - $methodInstance = $quote->getPayment()->getMethodInstance(); - if (!$methodInstance instanceof \Buckaroo\Magento2\Model\Method\AbstractMethod) { - return $this; - } + $result = $this->calculate->calculatePaymentFee($quote, $total); - // Calculate the base payment fee using the getBaseFee method - $basePaymentFee = $this->getBaseFee($methodInstance, $quote, $total); - if ($basePaymentFee < 0.01) { + if ($result === null || $result->getAmount() < 0.01){ return $this; } - // Convert the fee to the store's currency - $paymentFee = $this->priceCurrency->convert($basePaymentFee, $quote->getStore()); + $amount = $this->priceCurrency->convert($result->getRoundedAmount()); // Add fee amounts using addTotalAmount to ensure proper accumulation with other totals - $total->addTotalAmount('buckaroo_fee_hyva', $paymentFee); - $total->addBaseTotalAmount('buckaroo_fee_hyva', $basePaymentFee); + $total->addTotalAmount('buckaroo_fee_hyva', $amount); + $total->addBaseTotalAmount('buckaroo_fee_hyva', $result->getRoundedAmount()); - // Set the fee on the total object for further calculations /** * @noinspection PhpUndefinedMethodInspection */ - $total->setBuckarooFee($paymentFee); + $total->setBuckarooFee($amount); /** * @noinspection PhpUndefinedMethodInspection */ - $total->setBaseBuckarooFee($basePaymentFee); + $total->setBaseBuckarooFee($result->getRoundedAmount()); return $this; } @@ -199,88 +145,19 @@ public function collect( * @param Total $total * @return array */ - public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total) + public function fetch(Quote $quote, Total $total) { - // Determine whether to include tax in the fee value based on your configuration settings - $includeTax = $this->configProviderBuckarooFee->getPaymentFeeTax() == \Buckaroo\Magento2\Model\Config\Source\TaxClass\Calculation::DISPLAY_TYPE_INCLUDING_TAX; - - // Calculate the value based on the settings (either including or excluding tax) - $value = $includeTax ? $total->getBuckarooFeeInclTax() : $total->getBuckarooFee(); - return [ 'code' => $this->getCode(), 'title' => $this->getLabel(), - 'value' => $value + 'value' => $total->getBuckarooFee() ]; } - /** - * @param \Buckaroo\Magento2\Model\Method\AbstractMethod $methodInstance - * @param \Magento\Quote\Model\Quote $quote - * @param \Magento\Quote\Model\Quote\Address\Total $total - * - * @return bool|false|float - * @throws \Buckaroo\Magento2\Exception - */ - public function getBaseFee( - \Buckaroo\Magento2\Model\Method\AbstractMethod $methodInstance, - \Magento\Quote\Model\Quote $quote, - \Magento\Quote\Model\Quote\Address\Total $total - ) { - $buckarooPaymentMethodCode = $methodInstance->buckarooPaymentMethodCode; - if (!$this->configProviderMethodFactory->has($buckarooPaymentMethodCode)) { - return false; - } - - $configProvider = $this->configProviderMethodFactory->get($buckarooPaymentMethodCode); - $basePaymentFeeRaw = trim($configProvider->getPaymentFee($quote->getStore())); - - $inclTax= $this->configProviderBuckarooFee->getPaymentFeeTax() == - Calculation::DISPLAY_TYPE_INCLUDING_TAX; - - // Determine if the fee is a percentage or fixed amount - $isPercentage = strpos($basePaymentFeeRaw, '%') !== false; - - if ($isPercentage) { - $subtotal = $total->getData('base_subtotal_incl_tax'); - if (!$subtotal) { - $subtotal = $total->getTotalAmount('subtotal'); - } - $percentage = (float) rtrim($basePaymentFeeRaw, '%'); - $basePaymentFee = ($percentage / 100) * $subtotal; - } else { - $basePaymentFee = (float) $basePaymentFeeRaw; - } - - if (!$inclTax) { - $shippingAddress = $quote->getShippingAddress() ?: $quote->getBillingAddress(); - $billingAddress = $quote->getBillingAddress(); - $customerTaxClassId = $quote->getCustomerTaxClassId(); - $storeId = $quote->getStoreId(); - $taxClassId = $this->configProviderBuckarooFee->getTaxClass(); - if (!$taxClassId) { - $taxClassId = 0; - } - - $taxRate = $this->taxCalculation->getRate( - $this->taxCalculation->getRateRequest( - $shippingAddress, - $billingAddress, - $customerTaxClassId, - $storeId - )->setProductClassId($taxClassId) - ); - $paymentFee = $basePaymentFee * (1 + $taxRate / 100); - } else { - $paymentFee = $basePaymentFee; - } - - return $paymentFee; - } /** * Get Buckaroo label * - * @return \Magento\Framework\Phrase + * @return Phrase */ public function getLabel() { diff --git a/Model/Total/Quote/Tax/BuckarooFee.php b/Model/Total/Quote/Tax/BuckarooFee.php old mode 100644 new mode 100755 index 6ba49db52..f16b6ecba --- a/Model/Total/Quote/Tax/BuckarooFee.php +++ b/Model/Total/Quote/Tax/BuckarooFee.php @@ -1,5 +1,4 @@ getConstructor(); + + // The parent call fails when running setup:di:compile in 2.4.3 and lower due to an extra parameter. + if ($parentConstructor->getNumberOfParameters() == 9) { + // @phpstan-ignore-next-line + parent::__construct( + $taxConfig, + $taxCalculationService, + $quoteDetailsDataObjectFactory, + $quoteDetailsItemDataObjectFactory, + $taxClassKeyDataObjectFactory, + $customerAddressFactory, + $customerAddressRegionFactory, + $taxHelper, + $quoteDetailsItemExtensionInterfaceFactory + ); + } else { + // @phpstan-ignore-next-line + parent::__construct( + $taxConfig, + $taxCalculationService, + $quoteDetailsDataObjectFactory, + $quoteDetailsItemDataObjectFactory, + $taxClassKeyDataObjectFactory, + $customerAddressFactory, + $customerAddressRegionFactory, + $taxHelper, + $quoteDetailsItemExtensionInterfaceFactory, + $customerAccountManagement + ); + } + + $this->priceCurrency = $priceCurrency; + $this->groupTransaction = $groupTransaction; + $this->calculate = $calculate; + $this->configProviderAccount = $configProviderAccount; $this->setCode('pretax_buckaroo_fee'); } /** * Collect buckaroo fee related items and add them to tax calculation * - * @param \Magento\Quote\Model\Quote $quote - * @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment - * @param \Magento\Quote\Model\Quote\Address\Total $total + * @param Quote $quote + * @param ShippingAssignmentInterface $shippingAssignment + * @param Total $total * @return $this */ public function collect( - \Magento\Quote\Model\Quote $quote, - \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment, - \Magento\Quote\Model\Quote\Address\Total $total + Quote $quote, + ShippingAssignmentInterface $shippingAssignment, + Total $total ) { if (!$shippingAssignment->getItems()) { return $this; } - $paymentMethod = $quote->getPayment()->getMethod(); - if (!$paymentMethod || strpos($paymentMethod, 'buckaroo_magento2_') !== 0) { + $orderId = $quote->getReservedOrderId(); + + // Check if already paid amount is affecting the calculation + if ($this->groupTransaction->getAlreadyPaid($orderId) > 0) { return $this; } - $methodInstance = $quote->getPayment()->getMethodInstance(); - if (!$methodInstance instanceof \Buckaroo\Magento2\Model\Method\AbstractMethod) { + $result = $this->calculate->calculatePaymentFee($quote, $total); + if ($result === null){ return $this; } + $amount = $this->priceCurrency->convert($result->getRoundedAmount()); - $orderId = $quote->getReservedOrderId(); + $this->addAssociatedTaxable($shippingAssignment, $result, $quote); - if ($this->groupTransaction->getAlreadyPaid($orderId) > 0) { - return $this; - } + $feeDataObject = $this->quoteDetailsItemDataObjectFactory->create() + ->setType('buckaroo_fee') + ->setCode('buckaroo_fee') + ->setQuantity(1); - $basePaymentFee = $this->getBaseFee($methodInstance, $quote, $total); + $feeDataObject->setUnitPrice($result->getRoundedAmount()); + $feeDataObject->setTaxClassKey( + $this->taxClassKeyDataObjectFactory->create() + ->setType(TaxClassKeyInterface::TYPE_ID) + ->setValue(4) + ); + $feeDataObject->setIsTaxIncluded(true); - if ($basePaymentFee < 0.01) { - return $this; - } + $quoteDetails = $this->prepareQuoteDetails($shippingAssignment, [$feeDataObject]); + + $this->taxCalculationService->calculateTax($quoteDetails, $quote->getStoreId()); - $paymentFee = $this->priceCurrency->convert($basePaymentFee, $quote->getStore()); + parent::collect($quote, $shippingAssignment, $total); - $productTaxClassId = $this->configProviderBuckarooFee->getTaxClass($quote->getStore()); + + return $this; + } + + /** + * @param ShippingAssignmentInterface $shippingAssignment + * @param Result $result + * @param Quote $quote + */ + private function addAssociatedTaxable(ShippingAssignmentInterface $shippingAssignment, Result $result, Quote $quote) + { + $fullAmount = $this->priceCurrency->convert($result->getRoundedAmount()); $address = $shippingAssignment->getShipping()->getAddress(); /** @@ -118,23 +210,22 @@ public function collect( $associatedTaxables = []; } + $taxClassId = $this->configProviderAccount->getBuckarooFeeTaxClass(); + $associatedTaxables[] = [ CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_TYPE => self::QUOTE_TYPE, CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_CODE => self::CODE_QUOTE_GW, - CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_UNIT_PRICE => $paymentFee, - CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_BASE_UNIT_PRICE => $basePaymentFee, + CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_UNIT_PRICE => $fullAmount, + CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_BASE_UNIT_PRICE => $result->getRoundedAmount(), CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_QUANTITY => 1, - CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_TAX_CLASS_ID => $productTaxClassId, - CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_PRICE_INCLUDES_TAX => true, - CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_ASSOCIATION_ITEM_CODE - => CommonTaxCollector::ASSOCIATION_ITEM_CODE_FOR_QUOTE, + CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_TAX_CLASS_ID => $taxClassId, + CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_PRICE_INCLUDES_TAX => false, + CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_ASSOCIATION_ITEM_CODE => CommonTaxCollector::ASSOCIATION_ITEM_CODE_FOR_QUOTE, ]; /** * @noinspection PhpUndefinedMethodInspection */ $address->setAssociatedTaxables($associatedTaxables); - - return $this; } } diff --git a/Service/BuckarooFee/Calculate.php b/Service/BuckarooFee/Calculate.php new file mode 100755 index 000000000..1e5a259bc --- /dev/null +++ b/Service/BuckarooFee/Calculate.php @@ -0,0 +1,94 @@ +configProviderMethodFactory = $configProviderMethodFactory; + $this->fixedAmount = $fixedAmount; + $this->percentage = $percentage; + } + + public function calculatePaymentFee(Quote $quote, Total $total) + { + $paymentFee = $this->getPaymentFee($quote); + + if ($paymentFee === null){ + return null; + } + if(strpos($paymentFee, '%') !== false){ + return $this->percentage->calculate($quote, $total, $paymentFee); + } + + return $this->fixedAmount->calculate($quote, $total, (float)$paymentFee); + } + + public function getPaymentFee(Quote $quote) + { + $paymentMethod = $quote->getPayment()->getMethod(); + + if (!$paymentMethod || strpos($paymentMethod, 'buckaroo_magento2_') !== 0) { + return null; + } + + $methodInstance = $quote->getPayment()->getMethodInstance(); + if (!$methodInstance instanceof AbstractMethod) { + return null; + } + + $buckarooPaymentMethodCode = $methodInstance->buckarooPaymentMethodCode; + if (!$this->configProviderMethodFactory->has($buckarooPaymentMethodCode)) { + return null; + } + + $configProvider = $this->configProviderMethodFactory->get($buckarooPaymentMethodCode); + return trim($configProvider->getPaymentFee($quote->getStore())); + } +} diff --git a/Service/BuckarooFee/Result.php b/Service/BuckarooFee/Result.php new file mode 100755 index 000000000..417ee1d94 --- /dev/null +++ b/Service/BuckarooFee/Result.php @@ -0,0 +1,90 @@ +amount; + } + + /** + * @return float + */ + public function getRoundedAmount() + { + return round($this->amount, 2); + } + + /** + * @param float $amount + */ + public function setAmount($amount) + { + $this->amount = $amount; + } + + /** + * @return float + */ + public function getTaxAmount() + { + return $this->taxAmount; + } + + /** + * @return float + */ + public function getRoundedTaxAmount() + { + return round($this->taxAmount, 2); + } + + /** + * @param float $taxAmount + */ + public function setTaxAmount(float $taxAmount) + { + $this->taxAmount = $taxAmount; + } + + /** + * @return float + */ + public function getAmountIncludingTax() + { + return $this->amount + $this->taxAmount; + } +} diff --git a/Service/BuckarooFee/Types/FixedAmount.php b/Service/BuckarooFee/Types/FixedAmount.php new file mode 100755 index 000000000..51953fb2d --- /dev/null +++ b/Service/BuckarooFee/Types/FixedAmount.php @@ -0,0 +1,60 @@ +resultFactory = $resultFactory; + $this->taxCalculate = $taxCalculate; + } + + public function calculate(CartInterface $cart, Total $total, float $amount){ + + $tax = $this->taxCalculate->getTaxFromAmountIncludingTax($cart, $amount); + /** @var Result $result */ + $result = $this->resultFactory->create(); + $result->setAmount($amount - $tax); + $result->setTaxAmount($tax); + + return $result; + } +} diff --git a/Service/BuckarooFee/Types/Percentage.php b/Service/BuckarooFee/Types/Percentage.php new file mode 100755 index 000000000..5ed18ed17 --- /dev/null +++ b/Service/BuckarooFee/Types/Percentage.php @@ -0,0 +1,74 @@ +resultFactory = $resultFactory; + $this->taxCalculate = $taxCalculate; + } + + + public function calculate(CartInterface $cart, Total $total, $percentage){ + $percentage = (float) rtrim($percentage, '%'); + if ($percentage <= 0) { + return null; + } + $subtotal = $total->getData('base_subtotal_incl_tax'); + if (!$subtotal) { + $subtotal = $total->getTotalAmount('subtotal'); + } + if ($subtotal <= 0) { + return null; + } + + $calculatedResult = ($subtotal / 100) * $percentage; + $tax = $this->taxCalculate->getTaxFromAmountIncludingTax($cart, $calculatedResult); + + /** @var Result $result */ + $result = $this->resultFactory->create(); + $result->setAmount($calculatedResult - $tax); + $result->setTaxAmount($tax); + + return $result; + } +} diff --git a/Service/Sales/Pdf/BuckarooFee.php b/Service/Sales/Pdf/BuckarooFee.php index a7e03a008..31268891d 100644 --- a/Service/Sales/Pdf/BuckarooFee.php +++ b/Service/Sales/Pdf/BuckarooFee.php @@ -19,41 +19,52 @@ */ namespace Buckaroo\Magento2\Service\Sales\Pdf; -use Magento\Framework\App\Config\ScopeConfigInterface; +use Buckaroo\Magento2\Model\Config\Source\Display\Type as DisplayType; +use Buckaroo\Magento2\Model\ConfigProvider\Account; use Magento\Sales\Model\Order\Pdf\Total\DefaultTotal; use Magento\Store\Model\ScopeInterface; use Magento\Tax\Helper\Data; use Magento\Tax\Model\Calculation; use Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory; use Buckaroo\Magento2\Helper\PaymentFee; -use Buckaroo\Magento2\Model\Config\Source\Display\Type; use Buckaroo\Magento2\Model\ConfigProvider\BuckarooFee as ConfigProviderBuckarooFee; class BuckarooFee extends DefaultTotal { - /** @var ScopeConfigInterface */ - private $scopeConfig; - /** @var PaymentFee */ private $paymentFee; /** - * {@inheritdoc} - * - * @param ScopeInterface $scopeConfig - * @param PaymentFee $paymentFee + * @var Account + */ + protected $configProviderAccount; + + /** + * @var ConfigProviderBuckarooFee + */ + protected $configProviderBuckarooFee; + + /** + * @param Data $taxHelper + * @param Calculation $taxCalculation + * @param CollectionFactory $ordersFactory + * @param PaymentFee $paymentFee + * @param Account $configProviderAccount + * @param ConfigProviderBuckarooFee $configProviderBuckarooFee + * @param array $data */ public function __construct( Data $taxHelper, Calculation $taxCalculation, CollectionFactory $ordersFactory, - ScopeConfigInterface $scopeConfig, PaymentFee $paymentFee, + Account $configProviderAccount, + ConfigProviderBuckarooFee $configProviderBuckarooFee, array $data = [] ) { - $this->scopeConfig = $scopeConfig; $this->paymentFee = $paymentFee; - + $this->configProviderAccount = $configProviderAccount; + $this->configProviderBuckarooFee = $configProviderBuckarooFee; parent::__construct($taxHelper, $taxCalculation, $ordersFactory, $data); } @@ -67,6 +78,8 @@ public function getTotalsForDisplay() $label = $this->paymentFee->getBuckarooPaymentFeeLabel($this->getOrder()); $fontSize = $this->getFontSize() ? $this->getFontSize() : 7; + $isFeeInclusiveOfTax = (bool)$this->configProviderAccount->getBuckarooFeeTaxClass(); + $amountInclTax = $this->getSource()->getBuckarooFeeInclTax(); if (!$amountInclTax) { @@ -75,47 +88,31 @@ public function getTotalsForDisplay() $amountInclTax = $this->getOrder()->formatPriceTxt($amountInclTax); - $displaySalesBuckarooFee = $this->scopeConfig->getValue( - ConfigProviderBuckarooFee::XPATH_BUCKAROOFEE_PRICE_DISPLAY_SALES, - ScopeInterface::SCOPE_STORE, - $store - ); - - switch ($displaySalesBuckarooFee) { - case Type::DISPLAY_TYPE_BOTH: - $totals = [ - [ - 'amount' => $this->getAmountPrefix() . $amount, - 'label' => __($label . ' (Excl. Tax)') . ':', - 'font_size' => $fontSize, - ], - [ - 'amount' => $this->getAmountPrefix() . $amountInclTax, - 'label' => __($label . ' (Incl. Tax)') . ':', - 'font_size' => $fontSize - ], - ]; - break; - case Type::DISPLAY_TYPE_INCLUDING_TAX: - $totals = [ - [ - 'amount' => $this->getAmountPrefix() . $amountInclTax, - 'label' => __($label) . ':', - 'font_size' => $fontSize, - ], - ]; - break; - default: - $totals = [ - [ - 'amount' => $this->getAmountPrefix() . $amount, - 'label' => __($label) . ':', - 'font_size' => $fontSize, - ], - ]; - break; + if ($isFeeInclusiveOfTax && $this->buckarooPaymentCalculationInclTax($store)) { + $totals = [ + [ + 'amount' => $this->getAmountPrefix() . $amountInclTax, + 'label' => __($label) . ':', + 'font_size' => $fontSize, + ], + ]; + } else { + $totals = [ + [ + 'amount' => $this->getAmountPrefix() . $amount, + 'label' => __($label) . ':', + 'font_size' => $fontSize, + ], + ]; } return $totals; } + + public function buckarooPaymentCalculationInclTax($store = null) + { + $configValue = $this->configProviderBuckarooFee->getPaymentFeeTax($store); + + return $configValue == DisplayType::DISPLAY_TYPE_INCLUDING_TAX; + } } diff --git a/Service/Tax/TaxCalculate.php b/Service/Tax/TaxCalculate.php new file mode 100755 index 000000000..54a420093 --- /dev/null +++ b/Service/Tax/TaxCalculate.php @@ -0,0 +1,80 @@ +taxCalculation = $taxCalculation; + $this->configProviderAccount = $configProviderAccount; + } + + public function getTaxFromAmountIncludingTax(CartInterface $cart, $amount) + { + $shippingAddress = $cart->getShippingAddress(); + $billingAddress = $cart->getBillingAddress(); + $customerTaxClassId = $cart->getCustomerTaxClassId(); + $storeId = $cart->getStoreId(); + $taxClassId = $this->configProviderAccount->getBuckarooFeeTaxClass(); + + if (empty($taxClassId) || !is_numeric($taxClassId)) { + // If the tax class ID is not set, return zero tax amount to avoid errors + return 0.0; + } + + $request = $this->taxCalculation->getRateRequest( + $shippingAddress, + $billingAddress, + $customerTaxClassId, + $storeId + ); + + $request->setProductClassId($taxClassId); + + $rate = $this->taxCalculation->getRate($request); + + return $this->taxCalculation->calcTaxAmount( + $amount, + $rate, + true, + false + ); + } +} diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 9ffd9d86f..58e89c5b4 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -21,9 +21,6 @@ --> -
- -
diff --git a/etc/adminhtml/system/account.xml b/etc/adminhtml/system/account.xml old mode 100644 new mode 100755 index 4496641dc..fdadf2b89 --- a/etc/adminhtml/system/account.xml +++ b/etc/adminhtml/system/account.xml @@ -105,9 +105,15 @@ buckaroo_magento2/account/idin + + + + \Magento\Tax\Model\TaxClass\Source\Product + buckaroo_magento2/account/buckaroo_fee_tax_class + + - Buckaroo\Magento2\Model\Config\Source\Idinmode buckaroo_magento2/account/idin_mode diff --git a/etc/adminhtml/system/tax.xml b/etc/adminhtml/system/tax.xml deleted file mode 100644 index 8c8166efa..000000000 --- a/etc/adminhtml/system/tax.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - Buckaroo\Magento2\Model\Config\Source\TaxClass\Product - - - - - - This sets whether buckaroo payment fee amounts entered from Magento Admin include tax. - Buckaroo\Magento2\Model\Config\Source\TaxClass\Calculation - - - - - - Buckaroo\Magento2\Model\Config\Source\Display\Type - - - - - - Buckaroo\Magento2\Model\Config\Source\Display\Type - - - diff --git a/etc/di.xml b/etc/di.xml index 0282f31d5..d644fc032 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -468,6 +468,12 @@ + + + Buckaroo\Magento2\Service\BuckarooFee\Result + + + diff --git a/view/adminhtml/templates/sales/order/creditmemo/buckaroo_fee.phtml b/view/adminhtml/templates/sales/order/creditmemo/buckaroo_fee.phtml index 718f4a384..994f2002e 100644 --- a/view/adminhtml/templates/sales/order/creditmemo/buckaroo_fee.phtml +++ b/view/adminhtml/templates/sales/order/creditmemo/buckaroo_fee.phtml @@ -24,7 +24,7 @@ getTotals() as $_code => $_total): ?> - +
diff --git a/view/adminhtml/templates/sales/order/total.phtml b/view/adminhtml/templates/sales/order/total.phtml index 39d8af5a6..16f47766b 100644 --- a/view/adminhtml/templates/sales/order/total.phtml +++ b/view/adminhtml/templates/sales/order/total.phtml @@ -11,7 +11,7 @@ getSource()->getBuckarooFee()): ?> - + getSource()->getBuckarooFeeLabel() ?: __('Payment fee') ?> displayPrices($block->getSource()->getBaseBuckarooFee(), $block->getSource()->getBuckarooFee()); ?> diff --git a/view/frontend/web/js/model/buckaroo-fee.js b/view/frontend/web/js/model/buckaroo-fee.js deleted file mode 100644 index 6742a9f34..000000000 --- a/view/frontend/web/js/model/buckaroo-fee.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*global define*/ -define( - [ - - ], - function () { - "use strict"; - - var buckarooFeeConfig = window.buckarooConfig ? - window.buckarooConfig.buckarooFee : - window.checkoutConfig.buckarooFee; - - return function (itemId) { - return { - itemId: itemId, - - /** - * @param key - * @returns {*} - */ - getConfigValue: function (key) { - return buckarooFeeConfig[key]; - }, - - /** - * @returns {window.buckarooConfig.priceFormat|*|mage.configurable.options.priceFormat|.options.priceFormat|priceFormat} - */ - getPriceFormat: function () { - return window.buckarooConfig.priceFormat; - }, - - /** - * Get buckaroo fee price display mode. - * - * @returns {Boolean} - */ - displayBothPrices: function () { - return !!buckarooFeeConfig.cart.displayBuckarooFeeBothPrices; - }, - - /** - * Get buckaroo fee price display mode. - * - * @returns {Boolean} - */ - displayInclTaxPrice: function () { - return !!buckarooFeeConfig.cart.displayBuckarooFeeInclTax; - } - }; - }; - } -); diff --git a/view/frontend/web/js/view/checkout/cart/totals/buckaroo_fee.js b/view/frontend/web/js/view/checkout/cart/totals/buckaroo_fee.js index 3007da192..589d47f7d 100644 --- a/view/frontend/web/js/view/checkout/cart/totals/buckaroo_fee.js +++ b/view/frontend/web/js/view/checkout/cart/totals/buckaroo_fee.js @@ -15,17 +15,17 @@ define( template: 'Buckaroo_Magento2/cart/totals/buckaroo_fee' }, /** - * @override - * - * @returns {boolean} - */ + * @override + * + * @returns {boolean} + */ isDisplayed: function () { return true; }, /** - * @override - */ + * @override + */ isFullMode: function () { return true; } diff --git a/view/frontend/web/js/view/checkout/summary/already-paid.js b/view/frontend/web/js/view/checkout/summary/already-paid.js index 189a9e139..46568a317 100644 --- a/view/frontend/web/js/view/checkout/summary/already-paid.js +++ b/view/frontend/web/js/view/checkout/summary/already-paid.js @@ -34,9 +34,6 @@ define([ } return parseFloat(buckarooFeeSegment.value).toFixed(2); - }, - getFormattedPrice: function (price) { - return priceUtils.formatPrice(price, quote.getPriceFormat()); } }); }); diff --git a/view/frontend/web/js/view/checkout/summary/remaining-amount.js b/view/frontend/web/js/view/checkout/summary/remaining-amount.js index 9a12ae4f2..e79c72142 100644 --- a/view/frontend/web/js/view/checkout/summary/remaining-amount.js +++ b/view/frontend/web/js/view/checkout/summary/remaining-amount.js @@ -29,9 +29,6 @@ define([ }, getTitle: function () { return this.title; - }, - getFormattedPrice: function (price) { - return priceUtils.formatPrice(price, quote.getPriceFormat()); } }); }); diff --git a/view/frontend/web/js/view/summary/totals.js b/view/frontend/web/js/view/summary/totals.js index 189240767..b4c5957c7 100644 --- a/view/frontend/web/js/view/summary/totals.js +++ b/view/frontend/web/js/view/summary/totals.js @@ -3,169 +3,136 @@ * See COPYING.txt for license details. */ /*global define*/ -define( - [ - 'jquery', - 'Magento_Checkout/js/view/summary/abstract-total', - 'Magento_Checkout/js/model/quote', - 'Magento_Checkout/js/model/totals', - 'Buckaroo_Magento2/js/model/buckaroo-fee', - 'Magento_Ui/js/model/messageList', - 'mage/translate', - 'Magento_Ui/js/modal/alert', - 'ko', - 'mage/url' - ], - function ($, Component, quote, totals, BuckarooFee, globalMessageList, $t, alert, ko, url) { - 'use strict'; - - return Component.extend( - { - defaults : { - template : 'Buckaroo_Magento2/summary/buckaroo_fee' - }, - totals : quote.getTotals(), - model : {}, - excludingTaxMessage : '(Excluding Tax)', - includingTaxMessage : '(Including Tax)', - - /** - * @override - */ - initialize : function (options) { - this.model = new BuckarooFee(); - - window.checkoutConfig.buckarooFee.title = ko.observable(options.title); - - return this._super(options); - }, - - /** - * Get buckaroo fee price based on options. - * - * @returns {int} - */ - getValue : function () { - var price = 0, - buckarooFeeSegment; - - if (this.totals() - && totals.getSegment('buckaroo_fee') - && totals.getSegment('buckaroo_fee').hasOwnProperty('extension_attributes') - ) { - buckarooFeeSegment = totals.getSegment('buckaroo_fee')['extension_attributes']; - - price = buckarooFeeSegment.hasOwnProperty('buckaroo_fee') ? - buckarooFeeSegment['buckaroo_fee'] : - 0; - } - - return this.getFormattedPrice(price); - }, - - /** - * Get buckaroo fee price (including tax) based on options. - * - * @returns {int} - */ - getIncludingTaxValue : function () { - var price = 0, - buckarooFeeSegment; - - if (this.totals() - && totals.getSegment('buckaroo_fee') - && totals.getSegment('buckaroo_fee').hasOwnProperty('extension_attributes') - ) { - buckarooFeeSegment = totals.getSegment('buckaroo_fee')['extension_attributes']; - - price = buckarooFeeSegment.hasOwnProperty('buckaroo_fee_incl_tax') ? - buckarooFeeSegment['buckaroo_fee_incl_tax'] : - 0; - } - - return this.getFormattedPrice(price); - }, - - /** - * Check buckaroo fee option availability. - * - * @returns {Boolean} - */ - isAvailable : function () { - var isAvailable = false; +define([ + 'jquery', + 'Magento_Checkout/js/view/summary/abstract-total', + 'Magento_Checkout/js/model/quote', + 'Magento_Checkout/js/model/totals', + 'Magento_Ui/js/model/messageList', + 'mage/translate', + 'Magento_Ui/js/modal/alert', + 'ko' +], +function ($, Component, quote, totals , globalMessageList, $t, alert, ko) { + 'use strict'; + + return Component.extend({ + defaults : { + template : 'Buckaroo_Magento2/summary/buckaroo_fee' + }, + totals : quote.getTotals(), + + /** + * @override + */ + initialize : function (options) { + this._super(); + + window.checkoutConfig.buckarooFee.title = ko.observable(options.title); + + quote.paymentMethod.subscribe(this.updateFeeVisibility.bind(this)); + + return this; + }, + + /** + * Update visibility of the Buckaroo fee based on payment method. + */ + updateFeeVisibility: function (paymentMethod) { + if (!this.hasFee(paymentMethod)) { + // Clear the fee segment if the selected payment method has no fee + totals.getSegment('buckaroo_fee', null); + } + totals.isLoading(true); // Force totals to recalculate + }, + + /** + * Determine if the selected payment method includes a fee. + */ + hasFee: function (paymentMethod) { + return paymentMethod && paymentMethod.method && paymentMethod.method.includes('buckaroo'); + }, + + /** + * Get buckaroo fee price based on options. + * + * @returns {int} + */ + getValue : function () { + var price = 0, + buckarooFeeSegment; + if (this.totals() + && totals.getSegment('buckaroo_fee') + && totals.getSegment('buckaroo_fee').hasOwnProperty('extension_attributes') + ) { + buckarooFeeSegment = totals.getSegment('buckaroo_fee')['extension_attributes']; + + price = buckarooFeeSegment.hasOwnProperty('buckaroo_fee') ? + buckarooFeeSegment['buckaroo_fee'] : + 0; + } - if (!this.isFullMode()) { - return false; - } + return this.getFormattedPrice(price); + }, + + /** + * Check buckaroo fee option availability. + * + * @returns {Boolean} + */ + isAvailable : function () { + var isAvailable = false; + if (!this.isFullMode()) { + return false; + } - if (this.totals() - && totals.getSegment('buckaroo_fee') - && totals.getSegment('buckaroo_fee').hasOwnProperty('extension_attributes') - ) { - isAvailable = (0 < totals.getSegment('buckaroo_fee')['extension_attributes'].buckaroo_fee); - } + if (this.totals() + && totals.getSegment('buckaroo_fee') + && totals.getSegment('buckaroo_fee').hasOwnProperty('extension_attributes') + ) { + isAvailable = (0 < totals.getSegment('buckaroo_fee')['extension_attributes'].buckaroo_fee); + } - return isAvailable; - }, - - /** - * Check if both buckaroo fee prices should be displayed. - * - * @returns {Boolean} - */ - displayBothPrices : function () { - return (true == this.model.displayBothPrices()); - }, - - /** - * Check if buckaroo fee prices should be displayed including tax. - * - * @returns {Boolean} - */ - displayPriceInclTax : function () { - var displayPriceInclTax = this.model.displayInclTaxPrice(); - - return displayPriceInclTax && !this.displayBothPrices(); - }, - - /** - * Check if buckaroo fee prices should be displayed excluding tax. - * - * @returns {Boolean} - */ - displayPriceExclTax : function () { - return !this.displayPriceInclTax() && !this.displayBothPrices(); - }, - - getTitle : function () { - return window.checkoutConfig.buckarooFee.title(); - }, - - getAlreadyPayTitle : function () { - return 'Paid with Giftcard'; - }, - - getAlreadyPayValue : function () { - var buckarooFeeSegment = totals.getSegment('buckaroo_already_paid'); - try { - if (buckarooFeeSegment.title) { - var items = JSON.parse(buckarooFeeSegment.title); - if ((typeof items === 'object') && (items.length > 0)) { - for (var i = 0; i < items.length; i++) { - items[i].amount = this.getFormattedPrice(items[i].amount); - } - return items; - } + return isAvailable; + }, + + getTitle : function () { + return window.checkoutConfig.buckarooFee.title(); + }, + + /** + * Title for 'Paid with Giftcard' option. + * + * @returns {string} + */ + getAlreadyPayTitle: function () { + return $t('Paid with Giftcard'); + }, + + /** + * Get value for 'Paid with Giftcard'. + * + * @returns {string|boolean} + */ + getAlreadyPayValue : function () { + var buckarooFeeSegment = totals.getSegment('buckaroo_already_paid'); + try { + if (buckarooFeeSegment.title) { + var items = JSON.parse(buckarooFeeSegment.title); + if ((typeof items === 'object') && (items.length > 0)) { + for (var i = 0; i < items.length; i++) { + items[i].amount = this.getFormattedPrice(items[i].amount); } - } catch (e) { - // console.log(e); + return items; } - - return buckarooFeeSegment.value ? - this.getFormattedPrice(buckarooFeeSegment.value) : - false; - }, + } + } catch (e) { + // console.log(e); } - ); - } -); + + return buckarooFeeSegment.value ? + this.getFormattedPrice(buckarooFeeSegment.value) : + false; + }, + }); +}); diff --git a/view/frontend/web/template/cart/totals/buckaroo_fee.html b/view/frontend/web/template/cart/totals/buckaroo_fee.html index bd9e933f9..b4feb289b 100644 --- a/view/frontend/web/template/cart/totals/buckaroo_fee.html +++ b/view/frontend/web/template/cart/totals/buckaroo_fee.html @@ -1,27 +1,4 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -29,4 +6,3 @@ - diff --git a/view/frontend/web/template/summary/buckaroo_fee.html b/view/frontend/web/template/summary/buckaroo_fee.html index be4f20260..9e57cbbd8 100644 --- a/view/frontend/web/template/summary/buckaroo_fee.html +++ b/view/frontend/web/template/summary/buckaroo_fee.html @@ -1,46 +1,19 @@ - - - - - - - - - - - - - - - - + - + - - - - - - - - - - + - - - + @@ -48,8 +21,8 @@ - + - + - \ No newline at end of file + From 310c8bee0d367345b84f21e62b3cdd6ead4fbdf7 Mon Sep 17 00:00:00 2001 From: "v.carkaxhija" Date: Tue, 19 Nov 2024 15:04:23 +0100 Subject: [PATCH 2/2] fix text --- etc/adminhtml/system/payment_methods/afterpay.xml | 6 +++--- etc/adminhtml/system/payment_methods/afterpay2.xml | 4 ++-- etc/adminhtml/system/payment_methods/afterpay20.xml | 6 +++--- etc/adminhtml/system/payment_methods/alipay.xml | 4 ++-- etc/adminhtml/system/payment_methods/belfius.xml | 4 ++-- etc/adminhtml/system/payment_methods/billink.xml | 4 ++-- etc/adminhtml/system/payment_methods/blik.xml | 2 +- etc/adminhtml/system/payment_methods/capayable_in3.xml | 6 +++--- .../system/payment_methods/capayable_postpay.xml | 4 ++-- etc/adminhtml/system/payment_methods/creditcards.xml | 2 +- etc/adminhtml/system/payment_methods/emandate.xml | 6 +++--- etc/adminhtml/system/payment_methods/eps.xml | 6 +++--- etc/adminhtml/system/payment_methods/ideal.xml | 2 +- etc/adminhtml/system/payment_methods/idealprocessing.xml | 4 ++-- etc/adminhtml/system/payment_methods/kbc.xml | 4 ++-- etc/adminhtml/system/payment_methods/klarna.xml | 6 +++--- etc/adminhtml/system/payment_methods/klarnain.xml | 6 +++--- etc/adminhtml/system/payment_methods/klarnakp.xml | 6 +++--- etc/adminhtml/system/payment_methods/knaken.xml | 4 ++-- etc/adminhtml/system/payment_methods/mbway.xml | 4 ++-- etc/adminhtml/system/payment_methods/mrcash.xml | 4 ++-- etc/adminhtml/system/payment_methods/multibanco.xml | 4 ++-- etc/adminhtml/system/payment_methods/p24.xml | 4 ++-- etc/adminhtml/system/payment_methods/payconiq.xml | 4 ++-- etc/adminhtml/system/payment_methods/paypal.xml | 2 +- etc/adminhtml/system/payment_methods/payperemail.xml | 8 ++++---- etc/adminhtml/system/payment_methods/pospayment.xml | 4 ++-- .../system/payment_methods/sepa_direct_debit.xml | 6 +++--- etc/adminhtml/system/payment_methods/transfer.xml | 4 ++-- etc/adminhtml/system/payment_methods/trustly.xml | 4 ++-- etc/adminhtml/system/payment_methods/voucher.xml | 2 +- etc/adminhtml/system/payment_methods/wechatpay.xml | 4 ++-- i18n/de_DE.csv | 2 +- i18n/es_ES.csv | 2 +- i18n/fr_FR.csv | 2 +- i18n/nl_BE.csv | 2 +- i18n/nl_NL.csv | 2 +- 37 files changed, 75 insertions(+), 75 deletions(-) diff --git a/etc/adminhtml/system/payment_methods/afterpay.xml b/etc/adminhtml/system/payment_methods/afterpay.xml index 6689ba7e6..2c02261ce 100644 --- a/etc/adminhtml/system/payment_methods/afterpay.xml +++ b/etc/adminhtml/system/payment_methods/afterpay.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_afterpay/subtext
- + @@ -91,7 +91,7 @@ Magento\Config\Model\Config\Source\Yesno payment/buckaroo_magento2_afterpay/financial_warning - + @@ -154,7 +154,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_afterpay/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/afterpay2.xml b/etc/adminhtml/system/payment_methods/afterpay2.xml index c08e4aa4d..4160cd6f4 100644 --- a/etc/adminhtml/system/payment_methods/afterpay2.xml +++ b/etc/adminhtml/system/payment_methods/afterpay2.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_afterpay2/subtext - + @@ -154,7 +154,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_afterpay2/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/afterpay20.xml b/etc/adminhtml/system/payment_methods/afterpay20.xml index 23ffbadb3..1f29476d9 100644 --- a/etc/adminhtml/system/payment_methods/afterpay20.xml +++ b/etc/adminhtml/system/payment_methods/afterpay20.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_afterpay20/subtext - + @@ -93,7 +93,7 @@ both,b2b - + @@ -133,7 +133,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_afterpay20/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/alipay.xml b/etc/adminhtml/system/payment_methods/alipay.xml index 5e9f1f23e..06d0eeb54 100644 --- a/etc/adminhtml/system/payment_methods/alipay.xml +++ b/etc/adminhtml/system/payment_methods/alipay.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_alipay/subtext - + @@ -77,7 +77,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_alipay/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/belfius.xml b/etc/adminhtml/system/payment_methods/belfius.xml index a34d477aa..da72fedbe 100644 --- a/etc/adminhtml/system/payment_methods/belfius.xml +++ b/etc/adminhtml/system/payment_methods/belfius.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_belfius/subtext - + @@ -77,7 +77,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_belfius/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/billink.xml b/etc/adminhtml/system/payment_methods/billink.xml index 922cef49c..4ecdd83f8 100644 --- a/etc/adminhtml/system/payment_methods/billink.xml +++ b/etc/adminhtml/system/payment_methods/billink.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_billink/subtext - + @@ -102,7 +102,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_billink/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/blik.xml b/etc/adminhtml/system/payment_methods/blik.xml index 382f2eda7..70f399cc1 100644 --- a/etc/adminhtml/system/payment_methods/blik.xml +++ b/etc/adminhtml/system/payment_methods/blik.xml @@ -77,7 +77,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_blik/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/capayable_in3.xml b/etc/adminhtml/system/payment_methods/capayable_in3.xml index ac01e3b81..72cae7f4c 100644 --- a/etc/adminhtml/system/payment_methods/capayable_in3.xml +++ b/etc/adminhtml/system/payment_methods/capayable_in3.xml @@ -48,7 +48,7 @@ payment/buckaroo_magento2_capayablein3/subtext - + @@ -66,7 +66,7 @@ - payment/buckaroo_magento2_capayablein3/sort_order + payment/buckaroo_magento2_capayablein3/sort_order @@ -88,7 +88,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_capayablein3/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/capayable_postpay.xml b/etc/adminhtml/system/payment_methods/capayable_postpay.xml index 8e3fcc608..239694c6a 100644 --- a/etc/adminhtml/system/payment_methods/capayable_postpay.xml +++ b/etc/adminhtml/system/payment_methods/capayable_postpay.xml @@ -41,7 +41,7 @@ payment/buckaroo_magento2_capayablepostpay/subtext - + @@ -82,7 +82,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_capayablepostpay/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/creditcards.xml b/etc/adminhtml/system/payment_methods/creditcards.xml index a61118c63..a0112fb53 100644 --- a/etc/adminhtml/system/payment_methods/creditcards.xml +++ b/etc/adminhtml/system/payment_methods/creditcards.xml @@ -103,7 +103,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_creditcards/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/emandate.xml b/etc/adminhtml/system/payment_methods/emandate.xml index c1457d1ea..b00c9c3f7 100644 --- a/etc/adminhtml/system/payment_methods/emandate.xml +++ b/etc/adminhtml/system/payment_methods/emandate.xml @@ -40,7 +40,7 @@ payment/buckaroo_magento2_emandate/subtext - + @@ -55,7 +55,7 @@ Buckaroo\Magento2\Block\Config\Form\Field\ColorPicker - + @@ -93,7 +93,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_emandate/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/eps.xml b/etc/adminhtml/system/payment_methods/eps.xml index 8acc14fc6..aaafdc9ed 100644 --- a/etc/adminhtml/system/payment_methods/eps.xml +++ b/etc/adminhtml/system/payment_methods/eps.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_eps/subtext - + @@ -58,7 +58,7 @@ Buckaroo\Magento2\Block\Config\Form\Field\ColorPicker - + @@ -77,7 +77,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_eps/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/ideal.xml b/etc/adminhtml/system/payment_methods/ideal.xml index 908a3a4a1..e49a53568 100644 --- a/etc/adminhtml/system/payment_methods/ideal.xml +++ b/etc/adminhtml/system/payment_methods/ideal.xml @@ -121,7 +121,7 @@ For precise cost details, please reach out to - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_ideal/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/idealprocessing.xml b/etc/adminhtml/system/payment_methods/idealprocessing.xml index 1c20cae97..722f0fd32 100644 --- a/etc/adminhtml/system/payment_methods/idealprocessing.xml +++ b/etc/adminhtml/system/payment_methods/idealprocessing.xml @@ -49,7 +49,7 @@ For precise cost details, please reach out to @@ -93,7 +93,7 @@ For precise cost details, please reach out to - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_idealprocessing/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/kbc.xml b/etc/adminhtml/system/payment_methods/kbc.xml index 6076c45d4..226ffb178 100644 --- a/etc/adminhtml/system/payment_methods/kbc.xml +++ b/etc/adminhtml/system/payment_methods/kbc.xml @@ -41,7 +41,7 @@ payment/buckaroo_magento2_kbc/subtext - + @@ -75,7 +75,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_kbc/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/klarna.xml b/etc/adminhtml/system/payment_methods/klarna.xml index 7aac352b1..83e71765b 100644 --- a/etc/adminhtml/system/payment_methods/klarna.xml +++ b/etc/adminhtml/system/payment_methods/klarna.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_klarna/subtext - + @@ -84,7 +84,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_klarna/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee @@ -182,4 +182,4 @@ - \ No newline at end of file + diff --git a/etc/adminhtml/system/payment_methods/klarnain.xml b/etc/adminhtml/system/payment_methods/klarnain.xml index 99a90ecbb..6c2c4aa97 100644 --- a/etc/adminhtml/system/payment_methods/klarnain.xml +++ b/etc/adminhtml/system/payment_methods/klarnain.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_klarnain/subtext - + @@ -84,7 +84,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_klarnain/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee @@ -182,4 +182,4 @@ - \ No newline at end of file + diff --git a/etc/adminhtml/system/payment_methods/klarnakp.xml b/etc/adminhtml/system/payment_methods/klarnakp.xml index 006e63bee..7e80678fd 100644 --- a/etc/adminhtml/system/payment_methods/klarnakp.xml +++ b/etc/adminhtml/system/payment_methods/klarnakp.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_klarnakp/subtext - + @@ -84,7 +84,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_klarnakp/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee @@ -189,4 +189,4 @@ - \ No newline at end of file + diff --git a/etc/adminhtml/system/payment_methods/knaken.xml b/etc/adminhtml/system/payment_methods/knaken.xml index 6a83d5e59..ff2dcc5e4 100644 --- a/etc/adminhtml/system/payment_methods/knaken.xml +++ b/etc/adminhtml/system/payment_methods/knaken.xml @@ -41,7 +41,7 @@ payment/buckaroo_magento2_knaken/subtext - + @@ -75,7 +75,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_knaken/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/mbway.xml b/etc/adminhtml/system/payment_methods/mbway.xml index cdd178b6f..ab34946b0 100644 --- a/etc/adminhtml/system/payment_methods/mbway.xml +++ b/etc/adminhtml/system/payment_methods/mbway.xml @@ -41,7 +41,7 @@ payment/buckaroo_magento2_mbway/subtext - + @@ -75,7 +75,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_mbway/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/mrcash.xml b/etc/adminhtml/system/payment_methods/mrcash.xml index c59d1e415..5abab90da 100644 --- a/etc/adminhtml/system/payment_methods/mrcash.xml +++ b/etc/adminhtml/system/payment_methods/mrcash.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_mrcash/subtext - + @@ -77,7 +77,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_mrcash/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/multibanco.xml b/etc/adminhtml/system/payment_methods/multibanco.xml index 91bcc8f32..e402c00fa 100644 --- a/etc/adminhtml/system/payment_methods/multibanco.xml +++ b/etc/adminhtml/system/payment_methods/multibanco.xml @@ -41,7 +41,7 @@ payment/buckaroo_magento2_multibanco/subtext - + @@ -75,7 +75,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_multibanco/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/p24.xml b/etc/adminhtml/system/payment_methods/p24.xml index f3646596d..9d026ce91 100644 --- a/etc/adminhtml/system/payment_methods/p24.xml +++ b/etc/adminhtml/system/payment_methods/p24.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_p24/subtext - + @@ -77,7 +77,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_p24/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/payconiq.xml b/etc/adminhtml/system/payment_methods/payconiq.xml index cf93ea4e4..d322df434 100644 --- a/etc/adminhtml/system/payment_methods/payconiq.xml +++ b/etc/adminhtml/system/payment_methods/payconiq.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_payconiq/subtext - + @@ -78,7 +78,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_payconiq/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/paypal.xml b/etc/adminhtml/system/payment_methods/paypal.xml index 550d75979..2ec44a858 100644 --- a/etc/adminhtml/system/payment_methods/paypal.xml +++ b/etc/adminhtml/system/payment_methods/paypal.xml @@ -140,7 +140,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_paypal/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/payperemail.xml b/etc/adminhtml/system/payment_methods/payperemail.xml index c6b0a5c6e..fc59f99e0 100644 --- a/etc/adminhtml/system/payment_methods/payperemail.xml +++ b/etc/adminhtml/system/payment_methods/payperemail.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_payperemail/subtext - + @@ -58,7 +58,7 @@ Buckaroo\Magento2\Block\Config\Form\Field\ColorPicker - + @@ -72,7 +72,7 @@ Magento\Config\Model\Config\Source\Yesno payment/buckaroo_magento2_payperemail/send_mail - + @@ -177,7 +177,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_payperemail/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/pospayment.xml b/etc/adminhtml/system/payment_methods/pospayment.xml index 2a4460fc3..5affaf9c9 100644 --- a/etc/adminhtml/system/payment_methods/pospayment.xml +++ b/etc/adminhtml/system/payment_methods/pospayment.xml @@ -41,7 +41,7 @@ payment/buckaroo_magento2_pospayment/subtext - + @@ -88,7 +88,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_pospayment/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/sepa_direct_debit.xml b/etc/adminhtml/system/payment_methods/sepa_direct_debit.xml index 2bf6de454..99c7f2bb6 100644 --- a/etc/adminhtml/system/payment_methods/sepa_direct_debit.xml +++ b/etc/adminhtml/system/payment_methods/sepa_direct_debit.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_sepadirectdebit/subtext - + @@ -58,7 +58,7 @@ Buckaroo\Magento2\Block\Config\Form\Field\ColorPicker - + @@ -124,7 +124,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_sepadirectdebit/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/transfer.xml b/etc/adminhtml/system/payment_methods/transfer.xml index f02769cb4..812fd2ab3 100644 --- a/etc/adminhtml/system/payment_methods/transfer.xml +++ b/etc/adminhtml/system/payment_methods/transfer.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_transfer/subtext - + @@ -139,7 +139,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_transfer/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/trustly.xml b/etc/adminhtml/system/payment_methods/trustly.xml index 275af2725..668b7dfa0 100644 --- a/etc/adminhtml/system/payment_methods/trustly.xml +++ b/etc/adminhtml/system/payment_methods/trustly.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_trustly/subtext - + @@ -76,7 +76,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_trustly/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/voucher.xml b/etc/adminhtml/system/payment_methods/voucher.xml index f69baa7d3..d30ea4111 100644 --- a/etc/adminhtml/system/payment_methods/voucher.xml +++ b/etc/adminhtml/system/payment_methods/voucher.xml @@ -77,7 +77,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_voucher/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/etc/adminhtml/system/payment_methods/wechatpay.xml b/etc/adminhtml/system/payment_methods/wechatpay.xml index 220f3c884..c3e614ce2 100644 --- a/etc/adminhtml/system/payment_methods/wechatpay.xml +++ b/etc/adminhtml/system/payment_methods/wechatpay.xml @@ -43,7 +43,7 @@ payment/buckaroo_magento2_wechatpay/subtext - + @@ -77,7 +77,7 @@ - Configuration > Sales > Tax.]]> + General configuration and account information > Buckaroo Payment Fee Tax Class.]]> payment/buckaroo_magento2_wechatpay/payment_fee Buckaroo\Magento2\Model\Config\Backend\PaymentFee diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv index a32506847..28edf7673 100644 --- a/i18n/de_DE.csv +++ b/i18n/de_DE.csv @@ -11,7 +11,7 @@ "Send order confirmation email","Bestellbestätigungs-E-Mail senden" "Enable to send an order confirmation email to the customer when the creating of the order is successful. Specific for this payment method.","Aktivieren, um eine Bestellbestätigungs-E-Mail zu senden, wenn die Bestellung erstellt wird. Spezifisch für diese Zahlungsmethode." "Payment fee","Gebühr"Payment fee -"The above amount is calculated based on de Tax settings in Stores > Configuration > Sales > Tax.","Dieser Betrag wird basierend auf den Mehrwertsteuereinstellungen berechnet in: Stores > Configuration > Sales > Tax." +"The above amount is calculated based on de Tax settings in Buckaroo > General configuration and account information > Buckaroo Payment Fee Tax Class.","Dieser Betrag wird basierend auf den Mehrwertsteuereinstellungen berechnet in: Stores > Configuration > Sales > Tax." "Payment fee frontend label","Zahlungsgebühren-Front-End-Etikett" "This label will be displayed next to the fee on the checkout, order, invoice and creditmemo pages and pdfs.","Das Etikett wird beim Checkout neben dem Zahlungsaufschlag sowie auf den Bestell-, Rechnungs-, Gutschriftseiten und im PDF angezeigt." "Max order amount (in Base Currency)","Maximaler Bestellbetrag (in Basiswährung)" diff --git a/i18n/es_ES.csv b/i18n/es_ES.csv index e46543c34..6fafd0d5a 100644 --- a/i18n/es_ES.csv +++ b/i18n/es_ES.csv @@ -11,7 +11,7 @@ "Send order confirmation email","Enviar correo electrónico de confirmación de pedido" "Enable to send an order confirmation email to the customer when the creating of the order is successful. Specific for this payment method.","Activar para enviar un correo electrónico de confirmación de pedido al cliente cuando se crea correctamente el pedido. Específico para este método de pago." "Payment fee","Tarifa de pago" -"The above amount is calculated based on de Tax settings in Stores > Configuration > Sales > Tax.","La cantidad anterior se calcula a partir de los ajustes de Impuesto en Tiendas > Configuración > Ventas > Impuesto." +"The above amount is calculated based on de Tax settings in Buckaroo > General configuration and account information > Buckaroo Payment Fee Tax Class.","La cantidad anterior se calcula a partir de los ajustes de Impuesto en Tiendas > Configuración > Ventas > Impuesto." "Payment fee frontend label","Etiqueta front-end de tarifa de pago" "This label will be displayed next to the fee on the checkout","Esta etiqueta aparecerá junto a la tarifa en la pantalla de compra, el pedido, la factura, las notas de abono y los PDF." "Max order amount (in Base Currency)","Importe máx. del pedido (en moneda de base)" diff --git a/i18n/fr_FR.csv b/i18n/fr_FR.csv index c14c45df8..a12bf3c43 100644 --- a/i18n/fr_FR.csv +++ b/i18n/fr_FR.csv @@ -11,7 +11,7 @@ "Send order confirmation email","Envoyer un e-mail de confirmation de commande" "Enable to send an order confirmation email to the customer when the creating of the order is successful. Specific for this payment method.","Activer pour envoyer un e-mail de confirmation de commande au client lorsque la création de la commande est réussie. Spécifique pour ce mode de paiement." "Payment fee","Frais de paiement" -"The above amount is calculated based on de Tax settings in Stores > Configuration > Sales > Tax.","Le montant ci-dessus est calculé en fonction des paramètres de taxe dans Boutiques > Configuration > Ventes > Taxe." +"The above amount is calculated based on de Tax settings in Buckaroo > General configuration and account information > Buckaroo Payment Fee Tax Class.","Le montant ci-dessus est calculé en fonction des paramètres de taxe dans Boutiques > Configuration > Ventes > Taxe." "Payment fee frontend label","Étiquette frontale des frais de paiement" "This label will be displayed next to the fee on the checkout, order, invoice and creditmemo pages and pdfs.","Cette étiquette sera affichée à côté des frais sur les pages de paiement, de commande, de facture et de note de crédit et sur les fichiers .PDF." "Max order amount (in Base Currency)","Montant maximum de la commande (en devise de base)" diff --git a/i18n/nl_BE.csv b/i18n/nl_BE.csv index 0925b2c0b..0d2ddec2c 100644 --- a/i18n/nl_BE.csv +++ b/i18n/nl_BE.csv @@ -11,7 +11,7 @@ "Send order confirmation email","Verstuur order bevestigingsmail" "Enable to send an order confirmation email to the customer when the creating of the order is successful. Specific for this payment method.","Activeer om een order bevestigings email te versturen wanneer de order is aangemaakt. Specifiek voor deze betaalmethode." "Payment fee","Betaaltoeslag" -"The above amount is calculated based on de Tax settings in Stores > Configuration > Sales > Tax.","Dit bedrag wordt berekend op basis van de BTW instellingen in: Stores > Configuration > Verkoop > Belasting" +"The above amount is calculated based on de Tax settings in Buckaroo > General configuration and account information > Buckaroo Payment Fee Tax Class.","Dit bedrag wordt berekend op basis van de BTW instellingen in: Stores > Configuration > Verkoop > Belasting" "Payment fee frontend label","Betaaltoeslag label aan de voorkant" "This label will be displayed next to the fee on the checkout, order, invoice and creditmemo pages and pdfs.","Het label wordt getoond naast de betaaltoeslag tijdens de checkout en op de order, invoice, creditmemo pagina's en PDF." "Max order amount (in Base Currency)","Max. order bedrag (in basis munteenheid)" diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index f36ffe22d..bc0f9cead 100644 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -13,7 +13,7 @@ "Send order confirmation email","Verstuur order bevestigingsmail" "Enable to send an order confirmation email to the customer when the creating of the order is successful. Specific for this payment method.","Activeer om een order bevestigings email te versturen wanneer de order is aangemaakt. Specifiek voor deze betaalmethode." "Payment fee","Betaaltoeslag" -"The above amount is calculated based on de Tax settings in Stores > Configuration > Sales > Tax.","Dit bedrag wordt berekend op basis van de BTW instellingen in: Stores > Configuration > Verkoop > Belasting" +"The above amount is calculated based on de Tax settings in Buckaroo > General configuration and account information > Buckaroo Payment Fee Tax Class.","Dit bedrag wordt berekend op basis van de BTW instellingen in: Stores > Configuration > Verkoop > Belasting" "Payment fee frontend label","Betaaltoeslag label aan de voorkant" "This label will be displayed next to the fee on the checkout, order, invoice and creditmemo pages and pdfs.","Het label wordt getoond naast de betaaltoeslag tijdens de checkout en op de order, invoice, creditmemo pagina's en PDF." "Max order amount (in Base Currency)","Max. order bedrag (in basis munteenheid)"