mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
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:
@@ -86,9 +86,12 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
|
||||
|
||||
if ($config_stripe_client_pays_fees == 1) {
|
||||
$balance_before_fees = $balance_to_pay;
|
||||
// Calculate the Gateway fee
|
||||
$gateway_fee = round($balance_to_pay * $config_stripe_percentage_fee + $config_stripe_flat_fee, 2);
|
||||
$balance_to_pay = $balance_to_pay + $gateway_fee;
|
||||
// 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_to_pay + $config_stripe_flat_fee) / (1 - $config_stripe_percentage_fee);
|
||||
// Calculate the fee amount
|
||||
$gateway_fee = round($balance_to_pay - $balance_before_fees, 2);
|
||||
|
||||
}
|
||||
|
||||
//Round balance to pay to 2 decimal places
|
||||
@@ -276,10 +279,12 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
|
||||
|
||||
// Check config to see if client pays fees is enabled or if should expense it
|
||||
if ($config_stripe_client_pays_fees == 1) {
|
||||
// Calculate gateway expense fee
|
||||
$gateway_fee = round($balance_to_pay * $config_stripe_percentage_fee + $config_stripe_flat_fee, 2);
|
||||
$balance_before_fees = $balance_to_pay;
|
||||
// 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_to_pay + $gateway_fee;
|
||||
$balance_to_pay = ($balance_to_pay + $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 Expense Fields are configured and client pays fee is off then create expense
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user