{{ __('WhatsApp Settings') }}

{{ __('These settings apply to all branches of your business. Messages use the customer mobile number saved in Customers.') }}

@error('whatsapp_token')
{{ $message }}
@enderror
{{ __('Use the sender number format configured with Flaxxa.') }}
@error('whatsapp_sender')
{{ $message }}
@enderror
{{ __('Send messages for') }}
{{ __('When confirmation is off, enabled sale messages are queued automatically. Invoice edits and exchanges do not send messages.') }}
@error('whatsapp_template')
{{ $message }}
@enderror
{{ implode(' ', array_map(fn ($key) => '{'.$key.'}', \App\Services\WhatsAppSms::PLACEHOLDERS)) }}
{{ $this->whatsappPreview() }}
{{ __('Send a test WhatsApp message') }}

{{ __('Save your token and sender number above first. This sends directly using saved settings, even when automatic notifications are off. Pakistani local numbers such as 03001234567 are supported automatically.') }}

@error('whatsapp_test_number')
{{ $message }}
@enderror
@error('whatsapp_test_message')
{{ $message }}
@enderror
@if ($whatsapp_test_result)
{{ __('Test result') }}: {{ __(ucfirst($whatsapp_test_result['state'])) }} @if (isset($whatsapp_test_result['http_status'])) (HTTP {{ $whatsapp_test_result['http_status'] }}) @endif
{{ __($whatsapp_test_result['failure_reason'] ?? '') }}
@if (($whatsapp_test_result['state'] ?? '') === 'unknown')
{{ __('Check WhatsApp on the test number to confirm receipt. This response does not confirm token validity or delivery.') }}
@endif
@endif
{{ __('Recent WhatsApp activity — current branch') }}

{{ __('Pending messages are waiting to be processed. Unknown means provider acceptance or delivery could not be confirmed; messages are not retried automatically.') }}

@forelse ($this->whatsappHistory() as $attempt) @empty @endforelse
{{ __('Date') }}{{ __('Invoice ID') }}{{ __('Status') }}{{ __('Details') }}
{{ $attempt->created_at->format('d M Y H:i') }}{{ $attempt->invoice_id }}{{ __(ucwords(str_replace('_', ' ', $attempt->state))) }}{{ $attempt->failure_reason }}
{{ __('No WhatsApp activity yet.') }}