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
@@ -75,6 +75,8 @@ function GiftItem({ gift, onChange }: { gift: Gift; onChange: (g: Gift) => void
</div>
{gift.status === "redeemed" ? (
<span className="badge">Beváltva{gift.redeemed_at ? `: ${day(gift.redeemed_at)}` : ""}</span>
) : gift.status === "refunded" ? (
<span className="badge">Visszatérítve{gift.refunded_at ? `: ${day(gift.refunded_at)}` : ""}</span>
) : (
<span className="badge badge-gold">Még nincs beváltva</span>
)}
@@ -94,23 +96,29 @@ function GiftItem({ gift, onChange }: { gift: Gift; onChange: (g: Gift) => void
E-mailben elküldve ide: <strong>{gift.recipient_email}</strong>
{gift.sendings > 1 ? ` (${gift.sendings}×)` : ""}
</>
) : (
) : open ? (
"Te adod át: töltsd le az utalványt."
) : (
"Nem e-mailben ment."
)}
{gift.from_name && <span className="hint"> · Kitől: {gift.from_name}</span>}
</p>
{gift.message && <blockquote className="gift-message">{gift.message}</blockquote>}
<div className="form-actions">
<a className="btn btn-primary btn-sm" href={`/api/v1/gifts/${gift.id}/card.pdf`} download>
Utalvány letöltése (PDF)
</a>
{open && gift.can_send && !sending && (
<button type="button" className="btn btn-sm" onClick={() => setSending(true)}>
{gift.recipient_email ? "Újraküldés e-mailben" : "Küldés e-mailben"}
</button>
)}
</div>
{gift.status === "refunded" ? (
<p className="hint">Elálltál a vásárlástól: a kód már nem érvényes, az árát visszatérítettük.</p>
) : (
<div className="form-actions">
<a className="btn btn-primary btn-sm" href={`/api/v1/gifts/${gift.id}/card.pdf`} download>
Utalvány letöltése (PDF)
</a>
{open && gift.can_send && !sending && (
<button type="button" className="btn btn-sm" onClick={() => setSending(true)}>
{gift.recipient_email ? "Újraküldés e-mailben" : "Küldés e-mailben"}
</button>
)}
</div>
)}
{open && !gift.can_send && gift.sendings > 0 && (
<p className="hint">E-mailben már többször elküldtük. Ha nem érkezett meg, töltsd le az utalványt, és küldd el te.</p>
)}