ÁSZF consent on Stripe's page off until the opening (TERMS_CONSENT)
Stripe refuses the terms consent until the terms URL is set in its Public details, so purchases would fail. TERMS_CONSENT=false (the default) leaves the consent out; then the package cards do not mention the withdrawal waiver and no purchase confirmation is sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -91,6 +91,9 @@ services:
|
|||||||
# Stripe purchases for everyone (false: admins only, until the opening;
|
# Stripe purchases for everyone (false: admins only, until the opening;
|
||||||
# with a test key always admins only).
|
# with a test key always admins only).
|
||||||
PURCHASES_OPEN: ${PURCHASES_OPEN:-false}
|
PURCHASES_OPEN: ${PURCHASES_OPEN:-false}
|
||||||
|
# Buyers accept the ÁSZF on Stripe's page (needs the terms URL in
|
||||||
|
# Stripe's Public details): off until the opening.
|
||||||
|
TERMS_CONSENT: ${TERMS_CONSENT:-false}
|
||||||
# VAT on the invoices: AAM (alanyi adómentes) or a rate like 27%.
|
# VAT on the invoices: AAM (alanyi adómentes) or a rate like 27%.
|
||||||
INVOICE_VAT: ${INVOICE_VAT:-AAM}
|
INVOICE_VAT: ${INVOICE_VAT:-AAM}
|
||||||
# Users inviting others ("Meghívom"): shown but off until the launch.
|
# Users inviting others ("Meghívom"): shown but off until the launch.
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ services:
|
|||||||
# Stripe purchases for everyone (false: admins only, until the opening;
|
# Stripe purchases for everyone (false: admins only, until the opening;
|
||||||
# with a test key always admins only).
|
# with a test key always admins only).
|
||||||
PURCHASES_OPEN: ${PURCHASES_OPEN:-false}
|
PURCHASES_OPEN: ${PURCHASES_OPEN:-false}
|
||||||
|
TERMS_CONSENT: ${TERMS_CONSENT:-false}
|
||||||
# VAT on the invoices: AAM (alanyi adómentes) or a rate like 27%.
|
# VAT on the invoices: AAM (alanyi adómentes) or a rate like 27%.
|
||||||
INVOICE_VAT: ${INVOICE_VAT:-AAM}
|
INVOICE_VAT: ${INVOICE_VAT:-AAM}
|
||||||
FREE_PERSON_SLOTS: ${FREE_PERSON_SLOTS:-0}
|
FREE_PERSON_SLOTS: ${FREE_PERSON_SLOTS:-0}
|
||||||
|
|||||||
+2
-2
@@ -15,9 +15,9 @@ A csomagokat a Stripe Checkout fizetési oldalán lehet megvenni. A csomagok nev
|
|||||||
|
|
||||||
## ÁSZF és elállási jog
|
## ÁSZF és elállási jog
|
||||||
|
|
||||||
Minden vásárlásnál a Stripe fizetési oldalán kötelező bepipálni: „Elfogadom az ÁSZF-et, kérem a szolgáltatás azonnali megkezdését, és tudomásul veszem, hogy ezzel elveszítem a 14 napos elállási jogomat.” (`consent_collection[terms_of_service]=required` és `custom_text[terms_of_service_acceptance]`). Digitális tartalomnál így szűnik meg az elállási jog (45/2014. Korm. rendelet 29. §). Ehhez **a Stripe felületén meg kell adni az ÁSZF címét** (Settings → Business → Public details → Terms of service: `https://sorsfonalak.hu/aszf`), különben a Stripe nem indítja el a fizetést.
|
**A megnyitásig ki van kapcsolva** (`TERMS_CONSENT=false`, az alapértelmezés): a Stripe nem kéri az elfogadást, a csomagkártyák nem írnak az elállási jogról, és visszaigazoló e-mail sem megy. Bekapcsolva (`TERMS_CONSENT=true` a `.env`-ben, a backend újraindításával) minden vásárlásnál a Stripe fizetési oldalán kötelező bepipálni: „Elfogadom az ÁSZF-et, kérem a szolgáltatás azonnali megkezdését, és tudomásul veszem, hogy ezzel elveszítem a 14 napos elállási jogomat.” (`consent_collection[terms_of_service]=required` és `custom_text[terms_of_service_acceptance]`). Digitális tartalomnál így szűnik meg az elállási jog (45/2014. Korm. rendelet 29. §). Ehhez **a Stripe felületén meg kell adni az ÁSZF címét** (Settings → Business → Public details → Terms of service: `https://sorsfonalak.hu/aszf`), különben a Stripe nem indítja el a fizetést.
|
||||||
|
|
||||||
Az elfogadás idejét és az ÁSZF változatát (`TERMS_VERSION`, a frontend `TERMS_UPDATED`-jével együtt kell léptetni) a `stripe_checkouts` sor őrzi (`terms_accepted_at`, `terms_version`). Fizetés után a backend visszaigazoló e-mailt küld (`purchase_confirmation`): a csomag, az összeg, a dátum és a lemondás az elállási jogról; ez a rendelet szerinti visszaigazolás.
|
Az elfogadás idejét és az ÁSZF változatát (`TERMS_VERSION`, a frontend `TERMS_UPDATED`-jével együtt kell léptetni) a `stripe_checkouts` sor őrzi (`terms_accepted_at`, `terms_version`). Elfogadott ÁSZF esetén fizetés után a backend visszaigazoló e-mailt küld (`purchase_confirmation`): a csomag, az összeg, a dátum és a lemondás az elállási jogról; ez a rendelet szerinti visszaigazolás.
|
||||||
|
|
||||||
Az ÁSZF az `/aszf` oldalon van (`services/frontend/src/app/aszf/page.tsx`); a céges adatok a `lib/legal.ts`-ből jönnek. Megnyitás előtt jogásszal át kell nézetni.
|
Az ÁSZF az `/aszf` oldalon van (`services/frontend/src/app/aszf/page.tsx`); a céges adatok a `lib/legal.ts`-ből jönnek. Megnyitás előtt jogásszal át kell nézetni.
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ pub struct Config {
|
|||||||
/// Until the opening only admins can (and with a test key always only
|
/// Until the opening only admins can (and with a test key always only
|
||||||
/// admins), so nobody types a real card into a test or unfinished setup.
|
/// admins), so nobody types a real card into a test or unfinished setup.
|
||||||
pub purchases_open: bool,
|
pub purchases_open: bool,
|
||||||
|
/// `TERMS_CONSENT` (default `false`): Stripe's payment page asks every
|
||||||
|
/// buyer to accept the ÁSZF and give up the withdrawal right. Needs the
|
||||||
|
/// terms URL in Stripe's Public details; off until the opening.
|
||||||
|
pub terms_consent: bool,
|
||||||
/// `USER_INVITES` (default `false`): users may invite others ("how
|
/// `USER_INVITES` (default `false`): users may invite others ("how
|
||||||
/// compatible are we?" links, which also let the invitee sign up). Off
|
/// compatible are we?" links, which also let the invitee sign up). Off
|
||||||
/// until the launch; admins may always.
|
/// until the launch; admins may always.
|
||||||
@@ -187,6 +191,7 @@ impl Config {
|
|||||||
.trim_end_matches('/')
|
.trim_end_matches('/')
|
||||||
.to_string(),
|
.to_string(),
|
||||||
purchases_open: parsed("PURCHASES_OPEN", false)?,
|
purchases_open: parsed("PURCHASES_OPEN", false)?,
|
||||||
|
terms_consent: parsed("TERMS_CONSENT", false)?,
|
||||||
user_invites: parsed("USER_INVITES", false)?,
|
user_invites: parsed("USER_INVITES", false)?,
|
||||||
referral_rewards: parsed("REFERRAL_REWARDS", false)?,
|
referral_rewards: parsed("REFERRAL_REWARDS", false)?,
|
||||||
google_client_ids: list("GOOGLE_CLIENT_IDS"),
|
google_client_ids: list("GOOGLE_CLIENT_IDS"),
|
||||||
@@ -231,6 +236,7 @@ impl Config {
|
|||||||
billingo_api_key: Some("billingo-fake".into()),
|
billingo_api_key: Some("billingo-fake".into()),
|
||||||
billingo_api_url: format!("{horoscope_api_url}/billingo"),
|
billingo_api_url: format!("{horoscope_api_url}/billingo"),
|
||||||
purchases_open: true,
|
purchases_open: true,
|
||||||
|
terms_consent: true,
|
||||||
user_invites: true,
|
user_invites: true,
|
||||||
referral_rewards: true,
|
referral_rewards: true,
|
||||||
google_client_ids: vec!["test-client.apps.googleusercontent.com".into()],
|
google_client_ids: vec!["test-client.apps.googleusercontent.com".into()],
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ async fn public_config(State(state): St) -> Json<Value> {
|
|||||||
"payments_test": c.stripe.as_ref().is_some_and(|s| s.test_mode()),
|
"payments_test": c.stripe.as_ref().is_some_and(|s| s.test_mode()),
|
||||||
// "AAM" (alanyi adómentes: the prices carry no VAT) or a rate like "27%".
|
// "AAM" (alanyi adómentes: the prices carry no VAT) or a rate like "27%".
|
||||||
"vat": c.invoice_vat.code(),
|
"vat": c.invoice_vat.code(),
|
||||||
|
// Buyers accept the ÁSZF on Stripe's page (off until the opening).
|
||||||
|
"terms_consent": c.terms_consent,
|
||||||
"user_invites": c.user_invites,
|
"user_invites": c.user_invites,
|
||||||
"referral_rewards": c.referral_rewards,
|
"referral_rewards": c.referral_rewards,
|
||||||
"signup_mode": c.signup_mode.as_str(),
|
"signup_mode": c.signup_mode.as_str(),
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ pub async fn checkout(
|
|||||||
let package = packages::find(&req.package).ok_or(ApiError::NotFound("package"))?;
|
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 back = format!("{}{}", state.config.public_base_url, return_path(req.return_path.as_deref()));
|
||||||
let field = |k: &str, v: &str| (k.to_string(), v.to_string());
|
let field = |k: &str, v: &str| (k.to_string(), v.to_string());
|
||||||
let form = vec![
|
let mut form = vec![
|
||||||
field("mode", "payment"),
|
field("mode", "payment"),
|
||||||
field("locale", "hu"),
|
field("locale", "hu"),
|
||||||
field("client_reference_id", &auth.id().to_string()),
|
field("client_reference_id", &auth.id().to_string()),
|
||||||
@@ -152,21 +152,23 @@ pub async fn checkout(
|
|||||||
field("metadata[user_id]", &auth.id().to_string()),
|
field("metadata[user_id]", &auth.id().to_string()),
|
||||||
field("payment_intent_data[description]", &format!("Sorsfonalak – {}", package.name)),
|
field("payment_intent_data[description]", &format!("Sorsfonalak – {}", package.name)),
|
||||||
field("payment_intent_data[metadata][package]", package.id),
|
field("payment_intent_data[metadata][package]", package.id),
|
||||||
|
field("success_url", &format!("{back}?fizetes={{CHECKOUT_SESSION_ID}}")),
|
||||||
|
field("cancel_url", &format!("{back}?fizetes=megszakitva")),
|
||||||
|
];
|
||||||
|
if state.config.terms_consent {
|
||||||
// Every purchase accepts the terms and asks for immediate delivery,
|
// Every purchase accepts the terms and asks for immediate delivery,
|
||||||
// giving up the 14-day withdrawal right (45/2014. Korm. rendelet 29. §).
|
// giving up the 14-day withdrawal right (45/2014. Korm. rendelet 29. §).
|
||||||
// Stripe needs the terms URL in its dashboard (Public details) for this.
|
// Stripe needs the terms URL in its dashboard (Public details) for this.
|
||||||
field("consent_collection[terms_of_service]", "required"),
|
form.push(field("consent_collection[terms_of_service]", "required"));
|
||||||
field(
|
form.push(field(
|
||||||
"custom_text[terms_of_service_acceptance][message]",
|
"custom_text[terms_of_service_acceptance][message]",
|
||||||
&format!(
|
&format!(
|
||||||
"Elfogadom az [ÁSZF-et]({}/aszf), kérem a szolgáltatás azonnali megkezdését, és tudomásul veszem, \
|
"Elfogadom az [ÁSZF-et]({}/aszf), kérem a szolgáltatás azonnali megkezdését, és tudomásul veszem, \
|
||||||
hogy ezzel elveszítem a 14 napos elállási jogomat.",
|
hogy ezzel elveszítem a 14 napos elállási jogomat.",
|
||||||
state.config.public_base_url
|
state.config.public_base_url
|
||||||
),
|
),
|
||||||
),
|
));
|
||||||
field("success_url", &format!("{back}?fizetes={{CHECKOUT_SESSION_ID}}")),
|
}
|
||||||
field("cancel_url", &format!("{back}?fizetes=megszakitva")),
|
|
||||||
];
|
|
||||||
let session = state.stripe.create_session(config, &form).await?;
|
let session = state.stripe.create_session(config, &form).await?;
|
||||||
let url = session.url.ok_or_else(|| ApiError::Internal(format!("checkout session {} has no url", session.id)))?;
|
let url = session.url.ok_or_else(|| ApiError::Internal(format!("checkout session {} has no url", session.id)))?;
|
||||||
sqlx::query("INSERT INTO stripe_checkouts (id, user_id, package, price_huf, live) VALUES ($1, $2, $3, $4, $5)")
|
sqlx::query("INSERT INTO stripe_checkouts (id, user_id, package, price_huf, live) VALUES ($1, $2, $3, $4, $5)")
|
||||||
@@ -210,7 +212,7 @@ async fn complete(state: &AppState, session: &stripe::Session) -> Result<bool, A
|
|||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
if !session.terms_accepted() {
|
if state.config.terms_consent && !session.terms_accepted() {
|
||||||
tracing::warn!(session = %session.id, "paid without the terms consent");
|
tracing::warn!(session = %session.id, "paid without the terms consent");
|
||||||
}
|
}
|
||||||
sqlx::query(
|
sqlx::query(
|
||||||
@@ -227,7 +229,10 @@ async fn complete(state: &AppState, session: &stripe::Session) -> Result<bool, A
|
|||||||
.bind(TERMS_VERSION)
|
.bind(TERMS_VERSION)
|
||||||
.execute(&mut *tx)
|
.execute(&mut *tx)
|
||||||
.await?;
|
.await?;
|
||||||
confirm_by_email(&mut tx, state, session, user_id, package, amount_huf.unwrap_or(i64::from(price_huf))).await?;
|
// The confirmation confirms the withdrawal waiver: only when it was given.
|
||||||
|
if session.terms_accepted() {
|
||||||
|
confirm_by_email(&mut tx, state, session, user_id, package, amount_huf.unwrap_or(i64::from(price_huf))).await?;
|
||||||
|
}
|
||||||
let buyer = invoices::Buyer::from_stripe(session.customer_details.as_ref().unwrap_or(&Value::Null), None);
|
let buyer = invoices::Buyer::from_stripe(session.customer_details.as_ref().unwrap_or(&Value::Null), None);
|
||||||
let (item, comment) = package.invoice_item();
|
let (item, comment) = package.invoice_item();
|
||||||
let gross = amount_huf.unwrap_or(i64::from(price_huf));
|
let gross = amount_huf.unwrap_or(i64::from(price_huf));
|
||||||
|
|||||||
@@ -2312,6 +2312,7 @@ async fn stripe_checkout_grants_the_paid_package_once(pool: PgPool) {
|
|||||||
assert_eq!(r.body["payments"], "stripe");
|
assert_eq!(r.body["payments"], "stripe");
|
||||||
assert_eq!(r.body["payments_test"], false);
|
assert_eq!(r.body["payments_test"], false);
|
||||||
assert_eq!(r.body["vat"], "AAM");
|
assert_eq!(r.body["vat"], "AAM");
|
||||||
|
assert_eq!(r.body["terms_consent"], true);
|
||||||
// Stripe replaces the stand-in payment.
|
// Stripe replaces the stand-in payment.
|
||||||
assert_eq!(r.body["mock_payments"], false);
|
assert_eq!(r.body["mock_payments"], false);
|
||||||
let anna = app.register("anna@example.com", "Anna").await;
|
let anna = app.register("anna@example.com", "Anna").await;
|
||||||
@@ -2549,14 +2550,21 @@ async fn stripe_purchases_wait_for_the_opening(pool: PgPool) {
|
|||||||
let app = TestApp::with_config(pool, |c| {
|
let app = TestApp::with_config(pool, |c| {
|
||||||
with_stripe(c, "sk_live_fake");
|
with_stripe(c, "sk_live_fake");
|
||||||
c.purchases_open = false;
|
c.purchases_open = false;
|
||||||
|
c.terms_consent = false;
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
let r = app.get("/v1/config", None).await;
|
let r = app.get("/v1/config", None).await;
|
||||||
assert_eq!((&r.body["payments_test"], &r.body["payments_admins_only"]), (&json!(false), &json!(true)));
|
assert_eq!((&r.body["payments_test"], &r.body["payments_admins_only"]), (&json!(false), &json!(true)));
|
||||||
|
assert_eq!(r.body["terms_consent"], false);
|
||||||
let anna = app.register("anna@example.com", "Anna").await;
|
let anna = app.register("anna@example.com", "Anna").await;
|
||||||
let r = app.post("/v1/payments/checkout", Some(&anna), json!({"package": "single"})).await;
|
let r = app.post("/v1/payments/checkout", Some(&anna), json!({"package": "single"})).await;
|
||||||
assert_eq!(r.status, StatusCode::FORBIDDEN);
|
assert_eq!(r.status, StatusCode::FORBIDDEN);
|
||||||
let admin = app.register("admin@example.com", "Admin").await;
|
let admin = app.register("admin@example.com", "Admin").await;
|
||||||
let r = app.post("/v1/payments/checkout", Some(&admin), json!({"package": "single"})).await;
|
let r = app.post("/v1/payments/checkout", Some(&admin), json!({"package": "single"})).await;
|
||||||
assert_eq!(r.status, StatusCode::OK, "{}", r.body);
|
assert_eq!(r.status, StatusCode::OK, "{}", r.body);
|
||||||
|
// Until the opening Stripe's page does not ask for the ÁSZF (TERMS_CONSENT).
|
||||||
|
let id = r.body["url"].as_str().unwrap().rsplit('/').next().unwrap().to_string();
|
||||||
|
assert_eq!(stripe_form(&id, "billing_address_collection").as_deref(), Some("required"));
|
||||||
|
assert_eq!(stripe_form(&id, "consent_collection[terms_of_service]"), None);
|
||||||
|
assert_eq!(stripe_form(&id, "custom_text[terms_of_service_acceptance][message]"), None);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { useRouter } from "next/navigation";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
import { api, errorText } from "@/lib/api";
|
import { api, errorText } from "@/lib/api";
|
||||||
import type { Package, PayMethod } from "@/lib/types";
|
import type { Package, PayMethod, PublicConfig } from "@/lib/types";
|
||||||
|
|
||||||
export const huf = (n: number) => `${n.toLocaleString("hu-HU")} Ft`;
|
export const huf = (n: number) => `${n.toLocaleString("hu-HU")} Ft`;
|
||||||
|
|
||||||
@@ -54,6 +54,16 @@ export function PackageCards({
|
|||||||
window.addEventListener("pageshow", reset);
|
window.addEventListener("pageshow", reset);
|
||||||
return () => window.removeEventListener("pageshow", reset);
|
return () => window.removeEventListener("pageshow", reset);
|
||||||
}, []);
|
}, []);
|
||||||
|
// Whether Stripe's page asks for the ÁSZF and the withdrawal waiver
|
||||||
|
// (TERMS_CONSENT, off until the opening).
|
||||||
|
const stripe = canPay === "stripe" || canPay === "stripe_test";
|
||||||
|
const [termsConsent, setTermsConsent] = useState(false);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!stripe) return;
|
||||||
|
api<PublicConfig>("/config")
|
||||||
|
.then((c) => setTermsConsent(c.terms_consent === true))
|
||||||
|
.catch(() => {});
|
||||||
|
}, [stripe]);
|
||||||
const shown = ids
|
const shown = ids
|
||||||
? ids.map((id) => packages.find((p) => p.id === id)).filter((p): p is Package => p !== undefined)
|
? ids.map((id) => packages.find((p) => p.id === id)).filter((p): p is Package => p !== undefined)
|
||||||
: packages.filter((p) => p.tier === "main");
|
: packages.filter((p) => p.tier === "main");
|
||||||
@@ -149,12 +159,17 @@ export function PackageCards({
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{canPay === "mock" && <p className="hint">Tesztüzem: a fizetés még nincs bekötve, a gomb nem terhel semmit.</p>}
|
{canPay === "mock" && <p className="hint">Tesztüzem: a fizetés még nincs bekötve, a gomb nem terhel semmit.</p>}
|
||||||
{(canPay === "stripe" || canPay === "stripe_test") && (
|
{stripe && (
|
||||||
<p className="hint">
|
<p className="hint">
|
||||||
<span aria-hidden="true">🔒</span> A fizetés a Stripe biztonságos oldalán történik (bankkártya, Apple Pay,
|
<span aria-hidden="true">🔒</span> A fizetés a Stripe biztonságos oldalán történik (bankkártya, Apple Pay,
|
||||||
Google Pay). A kártyaadataidat közvetlenül a Stripe-nak adod meg: mi nem látjuk és nem tároljuk őket. A
|
Google Pay). A kártyaadataidat közvetlenül a Stripe-nak adod meg: mi nem látjuk és nem tároljuk őket.
|
||||||
csomagot azonnal megkapod, ezért a fizetésnél kéred a teljesítés megkezdését, és ezzel lemondasz a 14 napos
|
{termsConsent && (
|
||||||
elállási jogról. <Link href="/aszf">ÁSZF</Link>
|
<>
|
||||||
|
{" "}
|
||||||
|
A csomagot azonnal megkapod, ezért a fizetésnél kéred a teljesítés megkezdését, és ezzel lemondasz a 14
|
||||||
|
napos elállási jogról. <Link href="/aszf">ÁSZF</Link>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{canPay === "stripe_test" && (
|
{canPay === "stripe_test" && (
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ export interface PublicConfig {
|
|||||||
payments_test: boolean;
|
payments_test: boolean;
|
||||||
/** "AAM": alanyi adómentes, the prices carry no VAT; otherwise the rate, e.g. "27%". */
|
/** "AAM": alanyi adómentes, the prices carry no VAT; otherwise the rate, e.g. "27%". */
|
||||||
vat: string;
|
vat: string;
|
||||||
|
/** Stripe's page asks for the ÁSZF and the withdrawal waiver (off until the opening). */
|
||||||
|
terms_consent?: boolean;
|
||||||
/** "invite": new accounts need an invitation. */
|
/** "invite": new accounts need an invitation. */
|
||||||
signup_mode: "invite" | "open";
|
signup_mode: "invite" | "open";
|
||||||
/** Users may invite others (off until the launch; admins always may). */
|
/** Users may invite others (off until the launch; admins always may). */
|
||||||
|
|||||||
Reference in New Issue
Block a user