diff --git a/ShowActs/show-to-Docu.php b/ShowActs/show-to-Docu.php index ecb89e4..831ec65 100644 --- a/ShowActs/show-to-Docu.php +++ b/ShowActs/show-to-Docu.php @@ -1,123 +1 @@ - trim($_POST['act_name'] ?? ''), - "person_count" => intval($_POST['person_count'] ?? 1), - "duration" => intval($_POST['duration'] ?? 0), - "description" => trim($_POST['description'] ?? ''), - "tech_needs" => trim($_POST['tech_needs'] ?? ''), - "contact_name" => trim($_POST['contact_name'] ?? ''), - "email" => filter_var(trim($_POST['email'] ?? ''), FILTER_VALIDATE_EMAIL), - "total_price" => trim($_POST['total_price'] ?? ''), - "terms_accepted" => isset($_POST['terms']) ? true : false -]; - -if (empty($api_key) || $api_key === 'DEIN_DOCUSEAL_API_KEY') { - die("Konfigurationsfehler: API-Key wurde nicht hinterlegt."); -} -if (!$data['email'] || empty($data['act_name']) || empty($data['contact_name'])) { - die("Validierungsfehler: Bitte fülle alle Pflichtfelder korrekt aus."); -} -if (!$data['terms_accepted']) { - die("Validierungsfehler: Die Teilnahmebedingungen müssen akzeptiert werden."); -} - -$payload = [ - "template_id" => $template_id, - "send_email" => false, - "submitters" => [ - [ - "email" => $data['email'], - "name" => $data['contact_name'], - "fields" => [ - [ - "name" => "act_name", - "default_value" => $data['act_name'] - ], - [ - "name" => "ansprechpartner", - "default_value" => $data['contact_name'] - ], - [ - "name" => "email", - "default_value" => $data['email'] - ], - [ - "name" => "anzahl_personen", - "default_value" => (string)$data['person_count'] - ], - [ - "name" => "dauer_minuten", - "default_value" => (string)$data['duration'] - ], - [ - "name" => "beschreibung", - "default_value" => $data['description'] - ], - [ - "name" => "technik", - "default_value" => $data['tech_needs'] - ], - [ - "name" => "gesamtbetrag", - "default_value" => $data['total_price'] - ], - [ - "name" => "teilnahmebedingungen", - "default_value" => true - ] - ] - ] - ] -]; - -$ch = curl_init($api_url); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_POST, true); -curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); -curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); -curl_setopt($ch, CURLOPT_HTTPHEADER, [ - 'X-Auth-Token: ' . $api_key, - 'Content-Type: application/json' -]); -$response = curl_exec($ch); -$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); -$curl_error = curl_error($ch); -if ($http_code === 200 || $http_code === 201) { - $responseData = json_decode($response, true); - $submitter = $responseData[0] ?? []; - $signing_url = $submitter['url'] ?? null; - if (!$signing_url && !empty($submitter['slug'])) { - $signing_url = "URL EINFÜGEN" . $submitter['slug']; - } - if ($signing_url) { - header("Location: " . $signing_url); - exit; - } else { - echo "

Fehler: Konnte den Signatur-Link nicht generieren!

"; - echo "Rohe API-Antwort:
" . htmlspecialchars($response) . "
"; - exit; - } - -} else { - echo "

🚨 VERBINDUNG ZU DOCUSEAL FEHLGESCHLAGEN 🚨

"; - echo "

HTTP-Code: " . htmlspecialchars($http_code) . "

"; - echo "

API-Antwort von DocuSeal: " . htmlspecialchars($response) . "

"; - echo "

Interner cURL-Fehler: " . htmlspecialchars($curl_error) . "

"; - exit; -} \ No newline at end of file +move to WebhookStuff