Fix client pays fees calculation. I didn't quite understand why the previous formula was used until i read this https://support.stripe.com/questions/passing-the-stripe-fee-on-to-customers

This commit is contained in:
johnnyq
2024-02-03 17:14:48 -05:00
parent 4f4bb56820
commit a6a93fd820
2 changed files with 19 additions and 7 deletions

View File

@@ -114,7 +114,14 @@ $amount_paid = floatval($row['amount_paid']);
$balance = $invoice_amount - $amount_paid;
// Calculate Gateway Fee
$gateway_fee = round($balance * $config_stripe_percentage_fee + $config_stripe_flat_fee, 2);
if ($config_stripe_client_pays_fees == 1) {
$balance_before_fees = $balance;
// See here for passing costs on to client https://support.stripe.com/questions/passing-the-stripe-fee-on-to-customers
// Calculate the amount to charge the client
$balance_to_pay = ($balance + $config_stripe_flat_fee) / (1 - $config_stripe_percentage_fee);
// Calculate the fee amount
$gateway_fee = round($balance_to_pay - $balance_before_fees, 2);
}
//check to see if overdue
$invoice_color = $invoice_badge_color; // Default