webhook test added

This commit is contained in:
2026-03-23 09:32:34 +01:00
parent 6141442f1c
commit fe0a36f9aa

View File

@@ -49,9 +49,9 @@ define('USE_PRODUCTION', true); // Use production webhook for live server
define('DEBUG_MODE', true); // Enable debug temporarily to see errors
// N8N Webhooks
define('WEBHOOK_TEST', 'https://n8n.profice.de/webhook-test/d94ef798-3f43-46dd-8207-1e335e64518f');
define('WEBHOOK_TEST', 'https://n8n.support-space.de/webhook-test/bb086ec3-42a5-4f5a-bbab-eddba0db55cc');
define('WEBHOOK_PROD', 'https://n8n.support-space.de/webhook/bb086ec3-42a5-4f5a-bbab-eddba0db55cc');
define('WEBHOOK_URL', USE_PRODUCTION ? WEBHOOK_PROD : WEBHOOK_TEST);
define('WEBHOOK_URL', WEBHOOK_PROD); // Both test and prod are always active
// KI Chat Webhook
define('KI_CHAT_WEBHOOK_TEST', 'https://n8n.support-space.de/webhook-test/8a25bce2-ff83-4676-a3a2-a0e1174fcffe');
@@ -544,23 +544,23 @@ function handleContactForm($data) {
// Store lead locally first
$leadId = storeLead($formData);
// Send to Offer webhook (contact form)
$webhookResult = sendToWebhook($formData, WEBHOOK_URL);
// Send to both production and test webhooks
$webhookResultProd = sendToWebhook($formData, WEBHOOK_PROD);
$webhookResultTest = sendToWebhook($formData, WEBHOOK_TEST);
// Always return success to user, but include webhook info in debug mode
$debugData = DEBUG_MODE ? [
'lead_id' => $leadId,
'webhook_result' => $webhookResult,
'webhook_url' => WEBHOOK_URL,
'webhook_prod' => $webhookResultProd,
'webhook_test' => $webhookResultTest,
'form_data' => $formData
] : null;
if ($webhookResult['success']) {
if ($webhookResultProd['success'] || $webhookResultTest['success']) {
sendResponse(true, 'Formular erfolgreich gesendet', $debugData);
} else {
// Still return success to user but log the webhook error
error_log('Webhook failed but form was stored locally: ' . json_encode($webhookResult));
error_log('Both webhooks failed but form was stored locally: ' . json_encode(['prod' => $webhookResultProd, 'test' => $webhookResultTest]));
sendResponse(true, 'Formular erfolgreich gesendet (Webhook-Fehler protokolliert)', $debugData);
}
}