ÁSZF: terms page, consent on every purchase, confirmation e-mail
CI / test (push) Successful in 1m28s
CI / build (push) Successful in 5m29s
CI / deploy (push) Skipped

The new /aszf page holds the terms (a draft for legal review; the
company data come from lib/legal.ts). Stripe's payment page asks every
buyer to accept them and to ask for immediate delivery, giving up the
14-day withdrawal right; the time and the terms version are stored, and
a purchase_confirmation e-mail confirms it. Login, the landing footer,
the package cards and the sitemap link the terms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-20 12:06:10 +00:00
co-authored by Claude Opus 5.5
parent ac5e7fa4fd
commit e326095f3f
14 changed files with 409 additions and 12 deletions
@@ -0,0 +1,6 @@
-- The buyer accepted the terms (ÁSZF) and asked for immediate delivery, giving
-- up the 14-day withdrawal right, on Stripe's payment page: when, and which
-- version of the terms. Kept as the proof of the consent.
ALTER TABLE stripe_checkouts
ADD COLUMN terms_accepted_at timestamptz,
ADD COLUMN terms_version text;
+82
View File
@@ -160,6 +160,7 @@ pub fn render(template: &str, locale: &str, payload: &Value) -> Result<Rendered,
("invitation", _) => invitation(lang, payload, url)?,
("synastry_invite", _) => synastry_invite(lang, payload, url)?,
("waitlist_joined", _) => waitlist_joined(lang, payload, url)?,
("purchase_confirmation", _) => purchase_confirmation(lang, payload, url)?,
_ => return Err(TemplateError::UnknownTemplate(template.to_owned())),
};
Ok(content.render(lang))
@@ -284,6 +285,69 @@ fn name(payload: &Value, field: &str) -> Option<String> {
(!name.is_empty()).then(|| name.to_owned())
}
/// The confirmation of a purchase: what was bought, and that the buyer asked
/// for immediate delivery and so gave up the 14-day withdrawal right (the
/// confirmation 45/2014. Korm. rendelet 29. § asks for).
fn purchase_confirmation(lang: Lang, payload: &Value, url: String) -> Result<Content, TemplateError> {
let package = name(payload, "package_name").ok_or(TemplateError::MissingField("package_name"))?;
let amount = field(payload, "amount")?;
let contents =
payload["contents"].as_str().map(|c| c.chars().filter(|c| !c.is_control()).take(300).collect::<String>());
let paid_on =
payload["paid_on"].as_str().and_then(|d| date(lang, d)).ok_or(TemplateError::MissingField("paid_on"))?;
let terms_url = field(payload, "terms_url")?;
let invoices_url = field(payload, "invoices_url")?;
let greeting = |hu: bool| match (hu, name(payload, "display_name")) {
(true, Some(n)) => format!("Szia {n}!"),
(true, None) => "Szia!".to_owned(),
(false, Some(n)) => format!("Hi {n},"),
(false, None) => "Hi,".to_owned(),
};
Ok(match lang {
Lang::Hu => Content {
subject: format!("Köszönjük a vásárlást: {package}"),
preheader: Some(format!("A(z) {package} csomag a tiéd.")),
greeting: greeting(true),
intro: format!(
"Megkaptuk a fizetésed ({amount}, {paid_on}), és jóváírtuk a(z) „{package}” csomagot.{}",
contents.map(|c| format!(" Tartalma: {c}.")).unwrap_or_default()
),
quote: Some(
"A fizetés előtt kérted a szolgáltatás azonnali megkezdését, és tudomásul vetted, hogy ezzel elveszíted a 14 napos elállási jogodat. A csomagot ennek megfelelően azonnal teljesítettük."
.into(),
),
points: None,
button: "Megnézem a csomagjaimat",
url,
note: format!(
"A számlát külön e-mailben küldjük, és a Számláim oldalon is letöltheted: {invoices_url}. A vásárlás feltételei (ÁSZF): {terms_url}. Ha valami nem működik, írj nekünk az info@sorsfonalak.hu címre."
),
reason: Some("Ezt a levelet a vásárlásod visszaigazolásaként kaptad.".into()),
unsubscribe: None,
unsubscribe_post_url: None,
},
Lang::En => Content {
subject: format!("Thank you for your purchase: {package}"),
preheader: Some(format!("The {package} package is yours.")),
greeting: greeting(false),
intro: format!("We received your payment ({amount}, {paid_on}) and added the “{package}” package to your account."),
quote: Some(
"Before paying you asked us to start the service at once and acknowledged that you thereby lose your 14-day right of withdrawal. The package was delivered at once accordingly."
.into(),
),
points: None,
button: "See my packages",
url,
note: format!(
"The invoice comes in a separate e-mail and can be downloaded on the Invoices page: {invoices_url}. Terms of purchase (ÁSZF): {terms_url}. If something does not work, write to info@sorsfonalak.hu."
),
reason: Some("You got this e-mail as the confirmation of your purchase.".into()),
unsubscribe: None,
unsubscribe_post_url: None,
},
})
}
/// The confirmation of a waitlist sign-up, with the link that takes the address off the list.
fn waitlist_joined(lang: Lang, payload: &Value, url: String) -> Result<Content, TemplateError> {
let unsubscribe_url = field(payload, "unsubscribe_url")?;
@@ -651,6 +715,24 @@ mod tests {
assert_eq!(render("invitation", "hu", &broken), Err(TemplateError::MissingField("unsubscribe_url")));
}
#[test]
fn purchase_confirmations_confirm_the_waiver() {
let payload = serde_json::json!({
"url": "https://sorsfonalak.hu/csomagok", "display_name": "Anna", "package_name": "Páros",
"contents": "2 részletes képletelemzés, 1 kapcsolati elemzés", "amount": "6\u{a0}000\u{a0}Ft",
"paid_on": "2026-11-20", "terms_url": "https://sorsfonalak.hu/aszf", "invoices_url": "https://sorsfonalak.hu/szamlak"
});
let hu = render("purchase_confirmation", "hu", &payload).unwrap();
assert_eq!(hu.subject, "Köszönjük a vásárlást: Páros");
assert!(hu.text.contains("2026. november 20.") && hu.text.contains("Tartalma: 2 részletes képletelemzés"));
assert!(hu.text.contains("elveszíted a 14 napos elállási jogodat"));
assert!(hu.text.contains("https://sorsfonalak.hu/aszf") && hu.text.contains("https://sorsfonalak.hu/szamlak"));
let en = render("purchase_confirmation", "en", &payload).unwrap();
assert!(en.text.contains("right of withdrawal"));
let missing = serde_json::json!({"url": "u", "package_name": "Páros"});
assert_eq!(render("purchase_confirmation", "hu", &missing), Err(TemplateError::MissingField("amount")));
}
#[test]
fn dates() {
assert_eq!(date(Lang::Hu, "2027-01-05").as_deref(), Some("2027. január 5."));