@extends('layouts.app') @php try { $paymentSettings = function_exists('get_payment_settings') ? get_payment_settings() : []; } catch (\Throwable $e) { $paymentSettings = []; } try { $availableMethods = function_exists('get_available_payment_methods') ? get_available_payment_methods() : []; } catch (\Throwable $e) { $availableMethods = []; } // Fallback: si aucune méthode n'est disponible, activer les méthodes par défaut if (empty($availableMethods)) { $availableMethods = [ 'stripe' => ['name' => 'Carte bancaire', 'icon' => 'fas fa-credit-card'], 'apple_pay' => ['name' => 'Apple Pay', 'icon' => 'fab fa-apple-pay'], 'google_pay' => ['name' => 'Google Pay', 'icon' => 'fab fa-google-pay'], 'klarna' => ['name' => 'Klarna', 'icon' => 'fab fa-klarna'], 'amazon_pay' => ['name' => 'Amazon Pay', 'icon' => 'fab fa-amazon'], 'cash' => ['name' => 'Espèces', 'icon' => 'fas fa-money-bill-wave'], ]; } // S'assurer que PayPal et virement ne sont jamais proposés unset($availableMethods['paypal'], $availableMethods['virement'], $availableMethods['iban']); $paymentRequirement = function_exists('normalize_payment_requirement_for_mode') ? normalize_payment_requirement_for_mode($booking->service?->payment_requirement ?? 'none') : ($booking->service?->payment_requirement ?? 'none'); $depositPct = (float) ($booking->service?->deposit_percentage ?? 0); $requirePaymentBeforeBooking = (bool) ($paymentSettings['require_payment_before_booking'] ?? false); $cashAllowedByCriteria = ($paymentRequirement === 'none') && !$requirePaymentBeforeBooking; $currentRouteName = request()->route()?->getName(); $isPrestataireContext = is_string($currentRouteName) && str_starts_with($currentRouteName, 'prestataire.'); $isClientContext = is_string($currentRouteName) && str_starts_with($currentRouteName, 'client.'); $routeForm = $isPrestataireContext && \Illuminate\Support\Facades\Route::has('prestataire.payments.form') ? route('prestataire.payments.form', $booking) : (\Illuminate\Support\Facades\Route::has('client.payments.form') ? route('client.payments.form', $booking) : (\Illuminate\Support\Facades\Route::has('payment.form') ? route('payment.form', $booking) : '#')); $routeIntent = $isPrestataireContext && \Illuminate\Support\Facades\Route::has('prestataire.payments.intent') ? route('prestataire.payments.intent', $booking) : (\Illuminate\Support\Facades\Route::has('client.payments.intent') ? route('client.payments.intent', $booking) : (\Illuminate\Support\Facades\Route::has('payment.intent') ? route('payment.intent', $booking) : '#')); $routeConfirm = $isPrestataireContext && \Illuminate\Support\Facades\Route::has('prestataire.payments.confirm') ? route('prestataire.payments.confirm', $booking) : (\Illuminate\Support\Facades\Route::has('client.payments.confirm') ? route('client.payments.confirm', $booking) : (\Illuminate\Support\Facades\Route::has('payment.confirm') ? route('payment.confirm', $booking) : '#')); $routeBack = $isPrestataireContext && \Illuminate\Support\Facades\Route::has('prestataire.payments.index') ? route('prestataire.payments.index') : (\Illuminate\Support\Facades\Route::has('client.bookings.index') ? route('client.bookings.index') : url('/')); // Stripe 3DS return URL (server callback records the transaction) $routeSuccess = \Illuminate\Support\Facades\Route::has('payment.success') ? route('payment.success', $booking) : $routeBack; $routeCash = $isPrestataireContext && \Illuminate\Support\Facades\Route::has('prestataire.payments.cash') ? route('prestataire.payments.cash', $booking) : (\Illuminate\Support\Facades\Route::has('client.payments.cash') ? route('client.payments.cash', $booking) : (\Illuminate\Support\Facades\Route::has('payment.cash') ? route('payment.cash', $booking) : '#')); @endphp @section('content')
{{-- Retour --}} Retour à mes réservations
{{-- Header --}}

💳 Paiement sécurisé

Réservation #{{ $booking->booking_number }}

{{-- Critères de paiement du prestataire --}}
Critères de paiement de l'annonce
@if($paymentRequirement === 'full') Paiement total requis pour valider la réservation. @elseif($paymentRequirement === 'deposit') Acompte requis ({{ $depositPct > 0 ? $depositPct . '%' : 'pourcentage non défini' }}). @else Aucun paiement n'est requis à l'avance. @endif
@if($requirePaymentBeforeBooking)
Le paiement avant réservation est requis par la plateforme.
@endif
{{-- Résumé de la réservation --}}

📋 Détails de la réservation

Service

{{ $booking->service?->name ?? 'Service' }}

Prestataire

{{ $booking->prestataire?->user?->name ?? 'N/A' }}

Date

{{ $booking->start_datetime?->format('d/m/Y à H:i') ?? '—' }}

Statut paiement

@if($booking->payment_status === 'paid') ✅ Payé @elseif($booking->payment_status === 'deposit_paid') 💰 Acompte payé @else ⏳ En attente @endif

{{-- Montants --}}
Montant total du service {{ number_format($booking->total_price, 2) }} €
@if($booking->deposit_amount > 0)
@if($booking->total_price > 0) Acompte ({{ round(($booking->deposit_amount / $booking->total_price) * 100) }}%) @else Acompte @endif {{ number_format($booking->deposit_amount, 2) }} €
@endif
Montant à payer {{ number_format($booking->deposit_amount > 0 && $booking->payment_status === 'pending' ? $booking->deposit_amount : ($booking->payment_status === 'deposit_paid' ? max(0, $booking->total_price - $booking->deposit_amount) : $booking->total_price), 2) }} €
{{-- Options de paiement (acompte/total) --}} @if($booking->deposit_amount > 0 && $booking->payment_status === 'pending')
@endif @if($booking->payment_status === 'deposit_paid')

✅ Acompte déjà payé : {{ number_format($booking->deposit_amount, 2) }} €
Il vous reste {{ number_format(max(0, $booking->total_price - $booking->deposit_amount), 2) }} € à payer.

@endif {{-- Sélection du moyen de paiement --}}
@if(isset($availableMethods['stripe'])) @endif @if(isset($availableMethods['apple_pay'])) @endif @if(isset($availableMethods['google_pay'])) @endif @if(isset($availableMethods['cash']) && $cashAllowedByCriteria) @endif @if(isset($availableMethods['klarna'])) @endif @if(isset($availableMethods['amazon_pay'])) @endif
@if(isset($availableMethods['cash']) && !$cashAllowedByCriteria)

Le paiement en espèces n'est pas disponible pour cette annonce selon les critères du prestataire.

@endif
{{-- Section Stripe (Carte) --}}
@csrf
Chargement du formulaire de paiement...
{{-- Conditions de paiement --}} @if(View::exists('components.payment-terms')) @include('components.payment-terms', ['booking' => $booking]) @endif
{{-- Section Espèces --}} {{-- Section Klarna --}} {{-- Section Amazon Pay --}} {{-- Sécurité --}}
Cryptage SSL
Paiement sécurisé
Stripe
@push('scripts') @endpush @endsection