[Skip to main content](#vessel-content)

#   Paypal plugin fee calculation

##

- **[johniac](/forum/user/48369-johniac "View johniac's Profile")**
- [![johniac's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/48369-johniac "View johniac's Profile") Topic Author
- [ Offline](/forum/user/48369-johniac)

Less More

- Posts: 5
- Thank you received: 1
-
-

9 years 7 months ago [\#263717](#263717) by [johniac](/forum/user/48369-johniac "View johniac's Profile")  *[Paypal plugin fee calculation](/forum/29-payment-methods/889109-paypal-plugin-fee-calculation#263717 "I searched the forum and didn't see anything about this. The Paypal fee isn't being calculated correctly, because Paypal calculates the fee based on the total amount you send to them (which includes...")* was created by *[johniac](/forum/user/48369-johniac "View johniac's Profile")*

I searched the forum and didn't see anything about this. The Paypal fee isn't being calculated correctly, because Paypal calculates the fee based on the total amount you send to them (which includes the fee), not on the base amount. For example, if your base amount is $30.00 and the Paypal formula is $0.30+2.2%, then it is incorrect to calculate 0.3+2.2%*(30) = 0.96 and then send $30.96 to Paypal. If you do, Paypal will charge $0.30+2.2%*($30.96) which is $0.98. So you end up with only $29.98 rather than $30.00. Does that make sense?

So the proper calculation would be:

( ( $30+$0.30) / 0.978) - $30

Or in the general case where B is the base amount we want to end up with, P is the price in the configuration menu, Q is the Percentage in the configuration menu and F is the calculated fee:

F = (B+P) / (1-Q) - B

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84ODkxMDktcGF5cGFsLXBsdWdpbi1mZWUtY2FsY3VsYXRpb24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86286
- Thank you received: 14263
-
-

9 years 7 months ago [\#263725](#263725) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Paypal plugin fee calculation](/forum/29-payment-methods/889109-paypal-plugin-fee-calculation#263725 "I searched the forum and didn't see anything about this. The Paypal fee isn't being calculated correctly, because Paypal calculates the fee based on the total amount you send to them (which includes...")*

Hi,

That's right, PayPal calculate its fees the same way the payment fee HikaShop payment plugins will calculate using the price and percentage settings in them based on the total amount before the fee is added, but since the payment fee calculated by the payment system is added during the checkout, the PayPal fee will be based on the total amount after the HiakShop payment fee has been added. So if you put the same numbers in the percentage and price field of the PayPal payment method of HikaShop, the payment fee calculated will have a different value that the fee PayPal will charge.

It's not that this is "incorrect", it's just not meant to try to do what you want it to do.
Payment fees is a system general to all the payment plugins of HikaShop. And its goal is not to come up with the same fees as PayPal. The price and percentage fields of payment plugins are based on the percentage and price fields of the shipping plugins and the calculations are done the same way, for consistency.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84ODkxMDktcGF5cGFsLXBsdWdpbi1mZWUtY2FsY3VsYXRpb24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[johniac](/forum/user/48369-johniac "View johniac's Profile")**
- [![johniac's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/48369-johniac "View johniac's Profile") Topic Author
- [ Offline](/forum/user/48369-johniac)

Less More

- Posts: 5
- Thank you received: 1
-
-

9 years 7 months ago [\#263823](#263823) by [johniac](/forum/user/48369-johniac "View johniac's Profile")  Replied by *[johniac](/forum/user/48369-johniac "View johniac's Profile")* on topic *[Paypal plugin fee calculation](/forum/29-payment-methods/889109-paypal-plugin-fee-calculation#263823 "I searched the forum and didn't see anything about this. The Paypal fee isn't being calculated correctly, because Paypal calculates the fee based on the total amount you send to them (which includes...")*

Thanks for your reply and I understand your reasoning, but still would like the calculation to match Paypal. Can you point me to what source code does the calculation so I can try to do my own mod?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84ODkxMDktcGF5cGFsLXBsdWdpbi1mZWUtY2FsY3VsYXRpb24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86286
- Thank you received: 14263
-
-

9 years 7 months ago [\#263824](#263824) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Paypal plugin fee calculation](/forum/29-payment-methods/889109-paypal-plugin-fee-calculation#263824 "I searched the forum and didn't see anything about this. The Paypal fee isn't being calculated correctly, because Paypal calculates the fee based on the total amount you send to them (which includes...")*

Hi,

It is done by the line: Code:

$methods[$k]-&gt;payment_price = $currencyClass-&gt;round(($price_all * (float)@$method-&gt;payment_params-&gt;payment_percentage / 100) + @$method-&gt;payment_price, $currencyClass-&gt;getRounding($currency,true));

in the file administrator/components/com_hikashop/class/payment.php

Beware that as explained before, changing that will change the calculations not only for the PayPal payment method but for all the payment methods on your website too.

The following user(s) said Thank You: [johniac](/forum/user/48369-johniac "View johniac's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84ODkxMDktcGF5cGFsLXBsdWdpbi1mZWUtY2FsY3VsYXRpb24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[johniac](/forum/user/48369-johniac "View johniac's Profile")**
- [![johniac's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/48369-johniac "View johniac's Profile") Topic Author
- [ Offline](/forum/user/48369-johniac)

Less More

- Posts: 5
- Thank you received: 1
-
-

9 years 7 months ago [\#264079](#264079) by [johniac](/forum/user/48369-johniac "View johniac's Profile")  Replied by *[johniac](/forum/user/48369-johniac "View johniac's Profile")* on topic *[Paypal plugin fee calculation](/forum/29-payment-methods/889109-paypal-plugin-fee-calculation#264079 "I searched the forum and didn't see anything about this. The Paypal fee isn't being calculated correctly, because Paypal calculates the fee based on the total amount you send to them (which includes...")*

Here's the new code if anybody else wants it:

$methods[$k]-&gt;payment_price = $currencyClass-&gt;round((($price_all + @$method-&gt;payment_price) / (1-(float)@$method-&gt;payment_params-&gt;payment_percentage / 100))-$price_all,$currencyClass-&gt;getRounding($currency,true));

But now when I go to checkout, it's showing the correct fee next to the payment method, but the amount shown under "Payment fee" at the bottom (and added into the total) is still the old calculation. Is there another place I need to change the formula?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84ODkxMDktcGF5cGFsLXBsdWdpbi1mZWUtY2FsY3VsYXRpb24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86286
- Thank you received: 14263
-
-

9 years 7 months ago [\#264082](#264082) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Paypal plugin fee calculation](/forum/29-payment-methods/889109-paypal-plugin-fee-calculation#264082 "I searched the forum and didn't see anything about this. The Paypal fee isn't being calculated correctly, because Paypal calculates the fee based on the total amount you send to them (which includes...")*

Hi,

Thanks !
It's probably just a cache thing. Logout and login again and that should clear it.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84ODkxMDktcGF5cGFsLXBsdWdpbi1mZWUtY2FsY3VsYXRpb24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[johniac](/forum/user/48369-johniac "View johniac's Profile")**
- [![johniac's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/48369-johniac "View johniac's Profile") Topic Author
- [ Offline](/forum/user/48369-johniac)

Less More

- Posts: 5
- Thank you received: 1
-
-

9 years 7 months ago [\#264145](#264145) by [johniac](/forum/user/48369-johniac "View johniac's Profile")  Replied by *[johniac](/forum/user/48369-johniac "View johniac's Profile")* on topic *[Paypal plugin fee calculation](/forum/29-payment-methods/889109-paypal-plugin-fee-calculation#264145 "I searched the forum and didn't see anything about this. The Paypal fee isn't being calculated correctly, because Paypal calculates the fee based on the total amount you send to them (which includes...")*

No, it's definitely persisting. Anything else I can try?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84ODkxMDktcGF5cGFsLXBsdWdpbi1mZWUtY2FsY3VsYXRpb24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86286
- Thank you received: 14263
-
-

9 years 7 months ago [\#264163](#264163) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Paypal plugin fee calculation](/forum/29-payment-methods/889109-paypal-plugin-fee-calculation#264163 "I searched the forum and didn't see anything about this. The Paypal fee isn't being calculated correctly, because Paypal calculates the fee based on the total amount you send to them (which includes...")*

Hi,

Then that line might need to be changed too: Code:

$payment-&gt;payment_price = $currencyClass-&gt;round(($price_all * (float)@$payment-&gt;payment_params-&gt;payment_percentage / 100) + $payment_price, $currencyClass-&gt;getRounding($currency, true));

it's in the same file.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84ODkxMDktcGF5cGFsLXBsdWdpbi1mZWUtY2FsY3VsYXRpb24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[johniac](/forum/user/48369-johniac "View johniac's Profile")**
- [![johniac's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/48369-johniac "View johniac's Profile") Topic Author
- [ Offline](/forum/user/48369-johniac)

Less More

- Posts: 5
- Thank you received: 1
-
-

9 years 7 months ago [\#264303](#264303) by [johniac](/forum/user/48369-johniac "View johniac's Profile")  Replied by *[johniac](/forum/user/48369-johniac "View johniac's Profile")* on topic *[Paypal plugin fee calculation](/forum/29-payment-methods/889109-paypal-plugin-fee-calculation#264303 "I searched the forum and didn't see anything about this. The Paypal fee isn't being calculated correctly, because Paypal calculates the fee based on the total amount you send to them (which includes...")*

That was it. It's perfect now. Thanks so much!

New code:

$payment-&gt;payment_price = $currencyClass-&gt;round((($price_all + $payment_price) / (1 - (float)@$payment-&gt;payment_params-&gt;payment_percentage / 100)) - $price_all,$currencyClass-&gt;getRounding($currency, true));

The following user(s) said Thank You: [lesk](/forum/user/58400-lesk "View lesk's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84ODkxMDktcGF5cGFsLXBsdWdpbi1mZWUtY2FsY3VsYXRpb24/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.380 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
