| @@ -139,8 +139,18 @@ | ||
| 139 | 139 | if (!wp_verify_nonce($_POST['nonce'] ?? '', 'yatra_enquiry_nonce')) { |
| 140 | 140 | wp_send_json_error(['message' => __('Security check failed.', 'yatra')]); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | + // reCAPTCHA v3 (no-op unless the enquiry form is protected in settings). | |
| 144 | + $recaptcha = \Yatra\Services\RecaptchaService::verifyForm( | |
| 145 | + 'enquiry', | |
| 146 | + (string) ($_POST['recaptcha_token'] ?? ''), | |
| 147 | + $_SERVER['REMOTE_ADDR'] ?? null | |
| 148 | + ); | |
| 149 | + if (empty($recaptcha['success'])) { | |
| 150 | + wp_send_json_error(['message' => $recaptcha['message'] ?? __('reCAPTCHA verification failed.', 'yatra')]); | |
| 151 | + } | |
| 152 | + | |
| 143 | 153 | // Validate required fields |
| 144 | 154 | $name = sanitize_text_field($_POST['name'] ?? ''); |
| 145 | 155 | $email = sanitize_email($_POST['email'] ?? ''); |
| 146 | 156 | $phone = sanitize_text_field($_POST['phone'] ?? ''); |