Surcharge On Paypal Express

Hi Guys,



Is surcharge on Paypal express checkout not working anymore.



It was find with 3.x, after upgrading to 4.x I started getting the following error with 4% surcharge.



Error 10413 Transaction refused because of an invalid argument. See additional error messages for details.: The totals of the cart item amounts do not match order amounts.



Any clue ?



regds,

Shikhar

@shikhar,



Hi. Unfortunately we have no active PayPal Express merchant account. But I have made a quick overview of the code. Please try the following solution:


  1. Open the “app/payments/paypal/paypa_express.functions.php”
  2. Replace this part of code



foreach ($data['products'] as $product) {
if ($product['price'] != 0) {
$order_data['L_PAYMENTREQUEST_0_NAME' . $product_index] = $product['product'];
$order_data['L_PAYMENTREQUEST_0_NUMBER' . $product_index] = $product['product_code'];
$order_data['L_PAYMENTREQUEST_0_DESC' . $product_index] = fn_paypal_get_product_option($product);
$order_data['L_PAYMENTREQUEST_0_QTY' . $product_index] = $product['amount'];
$order_data['L_PAYMENTREQUEST_0_AMT' . $product_index] = $product['price'];
$product_index++;
}
}




with this one:



foreach ($data['products'] as $product) {
if ($product['price'] != 0) {
$order_data['L_PAYMENTREQUEST_0_NAME' . $product_index] = $product['product'];
$order_data['L_PAYMENTREQUEST_0_NUMBER' . $product_index] = $product['product_code'];
$order_data['L_PAYMENTREQUEST_0_DESC' . $product_index] = fn_paypal_get_product_option($product);
$order_data['L_PAYMENTREQUEST_0_QTY' . $product_index] = $product['amount'];
$order_data['L_PAYMENTREQUEST_0_AMT' . $product_index] = $product['price'];
$product_index++;
}
}
if (floatval($data['payment_surcharge'])) {
$order_data['L_PAYMENTREQUEST_0_NAME' . $product_index] = __('surcharge');
$order_data['L_PAYMENTREQUEST_0_NUMBER' . $product_index] = 'SURCHARGE';
$order_data['L_PAYMENTREQUEST_0_DESC' . $product_index] = __('payment_surcharge');
$order_data['L_PAYMENTREQUEST_0_QTY' . $product_index] = 1;
$order_data['L_PAYMENTREQUEST_0_AMT' . $product_index] = $data['payment_surcharge'];
$product_index++;
}


3. Save the file and check the result.



Let me know the result, please.

Thanks ecom,



It worked with one more code edit, a line after your code snippet.





//$order_data['PAYMENTREQUEST_0_ITEMAMT'] = empty($data['subtotal_discount']) ? $data['subtotal'] : $data['subtotal'] - $data['subtotal_discount'];

$order_data['PAYMENTREQUEST_0_ITEMAMT'] = empty($data['subtotal_discount']) ? ($data['subtotal'] + $data['payment_surcharge']) : ($data['subtotal']+$data['payment_surcharge']) - $data['subtotal_discount'];

@shikhar,



Thanks for the comment. Hope it will be useful for community.

You may want to read the T & C's you agreed to when creating your PayPal account. They do vary from country to country but in mine you are not allowed to charge a surcharge for accepting PayPal.

Thanks eComLabs and shikhar, I needed this fix for a client of mine!