diff --git a/guest_pay_invoice_stripe.php b/guest_pay_invoice_stripe.php index 15ded8f5..921e36f7 100644 --- a/guest_pay_invoice_stripe.php +++ b/guest_pay_invoice_stripe.php @@ -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 diff --git a/guest_view_invoice.php b/guest_view_invoice.php index d4233dd4..216c61ff 100644 --- a/guest_view_invoice.php +++ b/guest_view_invoice.php @@ -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