| @@ -156,8 +156,24 @@ | ||
| 156 | 156 | |
| 157 | 157 | return new WP_HTTP_Response( $response, 403 ); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | + if ( is_array( $payment ) && ! empty( $payment['error'] ) ) { | |
| 161 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) { | |
| 162 | + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- Debug logging is guarded by WP_DEBUG checks. | |
| 163 | + error_log( 'Timetics Stripe payment intent failed: ' . wp_json_encode( $payment['error'] ) ); | |
| 164 | + } | |
| 165 | + | |
| 166 | + return new WP_HTTP_Response( | |
| 167 | + [ | |
| 168 | + 'success' => 0, | |
| 169 | + 'status_code' => 402, | |
| 170 | + 'message' => __( 'We could not start the payment. Please try again.', 'timetics' ), | |
| 171 | + ], | |
| 172 | + 402 | |
| 173 | + ); | |
| 174 | + } | |
| 175 | + | |
| 160 | 176 | return rest_ensure_response( $payment ); |
| 161 | 177 | } |
| 162 | 178 | |
| 163 | 179 | /** |