All checks were successful
Deploy to Dev / deploy (push) Successful in 0s
- widerruf.php zeigt jetzt Formular (Name + Bestellnr + E-Mail) ohne Token-Zwang - Token-Link aus Bestätigungs-Mail bleibt als Convenience, füllt Felder vor - submit_anonymous() in Revocation-Klasse: Lookup via order_number + customer_email - Anonymous-Eintrag wird inline angelegt, falls noch kein Token-basierter Record existiert - Button-Beschriftung 'Vertrag widerrufen' (Gesetzes-Empfehlung) - prefill_from_token() für Vorausfüllung bei Token-Link
215 lines
8.2 KiB
PHP
215 lines
8.2 KiB
PHP
<?php
|
||
/**
|
||
* Carteasy – Landingpage Widerruf (§ 356a BGB, ab 19.06.2026)
|
||
*
|
||
* GET → Leeres Formular
|
||
* GET ?t=<token> → Formular mit vorausgefüllten Feldern (Convenience aus Bestell-Mail)
|
||
* POST → Widerruf erfassen, Bestätigungsseite anzeigen
|
||
*
|
||
* Submit läuft IMMER über Bestellnr + E-Mail Lookup, nicht über Token.
|
||
*
|
||
* @copyright Wlanium / Thomas Bartelt
|
||
* @since 2026-04-19
|
||
*/
|
||
|
||
session_start();
|
||
ini_set('display_errors', 0);
|
||
error_reporting(0);
|
||
ini_set('log_errors', 1);
|
||
ini_set('error_log', __DIR__.'/error_log.txt');
|
||
|
||
header('X-Robots-Tag: noindex, nofollow', true);
|
||
header('Content-Security-Policy: default-src \'self\'; style-src \'unsafe-inline\'');
|
||
|
||
include_once './core/base.class.php';
|
||
include_once './core/registry.class.php';
|
||
$base_object = new base();
|
||
Registry::set('base', $base_object);
|
||
|
||
include_once './core/revocation.class.php';
|
||
$revocation = new Revocation($base_object);
|
||
|
||
$view = 'form';
|
||
$prefill = ['name' => '', 'order_number' => '', 'email' => ''];
|
||
$error = null;
|
||
|
||
// ------------------------------------------------------------
|
||
// Request dispatch
|
||
// ------------------------------------------------------------
|
||
|
||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||
|
||
$form_name = isset($_POST['name']) ? trim((string)$_POST['name']) : '';
|
||
$form_order_number = isset($_POST['order_number']) ? trim((string)$_POST['order_number']) : '';
|
||
$form_email = isset($_POST['email']) ? trim((string)$_POST['email']) : '';
|
||
$reason_id = isset($_POST['reason_id']) ? (int)$_POST['reason_id'] : 0;
|
||
$reason_text = isset($_POST['reason_text']) ? (string)$_POST['reason_text'] : '';
|
||
$confirm = isset($_POST['confirm']) && $_POST['confirm'] === '1';
|
||
|
||
// Eingaben für Fehlerfall ins Formular zurückspielen
|
||
$prefill = [
|
||
'name' => $form_name,
|
||
'order_number' => $form_order_number,
|
||
'email' => $form_email,
|
||
];
|
||
|
||
if (!$confirm) {
|
||
$view = 'form';
|
||
$error = 'no_confirm';
|
||
} else {
|
||
$ip = $_SERVER['REMOTE_ADDR'] ?? '';
|
||
$ua = $_SERVER['HTTP_USER_AGENT'] ?? '';
|
||
if ($revocation->submit_anonymous(
|
||
$form_name, $form_order_number, $form_email,
|
||
$reason_id, $reason_text, $ip, $ua
|
||
)) {
|
||
$view = 'success';
|
||
} else {
|
||
$view = 'form';
|
||
$error = $revocation->get_error();
|
||
}
|
||
}
|
||
|
||
} else {
|
||
|
||
// GET — bei Token-Link: Felder vorausfüllen
|
||
$token = isset($_GET['t']) ? (string)$_GET['t'] : '';
|
||
if ($token !== '') {
|
||
$pf = $revocation->prefill_from_token($token);
|
||
if ($pf) {
|
||
$prefill = $pf;
|
||
} elseif ($revocation->get_error() === 'feature_disabled') {
|
||
$view = 'error';
|
||
$error = 'feature_disabled';
|
||
}
|
||
// Bei anderen Token-Fehlern: leeres Formular anbieten ohne Hinweistext
|
||
}
|
||
}
|
||
|
||
$reasons = $revocation->fetch_reasons();
|
||
|
||
$messages = [
|
||
'no_confirm' => 'Bitte bestätigen Sie den Widerruf durch Setzen des Hakens.',
|
||
'missing_order' => 'Bitte geben Sie Ihre Bestellnummer an.',
|
||
'invalid_email' => 'Bitte geben Sie eine gültige E-Mail-Adresse an.',
|
||
'order_not_found' => 'Wir konnten keine Bestellung mit dieser Bestellnummer und E-Mail-Adresse finden. '
|
||
. 'Bitte prüfen Sie Ihre Eingaben.',
|
||
'expired' => 'Die 14-tägige Widerrufsfrist ist überschritten. '
|
||
. 'Wenden Sie sich bitte direkt an uns.',
|
||
'already_submitted' => 'Für diese Bestellung wurde bereits ein Widerruf erklärt.',
|
||
'feature_disabled' => 'Die elektronische Widerrufsfunktion ist aktuell noch nicht aktiv.',
|
||
'not_eligible' => 'Für diese Bestellung steht der elektronische Widerruf nicht zur Verfügung.',
|
||
];
|
||
$display_error = isset($messages[$error]) ? $messages[$error] : null;
|
||
|
||
?><!doctype html>
|
||
<html lang="de">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<meta name="robots" content="noindex,nofollow">
|
||
<title>Widerruf – Intelectra</title>
|
||
<style>
|
||
body {font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;
|
||
background:#f6f6f6;margin:0;color:#222;}
|
||
.wrap{max-width:640px;margin:40px auto;padding:32px;background:#fff;
|
||
border-radius:6px;box-shadow:0 2px 8px rgba(0,0,0,.08);}
|
||
h1{margin-top:0;color:#c00;}
|
||
h2{margin-top:1.6em;}
|
||
.meta{background:#f4f4f4;padding:12px 16px;border-left:4px solid #c00;
|
||
font-size:.9em;margin:16px 0;}
|
||
label{display:block;margin:12px 0 4px;font-weight:600;}
|
||
select,textarea,input[type=text],input[type=email]{width:100%;padding:10px;font-size:1em;
|
||
border:1px solid #ccc;border-radius:4px;box-sizing:border-box;}
|
||
textarea{min-height:90px;font-family:inherit;}
|
||
.check{margin:20px 0;font-size:.95em;font-weight:normal;}
|
||
.btn{background:#c00;color:#fff;border:0;padding:14px 28px;
|
||
font-size:1.05em;font-weight:bold;border-radius:4px;cursor:pointer;}
|
||
.btn:hover{background:#a00;}
|
||
.err{background:#ffe9e9;border-left:4px solid #c00;padding:10px 14px;
|
||
margin:12px 0;}
|
||
.ok{background:#e7f7e7;border-left:4px solid #2a7;padding:14px 18px;}
|
||
.muted{color:#666;font-size:.85em;}
|
||
footer{text-align:center;margin:20px 0;color:#999;font-size:.8em;}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="wrap">
|
||
|
||
<?php if ($view === 'form'): ?>
|
||
|
||
<h1>Vertrag widerrufen</h1>
|
||
<p>Gemäß § 355 BGB haben Sie das Recht, Ihren Vertrag binnen 14 Tagen
|
||
ohne Angabe von Gründen zu widerrufen. Füllen Sie bitte die folgenden
|
||
drei Pflichtfelder aus.</p>
|
||
|
||
<?php if ($display_error): ?><div class="err"><?= htmlspecialchars($display_error) ?></div><?php endif; ?>
|
||
|
||
<form method="post" action="<?= htmlspecialchars(strtok($_SERVER['REQUEST_URI'], '?')) ?>">
|
||
|
||
<label for="name">Vor- und Nachname</label>
|
||
<input type="text" id="name" name="name" required maxlength="120"
|
||
value="<?= htmlspecialchars($prefill['name']) ?>">
|
||
|
||
<label for="order_number">Bestellnummer</label>
|
||
<input type="text" id="order_number" name="order_number" required maxlength="32"
|
||
value="<?= htmlspecialchars($prefill['order_number']) ?>"
|
||
placeholder="z.B. 102345">
|
||
|
||
<label for="email">E-Mail-Adresse</label>
|
||
<input type="email" id="email" name="email" required maxlength="120"
|
||
value="<?= htmlspecialchars($prefill['email']) ?>"
|
||
placeholder="Die E-Mail, mit der Sie bestellt haben">
|
||
|
||
<label for="reason_id">Grund (optional, freiwillige Angabe)</label>
|
||
<select name="reason_id" id="reason_id">
|
||
<option value="0">— bitte wählen —</option>
|
||
<?php foreach ($reasons as $r): ?>
|
||
<option value="<?= (int)$r->id ?>"><?= htmlspecialchars($r->label) ?></option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
|
||
<label for="reason_text">Anmerkung (optional)</label>
|
||
<textarea name="reason_text" id="reason_text" maxlength="2000"
|
||
placeholder="Sie können uns hier eine Mitteilung hinterlassen – muss nicht."></textarea>
|
||
|
||
<label class="check">
|
||
<input type="checkbox" name="confirm" value="1" required>
|
||
Ich erkläre hiermit den Widerruf meiner oben genannten Bestellung.
|
||
</label>
|
||
|
||
<button type="submit" class="btn">Vertrag widerrufen</button>
|
||
|
||
<p class="muted" style="margin-top:20px;">Nach dem Absenden erhalten Sie eine
|
||
Bestätigungs-E-Mail mit der Rücksendeadresse und weiteren Informationen.</p>
|
||
</form>
|
||
|
||
<?php elseif ($view === 'success'): ?>
|
||
|
||
<h1>Widerruf entgegengenommen</h1>
|
||
<div class="ok">
|
||
<strong>Vielen Dank.</strong> Ihre Widerrufserklärung wurde erfasst.
|
||
Sie erhalten in Kürze eine Bestätigungs-E-Mail an die hinterlegte
|
||
Adresse mit der Rücksendeadresse und den nächsten Schritten.
|
||
</div>
|
||
<p class="muted">Bei Rückfragen erreichen Sie uns unter
|
||
<a href="mailto:<?= htmlspecialchars(REVOCATION_OWNER_EMAIL) ?>"><?= htmlspecialchars(REVOCATION_OWNER_EMAIL) ?></a>.</p>
|
||
|
||
<?php else: ?>
|
||
|
||
<h1>Widerruf nicht möglich</h1>
|
||
<div class="err"><?= htmlspecialchars($display_error ?: 'Widerruf zurzeit nicht verarbeitbar.') ?></div>
|
||
<p>Sie können Ihren Widerruf jederzeit auch formlos per E-Mail an
|
||
<a href="mailto:<?= htmlspecialchars(REVOCATION_OWNER_EMAIL) ?>"><?= htmlspecialchars(REVOCATION_OWNER_EMAIL) ?></a>
|
||
oder per Brief erklären.</p>
|
||
<p class="muted"><?= htmlspecialchars(REVOCATION_RETURN_COMPANY) ?> ·
|
||
<?= htmlspecialchars(REVOCATION_RETURN_STREET) ?> ·
|
||
<?= htmlspecialchars(REVOCATION_RETURN_CITY) ?></p>
|
||
|
||
<?php endif; ?>
|
||
|
||
</div>
|
||
<footer>Intelectra Online-Shop · <a href="/">Zurück zum Shop</a></footer>
|
||
</body>
|
||
</html>
|