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 | includes/helpers.php +38 -0 3.0.15 → 3.0.16 View file →
@@ -1073,8 +1073,46 @@
1073 1073 ];
1074 1074 }
1075 1075
1076 1076 /**
1077 + * Customer-facing label for a payment gateway id.
1078 + *
1079 + * Returns the same **Gateway Title** the checkout shows — the operator's custom
1080 + * title when they set one, otherwise the gateway's own translated title — so
1081 + * invoices, the confirmation page and the checkout all name a gateway the same
1082 + * way. Falls back to the prettified id (the historical behaviour) when the
1083 + * gateway is not registered any more, e.g. a Pro gateway while Pro is inactive,
1084 + * so an old document still reads sensibly.
1085 + *
1086 + * @param string|null $gatewayId Gateway id / slug as stored on the payment or booking.
1087 + * @param string $fallback Used when no id is stored at all.
1088 + */
1089 +function yatra_payment_gateway_label(?string $gatewayId, string $fallback = ''): string
1090 +{
1091 + $id = trim((string) $gatewayId);
1092 + if ($id === '') {
1093 + return $fallback;
1094 + }
1095 +
1096 + if (class_exists(\Yatra\PaymentGateways\PaymentGatewayRegistry::class)) {
1097 + $title = \Yatra\PaymentGateways\PaymentGatewayRegistry::getInstance()->resolveGatewayTitle($id);
1098 + if ($title !== '') {
1099 + return $title;
1100 + }
1101 + }
1102 +
1103 + // Only a slug-shaped value is a gateway id we may prettify. Anything else
1104 + // is operator free text — a manually recorded payment stores whatever they
1105 + // typed ("Cash on arrival", "SEPA Direct Debit") — and is returned exactly
1106 + // as entered rather than re-cased.
1107 + if (!preg_match('/^[A-Za-z0-9_-]+$/', $id)) {
1108 + return $id;
1109 + }
1110 +
1111 + return ucwords(str_replace(['_', '-'], ' ', $id));
1112 +}
1113 +
1114 +/**
1077 1115 * Are partial payments possible on this site at all?
1078 1116 *
1079 1117 * True when deposits or partial payments are switched on globally. Used to
1080 1118 * decide whether part-payment specific features (such as the separate