mirror of
https://github.com/itflow-org/itflow
synced 2026-03-18 11:44:51 +00:00
Added card icons to Saved Payments in Client Portal and spruced up ui
This commit is contained in:
@@ -92,7 +92,7 @@ if (!$stripe_public_key || !$stripe_secret_key) {
|
|||||||
<?php if (empty($saved_methods)) { ?>
|
<?php if (empty($saved_methods)) { ?>
|
||||||
<p>You currently have no saved payment methods. Please add one below.</p>
|
<p>You currently have no saved payment methods. Please add one below.</p>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<ul>
|
<ul class="list-unstyled">
|
||||||
<?php
|
<?php
|
||||||
try {
|
try {
|
||||||
$stripe = new \Stripe\StripeClient($stripe_secret_key);
|
$stripe = new \Stripe\StripeClient($stripe_secret_key);
|
||||||
@@ -100,6 +100,16 @@ if (!$stripe_public_key || !$stripe_secret_key) {
|
|||||||
foreach ($saved_methods as $method) {
|
foreach ($saved_methods as $method) {
|
||||||
$stripe_pm_id = $method['saved_payment_provider_method'];
|
$stripe_pm_id = $method['saved_payment_provider_method'];
|
||||||
$description = nullable_htmlentities($method['saved_payment_description']);
|
$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, []);
|
$pm = $stripe->paymentMethods->retrieve($stripe_pm_id, []);
|
||||||
$brand = nullable_htmlentities($pm->card->brand);
|
$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_month = nullable_htmlentities($pm->card->exp_month);
|
||||||
$exp_year = nullable_htmlentities($pm->card->exp_year);
|
$exp_year = nullable_htmlentities($pm->card->exp_year);
|
||||||
|
|
||||||
echo "<li>$brand card ending in $last4, expires $exp_month/$exp_year";
|
echo "<li><i class='$payment_icon fa-2x mr-2'></i>$brand x<strong>$last4</strong> | Exp. $exp_month/$exp_year";
|
||||||
echo " – <a href='post.php?delete_saved_payment={$method['saved_payment_id']}'>Remove</a></li>";
|
echo " – <a class='text-danger' href='post.php?delete_saved_payment={$method['saved_payment_id']}'>Remove</a></li>";
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$error = $e->getMessage();
|
$error = $e->getMessage();
|
||||||
|
|||||||
@@ -160,12 +160,22 @@ $balance = $invoice_amounts - $amount_paid;
|
|||||||
while ($row = mysqli_fetch_array($sql_saved_payment_methods)) {
|
while ($row = mysqli_fetch_array($sql_saved_payment_methods)) {
|
||||||
$saved_payment_id = intval($row['saved_payment_id']);
|
$saved_payment_id = intval($row['saved_payment_id']);
|
||||||
$saved_payment_description = nullable_htmlentities($row['saved_payment_description']);
|
$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']);
|
$payment_provider_name = nullable_htmlentities($row['payment_provider_name']);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<a class="dropdown-item confirm-link"
|
<a class="dropdown-item confirm-link"
|
||||||
href="post.php?add_payment_by_provider=<?= $saved_payment_id ?>&invoice_id=<?= $invoice_id ?>">
|
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>
|
</a>
|
||||||
<?php }
|
<?php }
|
||||||
} ?>
|
} ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user