Added card icons to Saved Payments in Client Portal and spruced up ui

This commit is contained in:
johnnyq 2025-09-03 17:40:09 -04:00
parent fc2cca5fdb
commit 2549a97a7e
2 changed files with 24 additions and 4 deletions

View File

@ -92,7 +92,7 @@ if (!$stripe_public_key || !$stripe_secret_key) {
<?php if (empty($saved_methods)) { ?>
<p>You currently have no saved payment methods. Please add one below.</p>
<?php } else { ?>
<ul>
<ul class="list-unstyled">
<?php
try {
$stripe = new \Stripe\StripeClient($stripe_secret_key);
@ -100,6 +100,16 @@ if (!$stripe_public_key || !$stripe_secret_key) {
foreach ($saved_methods as $method) {
$stripe_pm_id = $method['saved_payment_provider_method'];
$description = nullable_htmlentities($method['saved_payment_description']);
$payment_icon = "fas fa-credit-card"; // default icon
if (strpos($description, "visa") !== false) {
$payment_icon = "fab fa-cc-visa";
} elseif (strpos($description, "mastercard") !== false) {
$payment_icon = "fab fa-cc-mastercard";
} elseif (strpos($description, "american express") !== false || strpos($description, "amex") !== false) {
$payment_icon = "fab fa-cc-amex";
} elseif (strpos($description, "discover") !== false) {
$payment_icon = "fab fa-cc-discover";
}
$pm = $stripe->paymentMethods->retrieve($stripe_pm_id, []);
$brand = nullable_htmlentities($pm->card->brand);
@ -107,8 +117,8 @@ if (!$stripe_public_key || !$stripe_secret_key) {
$exp_month = nullable_htmlentities($pm->card->exp_month);
$exp_year = nullable_htmlentities($pm->card->exp_year);
echo "<li>$brand card ending in $last4, expires $exp_month/$exp_year";
echo " <a href='post.php?delete_saved_payment={$method['saved_payment_id']}'>Remove</a></li>";
echo "<li><i class='$payment_icon fa-2x mr-2'></i>$brand x<strong>$last4</strong> | Exp. $exp_month/$exp_year";
echo " <a class='text-danger' href='post.php?delete_saved_payment={$method['saved_payment_id']}'>Remove</a></li>";
}
} catch (Exception $e) {
$error = $e->getMessage();

View File

@ -160,12 +160,22 @@ $balance = $invoice_amounts - $amount_paid;
while ($row = mysqli_fetch_array($sql_saved_payment_methods)) {
$saved_payment_id = intval($row['saved_payment_id']);
$saved_payment_description = nullable_htmlentities($row['saved_payment_description']);
$payment_icon = "fas fa-credit-card"; // default icon
if (strpos($saved_payment_description, "visa") !== false) {
$payment_icon = "fab fa-cc-visa";
} elseif (strpos($saved_payment_description, "mastercard") !== false) {
$payment_icon = "fab fa-cc-mastercard";
} elseif (strpos($saved_payment_description, "american express") !== false || strpos($saved_payment_description, "amex") !== false) {
$payment_icon = "fab fa-cc-amex";
} elseif (strpos($saved_payment_description, "discover") !== false) {
$payment_icon = "fab fa-cc-discover";
}
$payment_provider_name = nullable_htmlentities($row['payment_provider_name']);
?>
<a class="dropdown-item confirm-link"
href="post.php?add_payment_by_provider=<?= $saved_payment_id ?>&invoice_id=<?= $invoice_id ?>">
<i class="fas fa-credit-card text-secondary mr-2"></i><?= $saved_payment_description ?>
<i class="<?php echo $payment_icon; ?> text-secondary mr-2"></i><?= $saved_payment_description ?>
</a>
<?php }
} ?>