| @@ -278,8 +278,37 @@ | ||
| 278 | 278 | ]; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | + * The gateway's customer-facing title — the same label the checkout shows. | |
| 283 | + * | |
| 284 | + * Prefers the operator's stored title, but ONLY when they actually | |
| 285 | + * customized it: the gateway's default title is persisted into the config | |
| 286 | + * at install time, and using that stored English string would shadow the | |
| 287 | + * translatable getTitle(). A genuine custom value (operator free-text, not | |
| 288 | + * translatable) is honored as-is. | |
| 289 | + * | |
| 290 | + * Works for any registered gateway, enabled or not, so a document about a | |
| 291 | + * past payment still names the gateway correctly after it was switched | |
| 292 | + * off. Returns '' when the id belongs to no registered gateway (e.g. a Pro | |
| 293 | + * gateway while Pro is inactive) so callers can fall back to the raw id. | |
| 294 | + */ | |
| 295 | + public function resolveGatewayTitle(string $gatewayId): string | |
| 296 | + { | |
| 297 | + $gateway = $this->get($gatewayId); | |
| 298 | + if (!$gateway) { | |
| 299 | + return ''; | |
| 300 | + } | |
| 301 | + | |
| 302 | + $config = $gateway->getConfig(); | |
| 303 | + $storedTitle = isset($config['title']) ? (string) $config['title'] : ''; | |
| 304 | + | |
| 305 | + return ($storedTitle !== '' && $storedTitle !== $gateway->getDefaultTitle()) | |
| 306 | + ? $storedTitle | |
| 307 | + : $gateway->getTitle(); | |
| 308 | + } | |
| 309 | + | |
| 310 | + /** | |
| 282 | 311 | * Gateways to show on checkout: all enabled in settings. |
| 283 | 312 | * Configuration is validated when processing payment (see processPayment). |
| 284 | 313 | */ |
| 285 | 314 | public function getForCheckout(): array |
| @@ -287,12 +316,23 @@ | ||
| 287 | 316 | $checkoutGateways = []; |
| 288 | 317 | |
| 289 | 318 | foreach ($this->getEnabledGateways() as $id => $gateway) { |
| 290 | 319 | $config = $gateway->getConfig(); |
| 320 | + // Prefer a stored title/description ONLY when the operator actually | |
| 321 | + // customized it. The gateway's default title/description gets | |
| 322 | + // persisted into the config at install time, and using that stored | |
| 323 | + // English string here shadowed the translatable getTitle()/ | |
| 324 | + // getDescription() — so the checkout label never translated. When | |
| 325 | + // the stored value equals the gateway's built-in default, fall | |
| 326 | + // through to the translated getter; a genuine custom value (which | |
| 327 | + // is operator free-text, not translatable) is still honored. | |
| 328 | + $storedDescription = isset($config['description']) ? (string) $config['description'] : ''; | |
| 291 | 329 | $checkoutGateways[] = [ |
| 292 | 330 | 'id' => $id, |
| 293 | - 'title' => !empty($config['title']) ? $config['title'] : $gateway->getTitle(), | |
| 294 | - 'description' => !empty($config['description']) ? $config['description'] : $gateway->getDescription(), | |
| 331 | + 'title' => $this->resolveGatewayTitle($id), | |
| 332 | + 'description' => ($storedDescription !== '' && $storedDescription !== $gateway->getDefaultDescription()) | |
| 333 | + ? $storedDescription | |
| 334 | + : $gateway->getDescription(), | |
| 295 | 335 | 'icon' => !empty($config['icon']) ? $config['icon'] : $gateway->getIcon(), |
| 296 | 336 | 'is_offline' => $gateway->isOffline(), |
| 297 | 337 | 'supports' => $gateway->getSupports(), |
| 298 | 338 | 'is_configured' => $gateway->isProperlyConfigured(), |