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 +