PluginProbe
Yatra – Travel Booking & Tour Operator Software / trunk
Yatra – Travel Booking & Tour Operator Software vtrunk
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 2.0.10 All 83 releases
← All changes | app/Controllers/PaymentController.php +12 -0 3.0.14.2trunk View file →
@@ -188,8 +188,16 @@
188 188 $data = $request->get_json_params();
189 189
190 190 try {
191 191 $payment = $this->paymentService->createPayment($data);
192 +
193 + // The service reports validation failures (unknown booking, invalid
194 + // status) as ['success' => false]; answering 201 made the admin form
195 + // redirect as if the payment had been saved.
196 + if (is_array($payment) && isset($payment['success']) && !$payment['success']) {
197 + return new WP_REST_Response($payment, 400);
198 + }
199 +
192 200 return new WP_REST_Response($payment, 201);
193 201 } catch (\Exception $e) {
194 202 return new WP_Error('payment_creation_failed', $e->getMessage(), ['status' => 400]);
195 203 }
@@ -207,8 +215,12 @@
207 215 $payment = $this->paymentService->updatePayment($id, $data);
208 216
209 217 if (!$payment) {
210 218 return new WP_Error('payment_not_found', 'Payment not found', ['status' => 404]);
219 + }
220 +
221 + if (is_array($payment) && isset($payment['success']) && !$payment['success']) {
222 + return new WP_REST_Response($payment, 400);
211 223 }
212 224
213 225 return new WP_REST_Response($payment, 200);
214 226 } catch (\Exception $e) {