2

tldr; According to magento fix notes the rounding error is fixed in 1.8 and later. We use 1.9 and have the rounding error for paypal express. How to fix it?


In a new storeview I have an error with paypal Express Checkout.

#10413 The totals of the cart item amounts do not match order amounts.

I could break it down (with debug mode) to a rounding problem. But I have also seen that some data is not passed to magento on the new storeview (address for example)

Here is the debug from the new storeview:

(
    [url] => https://api-3t.paypal.com/nvp
    [SetExpressCheckout] => Array
        (
            [PAYMENTACTION] => Authorization
            [AMT] => 97.80
            [CURRENCYCODE] => EUR
            [RETURNURL] => ...
            [CANCELURL] => ...
            [INVNUM] => 700000030
            [SOLUTIONTYPE] => Mark
            [GIROPAYCANCELURL] => ...
            [GIROPAYSUCCESSURL] => ...
            [BANKTXNPENDINGURL] => ...
            [LOCALECODE] => de_DE
            [ITEMAMT] => 75.55
            [TAXAMT] => 15.62
            [SHIPPINGAMT] => 6.64
            [L_NUMBER0] => LE-PANEL595-40-CW
            [L_NAME0] => ...Itemname...
            [L_QTY0] => 1
            [L_AMT0] => 75.55
            [METHOD] => SetExpressCheckout
            [VERSION] => 72.0
            [USER] => ****
            [PWD] => ****
            [SIGNATURE] => ****
            [BUTTONSOURCE] => Magento_Cart_Community
        )

    [response] => Array
        (
            [TIMESTAMP] => 2015-06-25T12:22:42Z
            [CORRELATIONID] => b9eeaea2f446
            [ACK] => Failure
            [VERSION] => 72.0
            [BUILD] => 17159089
            [L_ERRORCODE0] => 10413
            [L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details.
            [L_LONGMESSAGE0] => The totals of the cart item amounts do not match order amounts.
            [L_SEVERITYCODE0] => Error
        )

    [__pid] => 26085
)

and here the debug from the old storeview:

(
    [url] => https://api-3t.paypal.com/nvp
    [SetExpressCheckout] => Array
        (
            [PAYMENTACTION] => Authorization
            [AMT] => 107.80
            [CURRENCYCODE] => CHF
            [RETURNURL] => ...
            [CANCELURL] => ...
            [INVNUM] => 100000262
            [SOLUTIONTYPE] => Mark
            [GIROPAYCANCELURL] => ...
            [GIROPAYSUCCESSURL] => ...
            [BANKTXNPENDINGURL] => ...
            [LOCALECODE] => de_CH
            [ITEMAMT] => 92.50
            [TAXAMT] => 7.99
            [SHIPPINGAMT] => 7.31
            [L_NUMBER0] => LE-PANEL595-40-CW
            [L_NAME0] => ...itemname...
            [L_QTY0] => 1
            [L_AMT0] => 92.50
            [BUSINESS] => 
            [NOTETEXT] => 
            [EMAIL] => asdf@asdf.com
            [FIRSTNAME] => asdf
            [LASTNAME] => asdf
            [MIDDLENAME] => 
            [SALUTATION] => 
            [SUFFIX] => 
            [COUNTRYCODE] => CH
            [STATE] => 
            [CITY] => asdf
            [STREET] => asdf
            [ZIP] => 1111
            [PHONENUM] => 11 111 111
            [SHIPTOCOUNTRYCODE] => CH
            [SHIPTOSTATE] => 
            [SHIPTOCITY] => asdf
            [SHIPTOSTREET] => asdf
            [SHIPTOZIP] => 1111
            [SHIPTOPHONENUM] => 11 111 111
            [SHIPTOSTREET2] => 
            [STREET2] => 
            [SHIPTONAME] => asdf asdf
            [ADDROVERRIDE] => 1
            [METHOD] => SetExpressCheckout
            [VERSION] => 72.0
            [USER] => ****
            [PWD] => ****
            [SIGNATURE] => ****
            [BUTTONSOURCE] => Magento_Cart_Community
        )

    [response] => Array
        (
            [TOKEN] => EC-1TY898842U856944H
            [TIMESTAMP] => 2015-06-25T12:59:46Z
            [CORRELATIONID] => a456de03a7b81
            [ACK] => Success
            [VERSION] => 72.0
            [BUILD] => 17159089
        )

    [__pid] => 27391
)

There are alot of infos that are missing in the new storeview. But the problem is the rounding

Edit I said the shipping cost are not passed to paypal in the new store view. Thats wrong, the shipping costs are there [SHIPPINGAMT] => 6.64.

It is a rounding problem: [ITEMAMT] => 75.55 + [TAXAMT] => 15.62 + [SHIPPINGAMT] => 6.64 = 97.81, but [AMT] => 97.80. So that is the problem. I have read about some rounding problems in 1.7, but we use Magento Version 1.9.0.1. I will search for other similar problems now.

P.S. Our prices includes taxes.

3

The only "safe" solution I've found consist in blocking Magento to send to Paypal the order items.

In the admin panel goto System > Configuration > Sales > Payment Methods then select 'Paypal payment solutions' > 'Website payments standard' set 'Transfer Cart Line Items' to 'no'.

From now on Magento will tell paypal only the order total, shipment and taxes WITHOUT order details so paypal cannot make calculations anymore.

  • Sounds like a solution, sadly I cant test it anymore – nbar Feb 16 '16 at 16:37
1

This problem seems to be caused in Mage_Paypal_Model_Api_Abstract where _filterAmount is called. Magento uses round for rounding everywhere whilst sprintf is used for rounding here. When the 3rd decimal is a 5 this produces different results.

 sprintf('%.2F', 1.255);

This output 1.25 while

round(1.255,2);

outputs 1.26

changing sprintf('%.2F', $value); to round($value, 2); fixed the problem for me.

0

Change the taxes computation logic, it solved for me.

Check under: "System > Config > Sales > Taxes > Calculation Settings > Tax Calculation Method Based On"

Try using "Total" or "Row Total".

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.