0

I get the following 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).

I have a module installed called Charity Checkout where one can donate a $1 in the checkout process at Payment Information step 5, a pop-up appears when one clicks the next step button. If they agree to donate a $1 they get redirrected back to the cart with the above error.

I have seach ?google to death looking for a solution. It seems it has something to do with PayPal Express. I think the Charity Checkout extension dosen't work correctly with PayPal Express but regular PayPal. Anyway, here is the config for Charity Checkout

            <paypal_prepare_line_items>
            <observers>
                <charitycheckout_paypal_prepare_line_items>
                    <class>charitycheckout/observer</class>
                    <method>updatePaypalTotal</method>
                </charitycheckout_paypal_prepare_line_items>
            </observers>
        </paypal_prepare_line_items>

here is the observer:

    /**
 * Update PayPal Total
 *
 * @param Varien_Event_Observer $observer
 * @return GoodLabs_CharityCheckout_Model_Observer
 */
public function updatePaypalTotal(Varien_Event_Observer $observer)
{
    $cart = $observer->getEvent()->getPaypalCart();

    $cart->updateTotal(Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL, $cart->getSalesEntity()->getDonationAmount());

    return $this;
}

Here is my payment_paypal_express.log

    2016-03-17T17:17:01+00:00 DEBUG (7): Array
(
    [url] => https://api-3t.paypal.com/nvp
    [SetExpressCheckout] => Array
        (
            [PAYMENTACTION] => Sale
            [AMT] => 28.94
            [CURRENCYCODE] => USD
            [RETURNURL] => https://www.example.com/paypal/express/return/
            [CANCELURL] => https://www.example.com/paypal/express/cancel/
            [INVNUM] => 37084
            [SOLUTIONTYPE] => Sole
            [GIROPAYCANCELURL] => https://www.example.com/paypal/express/cancel/
            [GIROPAYSUCCESSURL] => https://www.example.com/checkout/onepage/success/
            [BANKTXNPENDINGURL] => https://www.example.com/checkout/onepage/success/
            [LOCALECODE] => en_US
            [ITEMAMT] => 21.97
            [TAXAMT] => 0.00
            [SHIPPINGAMT] => 7.97
            [L_NUMBER0] => 100029
            [L_NAME0] => Nature's Grace Love Angel Figurine 
            [L_QTY0] => 1
            [L_AMT0] => 19.97
            [L_NUMBER1] => 100020
            [L_NAME1] => Complimentary Angel Earrings
            [L_QTY1] => 1
            [L_AMT1] => 0.00
            [BUSINESS] => 
            [NOTETEXT] => 
            [EMAIL] => example@hotmail.com
            [FIRSTNAME] => john
            [LASTNAME] => doe
            [MIDDLENAME] => 
            [SALUTATION] => 
            [SUFFIX] => 
            [COUNTRYCODE] => US
            [STATE] => KY
            [CITY] => Corbin
            [STREET] => street address
            [ZIP] => 12345
            [PHONENUM] => 
            [SHIPTOCOUNTRYCODE] => US
            [SHIPTOSTATE] => KY
            [SHIPTOCITY] => Corbin
            [SHIPTOSTREET] => street address
            [SHIPTOZIP] => 12345
            [SHIPTOPHONENUM] => 
            [SHIPTOSTREET2] => 
            [STREET2] => 
            [SHIPTONAME] => john doe
            [ADDROVERRIDE] => 1
            [METHOD] => SetExpressCheckout
            [VERSION] => 72.0
            [USER] => ****
            [PWD] => ****
            [SIGNATURE] => ****
            [BUTTONSOURCE] => Magento_Cart_Community
        )

    [response] => Array
        (
            [TIMESTAMP] => 2016-03-17T17:17:02Z
            [CORRELATIONID] => e6cc21f446694
            [ACK] => Failure
            [VERSION] => 72.0
            [BUILD] => 18316154
            [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] => 356049
)

I think I have to upgrade this to paypal express? Everything works fine unless one chooses yes to donate. Thank you

  • is your issue solved or not? – Gem Jul 28 '17 at 11:45
1

You have the subtotal:

[ITEMAMT] => 21.97 It doesn't correspond to the total of all items: [L_AMT0] => 19.97 [L_AMT1] => 0.00 That's the reason why PayPal is showing the error.

Here is how the function should look in the observer:

public function updatePaypalTotal(Varien_Event_Observer $observer)
{
    $cart = $observer->getEvent()->getPaypalCart();

    $donationAmount = $cart->getSalesEntity()->getDonationAmount();
    if ($donationAmount > 0) {
        $cart->addItem('Additional Fees', 1, $donationAmount, 'donation');
    }

    return $this;
}
  • When I tried your code I get the following error: Call to a member function addItem() on null in public_html/app/code/local/GoodLabs/CharityCheckout/Model/Observer.php on line 49 My PHP Version is 5.6.17 and SQL version 5.5.48-37.8 Percona Server if those help. – Freejoy Mar 22 '16 at 16:44
  • Changing $paypalModel->addItem to $cart->addItem fixed the error. Thank you. – Freejoy Mar 26 '16 at 8:42
1

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.

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.