@php
use App\Models\PaymentGateway;
use App\Models\VirtualCardProvider;
/*
* Discover provider JS handlers automatically.
* Each enabled provider can ship a file at /frontend/js/virtualCardProvider/{code}.js
* which calls VCProviderRegistry.register(code, handler) on load.
* If a provider has no JS file, the registry's normalized JSON fallback is used —
* adding a new gateway requires zero edits to this partial.
*/
$providerCodes = VirtualCardProvider::active()->pluck('code')->all();
$stripeKey = null;
if (in_array('stripe', $providerCodes, true)) {
try {
$stripeKey = PaymentGateway::getCredentials('stripe')['stripe_key'] ?? null;
} catch (\Throwable $e) {
$stripeKey = null;
}
}
@endphp
@if(in_array('stripe', $providerCodes, true))
@if($stripeKey)
@endif
@endif
{{-- Registry first, then auto-discovered provider handlers --}}
@foreach($providerCodes as $code)
@php
$jsPath = "frontend/js/virtualCardProvider/{$code}.js";
$exists = file_exists(public_path($jsPath));
@endphp
@if($exists)
@endif
@endforeach
{{-- Main page logic (provider-agnostic) --}}