Prestashop: Put a commission to PayPal payment module.
Updated April 2016.
In our online store developed with Prestashop we can establish various payment methods. Including PayPal. So that you can pay through this platform must install the module payment.
PayPal will charge us a fee of approximately 3.5% per transaction. If we collect the surcharge to the customer at the time of payment, PayPal module for Prestashop does not give us that option. We need to modify the code in PHP module to change the way of calculating the total and add the commission as an expense over handling and transport.
Prestashop 1.5 and 1.6
Here’s the PayPal payment module with surcharge: paypal-comision.zip
This module includes a change: I modified the code file paypal.php to add the variable id_carrier. Thus, when using multiple carrier companies in our online store, the carrier selected during the purchase process will be used in the calculations.
This module is a contribution of Prestashop community. You can find comments and questions resolved in the forum.
You can also leave your comments and questions at the end of this post.
Here are the steps to modify the PayPal payment module:
1 – First you make a backup of the files that we will modify. For Prestashop 1.4 are in the folder:
2 – Change the total receivables in the submit.php file to add the commission:
$comisionP = 1.03; //for a 3% comission
$totalP = $cart->getOrderTotal(true, Cart::BOTH); //total basket
$totalP = $totalP * $comisionP; //total comission
Just below where values are assigned to the variable $smarty, replace the line:
‘total’ => $cart->getOrderTotal(true, Cart::BOTH),
‘total’ => $totalP,
3 – Change in paypalpayment.php the total receivables and shipping charges to add the commission and listed as an expense of handling and transport in the breakdown of the purchase:
$paymentAmount = (float)($cart->getOrderTotal());
$comision = $paymentAmount * 0.03; //comission calculation
$paymentAmount = $paymentAmount + $comision; //adding comission to total
$shipping = $this->PayPalRound($cart->getOrderShippingCost($cart->id_carrier, false));
//ship + comission:
$shipping = $shipping + $comision;
4 – Change the text displayed on the confirmation page to warn that a commission be added to the total:
In file modules/paypal/en.php (or the corresponding language file), find the line where it says “You have chosen to pay with PayPal.” and add a text to explain the included comission.
5 – Upload the changed files to the server and ready. : )