| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Yatra\PaymentGateways; |
| 6 |
|
| 7 |
/** |
| 8 |
* End-user safe messages for payment gateway errors (no internal config hints). |
| 9 |
*/ |
| 10 |
final class GatewayUserMessages |
| 11 |
{ |
| 12 |
public static function gatewayNotConfigured(PaymentGatewayInterface $gateway): string |
| 13 |
{ |
| 14 |
$title = self::displayTitle($gateway); |
| 15 |
|
| 16 |
return sprintf( |
| 17 |
/* translators: %s: Payment gateway display name, e.g. Square, Stripe */ |
| 18 |
__('The selected gateway (%s) is not properly configured. Please contact your website administrator.', 'yatra'), |
| 19 |
$title |
| 20 |
); |
| 21 |
} |
| 22 |
|
| 23 |
private static function displayTitle(PaymentGatewayInterface $gateway): string |
| 24 |
{ |
| 25 |
$config = $gateway->getConfig(); |
| 26 |
$custom = isset($config['title']) ? trim((string) $config['title']) : ''; |
| 27 |
|
| 28 |
return $custom !== '' ? $custom : $gateway->getTitle(); |
| 29 |
} |
| 30 |
} |
| 31 |
|