mirror of
https://github.com/itflow-org/itflow
synced 2026-07-25 01:40:40 +00:00
Remove Static payment processing fees from database and update field hints with useful info when adding / editing payment provider
This commit is contained in:
@@ -4394,10 +4394,16 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
|
||||
|
||||
}
|
||||
|
||||
// if (CURRENT_DATABASE_VERSION == '2.4.4') {
|
||||
// // Insert queries here required to update to DB version 2.4.5
|
||||
// // Then, update the database to the next sequential version
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.4.5'");
|
||||
if (CURRENT_DATABASE_VERSION == '2.4.4') {
|
||||
// Gateway fee expense now uses the actual fee from Stripe's balance transaction
|
||||
mysqli_query($mysqli, "ALTER TABLE `payment_providers` DROP `payment_provider_expense_percentage_fee`, DROP `payment_provider_expense_flat_fee`");
|
||||
|
||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.4.5'");
|
||||
}
|
||||
|
||||
// if (CURRENT_DATABASE_VERSION == '2.4.5') {
|
||||
// // Insert queries here required to update to DB version 2.4.6
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.4.6'");
|
||||
// }
|
||||
|
||||
} else {
|
||||
|
||||
@@ -16,11 +16,6 @@ ob_start();
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="alert alert-info text-center">
|
||||
<h6>Before Adding a Payment Provider!</h6>
|
||||
We recommend you add an <strong>Account</strong> and <strong>Vendor</strong> based off the Provider name before continuing eg <strong>Stripe</strong>
|
||||
</div>
|
||||
|
||||
<ul class="nav nav-pills nav-justified mb-3">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="pill" href="#pills-details">Details</a>
|
||||
@@ -90,6 +85,7 @@ ob_start();
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<small class="form-text text-muted">Should havea seperate account created off the payment provider's name e.g. Stripe</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -107,6 +103,10 @@ ob_start();
|
||||
|
||||
<div class="tab-pane fade" id="pills-expense">
|
||||
|
||||
<div class="alert alert-info text-center">
|
||||
Payment Processing Fee Expenses get reconciled nighly via the cron
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" name="enable_expense" checked value="1" id="enableExpenseSwitch">
|
||||
@@ -136,6 +136,7 @@ ob_start();
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<small class="form-text text-muted">Payment Privider name e.g. Stripe</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -166,29 +167,8 @@ ob_start();
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Percentage Fee to expense</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-percent"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" inputmode="decimal" pattern="[0-9]*\.?[0-9]{0,2}" name="percentage_fee" placeholder="Enter Percentage">
|
||||
</div>
|
||||
<small class="form-text text-muted">See <a href="https://stripe.com/pricing" target="_blank">here <i class="fas fa-fw fa-external-link-alt"></i></a> for the latest Stripe Fees.</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Flat Fee to expense</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-shopping-cart"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" inputmode="decimal" pattern="[0-9]*\.?[0-9]{0,3}" name="flat_fee" placeholder="0.030">
|
||||
</div>
|
||||
<small class="form-text text-muted">See <a href="https://stripe.com/pricing" target="_blank">here <i class="fas fa-fw fa-external-link-alt"></i></a> for the latest Stripe Fees.</small>
|
||||
</div>
|
||||
<small class="form-text text-muted">Processing Fee, Credit Card Fee etc</small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,12 +14,11 @@ $account_id = intval($row['payment_provider_account']);
|
||||
$threshold = floatval($row['payment_provider_threshold']);
|
||||
$vendor_id = intval($row['payment_provider_expense_vendor']);
|
||||
$category_id = intval($row['payment_provider_expense_category']);
|
||||
$percent_fee = floatval($row['payment_provider_expense_percentage_fee']) * 100;
|
||||
$flat_fee = floatval($row['payment_provider_expense_flat_fee']);
|
||||
|
||||
// Generate the HTML form content using output buffering.
|
||||
ob_start();
|
||||
|
||||
?>
|
||||
|
||||
<div class="modal-header bg-dark">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-credit-card mr-2"></i>Editing: <strong><?= $provider_name ?></strong></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
@@ -89,6 +88,7 @@ ob_start();
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<small class="form-text text-muted">Should havea seperate account created off the payment provider's name e.g. Stripe</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -106,6 +106,10 @@ ob_start();
|
||||
|
||||
<div class="tab-pane fade" id="pills-expense">
|
||||
|
||||
<div class="alert alert-info text-center">
|
||||
Payment Processing Fee Expenses get reconciled nighly via the cron
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Payment Provider Vendor <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
@@ -130,6 +134,7 @@ ob_start();
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<small class="form-text text-muted">Payment Privider name e.g. Stripe</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -160,28 +165,7 @@ ob_start();
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Percentage Fee to expense</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-percent"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" inputmode="decimal" pattern="[0-9]*\.?[0-9]{0,2}" name="percentage_fee" value="<?php echo $percent_fee; ?>" placeholder="Enter Percentage">
|
||||
</div>
|
||||
<small class="form-text text-muted">See <a href="https://stripe.com/pricing" target="_blank">here <i class="fas fa-fw fa-external-link-alt"></i></a> for the latest Stripe Fees.</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Flat Fee to expense</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-shopping-cart"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" inputmode="decimal" pattern="[0-9]*\.?[0-9]{0,3}" name="flat_fee" value="<?php echo $flat_fee; ?>" placeholder="0.030">
|
||||
</div>
|
||||
<small class="form-text text-muted">See <a href="https://stripe.com/pricing" target="_blank">here <i class="fas fa-fw fa-external-link-alt"></i></a> for the latest Stripe Fees.</small>
|
||||
<small class="form-text text-muted">Processing Fee, Credit Card Fee etc</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -54,9 +54,6 @@ $num_rows = mysqli_num_rows($sql);
|
||||
Expense Category <?php if ($sort == 'category_name') { echo $order_icon; } ?>
|
||||
</a>
|
||||
</th>
|
||||
<th>
|
||||
<a class="text-dark">Expensed Fee</a>
|
||||
</th>
|
||||
<th class="text-center">
|
||||
<a class="text-dark">Saved Payment Methods</a>
|
||||
</th>
|
||||
@@ -72,10 +69,13 @@ $num_rows = mysqli_num_rows($sql);
|
||||
$provider_description = escapeHtml($row['payment_provider_description']);
|
||||
$account_name = escapeHtml($row['account_name']);
|
||||
$threshold = floatval($row['payment_provider_threshold']);
|
||||
if (!$threshold) {
|
||||
$threshold = "Not Enforced";
|
||||
} else {
|
||||
$threshold = numfmt_format_currency($currency_format, $threshold, $session_company_currency);
|
||||
}
|
||||
$vendor_name = escapeHtml($row['vendor_name'] ?? "Expense Disabled");
|
||||
$category = escapeHtml($row['category_name']);
|
||||
$percent_fee = floatval($row['payment_provider_expense_percentage_fee']) * 100;
|
||||
$flat_fee = floatval($row['payment_provider_expense_flat_fee']);
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('saved_payment_id') AS saved_payment_count FROM client_saved_payment_methods WHERE saved_payment_provider_id = $provider_id"));
|
||||
$saved_payment_count = intval($row['saved_payment_count']);
|
||||
@@ -90,10 +90,9 @@ $num_rows = mysqli_num_rows($sql);
|
||||
<span class="text-secondary"><?php echo $provider_description; ?></span>
|
||||
</td>
|
||||
<td><?php echo $account_name; ?></td>
|
||||
<td><?php echo numfmt_format_currency($currency_format, $threshold, $session_company_currency); ?></td>
|
||||
<td><?= $threshold ?></td>
|
||||
<td><?php echo $vendor_name; ?></td>
|
||||
<td><?php echo $category; ?></td>
|
||||
<td><?php echo $percent_fee; ?>% + <?php echo numfmt_format_currency($currency_format, $flat_fee, $session_company_currency); ?></td>
|
||||
<td class="text-center">
|
||||
<a class="badge badge-dark badge-pill p-2" href="saved_payment_methods.php"><?= $saved_payment_count ?></a>
|
||||
</td>
|
||||
|
||||
@@ -17,8 +17,6 @@ if (isset($_POST['add_payment_provider'])) {
|
||||
$account = intval($_POST['account']);
|
||||
$expense_vendor = intval($_POST['expense_vendor']) ?? 0;
|
||||
$expense_category = intval($_POST['expense_category']) ?? 0;
|
||||
$percentage_fee = floatval($_POST['percentage_fee']) / 100 ?? 0;
|
||||
$flat_fee = floatval($_POST['flat_fee']) ?? 0;
|
||||
|
||||
// Check to ensure provider isn't added twice
|
||||
$sql = mysqli_query($mysqli, "SELECT 1 FROM payment_providers WHERE payment_provider_name = '$provider' LIMIT 1");
|
||||
@@ -27,7 +25,7 @@ if (isset($_POST['add_payment_provider'])) {
|
||||
redirect();
|
||||
}
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO payment_providers SET payment_provider_name = '$provider', payment_provider_public_key = '$public_key', payment_provider_private_key = '$private_key', payment_provider_threshold = $threshold, payment_provider_account = $account, payment_provider_expense_vendor = $expense_vendor, payment_provider_expense_category = $expense_category, payment_provider_expense_percentage_fee = $percentage_fee, payment_provider_expense_flat_fee = $flat_fee");
|
||||
mysqli_query($mysqli,"INSERT INTO payment_providers SET payment_provider_name = '$provider', payment_provider_public_key = '$public_key', payment_provider_private_key = '$private_key', payment_provider_threshold = $threshold, payment_provider_account = $account, payment_provider_expense_vendor = $expense_vendor, payment_provider_expense_category = $expense_category");
|
||||
|
||||
$provider_id = mysqli_insert_id($mysqli);
|
||||
|
||||
@@ -51,10 +49,8 @@ if (isset($_POST['edit_payment_provider'])) {
|
||||
$account = intval($_POST['account']);
|
||||
$expense_vendor = intval($_POST['expense_vendor']) ?? 0;
|
||||
$expense_category = intval($_POST['expense_category']) ?? 0;
|
||||
$percentage_fee = floatval($_POST['percentage_fee']) / 100;
|
||||
$flat_fee = floatval($_POST['flat_fee']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE payment_providers SET payment_provider_public_key = '$public_key', payment_provider_private_key = '$private_key', payment_provider_threshold = $threshold, payment_provider_account = $account, payment_provider_expense_vendor = $expense_vendor, payment_provider_expense_category = $expense_category, payment_provider_expense_percentage_fee = $percentage_fee, payment_provider_expense_flat_fee = $flat_fee WHERE payment_provider_id = $provider_id");
|
||||
mysqli_query($mysqli,"UPDATE payment_providers SET payment_provider_public_key = '$public_key', payment_provider_private_key = '$private_key', payment_provider_threshold = $threshold, payment_provider_account = $account, payment_provider_expense_vendor = $expense_vendor, payment_provider_expense_category = $expense_category WHERE payment_provider_id = $provider_id");
|
||||
|
||||
logAudit("Payment Provider", "Edit", "$session_name edited Payment Provider $provider");
|
||||
|
||||
@@ -71,7 +67,7 @@ if (isset($_GET['delete_payment_provider'])) {
|
||||
$provider_id = intval($_GET['delete_payment_provider']);
|
||||
|
||||
// When deleted it cascades deletes
|
||||
// all Recurring paymentes related to payment provider
|
||||
// all Recurring payments related to payment provider
|
||||
// Delete all Saved Cards related
|
||||
// Delete Client Payment Provider Releation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user