Sounds like an easy question, I know. I am literally stumped.
Here are two websites that have made the simple calculator:
I'm needing to calculate these PayPal's fees in my PHP application.
Here's what I got, say we wanted to be paid $30 even for membership fees. This is the function I'm using to calculate what we should charge to make up for it using PayPal's calculations (also described on both of the sites above): 2.9% of the transaction + $0.30.
function memfees()
{
$calc = round((30 * .029) + 30 + .30,2);
return $calc;
}
Test it here: http://matt.mw/junk/php/memfees.php
As you can see, it says 31.17.
Both of the other websites say it should be 31.20.
If I try $130.00, mine calculates to $134.07 and both of theirs calculate to $134.19.
What am I doing wrong?
Why am I using a Round function? Percentages cause some decimals to go past the hundredths place, and PayPal generates an error if there is more then 2 digits after the decimal. I thought people normally round money, (e.g. $31.6342 will be $31.63) but if that is the case, what am I doing wrong in my function? The amount that is off is further if there are large payments. This leads me to believe that something is wrong with the percentage portion.
Could you offer some help on this?
Thank you for your time.