Neutral invoice items; "kártya" instead of "kártyajóslás" on Stripe
Invoices: the add-ons share the item "Online tartalomszolgáltatás – kiegészítő csomag" and tarot readings are listed as "egyedi szöveges tartalom"; a test keeps "jóslás" and "kártya" off every invoice. Stripe's payment page and receipt call the tarot add-on "+5 kártya". The Telegram notice adds the package id to an add-on, so it still says which one was bought. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -245,11 +245,13 @@ impl Package {
|
||||
|
||||
/// The invoice item: a name that says what the service is (online,
|
||||
/// software-made content; no profession implied), and what the package
|
||||
/// contains (Áfa tv. 169. § e).
|
||||
/// contains (Áfa tv. 169. § e). Kept neutral: the main packages keep
|
||||
/// their plain names, the add-ons share one name, and tarot readings are
|
||||
/// listed as text content.
|
||||
pub fn invoice_item(&self) -> (String, String) {
|
||||
let name = match self.tier {
|
||||
Tier::Main => format!("Online tartalomszolgáltatás – {} csomag", self.name),
|
||||
Tier::Addon => format!("Online tartalomszolgáltatás – {} kiegészítő", self.name),
|
||||
Tier::Addon => "Online tartalomszolgáltatás – kiegészítő csomag".to_string(),
|
||||
};
|
||||
let lines: Vec<String> = [
|
||||
(self.natal, "képletelemzés"),
|
||||
@@ -257,7 +259,7 @@ impl Package {
|
||||
(self.forecast, "éves előrejelzés"),
|
||||
(self.persons, "további személy felvétele"),
|
||||
(self.questions, "kérdés"),
|
||||
(self.tarot, "kártyaértelmezés"),
|
||||
(self.tarot, "egyedi szöveges tartalom"),
|
||||
]
|
||||
.into_iter()
|
||||
.filter(|&(n, _)| n > 0)
|
||||
@@ -271,6 +273,13 @@ impl Package {
|
||||
(name, comment)
|
||||
}
|
||||
|
||||
/// The name and description on Stripe's payment page and receipt: as on
|
||||
/// the site, but tarot readings are called "kártya" there.
|
||||
pub fn checkout_text(&self) -> (String, String) {
|
||||
let plain = |s: &str| s.replace("kártyajóslás", "kártya");
|
||||
(format!("Sorsfonalak – {}", plain(self.name)), plain(self.tagline))
|
||||
}
|
||||
|
||||
/// What the package gives, unit by unit.
|
||||
pub fn contents(&self) -> [(Unit, i64); 6] {
|
||||
[
|
||||
@@ -420,12 +429,24 @@ mod tests {
|
||||
comment,
|
||||
"Hozzáférés a sorsfonalak.hu szoftveresen előállított, személyre szabott szöveges tartalmaihoz: \
|
||||
2 képletelemzés, 1 kapcsolati elemzés, 2 éves előrejelzés, 1 további személy felvétele, 3 kérdés, \
|
||||
5 kártyaértelmezés. Digitális tartalom."
|
||||
5 egyedi szöveges tartalom. Digitális tartalom."
|
||||
);
|
||||
let (name, comment) = find("addon_persons").unwrap().invoice_item();
|
||||
assert_eq!(name, "Online tartalomszolgáltatás – +5 személy kiegészítő");
|
||||
assert_eq!(name, "Online tartalomszolgáltatás – kiegészítő csomag");
|
||||
assert!(comment.ends_with("tartalmaihoz: 5 további személy felvétele. Digitális tartalom."), "{comment}");
|
||||
// No profession is implied.
|
||||
assert!(CATALOG.iter().all(|p| !format!("{:?}", p.invoice_item()).to_lowercase().contains("asztrol")));
|
||||
// No profession and no fortune-telling is implied.
|
||||
for package in &CATALOG {
|
||||
let item = format!("{:?}", package.invoice_item()).to_lowercase();
|
||||
assert!(!item.contains("asztrol") && !item.contains("jóslás") && !item.contains("kártya"), "{item}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stripe_says_kartya_instead_of_kartyajoslas() {
|
||||
let (name, description) = find("addon_tarot").unwrap().checkout_text();
|
||||
assert_eq!(name, "Sorsfonalak – +5 kártya");
|
||||
assert_eq!(description, "Öt újabb kártya a saját kérdéseidre.");
|
||||
assert_eq!(find("couple").unwrap().checkout_text().0, "Sorsfonalak – Páros");
|
||||
assert!(CATALOG.iter().all(|p| !format!("{:?}", p.checkout_text()).contains("jóslás")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +132,7 @@ pub async fn checkout(
|
||||
let config = stripe_for(&state, &auth)?;
|
||||
let package = packages::find(&req.package).ok_or(ApiError::NotFound("package"))?;
|
||||
let back = format!("{}{}", state.config.public_base_url, return_path(req.return_path.as_deref()));
|
||||
let (checkout_name, checkout_description) = package.checkout_text();
|
||||
let field = |k: &str, v: &str| (k.to_string(), v.to_string());
|
||||
let mut form = vec![
|
||||
field("mode", "payment"),
|
||||
@@ -147,11 +148,11 @@ pub async fn checkout(
|
||||
field("line_items[0][price_data][currency]", "huf"),
|
||||
// Stripe counts forints in fillér.
|
||||
field("line_items[0][price_data][unit_amount]", &(package.price_huf * 100).to_string()),
|
||||
field("line_items[0][price_data][product_data][name]", &format!("Sorsfonalak – {}", package.name)),
|
||||
field("line_items[0][price_data][product_data][description]", package.tagline),
|
||||
field("line_items[0][price_data][product_data][name]", &checkout_name),
|
||||
field("line_items[0][price_data][product_data][description]", &checkout_description),
|
||||
field("metadata[package]", package.id),
|
||||
field("metadata[user_id]", &auth.id().to_string()),
|
||||
field("payment_intent_data[description]", &format!("Sorsfonalak – {}", package.name)),
|
||||
field("payment_intent_data[description]", &checkout_name),
|
||||
field("payment_intent_data[metadata][package]", package.id),
|
||||
field("success_url", &format!("{back}?fizetes={{CHECKOUT_SESSION_ID}}")),
|
||||
field("cancel_url", &format!("{back}?fizetes=megszakitva")),
|
||||
|
||||
Reference in New Issue
Block a user