@php // Expected variables: // $amount (numeric/string) // $paymentMethod (string) optional, e.g. 'stripe' or 'mercadopago' // $currency (string) optional, e.g. 'ARS','USD' - if provided it will be used to format the label // If $paymentMethod not provided, try to derive from config and/or optional auth user $currencyCode = $currency ?? null; $pm = $paymentMethod ?? (isset($paymentMethod) ? $paymentMethod : null); if(!$pm){ $userCountry = optional(auth()->user())->country; if($userCountry){ $pm = config('payments.country_payment_method')[strtoupper($userCountry)] ?? config('payments.default_payment_method'); } else { $pm = config('payments.default_payment_method'); } } // Normalize amount formatting $amountVal = $amount; if(is_numeric($amountVal)){ // prefer explicit currency code if provided $formatted = number_format((float)$amountVal, 0, ',', '.'); if($currencyCode){ echo '$' . $formatted . ' ' . $currencyCode; } else { // For MercadoPago we expect integer-like amounts (local currency), but leave formatting flexible if($pm === 'mercadopago'){ // show as $X.XXX ARS (thousands separator) echo '$' . $formatted . ' ARS'; } else { // Stripe or default: show symbol before and without decimals, e.g. "$27 USD" echo '$' . $formatted . ' USD'; } } } else { // fallback: raw if($currencyCode){ echo $amount . ' ' . $currencyCode; } else { if($pm === 'mercadopago'){ echo '$' . $amount . ' ARS'; } else { echo $amount . ' USD'; } } } @endphp