| @@ -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 |
| @@ -295,15 +324,12 @@ | ||
| 295 | 324 | // getDescription() — so the checkout label never translated. When |
| 296 | 325 | // the stored value equals the gateway's built-in default, fall |
| 297 | 326 | // through to the translated getter; a genuine custom value (which |
| 298 | 327 | // is operator free-text, not translatable) is still honored. |
| 299 | - $storedTitle = isset($config['title']) ? (string) $config['title'] : ''; | |
| 300 | 328 | $storedDescription = isset($config['description']) ? (string) $config['description'] : ''; |
| 301 | 329 | $checkoutGateways[] = [ |
| 302 | 330 | 'id' => $id, |
| 303 | - 'title' => ($storedTitle !== '' && $storedTitle !== $gateway->getDefaultTitle()) | |
| 304 | - ? $storedTitle | |
| 305 | - : $gateway->getTitle(), | |
| 331 | + 'title' => $this->resolveGatewayTitle($id), | |
| 306 | 332 | 'description' => ($storedDescription !== '' && $storedDescription !== $gateway->getDefaultDescription()) |
| 307 | 333 | ? $storedDescription |
| 308 | 334 | : $gateway->getDescription(), |
| 309 | 335 | 'icon' => !empty($config['icon']) ? $config['icon'] : $gateway->getIcon(), |