Calculating Processing Fee Before it's made.

This may be a simple problem but I can seem to figure it out...

I'm writing a piece of software that sends payments though Paypal. PayPal charges a 2% fee per transaction that we in turn want to take out of the users payment.

For smaller transactions I can use the simple math of taking the transaction fee amount out before we send the payment and because of rounding the math will work out.

However, with larger transactions, because I am taking the fee out before sending it to Paypal, the actual fee applied to the transaction becomes less than what I took out.

For example:

If I need to send 100, we first take the 2% out and send 98. Then Paypal applies a fee 1.96. Thus we have ended up with .04 overbalance.

Is there an equation I can use to correct this balance?

-

I find it easier to work with decimals than with percent. So for example $3\%$ is $0.03$.

You receive an amount of money $A$. You seem to want to take out a certain fraction $t$ of it, that is, keep back the amount $tA$, and send the rest, namely $(1-t)A$ to PayPal.

Then PayPal will charge $2\%$ of $(1-t)A$. So the PayPal charge is $(0.02)(1-t)A$. Your text seems to say that you want the amount charged by PayPal to be the amount you had kept back. That gives us the equation $$(0.02)(1-t)A=tA.$$ We want to solve for $t$. The $A$'s cancel, and we obtain $(0.02)(1-t)=t$. This becomes $0.02 -0.02t=t$, and then $0.02=1.02 t$. Solve for $t$. We obtain $$t=\frac{0.02}{1.02}.$$ The answer looks nicer if we multiply top and bottom by $100$, obtaining $$t=\dfrac{2}{102}.$$ If PayPal alters the percentage it charges, the derivation above is easy to modify to suit the new situation.

In decimals, $t\approx 0.0196078$, or if you prefer percent, $t\approx 1.96078\%$.

-

2% of 98 is 1.96, not 1.94 (probably a typo). You have two issues. It seems you are subtracting instead of adding-if you want 100 to arrive at the other end, you need to send more than 100 through PayPal to get there. Then if PayPal is going to take 2%, you divide the amount you want to get there by 0.98. So for 100 to arrive, you need to send 10/0.98=102.0408 through PayPal.

In your example, if you send 100, take off 2, PayPal takes 1.96 and 96.04 is left. You need to add 2.0408, then PayPal takes the 2.0408 and 100 comes out the other end.

-
sorry I wasn't very clear, We want to take the Paypal fee out of the users balance. –  NSjonas Apr 18 '12 at 18:26

Given an amount $A$, you want $B$ such that 102% of $B$ is equal to $A$. In other words, $1.02 \times B = A$. You can do the rest yourself :-)

-