Gift withdrawal: admin refund (Stripe) and invoice storno (Billingo)
CI / test (push) Successful in 3m25s
CI / build (push) Skipped
CI / deploy (push) Skipped

- The buyer may withdraw from a gift purchase within 14 days while the
  code is not redeemed (ÁSZF 3., 5., 6.; terms version 2026-11-23); the
  consent on Stripe's page and the confirmation e-mail say so
- Admin → Ajándékok: the gifts with payment, invoice and storno; the
  refund button locks the gift and refuses a redeemed one, withdraws the
  code, refunds the PaymentIntent on Stripe (one refund per gift via the
  Idempotency-Key, retry when Stripe refuses) and queues the storno
- Worker: cancels the issued invoice in Billingo (POST /documents/{id}/
  cancel, e-mailed to the buyer), keeps the storno invoice's id and
  number; a lost answer is not asked again but left for an admin
- A withdrawn code cannot be redeemed, sent or downloaded; "My gifts"
  shows it as refunded

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-23 21:22:46 +00:00
co-authored by Claude Opus 5.5
parent c90232f40c
commit 0d62888831
18 changed files with 1014 additions and 46 deletions
+16 -9
View File
@@ -86,7 +86,7 @@ pub fn method(config: &crate::config::Config) -> Option<&'static str> {
}
/// The terms (ÁSZF) version a purchase accepts; the frontend's `TERMS_UPDATED`.
pub const TERMS_VERSION: &str = "2026-11-22";
pub const TERMS_VERSION: &str = "2026-11-23";
/// Only admins can buy through Stripe: until purchases open, and always with a
/// test key (nobody gets packages with Stripe's test cards, nobody types a
@@ -181,15 +181,22 @@ pub(super) async fn start_checkout(
// Every purchase accepts the terms and asks for immediate delivery,
// giving up the 14-day withdrawal right (45/2014. Korm. rendelet 29. §).
// Stripe needs the terms URL in its dashboard (Public details) for this.
// A gift is performed when its code is redeemed: until then (within
// the 14 days) the buyer may withdraw.
let terms = format!("{}/aszf", state.config.public_base_url);
let message = if gift.is_some() {
format!(
"Elfogadom az [ÁSZF-et]({terms}), és kérem, hogy az ajándékkód beváltásakor a szolgáltatás azonnal \
megkezdődjön. Tudomásul veszem, hogy a beváltással a 14 napos elállási jog megszűnik."
)
} else {
format!(
"Elfogadom az [ÁSZF-et]({terms}), 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."
)
};
form.push(field("consent_collection[terms_of_service]", "required"));
form.push(field(
"custom_text[terms_of_service_acceptance][message]",
&format!(
"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.",
state.config.public_base_url
),
));
form.push(field("custom_text[terms_of_service_acceptance][message]", &message));
}
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)))?;