have you got your maths hat on ?
I am doing some credit card processing work, and i need to on-charge the bank service fee as a convenience fee to the customer.
If i sell something for $100
and i get charged 3% of my total transaction as a bank service fee.
How much do i need to charge in total to make sure i still end up with $100 in my hand (after the bank has taken their 3% fee away)
So anyway I need a formula that I can use that will handle different sales amounts and percentages to calculate the correct surcharge to pass on
hope that makes sense
This was my first attempt, it works fine for small numbers but for large amounts (eg $5000) it is wrong
$surcharge = ($total + ($total * $rate)) * $rate;
Here is an example for those that say just add the bank pct on
$sale = $100
$pct_rate = 0.03;
$surcharge = $sale * $pct_rate;
$total = $100 + surcharge ; // =103
// test it
$moneyinthehand = 103 - (103 * $rate); // moneyinthehand = $99.91 (which is not $sale price)
Given:
I think this does what you need:
Example of the maths (python):