responseField()] ?? null; if (empty($token)) { return false; } try { $response = Http::asForm() ->timeout((int) config('captcha.hcaptcha.timeout', 5)) ->post(self::VERIFY_URL, [ 'secret' => config_cache('captcha.hcaptcha.secret'), 'response' => $token, ]); } catch (\Throwable $e) { Log::warning('[captcha:hcaptcha] verify request failed: '.$e->getMessage()); return (bool) config('captcha.hcaptcha.fail_open', false); } if ($response->failed()) { return (bool) config('captcha.hcaptcha.fail_open', false); } return (bool) $response->json('success', false); } public function render(array $attributes = []): string { $sitekey = e((string) config_cache('captcha.hcaptcha.sitekey')); $attrs = ''; foreach ($attributes as $key => $value) { $attrs .= ' '.e($key).'="'.e($value).'"'; } return '
'; } public function scripts(): string { $src = self::SCRIPT_URL; // Localize the widget when a locale is configured. $lang = config('captcha.hcaptcha.lang'); if (! empty($lang)) { $src .= '?hl='.urlencode((string) $lang); } return ''; } }