@php /** * SAVED PAYMENT METHODS — the one manager in the product. * * Rendered on the customer's payment page and inside the dashboard account page, because a diner * keeping a card for ordering and an owner keeping one for placements are the same thing and must * not become two screens that drift apart. The forms post to /account/payment/*, which any signed-in * role may reach and which scopes every row to the signed-in user. * * THE RULES LIVE IN THE MODEL, NOT HERE. Whether a method can be removed, whether it still works, * which one leads the list — all of that is PaymentMethod's, and this asks rather than restates it. * A screen that keeps its own copy of a rule is a screen that will disagree with the server. * * @var array $methods this user's methods, best first * @var array $savable Stripe payment_method_types this site can keep on file */ $methods = $methods ?? []; $savable = $savable ?? []; $cardModel = new \App\Models\PaymentMethod(); $hasPaypal = false; foreach ($methods as $m) { if ((string) ($m['gateway'] ?? '') === 'paypal') { $hasPaypal = true; } } // A method belongs in the add list only if it can be charged again later with the payer absent. $canCard = $savable !== []; $canPaypal = \App\Services\Payment::isEnabled('paypal') && !$hasPaypal; @endphp @if (count($methods) > 0)
{!! $hasPaypal && !\App\Services\Payment::isEnabled('stripe') ? t('account.add_method_all_added') : t('account.add_card_unavailable') !!}