PayPal Gateway Rejected Request 10413 in Magento 1.9 – How to Resolve

checkoutmagento-1.9paypal-express

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

Best Answer

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;
}
Related Topic