@php /* * Normalize the checkout currency through the central currency helper. */ $checkoutCurrency = currency_code( $checkout->currency_code ?? $paymentSettings->default_currency ?? null ); $checkoutTotal = (float) ( $checkout->grand_total ?? 0 ); $formattedCheckoutTotal = money( $checkoutTotal, $checkoutCurrency ); $formattedWalletBalance = money( (float) ($walletBalance ?? 0), $checkoutCurrency ); /* * Normalize legacy bank-transfer account formats. */ $rawBankAccounts = $paymentSettings->bank_transfer_accounts ?? []; if (is_string($rawBankAccounts)) { $decodedBankAccounts = json_decode( $rawBankAccounts, true ); $rawBankAccounts = is_array($decodedBankAccounts) ? $decodedBankAccounts : []; } $bankAccounts = collect($rawBankAccounts) ->filter( static function ($account): bool { return is_array($account) && ( filled($account['bank_name'] ?? null) || filled($account['account_name'] ?? null) || filled($account['account_number'] ?? null) ); } ) ->values(); /* * Normalize available payment methods into a collection. */ $paymentMethods = collect( $availablePaymentMethods ?? [] ); /* * Restore the previously selected method after a validation error. * If none was selected, choose the first usable payment method. */ $selectedPaymentMethod = old('payment_method'); if ( blank($selectedPaymentMethod) || ! $paymentMethods->has($selectedPaymentMethod) ) { $selectedPaymentMethod = $paymentMethods ->keys() ->first( static function ($key) use ( $walletCanCoverCheckout ): bool { return $key !== 'wallet' || (bool) $walletCanCoverCheckout; } ); } @endphp
@push('styles') @endpush @push('scripts') @endpush