mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 00:59:03 +00:00
Autopay offered to clients: database 4.3.7 adds settings.config_invoice_offer_autopay and recurring_invoices.recurring_invoice_offer_autopay, an invoice from a recurring invoice with no autopay offers Set up autopay in its email and on its guest and portal pages, guest/guest_autopay.php sets it up with no sign-in through a Stripe Checkout Session in setup mode (name, email and agreement kept in its metadata and the recurring invoice's history), the card is saved and autopay turned on when Stripe sends them back, agents are told and the client gets a confirmation, the portal turns it on with a saved card, Settings > Invoices and each recurring invoice's Autopay card can turn the offer off; 26.12.3 changelog
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
/*
|
||||
* Client Portal
|
||||
* An invoice - as it prints, with what is owed and by when alongside, Pay,
|
||||
* the PDF, the payments made with their receipts, and the recurring
|
||||
* invoice it came from. On a phone, what is owed comes first.
|
||||
* the PDF, autopay offered when the recurring invoice it came from has none,
|
||||
* the payments made with their receipts, and the recurring invoice it came
|
||||
* from. On a phone, what is owed comes first.
|
||||
*
|
||||
* SCOPING: the invoice must be the session's client's, and not a draft.
|
||||
*/
|
||||
@@ -62,6 +63,11 @@ if ($recurring && $owing && intval($recurring['recurring_payment_saved_payment_i
|
||||
}
|
||||
}
|
||||
}
|
||||
// No autopay on it - offered: turned on with a card they have saved, or set up from the invoice's own link with a new one (functions/billing_pay.php)
|
||||
$autopay_offer = $recurring ? autopayOffer($invoice) : null;
|
||||
$offer_cards = $autopay_offer ? array_filter(billingSavedCards($session_client_id), function ($card) {
|
||||
return !$card['card']['expired'];
|
||||
}) : [];
|
||||
|
||||
$paper = [
|
||||
'type' => 'invoice',
|
||||
@@ -145,6 +151,34 @@ $paper = [
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php if ($autopay_offer) { ?>
|
||||
<section class="itflow-portal-panel mb-4" data-autopay-offer>
|
||||
<div class="itflow-portal-panel-body">
|
||||
<div class="fw-semibold mb-1"><i class="fas fa-sync-alt text-primary me-2"></i>Pay automatically from now on</div>
|
||||
<p class="small text-body-secondary mb-3">Set up autopay once, and the invoice for <?= escapeHtml($autopay_offer['title']) ?> each <?= escapeHtml($autopay_offer['period']) ?> is charged to your card on its due date<?= $autopay_offer['this_invoice'] ? ' - this one too' : '' ?>.</p>
|
||||
<?php if ($offer_cards) { ?>
|
||||
<form action="post.php" method="post">
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
<input type="hidden" name="set_recurring_payment" value="1">
|
||||
<input type="hidden" name="recurring_invoice_id" value="<?= intval($recurring['recurring_invoice_id']) ?>">
|
||||
<div class="input-group mb-2">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-credit-card"></i></span>
|
||||
<select class="form-select" name="saved_payment_id" aria-label="Card to charge">
|
||||
<?php foreach (array_reverse($offer_cards) as $card) { ?>
|
||||
<option value="<?= intval($card['saved_payment_id']) ?>">Pay with <?= escapeHtml($card['card']['label']) ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-primary w-100"><i class="fas fa-sync-alt me-2"></i>Turn on autopay</button>
|
||||
<div class="form-text"><?= escapeHtml(autopayConsentText($autopay_offer)) ?> <a href="<?= escapeHtml($autopay_offer['url']) ?>">Use another card</a></div>
|
||||
</form>
|
||||
<?php } else { ?>
|
||||
<a class="btn btn-outline-primary w-100" href="<?= escapeHtml($autopay_offer['url']) ?>"><i class="fas fa-sync-alt me-2"></i>Set up autopay</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($payments) { ?>
|
||||
<section class="itflow-portal-panel mb-4">
|
||||
<div class="itflow-portal-panel-head">
|
||||
|
||||
Reference in New Issue
Block a user