← All changes
|
app/PaymentGateways/Gateways/PayLater/PayLaterGateway.php
+31
-4
3.0.6
→
3.0.17
View file →
| @@ -14,8 +14,27 @@ | ||
| 14 | 14 | protected string $icon = 'pay-later.svg'; |
| 15 | 15 | protected bool $isOffline = true; |
| 16 | 16 | protected array $supports = ['pay_later', 'reservation']; |
| 17 | 17 | |
| 18 | + /** | |
| 19 | + * Translatable display title. The raw `$title` property can't carry a | |
| 20 | + * `__()` call (PHP property defaults must be constant), so the customer- | |
| 21 | + * facing label is translated here. An admin-set custom title (via gateway | |
| 22 | + * config) still takes precedence in PaymentGatewayRegistry::getForCheckout(). | |
| 23 | + */ | |
| 24 | + public function getTitle(): string | |
| 25 | + { | |
| 26 | + return __('Book Now, Pay Later', 'yatra'); | |
| 27 | + } | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * Translatable description shown under the gateway option at checkout. | |
| 31 | + */ | |
| 32 | + public function getDescription(): string | |
| 33 | + { | |
| 34 | + return __('Reserve now and pay before the trip', 'yatra'); | |
| 35 | + } | |
| 36 | + | |
| 18 | 37 | public function getConfigFields(): array |
| 19 | 38 | { |
| 20 | 39 | return [ |
| 21 | 40 | [ |
| @@ -103,15 +122,15 @@ | ||
| 103 | 122 | 'message' => $requireDeposit |
| 104 | 123 | ? sprintf( |
| 105 | 124 | /* translators: 1: formatted deposit amount, 2: number of days before the trip. */ |
| 106 | 125 | __('A deposit of %1$s is required to confirm your booking. Full payment is due %2$d days before your trip.', 'yatra'), |
| 107 | - number_format($depositAmount, 2), | |
| 126 | + yatra_format_price((float) $depositAmount, null, false), | |
| 108 | 127 | $deadlineDays |
| 109 | 128 | ) |
| 110 | 129 | : sprintf( |
| 111 | 130 | /* translators: 1: formatted total amount, 2: number of days before the trip. */ |
| 112 | 131 | __('Your booking is reserved! Full payment of %1$s is due %2$d days before your trip.', 'yatra'), |
| 113 | - number_format($amount, 2), | |
| 132 | + yatra_format_price((float) $amount, null, false), | |
| 114 | 133 | $deadlineDays |
| 115 | 134 | ), |
| 116 | 135 | ]; |
| 117 | 136 | } |
| @@ -117,10 +136,18 @@ | ||
| 117 | 136 | } |
| 118 | 137 | |
| 119 | 138 | public function verifyPayment(string $transactionId): array |
| 120 | 139 | { |
| 121 | - // Pay later doesn't need verification at checkout | |
| 122 | - return ['success' => true, 'status' => 'reserved']; | |
| 140 | + // Pay Later takes no money at checkout — the balance is settled offline | |
| 141 | + // later. There is nothing to verify online, so this MUST NOT report | |
| 142 | + // success: callers such as confirm_payment() / handle_callback() treat a | |
| 143 | + // successful verify as a captured payment and would otherwise mark the | |
| 144 | + // booking paid + completed before any money has arrived. | |
| 145 | + return [ | |
| 146 | + 'success' => false, | |
| 147 | + 'status' => 'reserved', | |
| 148 | + 'error' => __('Pay Later bookings are settled offline; there is no online payment to verify.', 'yatra'), | |
| 149 | + ]; | |
| 123 | 150 | } |
| 124 | 151 | |
| 125 | 152 | /** |
| 126 | 153 | * Get auto-cancel days setting |