Gift withdrawal in the confirmation e-mail through the feedback page
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -320,6 +320,8 @@ fn purchase_confirmation(lang: Lang, payload: &Value, url: String) -> Result<Con
|
|||||||
payload["paid_on"].as_str().and_then(|d| date(lang, d)).ok_or(TemplateError::MissingField("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 terms_url = field(payload, "terms_url")?;
|
||||||
let invoices_url = field(payload, "invoices_url")?;
|
let invoices_url = field(payload, "invoices_url")?;
|
||||||
|
// Gift withdrawals come through the feedback page (easier to handle there).
|
||||||
|
let feedback_url = format!("{}/visszajelzes", terms_url.trim_end_matches("/aszf"));
|
||||||
let greeting = |hu: bool| match (hu, name(payload, "display_name")) {
|
let greeting = |hu: bool| match (hu, name(payload, "display_name")) {
|
||||||
(true, Some(n)) => format!("Szia {n}!"),
|
(true, Some(n)) => format!("Szia {n}!"),
|
||||||
(true, None) => "Szia!".to_owned(),
|
(true, None) => "Szia!".to_owned(),
|
||||||
@@ -385,8 +387,7 @@ fn purchase_confirmation(lang: Lang, payload: &Value, url: String) -> Result<Con
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
quote: Some(
|
quote: Some(
|
||||||
"A vásárlástól számított 14 napon belül, amíg az ajándékkódot nem váltották be, elállhatsz a vásárlástól: írj az info@sorsfonalak.hu címre, és visszatérítjük az árát. A fizetés előtt kérted, hogy a kód beváltásakor a szolgáltatás azonnal megkezdődjön: a beváltással az elállási jog megszűnik."
|
format!("A vásárlástól számított 14 napon belül, amíg az ajándékkódot nem váltották be, elállhatsz a vásárlástól: írd meg nekünk az oldalon, belépve ({feedback_url}), és visszatérítjük az árát. A fizetés előtt kérted, hogy a kód beváltásakor a szolgáltatás azonnal megkezdődjön: a beváltással az elállási jog megszűnik."),
|
||||||
.into(),
|
|
||||||
),
|
),
|
||||||
points: None,
|
points: None,
|
||||||
code: code.map(|c| ("AJÁNDÉKKÓD", c)),
|
code: code.map(|c| ("AJÁNDÉKKÓD", c)),
|
||||||
@@ -438,8 +439,7 @@ fn purchase_confirmation(lang: Lang, payload: &Value, url: String) -> Result<Con
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
quote: Some(
|
quote: Some(
|
||||||
"Within 14 days of the purchase, while the gift code is not redeemed, you may withdraw from the purchase: write to info@sorsfonalak.hu and we refund it. Before paying you asked for the service to start as soon as the code is redeemed: redeeming it ends the right of withdrawal."
|
format!("Within 14 days of the purchase, while the gift code is not redeemed, you may withdraw from the purchase: tell us on the site, logged in ({feedback_url}), and we refund it. Before paying you asked for the service to start as soon as the code is redeemed: redeeming it ends the right of withdrawal."),
|
||||||
.into(),
|
|
||||||
),
|
),
|
||||||
points: None,
|
points: None,
|
||||||
code: code.map(|c| ("GIFT CODE", c)),
|
code: code.map(|c| ("GIFT CODE", c)),
|
||||||
@@ -1073,6 +1073,7 @@ mod tests {
|
|||||||
payload["gift"]["send_at"] = Value::from("2026-12-24 08:00");
|
payload["gift"]["send_at"] = Value::from("2026-12-24 08:00");
|
||||||
let hu = render("purchase_confirmation", "hu", &payload).unwrap();
|
let hu = render("purchase_confirmation", "hu", &payload).unwrap();
|
||||||
assert!(hu.text.contains("2026. december 24., 08:00-kor küldjük el ide: bea@example.com"), "{}", hu.text);
|
assert!(hu.text.contains("2026. december 24., 08:00-kor küldjük el ide: bea@example.com"), "{}", hu.text);
|
||||||
|
assert!(hu.text.contains("belépve (https://sorsfonalak.hu/visszajelzes)"), "{}", hu.text);
|
||||||
payload["gift"]["recipient_email"] = Value::Null;
|
payload["gift"]["recipient_email"] = Value::Null;
|
||||||
let hu = render("purchase_confirmation", "hu", &payload).unwrap();
|
let hu = render("purchase_confirmation", "hu", &payload).unwrap();
|
||||||
assert!(hu.text.contains("PDF-ben csatoltuk ehhez a levélhez"));
|
assert!(hu.text.contains("PDF-ben csatoltuk ehhez a levélhez"));
|
||||||
|
|||||||
Reference in New Issue
Block a user