diff --git a/guest_pay_invoice_stripe.php b/guest_pay_invoice_stripe.php index 244e088d..9c86c903 100644 --- a/guest_pay_invoice_stripe.php +++ b/guest_pay_invoice_stripe.php @@ -283,11 +283,8 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent // Check to see if Expense Fields are configured and client pays fee is off then create expense if ($config_stripe_client_pays_fees == 0 && $config_stripe_expense_vendor > 0 && $config_stripe_expense_category > 0) { - $balance_before_fees = $balance_to_pay; - // Calculate the amount to charge the client - $balance_to_not_pay = ($balance_to_pay + $config_stripe_flat_fee) / (1 - $config_stripe_percentage_fee); - // Calculate the fee amount - $gateway_expense_fee = round($balance_to_not_pay - $balance_before_fees, 2); + // Calculate gateway expense fee + $gateway_expense_fee = round($balance_to_pay * $config_stripe_percentage_fee + $config_stripe_flat_fee, 2); // Add Expense mysqli_query($mysqli,"INSERT INTO expenses SET expense_date = '$pi_date', expense_amount = $gateway_expense_fee, expense_currency_code = '$invoice_currency_code', expense_account_id = $config_stripe_account, expense_vendor_id = $config_stripe_expense_vendor, expense_client_id = $client_id, expense_category_id = $config_stripe_expense_category, expense_description = 'Stripe Transaction for Invoice $invoice_prefix$invoice_number In the Amount of $balance_to_pay', expense_reference = 'Stripe - $pi_id'");