6

So here's what I initially started with: You would go to pay via PayPal, and it would flat error out with

Paypal error # 10413: The totals of the cart item amounts do not match order amounts

I have corrected this part of the problem by setting the TOTAL_DISCOUNT constant in Paypal Cart.

I overrode the App/code/core/Mage/Paypal/Model/Cart.php Mage_Paypal_Model_Cart class, with MyCompany_Paypal_Model_Cart I extended the class and added a modified _render() Method.

The Gist of it was to replace:

self::TOTAL_DISCOUNT => abs($address->getBaseDiscountAmount()),

With this:

self::TOTAL_DISCOUNT => abs($this->_salesEntity->getData('gift_cards_amount_used')),

This added in the discount from our custom giftcard module. So then this created a new bug. The user is redirected to Paypal, and they 'pay' for their items, and redirected back to Magento where we get the error:

PayPal gateway has rejected the 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).

I started looking and dumping our objects in the Mage/Paypal/Controller/Express/Abstract.php: PlaceOrderAction() controller method and the _getQuote() Method, and I found the following values buried in the customer->_data attribute: (Keep in mind this MIGHT be a red herring, but I figured any information that appears incorrect or incomplete should be noted)

'subtotal' => string '49.9900' (length=7)
'base_subtotal' => string '49.9900' (length=7)
'subtotal_with_discount' => string '49.9900' (length=7)
'base_subtotal_with_discount' => string '49.9900' (length=7)

(These totals DO NOT contain the discount of $25)

Just to be clear, the line items look correct:

[L_NAME0] => Company Wrench
[L_NAME1] => Discount
[L_NUMBER0] => 20498
[L_QTY0] => 1
[L_QTY1] => 1
[L_TAXAMT0] => 0.00
[L_TAXAMT1] => 0.00
[L_AMT0] => 49.99
[L_AMT1] => -25.00

[L_PAYMENTREQUEST_0_NAME0] => Company Wrench
[L_PAYMENTREQUEST_0_NAME1] => Discount
[L_PAYMENTREQUEST_0_NUMBER0] => 20498
[L_PAYMENTREQUEST_0_QTY0] => 1
[L_PAYMENTREQUEST_0_QTY1] => 1
[L_PAYMENTREQUEST_0_TAXAMT0] => 0.00
[L_PAYMENTREQUEST_0_TAXAMT1] => 0.00
[L_PAYMENTREQUEST_0_AMT0] => 49.99
[L_PAYMENTREQUEST_0_AMT1] => -25.00
[PAYMENTREQUESTINFO_0_ERRORCODE] => 0

There are a few other questions close to this one, but they all deal with BEFORE the redirect to PayPal. This is occurring AFTER the redirect.

I have asked a few questions thus far, so pardon if I got anything in the question format incorrect, I would be happy to correct anything or provide more details. Thank you for your time!

* UPDATE: I think I know what the issue is. Since the discount is rendered as a line item, below would suggest that the discount line item at some point isn't being added to the item amount. I am going to test this by hard-coding the item amount and seeing if it takes it. *

[DoExpressCheckoutPayment] => Array
    (
        [TOKEN] => EC-TOKENYNUMBERTHING
        [PAYERID] => 8675309ABC
        [PAYMENTACTION] => Authorization
        [AMT] => 36.53
        [CURRENCYCODE] => USD
        [BUTTONSOURCE] => Magento_Cart_Community
        [NOTIFYURL] => https://companySandbox.com/paypal/ipn/
        [RETURNFMFDETAILS] => 1
        [ITEMAMT] => 49.99
        [TAXAMT] => 0.00
        [SHIPPINGAMT] => 11.54
        [METHOD] => DoExpressCheckoutPayment
        [VERSION] => 72.0
        [USER] => ****
        [PWD] => ****
        [SIGNATURE] => ****
    )

* UPDATE: If I hard code the subtotal with what it's supposed to be, it works. But the moment i add in the algorithmic solution, it all falls apart and I get the error message. (subtracting the giftcard from the subtotal) Very weird. I thought I cracked the case, but apparently not) Also, I did try to chase the possibility that the issues was due to type cast and rounding. No success, but I am still trying. *

* UPDATE: What I've discovered is that that all the variables and everything are good on it's way to Paypal, but on the way back to Magento the _render() method is called again and this is where the values of the discount and subtotal are dissappearing. So when I hard code the values Paypal will work. I suppose the next step is to save the discount in the database to be recalled by magento when Paypal redirects back. I really don't entirely know how to use the ORM yet. *

Also, the discount_amount is not being stored in my database. I really think that's the issue. I am new to Magento and not entirely sure how to use the ORM yet. I am reading about it right now.

database_1

So what this really boils down to is that the overridden _render() method in app/code/local/company/Paypal/Model/Cart.php is being hit AFTER you are returned to Magento from Paypal. This method sets a bunch of values. On this last trip through the values are missing for the discount. Thus, the correct values never make it into the subtotal, thus the thing errors out with: * # 10413: The totals of the cart item amounts do not match order amounts *

3

In my case, i activated 'SSL verification' and was not checked 'Transfer Cart Line Items'.

Now, I activated this opcion in Module Paypal - Configuration - Basic Settings and works fine.

| improve this answer | |
  • I never did figure this out. I had to turn it over to our Ukrainian team to fix and I never got an update on it. I am working in Laravel now. Magento just wasn't my thing, But I will give you an upvote. Sounds plausible to me! – dustbuster Apr 16 '19 at 20:48

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.