@extends('layouts/layoutMaster') @php $epaycoRejectionModal = session('epayco_rejection_modal'); @endphp @section('title', 'Plan y pago') @section('page-style') @endsection @section('page-script') @include('partials.epayco-inline-checkout') @endsection @section('content') @php $selectedPlan = $listing->selected_plan_code ? ($plans[$listing->selected_plan_code] ?? null) : null; $defaultPlan = $selectedPlan ?: (count($plans) ? reset($plans) : null); $defaultPlanTerm = $defaultPlan ? ($defaultPlan['terms'][$defaultPlan['default_term_months']] ?? reset($defaultPlan['terms'])) : null; $latestPayment = $listing->latestPayment; $paymentMap = [ \App\Models\MariachiListing::PAYMENT_NONE => ['label' => 'Sin pago', 'class' => 'secondary'], \App\Models\MariachiListing::PAYMENT_PENDING => ['label' => 'Pago pendiente', 'class' => 'warning'], \App\Models\MariachiListing::PAYMENT_APPROVED => ['label' => 'Pago aprobado', 'class' => 'success'], \App\Models\MariachiListing::PAYMENT_REJECTED => ['label' => 'Pago rechazado', 'class' => 'danger'], ]; $paymentMeta = $paymentMap[$listing->payment_status] ?? ['label' => $listing->paymentStatusLabel(), 'class' => 'secondary']; @endphp @if(session('status'))
{{ session('status') }}
@endif @if($errors->any())
@endif
Paso final: plan y pago

Anuncio: {{ $listing->title }} · Completitud: {{ $listing->listing_completion }}% · Pago: {{ $paymentMeta['label'] }}

El anuncio no se publicará hasta que el cobro quede aprobado en ePayco y luego lo envíes a revisión.
@if($listing->isPaymentPending()) Volver al panel @else Volver al editor @endif
@if(! $listing->listing_completed)
Este anuncio aún no cumple el mínimo para publicarse. Completa datos, ubicación, filtros y fotos antes de pagar.
@endif @if(! $epayco['is_configured'])
ePayco no está configurado en este momento. No podrás continuar al checkout hasta completar las llaves en el entorno.
@endif @if($listing->isPaymentPending())
Pago pendiente. Ya existe un checkout ePayco abierto para este anuncio. Puedes retomarlo con el plan seleccionado.
@elseif($listing->payment_status === \App\Models\MariachiListing::PAYMENT_APPROVED)
Pago aprobado. Si el anuncio ya está activo, también puedes renovar o subir de plan sin bajarlo del aire.
@elseif($listing->isPaymentRejected())
Pago rechazado. {{ $latestPayment?->rejection_reason ?: 'ePayco no aprobó la transacción. Revisa el cobro y vuelve a intentar.' }}
@endif
@foreach($plans as $code => $plan) @php $defaultTerm = $plan['terms'][$plan['default_term_months']] ?? reset($plan['terms']); $isCurrentSelection = $listing->selected_plan_code === $code; $canRenewCurrentPlan = $listing->status === \App\Models\MariachiListing::STATUS_ACTIVE && $listing->review_status === \App\Models\MariachiListing::REVIEW_APPROVED && $listing->payment_status === \App\Models\MariachiListing::PAYMENT_APPROVED && $isCurrentSelection; $buttonLabel = 'Pagar con ePayco'; if ($canRenewCurrentPlan) { $buttonLabel = 'Renovar con ePayco'; } elseif ($listing->payment_status === \App\Models\MariachiListing::PAYMENT_APPROVED && $listing->selected_plan_code === $code) { $buttonLabel = 'Plan aprobado'; } elseif ($listing->isPaymentPending()) { $buttonLabel = $isCurrentSelection ? 'Continuar pago en ePayco' : 'Pago pendiente en otro plan'; } elseif ($listing->isPaymentRejected() && $listing->selected_plan_code === $code) { $buttonLabel = 'Reintentar con ePayco'; } elseif ($listing->selected_plan_code === $code) { $buttonLabel = 'Continuar con este plan'; } $isDisabled = ! $listing->listing_completed || (! $isCurrentSelection && $listing->isPaymentPending()) || ! $epayco['is_configured'] || ($listing->payment_status === \App\Models\MariachiListing::PAYMENT_APPROVED && $listing->selected_plan_code === $code && ! $canRenewCurrentPlan); @endphp
{{ $plan['name'] }} @if($plan['badge_text']) {{ $plan['badge_text'] }} @endif
@if($listing->selected_plan_code === $code) Seleccionado @endif

{{ $plan['description'] }}

${{ number_format((int) ($defaultTerm['total_price_cop'] ?? $plan['price_cop']), 0, ',', '.') }} COP Total {{ $defaultTerm['label'] ?? '1 mes' }}

  • Este plan aplica solo a este anuncio
  • Borradores abiertos: {{ (int) ($plan['max_open_drafts'] ?? 0) === 0 ? 'sin tope' : ($plan['max_open_drafts'].' max.') }}
  • Publicados simultaneos: {{ (int) ($plan['max_published_listings'] ?? 0) === 0 ? 'ilimitados' : $plan['max_published_listings'] }}
  • Hasta {{ $plan['included_cities'] }} ciudad(es)
  • Hasta {{ $plan['max_zones_covered'] }} zona(s)
  • {{ $plan['max_photos_per_listing'] }} foto(s) por anuncio
  • {{ $plan['can_add_video'] ? $plan['max_videos_per_listing'].' video(s) por anuncio' : 'Sin videos incluidos' }}
  • WhatsApp visible: {{ $plan['show_whatsapp'] ? 'Sí' : 'No' }}
  • Teléfono visible: {{ $plan['show_phone'] ? 'Sí' : 'No' }}
@endforeach
Estado del anuncio
Plan solicitado
{{ $selectedPlan['name'] ?? 'Sin seleccionar' }}
Estado del pago {{ $paymentMeta['label'] }}
@if($latestPayment)
Ultimo comprobante
{{ $latestPayment->created_at?->format('d/m/Y H:i') ?: 'Sin fecha' }}
Monto enviado
${{ number_format((int) $latestPayment->amount_cop, 0, ',', '.') }} COP
@endif @if($latestPayment?->rejection_reason)

Motivo del rechazo

{{ $latestPayment->rejection_reason }}

@endif

Flujo actual

1. Eliges plan. 2. Pagas en ePayco. 3. ePayco confirma el cobro. 4. Vuelves al editor. 5. Envías el anuncio a revisión.

@csrf
@if($epaycoRejectionModal) @endif @endsection