PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | app/PaymentGateways/PaymentGatewayRegistry.php +42 -2 3.0.5 → 3.0.16 View file →
@@ -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(),