How can I correctly calculate a percentage of a number

58 Views Asked by At

I'm sending a transfer from the Stripe payout service API. I'd like to calculate out the Stripe payout fees ($0.25$%) from each transfer to a bank account?

Problem - I need to collect/recoup fees from each transfer to cover my fees ($5$%) plus the Stripe Connect fees ($0.25$%) and I'm unsure about how to compute the numbers as taking $0.25$% of the transfer will equate to a larger % than what Stripe will take in the payout.

FYI - Stripe takes their $0.25$% from the payout when sent to the bank account.

Ex. Transfer 10 dollars to bank account minus Stripe fees and my fees

$10$ dollars - $5$% (my fee) $\rightarrow$ $9.50$ dollars

Next I take out $0.25$% (stripe fee) of $9.50 = 9.50 - 0.2375c = 9.2625$

I now send(transfer) $9.2625$ to the bank account

Now when Stripe pays out it will take $0.25$% of $9.2625 = 0.2316c

So the problem is I'm taking $0.25$% out of $9.50$ and Stripe is taking $0.25$% out of $9.2625$.

Can anyone help correct this math?

1

There are 1 best solutions below

5
On BEST ANSWER

So you have $A$ money after deducing your own fee, and you want to deduce $x\%$ so that this is equal to $z\%$ deduction that Stripe does? In this case:

  • Your Stripe deduction: $A\frac{x}{100}$
  • Money sent: $A(1-\frac{x}{100})$
  • Stripe deduces: $A\left(1-\frac{x}{100}\right)\frac{z}{100}$

and you want:

$$A\frac{x}{100}=A\left(1-\frac{x}{100}\right)\frac{z}{100}$$

i.e. (cancelling $A$ and solving for $x$):

$$x=\frac{z}{1+\frac{z}{100}}$$

In our case, $z=0.25$ which means $x=\frac{1000}{401}\approx 0.249377$ to six significant digits. In other words, you would deduce $0.249377\%$.

For $10.00$, this means:

  • You would deduce your fee $5\%=0.50$. ($9.50$ remaining.)
  • You would deduce Stripe fee $9.50\cdot 0.249377\%=0.02369$. ($9.47631$ remaining.)
  • Stripe will transfer that and charge you $9.47631\cdot 0.25\%=0.02369$ - same as previous!