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

errorpaypal

is this using magento 1.9.0.1 has integrated the box expres paypal, in addition to this you have the plugin pro rewards points as reward points to buy some productosen which when it became the integration and buying products without using points of recompesa, payment by paypal nigun can be done without problem, but when customers use reward points, an error when confirming the order, which is

The gateway of PayPal rejected the request. The totals of the cart item Amounts Amounts do not match order (# 10413: Transaction refused Because of an invalid argument See additional error messages for details.)

Searching the net to try and fix this error, I suggest that you can modify the file Nav.php paypal adding any two codes which I put below:

first code

//Hack Start

$totalValue = $request['TAXAMT'] + $request['ITEMAMT'];
$finalValue = $totalValue - $request['AMT'];

if($request['SHIPPINGAMT'] > 0) {

$request['SHIPPINGAMT'] = ($request['AMT'] - ($request['TAXAMT'] + $request['ITEMAMT']));
$totalValue = $request['TAXAMT'] + $request['ITEMAMT'] + $request['SHIPPINGAMT'];
$finalValue = $totalValue - $request['AMT'];

}

if($request['AMT'] != $totalValue) {

if($totalValue > $request['AMT']) {
$request['TAXAMT'] = $request['TAXAMT'] - $finalValue;
}elseif($totalValue < $request['AMT']) {
$request['TAXAMT'] = $request['TAXAMT'] + $finalValue;
}else{
$request['AMT'] = $request['TAXAMT'] + $request['ITEMAMT'];
}
}

//Hack End

second Code

    // Check discount
$lineAmt = 0;
$discount = 0;
$line = 0;
$discountIndex = 0;
while(isset($request["L_AMT{$line}"])) {
if($request["L_NAME{$line}"] == 'Discount') {
$discount += $request["L_AMT{$line}"];
$discountIndex = $line;
}
else {
$lineAmt += $request["L_AMT{$line}"];
}
$line++;
}

if($discount) {
if($discount + $lineAmt != $request['ITEMAMT']) {
// Do correction
$request["L_AMT{$discountIndex}"] = ($request['ITEMAMT'] - $lineAmt);
} 
} else {
// Check item amount adds up
$correctItemAmt = $request['AMT'] - $request['SHIPPINGAMT'] - $request['TAXAMT'];
if($correctItemAmt != $request['ITEMAMT']) {
$request['ITEMAMT'] = $correctItemAmt;
}

//end

Adding either code, if allowed and make payment for that discount points, but the problem is that when you see the paypal payment, is charging the amount of discount rather than the total amount, the time that the paypal customers log in and go through the expres box, all amounts are correct and desglozadas in the end the total payment amount is fine, return to the store and confirm the order, which is made successfully, but when paypal payment in the amount of discount is what we receive, it exemplifies to make it clear

Product Cost> 340
Points usuados per customer> 125 equivalent to 20.54
Total purchase in store and paypal boxed expres> 319.46
Quantity recibda to see the account on paypal> 20.54

Apart from this, when buying payment unused reward points is made, an error indicating that the amount of the transaction is valid because it is Zero appears.

I've puzzled to see what the error codes either to modify it, but I can not do it, not if someone know I have to do or can help

Best Answer

Problem

The issue is pretty clear from the message: the total of item amounts and cart total amount that are sent to Paypal do not match.
As you've figured it out, this seems to be an issue with that points extension (or complete lack of support for Paypal Express).

Preferred solution

First thing I recommend is checking that you use the latest version of Reward Points Pro extension, as they may have already added support for Paypal Express or fixed the issue you are running into. If not, contact their support and try to get help from them.

Custom solution

NOTE: Please never ever modify a core Magento file. If there's no alternative (using an observer, etc) copy the file in local code pool and overwrite there.

You should take a look into file app/code/core/Mage/Paypal/Model/Cart.php line #318. As you can see Magento dispatches an event there that you can use to try to fix this problem.
By observing that event you will be able to access the actual Mage_Paypal_Model_Cart object that contains the items and totals of the cart that will be sent to Paypal.

I'm sorry, but not knowing how Reward Points Pro extension works internally, I can't give you exact guidance with code and everything. Basically, you should try to understand what happens in _render() & _validate() methods in app/code/core/Mage/Paypal/Model/Cart.php and make sure the discount from using points is correctly applied.

Also, I couldn't understand exactly the last part after the code, but please let me know if you have any questions.

Related Topic