I've just implemented Stripe payments on a site I work on. One of the conditions of the site is that the customer must pay the merchant fees. Right now, those fees are:
As first, this seemed fairly straightforward - simply multiply the total sale amount by 1.75%, add 30c and add this to the total sale amount. In other words:
surcharge = (total_sale * fee_percent) + fee_fixed
For example, for a $1000 sale:
surcharge = (1000 * 1.175%) + 0.30 = $17.80
The total charge to the customer should be $1017.80, right? Turns out...no!
If you put a charge of $1017.80 through Stripe, the merchant fee they deduct from the gross amount is $18.11, leaving you 31c out of pocket.
The problem is that Stripe applies the fee to the gross amount. Their calculation looks like this:
fees = (charge * fee_percent) + fee_fixed
fees = (1017.80 * 1.75%) + 0.30 = $18.11
net_payment = $1017.80 - $18.11 = $999.69
Okay...so a few cents probably isn't going to break the bank, and depending on how you account for the fees, this might not be a problem.
But in my recent experience, the charges were in the tens of thousands (yes...some people really do love their loyalty points enough to pay 1.75% on $30,000 charges!).
This may also create an issue for finance, who have lots of numbers that don't match to reconcile.
How to solve the problem?
Okay, so what we've realised is that we can't just work out the merchant fee on the sale total. We need a formula that will work out what to charge the customer that will result in the correct net fee once Stripe has deducted merchant fees.
That formula is this:
surcharge = ( total_sale / ( 1 - fee_percent/100 )) + ( 1 + ( fee_percent/100 * fee_percent/100 ) + fee_percent/100 ) * fee_fixed - total_sale
(it took me a solid hour of brain-bending to get to this, so excuse me for not showing my working)
Revisiting our previous example for a $1000 sale:
surcharge = ( 1000 / ( 1 - 1.75/100 )) + ( 1 + ( 1.75/100 * 1.75/100 ) + 1.75/100 ) * 0.30 - 1000)
surcharge = ( 1000 / ( 1 - 0.0175 )) + ( 1 + ( 0.0175 * 0.0175 ) + 0.0175 ) * 0.30 - 1000)
surcharge = $18.12
Charging your customer $1018.12 results in a $18.12 Stripe fee and a net payment to you of $1000.00. Perfect!!