Prestashop – Paypal module. Solution to the error of payment in orders and problem in the rounding of the prices of the products
We explain why the payment error status is generated in orders paid through the official Paypal module in Prestashop stores. We detail the causes that cause customers to make payments of different amounts than those listed in the store’s shopping cart.
What are the causes that cause the payment error status and the difference in amounts paid by customers through the official Paypal module on Prestashop ?
To this day, this problem is one of those that continues to bring many users and owners of Prestashop online stores to their heads. Surprisingly, no solution has been officially applied yet and therefore continues to appear in the latest versions of the official Paypal module . Even still in Prestashop stores version 1.7 We have clients who have reported this same problem to us.
The origin and also the explanation of the problem is in the following:
On the one hand we have the rounding system that Prestashop uses and that you can choose between several options within the selector “Rounding type” located in the Back-office:
Store parameters -> Setting -> Rounding type
Prestashop allows us to choose between the following types of rounding:
- Round on each item
- Round in each line (That is the system used by Paypal)
- Round over the total
On the other hand we have the Paypal module , which through its own API , calculates the tax amount for each product using its own rounding system.
The Paypal rounding system is independent of the system used by Prestashop and is based on the rounding of prices for each product line .
In the fact that the two platforms perform their own calculations, it causes that there are frequently differences between the amounts that Prestashop calculates in the shopping carts and the amounts calculated by Paypal in the payment process.
This is the summary explanation of why this problem occurs.
To delve a little deeper into the subject. What happens during the purchase process?
During the purchase process, Prestashop sends to Paypal all the detailed information of the shopping cart with all the amounts previously rounded depending on the option selected in the Back-office.
Paypal, through its API, calculates the amounts of each product and applies its own rounding (rounding for each product line) after adding the taxes to each base price sent by Prestashop.
During this process, on the one hand we have the amounts of the Prestashop shopping cart and on the other hand we have the amounts that Paypal calculates and which will be the ones that will definitely be charged to the customer.
As long as customers make purchases of few units of products or that the prices of said products are high, the amounts calculated by Prestashop and the amounts calculated by Paypal will coincide and the mentioned problem will not exist. Nevertheless, When purchases of many quantities of products are made and the prices of these products are low (less than one euro per unit), it is when the difference in the amounts calculated by both platforms originates due to the accumulation of errors during the calculation of the rounding of each unit.
After completing the payment in Paypal, the API returns the information of the operation to Prestashop. Among this information is the actual total amount paid by the customer. Therefore, since there is a difference between the total amount calculated by Prestashop and the actual amount paid through Paypal, Prestashop handles the operation as a payment error, showing the status “Payment error” when the order is generated.
We show an example of a real situation in a Prestashop store where the error of the calculation of the amounts occurs in the Paypal module
In the example that we show in the images we can see that in a Prestashop store, the total amount of the purchase is € 265.16 including taxes, the base price is € 219.14 and the total taxes are € 46.02. When choosing the payment method by Paypal and being redirected to the payment platform, we see that the total amount to pay is € 266.29 (A difference of € 1.13), an amount higher than that shown in the Prestashop store and that the customer ultimately has to overpay. We can verify that the error is in the calculation of total taxes by Paypal (€ 47.15).
Table with breakdown of amounts of the actual example shown
|Base amount||€ 219.14||€ 219.14|
|Total amount with taxes||€ 265.16||€ 266.29|
|Total amount of taxes (21%)||€ 46.02||€ 47.15|
Analyzing the previous example, we see that there is a difference in the amount to be paid between the amounts shown in the Prestashop shopping cart and the amount calculated by Paypal, which is the one that will actually be charged to the customer. This difference is in the amount from the tax calculation.
In addition to the error in the payment that originates in the order, also the customers realize that they have paid a different amount than the one shown in the Prestashop store. This situation leads to outrage among customers and complaints. The situation worsens when the amount to be paid in Paypal is much higher than that shown in the Prestashop store when mass purchases are made.
When it is the case that the amount calculated by Paypal is lower than that shown in the store, significant economic losses are caused for businesses.
The rounding error problem in the Paypal module is more frequent when stores sell many quantities of products whose prices are very low (amounts less than € 1).
At Liewebs we have developed a definitive solution
From Liewebs we have worked to offer a perfect solution to this problem of rounding in the Paypal platform for Prestashop versions 1.6 and 1.7
If we do an exhaustive search on the internet, we can read several articles that talk about this problem. Different solutions and “tricks” are even proposed to be able to solve or minimize this problem.
Those solutions in most cases are a small “fix” that work only for some versions of the Prestashop Paypal modules. On other sites, the modification of the concepts, amounts and products shown in Paypal is proposed. In the latter case, it could cause purchasing management problems in the Paypal platform if your advanced invoice and management tools.
Our solution is based on modifying the source code within the Paypal module, managing to send, in a specific way, the data of the products and amounts to Paypal through its API. Sending you on the one hand, the amounts of the products without taxes and on the other hand your specific taxes.
In this way, your system calculates the amounts of the products and their taxes, coinciding with the same calculation that Prestashop does. Therefore, the amounts and purchase concepts remain exactly the same and there is no variation after applying our patch.
As you can see in the previous image, we have managed not to vary the purchase concepts that are sent to the Paypal platform, so there will never be problems in managing purchases on said platform, since the information sent is the same as before applying. our patch.
Today it is one of the best solutions that we can offer to all our clients and interested parties who want to acquire it.
For your information, you have to bear in mind that these modifications require continuous supervision and review of the new versions of the Paypal module. In this way, you can apply different versions of the patch depending on the updated code in each version of the Paypal module.