webhook test added
This commit is contained in:
@@ -49,9 +49,9 @@ define('USE_PRODUCTION', true); // Use production webhook for live server
|
|||||||
define('DEBUG_MODE', true); // Enable debug temporarily to see errors
|
define('DEBUG_MODE', true); // Enable debug temporarily to see errors
|
||||||
|
|
||||||
// N8N Webhooks
|
// 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_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
|
// KI Chat Webhook
|
||||||
define('KI_CHAT_WEBHOOK_TEST', 'https://n8n.support-space.de/webhook-test/8a25bce2-ff83-4676-a3a2-a0e1174fcffe');
|
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
|
// Store lead locally first
|
||||||
$leadId = storeLead($formData);
|
$leadId = storeLead($formData);
|
||||||
|
|
||||||
// Send to Offer webhook (contact form)
|
// Send to both production and test webhooks
|
||||||
$webhookResult = sendToWebhook($formData, WEBHOOK_URL);
|
$webhookResultProd = sendToWebhook($formData, WEBHOOK_PROD);
|
||||||
|
$webhookResultTest = sendToWebhook($formData, WEBHOOK_TEST);
|
||||||
|
|
||||||
// Always return success to user, but include webhook info in debug mode
|
// Always return success to user, but include webhook info in debug mode
|
||||||
$debugData = DEBUG_MODE ? [
|
$debugData = DEBUG_MODE ? [
|
||||||
'lead_id' => $leadId,
|
'lead_id' => $leadId,
|
||||||
'webhook_result' => $webhookResult,
|
'webhook_prod' => $webhookResultProd,
|
||||||
'webhook_url' => WEBHOOK_URL,
|
'webhook_test' => $webhookResultTest,
|
||||||
'form_data' => $formData
|
'form_data' => $formData
|
||||||
] : null;
|
] : null;
|
||||||
|
|
||||||
if ($webhookResult['success']) {
|
if ($webhookResultProd['success'] || $webhookResultTest['success']) {
|
||||||
sendResponse(true, 'Formular erfolgreich gesendet', $debugData);
|
sendResponse(true, 'Formular erfolgreich gesendet', $debugData);
|
||||||
} else {
|
} else {
|
||||||
// Still return success to user but log the webhook error
|
error_log('Both webhooks failed but form was stored locally: ' . json_encode(['prod' => $webhookResultProd, 'test' => $webhookResultTest]));
|
||||||
error_log('Webhook failed but form was stored locally: ' . json_encode($webhookResult));
|
|
||||||
sendResponse(true, 'Formular erfolgreich gesendet (Webhook-Fehler protokolliert)', $debugData);
|
sendResponse(true, 'Formular erfolgreich gesendet (Webhook-Fehler protokolliert)', $debugData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user