0

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

0

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

3
  • 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 Jul 30 '19 at 15:51
  • Check store settings for the same once and also post custom code if you have done any – poojan sharma Jul 30 '19 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 Jul 30 '19 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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