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
+1 -1
View File
@@ -22,4 +22,4 @@ export const PRIVACY_UPDATED = "2026. november 22.";
export const PRIVACY_UPDATED_EN = "22 November 2026";
/** The terms (ÁSZF) in force; the backend records this version with every purchase (TERMS_VERSION). */
export const TERMS_UPDATED = "2026. november 22.";
export const TERMS_UPDATED = "2026. november 23.";
+27 -1
View File
@@ -633,6 +633,31 @@ export interface PromoCode {
redeemed_by: { email: string; name: string | null } | null;
}
/** A gift as admins see it (`GET /v1/admin/gifts`). */
export interface AdminGift {
id: string;
package: { id: string; name: string | null };
buyer_email: string | null;
recipient_name: string | null;
recipient_email: string | null;
paid_at: string;
code: string;
status: "open" | "redeemed" | "refunded";
redeemed_at: string | null;
redeemed_by: string | null;
refunded_at: string | null;
/** Withdrawn, but Stripe has not paid back yet (it refused: see refund_error; try again). */
refund_pending: boolean;
/** Stripe's refund id. */
refund_id: string | null;
refund_error: string | null;
/** Within the 14 days the buyer may withdraw. */
within_withdrawal: boolean;
checkout: { id: string; live: boolean | null; amount_huf: number | null } | null;
invoice: { number: string | null; status: string } | null;
storno: { status: string; number: string | null; error: string | null } | null;
}
/** A package the user bought as a gift (`GET /v1/gifts`). */
export interface Gift {
id: string;
@@ -646,8 +671,9 @@ export interface Gift {
paid_at: string;
/** ABCD-EFGH-JKLM */
code: string;
status: "open" | "redeemed";
status: "open" | "redeemed" | "refunded";
redeemed_at: string | null;
refunded_at: string | null;
/** E-mails sent so far. */
sendings: number;
/** Whether it can be sent by e-mail (again). */