{{ __('Admin') }} {{ __('Billing') }} {{ __('Meta credit & keys') }}
{{ __('Reseller billing · Meta credit line') }}

{{ __('Connect your') }} {{ __('Meta') }} {{ __('keys') }}.

{{ __('Attach your own Meta credit line to a customer\'s WhatsApp account so Meta bills you (the reseller) — not them. Follow the two steps below; the guide on the right shows exactly where to get each value.') }}

@foreach (['success' => 'wa-green', 'error' => 'accent-coral'] as $k => $c) @if (session($k))
{{ session($k) }}
@endif @endforeach {{-- Do you even need this page? --}}
{{ __('Optional — only for true reselling.') }} {{ __('You only need this if you want Meta to bill YOU for your customers\' messages. It requires Meta "Solution Partner" status + an approved Meta credit line. Until that\'s approved, everything still works: customers top up their wallet and you charge per message on') }} {{ __('Message pricing') }}.
@php // Currency is dynamic — pulled from the platform's own currencies, // nothing hardcoded. Default the picker to the platform currency. $metaCurrencies = \App\Models\Currency::query()->orderBy('code') ->pluck('code')->map(fn ($c) => strtoupper($c))->filter()->unique()->values()->all(); if (empty($metaCurrencies)) { $metaCurrencies = [strtoupper(\App\Support\FormatSettings::currencyFor()?->code ?? 'USD')]; } $platformCur = strtoupper(\App\Support\FormatSettings::currencyFor()?->code ?? 'USD'); $defaultCur = in_array($platformCur, $metaCurrencies, true) ? $platformCur : ($metaCurrencies[0] ?? 'USD'); @endphp
{{-- ══════════════ LEFT: the two steps ══════════════ --}}
{{-- STEP 1 — Connect --}}
1
{{ __('meta connection') }}

{{ __('Connect your Meta business') }}

{{ $configured ? __('Connected') : __('Not connected') }}
@csrf {{-- Hands-off mode — share the credit line automatically the moment any customer connects a number, so nobody attaches by hand. This is what makes it "customer just tops up and sends, Meta bills me". --}}
{{ __('The token is stored encrypted and never shown back.') }}
{{-- STEP 2 — Attach --}}
2
{{ __('attach manually — optional') }}

{{ __('Attach one customer by hand') }}

{{ ($autoAttach ?? false) ? __('Auto-attach is ON, so new customers attach themselves — use this only for a one-off.') : __('Or turn on auto-attach above and skip this entirely.') }}

@if ($configured)
@csrf
@endif
@if (empty($wabaAccounts))
{{ __('No customer has connected a WhatsApp Business (Cloud API) number yet. Once a workspace connects one under') }} /devices, {{ __('it will appear here to pick.') }}
@else
@csrf
{{ __('Locked once attached.') }} {{ __('Meta does not let you change the currency later — set it right the first time.') }}
@unless ($configured) {{ __('Finish step 1 first.') }} @endunless
@endif
{{-- Attached accounts --}}
{{ __('attached accounts') }}

{{ __('Credit lines in use') }}

@forelse ($rows as $r) @empty @endforelse
{{ __('Workspace') }} {{ __('WABA') }} {{ __('Alloc ID') }} {{ __('Currency') }} {{ __('Status') }} {{ __('Action') }}
{{ $workspaceNames[$r->workspace_id] ?? ('#' . $r->workspace_id) }} …{{ substr($r->waba_id, -6) }} {{ $r->allocation_config_id ?: '—' }} {{ $r->currency }} @php $sc = ['attached'=>'bg-wa-green/20 text-wa-deep','revoked'=>'bg-paper-100 text-ink-500','failed'=>'bg-accent-coral/20 text-accent-coral'][$r->status] ?? 'bg-paper-100'; @endphp {{ $r->status }} @if ($r->last_error)!@endif @if ($r->status === 'attached')
@csrf
@else — @endif
{{ __('No accounts attached yet. Finish steps 1 and 2 above.') }}
@if ($rows->hasPages())
{{ $rows->links() }}
@endif
{{-- ══════════════ RIGHT: setup guide with official links ══════════════ --}}