diff --git a/Model/Method/AbstractMethod.php b/Model/Method/AbstractMethod.php index 6cce2e77..c2bcb68a 100644 --- a/Model/Method/AbstractMethod.php +++ b/Model/Method/AbstractMethod.php @@ -2773,8 +2773,8 @@ public function checkTotalGrossAmount($requestData, $payment) } return $requestData; - } + public function canUseForCountry($country) { if ($this->getConfigData('allowspecific') != 1) { diff --git a/Model/Method/Afterpay.php b/Model/Method/Afterpay.php index f48b40b6..89b41794 100644 --- a/Model/Method/Afterpay.php +++ b/Model/Method/Afterpay.php @@ -778,11 +778,8 @@ protected function getTaxCategory($order) if (!$taxClassId) { return $taxCategory; } - /** - * @var \Buckaroo\Magento2\Model\ConfigProvider\Method\Afterpay $afterPayConfig - */ - $afterPayConfig = $this->configProviderMethodFactory - ->get($this->_code); + + $afterPayConfig = $this->configProviderMethodFactory->get($this->_code); $highClasses = explode(',', (string)$afterPayConfig->getHighTaxClasses($storeId)); $middleClasses = explode(',', (string)$afterPayConfig->getMiddleTaxClasses($storeId)); @@ -798,7 +795,6 @@ protected function getTaxCategory($order) } elseif (in_array($taxClassId, $zeroClasses)) { $taxCategory = 3; } else { - // No classes == 4 $taxCategory = 4; } diff --git a/Model/Total/Quote/Tax/BuckarooFee.php b/Model/Total/Quote/Tax/BuckarooFee.php index b50c6f35..a3094d61 100755 --- a/Model/Total/Quote/Tax/BuckarooFee.php +++ b/Model/Total/Quote/Tax/BuckarooFee.php @@ -159,9 +159,9 @@ public function collect( Total $total ) { if (!$shippingAssignment->getItems()) { + parent::collect($quote, $shippingAssignment, $total); return $this; } - $orderId = $quote->getReservedOrderId(); // Check if already paid amount is affecting the calculation @@ -170,30 +170,13 @@ public function collect( } $result = $this->calculate->calculatePaymentFee($quote, $total); + if ($result === null){ return $this; } - $amount = $this->priceCurrency->convert($result->getRoundedAmount()); $this->addAssociatedTaxable($shippingAssignment, $result, $quote); - $feeDataObject = $this->quoteDetailsItemDataObjectFactory->create() - ->setType('buckaroo_fee') - ->setCode('buckaroo_fee') - ->setQuantity(1); - - $feeDataObject->setUnitPrice($result->getRoundedAmount()); - $feeDataObject->setTaxClassKey( - $this->taxClassKeyDataObjectFactory->create() - ->setType(TaxClassKeyInterface::TYPE_ID) - ->setValue(4) - ); - $feeDataObject->setIsTaxIncluded(true); - - $quoteDetails = $this->prepareQuoteDetails($shippingAssignment, [$feeDataObject]); - - $this->taxCalculationService->calculateTax($quoteDetails, $quote->getStoreId()); - parent::collect($quote, $shippingAssignment, $total); return $this; @@ -225,7 +208,6 @@ private function addAssociatedTaxable(ShippingAssignmentInterface $shippingAssig // Retrieve the Buckaroo fee tax class ID from BuckarooFeeConfigProvider using the store $taxClassId = $this->configProviderBuckarooFee->getBuckarooFeeTaxClass($store); - $associatedTaxables[] = [ CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_TYPE => self::QUOTE_TYPE, CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_CODE => self::CODE_QUOTE_GW, diff --git a/Model/Total/Quote/Tax/BuckarooFeeAfterTax.php b/Model/Total/Quote/Tax/BuckarooFeeAfterTax.php index e61ae0af..37322724 100644 --- a/Model/Total/Quote/Tax/BuckarooFeeAfterTax.php +++ b/Model/Total/Quote/Tax/BuckarooFeeAfterTax.php @@ -74,11 +74,13 @@ public function collect( if (empty($extraTaxableDetails[BuckarooFee::QUOTE_TYPE])) { return $this; } + $itemTaxDetails = $extraTaxableDetails[BuckarooFee::QUOTE_TYPE]; if (empty($itemTaxDetails[CommonTaxCollector::ASSOCIATION_ITEM_CODE_FOR_QUOTE][0])) { return $this; } + $buckarooFeeTaxDetails = $itemTaxDetails[CommonTaxCollector::ASSOCIATION_ITEM_CODE_FOR_QUOTE][0]; $buckarooFeeBaseTaxAmount = $buckarooFeeTaxDetails['base_row_tax'];