News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

PayPal returned: The totals of the cart item amounts do not match order amounts

Started by fionny, October 12, 2011, 14:38:44 PM

Previous topic - Next topic

fionny

Help please!

I get this error when using the new Paypal API when there is a discount applied.

PayPal returned: The totals of the cart item amounts do not match order amounts.

If there is no discount on the cart the payment goes through without any issue! I urgently need to fix this so im hoping someone has found a solution already.

Thanks!
Fionn


fionny

Nobody any idea's?

Im sure it must be something wrong in this part on lines 1420 to 1441:

// SUBTOTAL CALCULATION
            $ret_str.="&L_AMT".$i."=".round($product_price,2);
            $ret_str.="&L_QTY".$i."=".$cart[$i]["quantity"];
            $ret_str.="&L_NAME".$i."=".urlencode($ps_product->get_field($_SESSION['cart'][$i]["product_id"], "product_name"));
            $item_total += round($product_price,2) * $cart[$i]["quantity"];
}
if( !empty($order_totals['coupon_discount'] ) ) {
// Discount is the difference left after order total has been reduced by subtotal, tax, shipping and shipping tax
$discount = round($order_totals['order_total'], 2)
- $item_total
- round($order_totals['order_tax'], 2)
- $order_totals['order_shipping']
- $order_totals['order_shipping_tax'];
            // add discount as line item
            $ret_str.="&L_AMT".$i."=".round($discount,2);
            $ret_str.="&L_QTY".$i."=1";
            $ret_str.="&L_NAME".$i."=".urlencode($VM_LANG->_('PHPSHOP_COUPON_DISCOUNT'));
           
$item_total += $discount;
}
$order_totals['item_total'] = round($item_total, 2);
$ret_str.="&ITEMAMT=".round($item_total, 2);