@extends('frontend.layouts.user.index') @section('title', __('Merchant API Configuration')) @push('styles') @endpush @section('content') @php $currentMode = $merchant->current_mode ?? \App\Enums\EnvironmentMode::SANDBOX; $merchantCurrencyCodes = $merchant->supportedCurrencies->pluck('code')->implode(', ') ?: ($merchant->currency?->code ?? '-'); $primaryCurrencyCode = $merchant->primaryCurrency()?->code ?? $merchant->currency?->code ?? '-'; $gatewayCount = $paymentMethods->count(); $selectedGatewayCount = count($selectedPaymentMethodIds); $credentialSetLabel = $currentMode->isSandbox() ? __('Test set') : __('Live set'); $productionLockedMessage = __('Production unlocks after admin approval. Sandbox remains active for safe integration testing.'); $environmentMeta = collect(\App\Enums\EnvironmentMode::cases())->mapWithKeys(fn ($env) => [ $env->value => [ 'label' => $env->label(), 'icon' => $env->icon(), 'caption' => $env->isSandbox() ? __('Test calls') : __('Live payments'), 'keyset' => $env->isSandbox() ? __('Test set') : __('Live set'), 'description' => $env->description(), ], ]); @endphp
{{ __('Back to Merchants') }}
{{ __('API console') }}

{{ $merchant->business_name }}

{{ __('Manage mode, keys, gateways, and launch checks from one focused workspace.') }}

{{ __('Status') }} {{ $merchant->status->label() }}
{{ __('Primary') }} {{ $primaryCurrencyCode }}
{{ __('Rails') }} {{ $merchantCurrencyCodes }}
{{ __('Active Mode') }} {{ $currentMode->label() }}
{{ __('Credential Set') }} {{ $credentialSetLabel }}
{{ __('Gateways') }} {{ $selectedGatewayCount }}/{{ $gatewayCount }}
{{ __('Currency Rail') }} {{ $primaryCurrencyCode }}

{{ __('Environment') }}

{{ __('Switch mode and use the matching credential set.') }}

@foreach(\App\Enums\EnvironmentMode::cases() as $env) @php $isProductionLocked = $env->isProduction() && ! $merchant->isApproved(); $environmentTitle = $isProductionLocked ? __('Production requires merchant approval') : $env->description(); @endphp @endforeach
{{ $merchant->isApproved() ? '' : $productionLockedMessage }}
{{ __('Mode note') }} {{ $currentMode->description() }}
@foreach(\App\Enums\EnvironmentMode::cases() as $env)
@php $credentials = [ 'merchant_key' => [ 'label' => __('Merchant ID'), 'icon' => 'fas fa-id-badge', 'hint' => __('Identifies the shop in every server request.'), 'value' => $env->isSandbox() ? ($merchant->test_merchant_key ?: __('Generate by switching to sandbox')) : ($merchant->merchant_key ?: __('Available after approval')), 'copy_title' => $env->isSandbox() ? __('Copy Test Merchant Key') : __('Copy Merchant Key'), ], 'api_key' => [ 'label' => $env->isSandbox() ? __('Test API Key') : __('API Key'), 'icon' => 'fas fa-key', 'hint' => __('Send with API calls from your backend.'), 'value' => $env->isSandbox() ? ($merchant->test_api_key ?: __('Generate by switching to sandbox')) : $merchant->api_key, 'copy_title' => $env->isSandbox() ? __('Copy Test API Key') : __('Copy API Key'), ], 'api_secret' => [ 'label' => $env->isSandbox() ? __('Test API Secret Key') : __('API Secret Key'), 'icon' => 'fas fa-shield-alt', 'hint' => __('Keep private and use it only for signing.'), 'value' => $env->isSandbox() ? ($merchant->test_api_secret ?: __('Generate by switching to sandbox')) : $merchant->api_secret, 'copy_title' => $env->isSandbox() ? __('Copy Test Secret Key') : __('Copy Secret Key'), ], ]; @endphp

{{ __('Credentials') }}

{{ __('Server-side keys for the selected mode.') }}

{{ $env->isSandbox() ? __('Test keys') : __('Live keys') }}
@foreach($credentials as $key => $credential)
{{ $credential['label'] }} {{ $credential['value'] }} {{ $credential['hint'] }}
@endforeach
{{ __('Backend only') }} {{ __('Create payment sessions from your server, never from browser code.') }}
{{ __('Mode aware') }} {{ __('Sandbox and production use separate IDs, keys, and secrets.') }}
{{ __('Rotate safely') }} {{ __('Replace exposed keys before accepting live payments.') }}
@endforeach
@endsection @section('scripts') @endsection