@extends('frontend.layouts.user.index') @section('title', __('Merchants')) @push('styles') @endpush @section('content') @php $walletCurrencyCodes = collect($walletCurrencyCodes ?? []) ->map(fn ($code): string => strtoupper((string) $code)) ->filter() ->unique() ->values(); $currencyCodesFor = function ($merchant) { $codes = $merchant->supportedCurrencies->pluck('code'); if ($codes->isEmpty() && $merchant->currency?->code) { $codes = collect([$merchant->currency->code]); } return $codes ->map(fn ($code): string => strtoupper((string) $code)) ->filter() ->unique() ->values(); }; $gatewayCountFor = function ($merchant) use ($currencyCodesFor, $walletCurrencyCodes): int { $walletReadyCodes = $currencyCodesFor($merchant)->intersect($walletCurrencyCodes)->values(); return $merchant->paymentMethods ->filter(fn (\App\Models\DepositMethod $method): bool => (bool) $method->status && $method->type === \App\Enums\MethodType::AUTOMATIC && $walletReadyCodes->contains(strtoupper((string) $method->currency))) ->count(); }; $approvedCount = $merchants->filter(fn ($merchant) => $merchant->status === \App\Enums\MerchantStatus::APPROVED)->count(); $pendingCount = $merchants->filter(fn ($merchant) => $merchant->status === \App\Enums\MerchantStatus::PENDING)->count(); $currencyCodes = $merchants ->flatMap(fn ($merchant) => $currencyCodesFor($merchant)) ->filter() ->unique() ->values(); $walletReadyCurrencyCodes = $currencyCodes->intersect($walletCurrencyCodes)->values(); $statusInsightFor = function ($merchant, int $gatewayCount, $missingWalletCodes): array { if ($merchant->status === \App\Enums\MerchantStatus::PENDING) { return [ 'tone' => 'warning', 'icon' => 'fa-hourglass-half', 'label' => __('Under admin review'), 'detail' => __('Production unlocks after approval.'), ]; } if ($merchant->status === \App\Enums\MerchantStatus::DISABLED) { return [ 'tone' => 'danger', 'icon' => 'fa-ban', 'label' => __('Shop disabled'), 'detail' => __('Payments and live API are paused.'), ]; } if ($merchant->status === \App\Enums\MerchantStatus::REJECTED) { return [ 'tone' => 'danger', 'icon' => 'fa-circle-xmark', 'label' => __('Review rejected'), 'detail' => __('Update profile or contact support.'), ]; } if ($missingWalletCodes->isNotEmpty()) { return [ 'tone' => 'warning', 'icon' => 'fa-wallet', 'label' => __('Wallet missing'), 'detail' => __('Activate :currencies wallet before checkout.', ['currencies' => $missingWalletCodes->implode(', ')]), ]; } if ($gatewayCount < 1) { return [ 'tone' => 'warning', 'icon' => 'fa-credit-card', 'label' => __('Gateway missing'), 'detail' => __('Select a matching gateway in API config.'), ]; } return [ 'tone' => 'success', 'icon' => 'fa-circle-check', 'label' => __('Ready for payments'), 'detail' => __('Wallet, API, and gateway are ready.'), ]; }; @endphp
{{ __('Payments') }} {{ __('Create Merchant') }}
@if($merchants->isEmpty())
{{ __('Merchant workspace') }}

{{ __('Build your first checkout profile') }}

{{ __('Create a merchant once, select supported wallet currencies, then connect payment links or API checkout after approval.') }}

{{ __('Create Merchant') }}
@endif
{{ __('Total shops') }} {{ $merchants->count() }} {{ __('All merchant profiles') }}
{{ __('Live ready') }} {{ $approvedCount }} {{ __('Approved for production') }}
{{ __('In review') }} {{ $pendingCount }} {{ __('Waiting admin decision') }}
{{ __('Wallet coverage') }} {{ $walletReadyCurrencyCodes->count() }}/{{ $currencyCodes->count() }} {{ __('Ready currency rails') }}
@if($merchants->isNotEmpty())
{{ __('Shop list') }} {{ __('Shop readiness overview') }}
{{ __('Each row shows approval, wallet rail, gateway, and checkout action status.') }}
@endif @forelse($merchants as $merchant) @php $locked = $merchant->isActionLocked(); $lockTitle = $locked ? __('Unavailable: merchant is disabled or rejected') : null; $lockAttrs = $locked ? ' tabindex="-1" aria-disabled="true"' : ''; $lockClasses = $locked ? ' disabled pointer-events-none opacity-75' : ''; $merchantCurrencyCodes = $currencyCodesFor($merchant); $walletReadyCodes = $merchantCurrencyCodes->intersect($walletCurrencyCodes)->values(); $missingWalletCodes = $merchantCurrencyCodes->diff($walletCurrencyCodes)->values(); $primaryCurrencyCode = strtoupper((string) ($merchant->primaryCurrency()?->code ?? $merchant->currency?->code ?? $merchantCurrencyCodes->first() ?? '-')); $gatewayCount = $gatewayCountFor($merchant); $mode = $merchant->current_mode ?? \App\Enums\EnvironmentMode::SANDBOX; $statusInsight = $statusInsightFor($merchant, $gatewayCount, $missingWalletCodes); @endphp
{{ $merchant->business_name }}
@if($merchant->site_url) {{ $merchant->site_url }} @else {{ __('No site URL') }} @endif
{{ $mode->label() }} {{ __('Wallet :ready/:total', ['ready' => $walletReadyCodes->count(), 'total' => $merchantCurrencyCodes->count()]) }}
{{ $statusInsight['label'] }} {{ $statusInsight['detail'] }}
@foreach($merchantCurrencyCodes as $code) @php $isPrimaryCurrency = $primaryCurrencyCode === $code; $hasWallet = $walletReadyCodes->contains($code); @endphp {{ $code }} @endforeach @if($merchantCurrencyCodes->isEmpty()) {{ __('No currency') }} @endif
  • {{ __('ID') }} {{ $merchant->merchant_key ?: __('Pending') }}
  • {{ __('Gateways') }} {{ $gatewayCount }}
  • {{ __('Fee') }} {{ number_format((float) ($merchant->fee ?? 0), 2) }}%
@empty @endforelse
@endsection