1

While placing an order using Paypal as payment, Magento 2 is adding the total tax twice to the AMT (amount) sent to PayPal.

Here is what is sent to paypal :

'AMT' => 134.10,  // should be 114.10
'SHIPPINGAMT' => 5.00, 
'ITEMAMT' => 89.10, 
'TAXAMT' => 20.00,

Here is Paypal's error:

PayPal gateway has rejected request. The totals of the cart item amounts do not match order amounts (#10413: Transaction refused because of an invalid argument. See additional error messages for details).

The quote tax is set via a plugin :

<preference for="Magento\Tax\Model\Sales\Total\Quote\Tax" type="Vendor\Module\Model\Sales\Total\Quote\Tax"/>

Class :

class Tax extends \Magento\Tax\Model\Sales\Total\Quote\Tax{
    public function __construct(
        \Magento\Tax\Model\Config $taxConfig,
        \Magento\Tax\Api\TaxCalculationInterface $taxCalculationService,
        \Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory,
        \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory,
        \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory,
        CustomerAddressFactory $customerAddressFactory,
        CustomerAddressRegionFactory $customerAddressRegionFactory,
        \Magento\Tax\Helper\Data $taxData ) {
        $this->setCode('tax');
        parent::__construct($taxConfig, $taxCalculationService, $quoteDetailsDataObjectFactory, $quoteDetailsItemDataObjectFactory, $taxClassKeyDataObjectFactory, $customerAddressFactory, $customerAddressRegionFactory, $taxData
        );
    }

    public function collect(
        \Magento\Quote\Model\Quote $quote,
        \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
        \Magento\Quote\Model\Quote\Address\Total $total ) {
        $total->setTotalAmount('tax', 20);     //set fixed value for testing
        $total->setBaseTotalAmount('tax', 20); //set fixed value for testing
        return $this;
    }

}

When the payment is "Check / Money order" the Order's totals and tax are correct. Correct amount and tax on order screen

I have been trying to solve this issue over the last week but without any success. Our Magento 2.3 instance doesn't have any other module and this is the only place the quote has been modified or even used.

Thanks

1
  • Did you find any solution to this issue?
    – mechanic
    Commented Nov 16, 2022 at 11:06

1 Answer 1

-1

login in Magento admin section and navigate to

store -> configration -> sales -> Tax

Click on shopping cart display settings and make sure you have No for Display Full Tax Summary. If it is yes make it No.

After change configuration Clear cache.

Please find attachment enter image description here

5
  • Turning Display Full Tax Summary to No does not fix the issue, the tax is still applied twice on the Paypal AMT. I also tried to force Include Tax in Order Total to no without success.
    – Guilhem
    Commented Jul 30, 2019 at 15:51
  • Check store settings for the same once and also post custom code if you have done any Commented Jul 30, 2019 at 16:23
  • I have changed everything i could find and the AMT set by magento is still equal to itemamout + shipping + tax + tax. I don't have any other custom code.
    – Guilhem
    Commented Jul 30, 2019 at 18:19
  • Did you find a solution for this?
    – mechanic
    Commented Sep 30, 2022 at 17:49
  • Sadly no @mechanic, if i remember correctly we just said F it, then we removed paypal....
    – Guilhem
    Commented Nov 17, 2022 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.