Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7745d5862d | ||
|
|
d45700a9ef | ||
|
|
1ca09cbaef | ||
|
|
33f5096bf1 | ||
|
|
51b6d79bbf | ||
|
|
df105aafca | ||
|
|
a28d18c3e6 | ||
|
|
1ce7947d93 | ||
|
|
c1ad9ad2ca |
No files matched your search
@@ -33,7 +33,7 @@ Stripe-Testbuchung mit Webhooks lokal:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
stripe listen --forward-to localhost:3000/api/stripe/webhook # gibt das whsec_… für STRIPE_WEBHOOK_SECRET aus
|
stripe listen --forward-to localhost:3000/api/stripe/webhook # gibt das whsec_… für STRIPE_WEBHOOK_SECRET aus
|
||||||
pnpm worker # Reservierungen, Raten, E-Mails (im Cluster: CronJob)
|
pnpm worker # Reservierungen, Raten-Abgleich, E-Mails (im Cluster: CronJob)
|
||||||
```
|
```
|
||||||
|
|
||||||
Testkarte `4242 4242 4242 4242`, für 3-D-Secure-Fälle `4000 0027 6000 3184`. E-Mails landen mit `MAIL_TRANSPORT=file` als `.eml` in `.mail-outbox/` (oder in Mailpit unter http://localhost:8025).
|
Testkarte `4242 4242 4242 4242`, für 3-D-Secure-Fälle `4000 0027 6000 3184`. E-Mails landen mit `MAIL_TRANSPORT=file` als `.eml` in `.mail-outbox/` (oder in Mailpit unter http://localhost:8025).
|
||||||
|
|||||||
+15
-10
@@ -44,22 +44,27 @@ Der gehostete Checkout bildet den Ablauf vollständig ab: Betrag, Ablaufzeit, da
|
|||||||
|
|
||||||
## ADR-3: Endliche Ratenpläne
|
## ADR-3: Endliche Ratenpläne
|
||||||
|
|
||||||
**Gewählt:** Die erste Rate läuft über Stripe Checkout mit `setup_future_usage=off_session`. Die Folgeraten sind einzelne Off-Session-PaymentIntents, die ein idempotenter Kubernetes-CronJob am Fälligkeitstag um 9:00 Uhr Berliner Zeit auslöst.
|
**Gewählt (seit 05.10.2026): Stripe Billing zieht die Folgeraten ein.** Die erste Rate läuft wie bisher über Stripe Checkout mit `setup_future_usage=off_session`. Sobald sie bezahlt ist, legt die Anwendung bei Stripe einen Subscription Schedule an (`src/lib/installment-billing.ts`). Danach kümmert sich Stripe um Einzug, Wiederholungen, 3-D-Secure-Links und Mahnungen; die Anwendung verbucht nur noch die Rechnungs-Events.
|
||||||
|
|
||||||
**Verworfen: Subscription Schedules.** Sie sind laut Stripe-Doku das Standardmuster für Ratenzahlung, rechnen aber in festen Intervallen (z. B. monatlich). Die geforderte Regel „letzte Rate spätestens 30 Tage vor Anreise“ und eine vom Buchungstag abhängige Mitte lassen sich damit nicht sauber abbilden. Außerdem wäre es formal ein Abonnement.
|
**Wie die Regel auf Stripe passt:** Die Folgeraten sind immer gleich hoch (ein Rest steckt in Rate 1). Der Zeitplan hat deshalb genau einen Preis: Start = Fälligkeit der zweiten Rate, Intervall = Abstand zwischen Rate 2 und 3 in Tagen (bei zwei Raten 1 Tag), Ende = Start + Anzahl Folgeraten × Intervall, `end_behavior=cancel`. Mit Stripe-Testuhr geprüft: genau eine Rechnung je Folgerate, danach endet das Abonnement ohne weitere Rechnung. Ein Wechsel von Preisen zwischen Phasen erzeugt dagegen keine Rechnung und wurde deshalb verworfen.
|
||||||
|
|
||||||
**Gründe für den gewählten Weg:**
|
**Vorher (bis 05.10.2026):** Off-Session-PaymentIntents, ausgelöst vom Worker-CronJob. Abgelöst, weil Wiederholungen, Bestätigungslinks und Mahnungen bei Stripe liegen sollen statt beim Betreiber. Invoice Payment Plans (Stripe) kamen nicht in Frage: Private Preview und kein automatischer Einzug.
|
||||||
- Die Raten sind exakte, unveränderliche Datenbankzeilen (per DB-Trigger geschützt). Beträge wie 800 + 700 + 700 € sind direkt abbildbar.
|
|
||||||
- Endlichkeit ist dreifach gesichert: Es gibt maximal drei Ratenzeilen, jeder Einzug prüft `paid + Rate ≤ Gesamt`, und nach der letzten Rate wird die Zahlungsmethode bei Stripe getrennt.
|
**Sicherungen:**
|
||||||
|
- Die Raten bleiben exakte, unveränderliche Datenbankzeilen (per DB-Trigger geschützt). Jede Stripe-Rechnung wird genau einer Rate zugeordnet (`Installment.stripeInvoiceId`); Stripe erzeugt die Rechnungen nacheinander, die neue gehört zur ersten noch offenen Rate.
|
||||||
|
- Endlichkeit: Der Zeitplan endet nach der letzten Rate von selbst. Eine Zahlung ohne passende offene Rate oder über den Gesamtpreis hinaus landet als „Prüfung nötig“ im Admin. Nach der letzten Rate wird die Zahlungsmethode getrennt.
|
||||||
|
- Storno beendet den Zeitplan sofort und storniert offene Rechnungen (`void`). Scheitert das bei Stripe, holt der Worker es nach; die Zahlungsmethode wird erst danach getrennt.
|
||||||
|
- Fehlschlag: Stripe wiederholt nach den Einstellungen unter „Revenue recovery“ (Smart Retries). Die Rate steht auf `FAILED` mit nächstem Versuch, die Kundin bekommt eine Mail mit Zahlungslink. Gibt Stripe auf, wird die Buchung „Prüfung nötig“.
|
||||||
|
- Verlangt die Bank eine Bestätigung, geht die Rate auf `REQUIRES_ACTION`. Die Kundin zahlt über Stripes Rechnungsseite (`hosted_invoice_url`), auch mit einer anderen Zahlungsmethode. Eine eigene Checkout-Session gibt es bewusst nicht, sonst würde Stripe parallel weiter einziehen.
|
||||||
|
- „Prüfung nötig“ hält den Plan an: Gerät eine Buchung in Prüfung (z. B. Rückbuchung, Doppelzahlung), wird der Stripe-Plan beendet, offene Rechnungen werden storniert und unbezahlte Folgeraten gehen zurück auf `PENDING`. Bestätigt ein Mensch die Buchung, legt der Worker einen neuen Plan für die offenen Raten an (Start an der Fälligkeit oder, falls vorbei, am nächsten 9-Uhr-Termin; letzte Rate bleibt am Stichtag). So zieht Stripe wie früher der Worker nur bei bestätigten Buchungen ein.
|
||||||
|
- Idempotenz: Vor dem Anlegen sucht die Anwendung bei Stripe nach einem laufenden Plan dieser Buchung (Metadaten `bookingId`) und übernimmt ihn, auch wenn das Speichern der ID früher scheiterte. Angelegt wird mit Schlüssel `schedule:<buchung>:<generation>:<start>`; die Generation steigt mit jedem Anhalten, sonst lieferte Stripe binnen 24 Stunden den alten, beendeten Plan zurück. Doppelte oder ungeordnete Events werden über die Rechnungs-ID und den PaymentIntent nur einmal verbucht.
|
||||||
|
- Verlorene Webhooks: Der Worker legt fehlende Zeitpläne an und fragt bei Raten, die seit 6 Stunden fällig und nicht verbucht sind, die Rechnungen des Zeitplans ab.
|
||||||
- Zustimmung: Vor der Zahlung wird ausdrücklich dem Einzug zugestimmt, mit Zeitstempel `installmentMandateAt`.
|
- Zustimmung: Vor der Zahlung wird ausdrücklich dem Einzug zugestimmt, mit Zeitstempel `installmentMandateAt`.
|
||||||
- Verlangt die Bank eine Authentifizierung, geht die Rate auf `REQUIRES_ACTION`, und die Kundin bekommt per E-Mail einen Link und zahlt über eine eigene Checkout-Session.
|
- Keine Gleichsetzung mit Klarna: Es ist die eigene Ratenvereinbarung des Veranstalters, das Ausfallrisiko bleibt beim Veranstalter. Im Livemodus ist sie erst nach ausdrücklicher Freigabe verfügbar.
|
||||||
- Bei Fehlschlag gibt es bis zu drei Versuche im Abstand von drei Tagen, danach „Prüfung nötig“ im Admin.
|
|
||||||
- Idempotenzschlüssel `offsession:<rate>:<versuch>` verhindern Doppelabbuchungen, auch nach Netzwerkfehlern oder Worker-Abbrüchen.
|
|
||||||
- Keine Gleichsetzung mit Klarna: Es ist die eigene Ratenvereinbarung des Veranstalters. Im Livemodus ist sie erst nach ausdrücklicher Freigabe verfügbar.
|
|
||||||
|
|
||||||
**Aufteilung:** Ist der Betrag ohne Centrest teilbar, sind alle Raten gleich. Sonst werden die Folgeraten auf volle 50 € abgerundet, der Rest fällt in Rate 1. Das reproduziert alle zwölf Vorgabewerte (Tests).
|
**Aufteilung:** Ist der Betrag ohne Centrest teilbar, sind alle Raten gleich. Sonst werden die Folgeraten auf volle 50 € abgerundet, der Rest fällt in Rate 1. Das reproduziert alle zwölf Vorgabewerte (Tests).
|
||||||
|
|
||||||
**Termine:** Die letzte Rate ist am Stichtag fällig (Anreise minus 30 Tage). Bei drei Raten liegt die zweite in der Mitte zwischen Buchungstag und Stichtag. Der Mindestabstand beträgt 14 Tage, sonst ist die Variante serverseitig deaktiviert. Diese Terminregel ist ein Vorschlag und braucht vor dem Live-Verkauf eine Freigabe.
|
**Termine:** Die letzte Rate ist am Stichtag fällig (Anreise minus 30 Tage). Bei drei Raten liegt die zweite in der Mitte zwischen Buchungstag und Stichtag. Der Mindestabstand beträgt 14 Tage, sonst ist die Variante serverseitig deaktiviert. Stripe zieht ab dem Fälligkeitstag um 9:00 Uhr Berliner Zeit ein; liegt zwischen zwei Raten eine Zeitumstellung, verschiebt sich die Uhrzeit der dritten Rate um eine Stunde (Intervall in ganzen Tagen), der Tag bleibt gleich. Diese Terminregel ist ein Vorschlag und braucht vor dem Live-Verkauf eine Freigabe.
|
||||||
|
|
||||||
## ADR-4: Kapazität und Gutscheine ohne Überbuchung
|
## ADR-4: Kapazität und Gutscheine ohne Überbuchung
|
||||||
|
|
||||||
|
|||||||
+10
-4
@@ -26,7 +26,7 @@ Der Build braucht Internet für `next/font` (Schriften werden eingebettet), aber
|
|||||||
## 2. Einmalig einrichten
|
## 2. Einmalig einrichten
|
||||||
|
|
||||||
**Was ausgerollt wird:** StatefulSet PostgreSQL, Services (App, Postgres), Ingress, App-Deployment (mit Migration als initContainer), zwei SMB-Volumes (Postgres-Daten, Medien) und zusätzlich:
|
**Was ausgerollt wird:** StatefulSet PostgreSQL, Services (App, Postgres), Ingress, App-Deployment (mit Migration als initContainer), zwei SMB-Volumes (Postgres-Daten, Medien) und zusätzlich:
|
||||||
- der Worker-CronJob, nötig für Folgeraten, Reservierungsfreigabe und Mail-Wiederholung
|
- der Worker-CronJob, nötig für Reservierungsfreigabe, Abgleich der Folgeraten und Mail-Wiederholung
|
||||||
- ConfigMap
|
- ConfigMap
|
||||||
- zwei NetworkPolicies (Schutz der Rate Limits und der Datenbank)
|
- zwei NetworkPolicies (Schutz der Rate Limits und der Datenbank)
|
||||||
|
|
||||||
@@ -55,9 +55,13 @@ Migrationen sind vorwärtskompatibel zu schreiben (erst Spalten ergänzen, spät
|
|||||||
|
|
||||||
- **Schlüssel:** Im Test `sk_test_…`, live `sk_live_…` (nur mit `APP_ENV=production`). Empfohlen ist ein eingeschränkter Schlüssel mit Schreibrechten auf Customers, Checkout Sessions, PaymentIntents, PaymentMethods und Refunds.
|
- **Schlüssel:** Im Test `sk_test_…`, live `sk_live_…` (nur mit `APP_ENV=production`). Empfohlen ist ein eingeschränkter Schlüssel mit Schreibrechten auf Customers, Checkout Sessions, PaymentIntents, PaymentMethods und Refunds.
|
||||||
- **Webhook-Endpunkt:** `https://<domain>/api/stripe/webhook`. Diese Events abonnieren:
|
- **Webhook-Endpunkt:** `https://<domain>/api/stripe/webhook`. Diese Events abonnieren:
|
||||||
`checkout.session.completed`, `checkout.session.async_payment_succeeded`, `checkout.session.async_payment_failed`, `checkout.session.expired`, `payment_intent.succeeded`, `payment_intent.payment_failed`, `charge.refunded`, `refund.created`, `refund.updated`, `charge.dispute.created`.
|
`checkout.session.completed`, `checkout.session.async_payment_succeeded`, `checkout.session.async_payment_failed`, `checkout.session.expired`, `invoice.paid`, `invoice.payment_failed`, `invoice.payment_action_required`, `charge.refunded`, `refund.created`, `refund.updated`, `charge.dispute.created`.
|
||||||
Das Signing Secret gehört als `STRIPE_WEBHOOK_SECRET` ins Secret. Test- und Live-Endpunkt haben getrennte Secrets.
|
Das Signing Secret gehört als `STRIPE_WEBHOOK_SECRET` ins Secret. Test- und Live-Endpunkt haben getrennte Secrets.
|
||||||
- **Zahlungsarten** (Dashboard → Zahlungsmethoden): Für Ratenzahlung nur wiederverwendbare Methoden aktivieren (Karten, gegebenenfalls SEPA-Lastschrift). Checkout blendet bei Ratenzahlung ohnehin nur Methoden ein, die `setup_future_usage` unterstützen.
|
- **Zahlungsarten** (Dashboard → Zahlungsmethoden): Für Ratenzahlung nur wiederverwendbare Methoden aktivieren (Karten, gegebenenfalls SEPA-Lastschrift). Checkout blendet bei Ratenzahlung ohnehin nur Methoden ein, die `setup_future_usage` unterstützen.
|
||||||
|
- **Folgeraten (Stripe Billing):** Stripe zieht die Raten 2 und 3 über einen Subscription Schedule ein (docs/ARCHITEKTUR.md, ADR-3). Im Dashboard unter Billing → Einstellungen festlegen:
|
||||||
|
- **Revenue recovery → Retries:** Smart Retries an (z. B. 4 Versuche innerhalb von 2 Wochen). Nach dem letzten Versuch: Abonnement kündigen. Die Buchung erscheint dann als „Prüfung nötig“.
|
||||||
|
- **E-Mails an Kunden:** „Zahlung fehlgeschlagen“ und „Bestätigung für 3-D Secure erforderlich“ einschalten, damit Stripe selbst mahnt und Bestätigungslinks schickt. Die App schickt zusätzlich eine eigene deutschsprachige Mail mit Link zur Statusseite.
|
||||||
|
- Der eingeschränkte Schlüssel braucht zusätzlich Schreibrechte für Products, Subscription Schedules, Subscriptions und Invoices.
|
||||||
- **Test lokal:** `stripe listen --forward-to localhost:3000/api/stripe/webhook`
|
- **Test lokal:** `stripe listen --forward-to localhost:3000/api/stripe/webhook`
|
||||||
- **Sicherheitsnetz:** Der Worker gleicht bei abgelaufenen Reservierungen und hängenden Einzügen immer mit Stripe ab. Ein verlorener Webhook führt so nicht zu verlorenen Zahlungen.
|
- **Sicherheitsnetz:** Der Worker gleicht bei abgelaufenen Reservierungen und hängenden Einzügen immer mit Stripe ab. Ein verlorener Webhook führt so nicht zu verlorenen Zahlungen.
|
||||||
|
|
||||||
@@ -69,8 +73,10 @@ Migrationen sind vorwärtskompatibel zu schreiben (erst Spalten ergänzen, spät
|
|||||||
|
|
||||||
Der CronJob `artista-modelcamp-worker` läuft alle 10 Minuten und kümmert sich um:
|
Der CronJob `artista-modelcamp-worker` läuft alle 10 Minuten und kümmert sich um:
|
||||||
- abgelaufene Reservierungen, vorher mit Rückfrage bei Stripe
|
- abgelaufene Reservierungen, vorher mit Rückfrage bei Stripe
|
||||||
- hängende Einzüge
|
- hängende erste Zahlungen (SEPA)
|
||||||
- fällige Raten
|
- fehlende Stripe-Ratenpläne anlegen (z. B. nach Bestätigung einer geprüften Buchung)
|
||||||
|
- Abgleich überfälliger Raten mit den Stripe-Rechnungen (verlorene Webhooks)
|
||||||
|
- Ratenpläne stornierter Buchungen beenden, falls das beim Storno scheiterte
|
||||||
- das Trennen der Zahlungsmethode nach der letzten Rate
|
- das Trennen der Zahlungsmethode nach der letzten Rate
|
||||||
- den E-Mail-Versand
|
- den E-Mail-Versand
|
||||||
- das Aufräumen der Rate Limits
|
- das Aufräumen der Rate Limits
|
||||||
|
|||||||
+24
-2
@@ -13,7 +13,7 @@ Dateinamen bitte so schreiben: ohne Leerzeichen und Umlaute. Gross- und Kleinsch
|
|||||||
| `logo.svg` (oder `.png`, `.webp`) | Dunkles Logo für helle Flächen: Kopfzeile nach dem Scrollen, Fußbereich | SVG bevorzugt, PNG mit transparentem Hintergrund |
|
| `logo.svg` (oder `.png`, `.webp`) | Dunkles Logo für helle Flächen: Kopfzeile nach dem Scrollen, Fußbereich | SVG bevorzugt, PNG mit transparentem Hintergrund |
|
||||||
| `logo-hell.svg` (oder `.png`, `.webp`) | Helles bzw. weißes Logo über dem Headerbild | Fehlt es, wird `logo.*` verwendet |
|
| `logo-hell.svg` (oder `.png`, `.webp`) | Helles bzw. weißes Logo über dem Headerbild | Fehlt es, wird `logo.*` verwendet |
|
||||||
|
|
||||||
Das Logo wird 32 bis 40 px hoch angezeigt. Ein querformatiges Logo ohne Rand wirkt am besten.
|
Das Logo wird über dem Headerbild bis 176 px hoch angezeigt, nach dem Scrollen 80 px. Die Seite misst selbst, ob eine Datei hell oder dunkel ist, und setzt sie auf den passenden Untergrund. Liegt nur eine helle Fassung vor, wird sie auf hellen Flächen automatisch abgedunkelt (und umgekehrt). Große PNGs werden verkleinert ausgeliefert.
|
||||||
|
|
||||||
## Headerbild
|
## Headerbild
|
||||||
|
|
||||||
@@ -22,6 +22,14 @@ Das Logo wird 32 bis 40 px hoch angezeigt. Ein querformatiges Logo ohne Rand wir
|
|||||||
| `header.jpg` (oder `.webp`, `.png`) | Bild über die ganze Breite oben | Querformat, mindestens 2400 px breit. Ohne Datei erscheint die Luftaufnahme der Villa |
|
| `header.jpg` (oder `.webp`, `.png`) | Bild über die ganze Breite oben | Querformat, mindestens 2400 px breit. Ohne Datei erscheint die Luftaufnahme der Villa |
|
||||||
| `header.mp4` (optional) | Video statt Standbild, läuft stumm in Schleife | Kurz halten (unter 15 s, unter 10 MB). `header.jpg` dient als Vorschaubild |
|
| `header.mp4` (optional) | Video statt Standbild, läuft stumm in Schleife | Kurz halten (unter 15 s, unter 10 MB). `header.jpg` dient als Vorschaubild |
|
||||||
|
|
||||||
|
## Video unter dem Headerbild
|
||||||
|
|
||||||
|
| Datei | Wofür | Hinweis |
|
||||||
|
|---|---|---|
|
||||||
|
| `intro.mp4` | Video direkt unter dem Headerbild, startet erst nach Klick | Quer- oder Hochformat. Ohne Datei entfällt der Abschnitt |
|
||||||
|
| `intro.jpg` (oder `.webp`, `.png`) | Vorschaubild des Videos | Empfohlen: Mit Vorschaubild lädt vom Video vorab nichts |
|
||||||
|
| `intro.web.mp4` (optional) | Web-Fassung, wird bevorzugt angezeigt | Erzeugen mit `pnpm media:optimize`, siehe unten |
|
||||||
|
|
||||||
## Team (Ordner `team/`)
|
## Team (Ordner `team/`)
|
||||||
|
|
||||||
Hochformat 3:4 oder 4:5, mindestens 1200 px breit, Gesicht im oberen Drittel. Das Bild wird oben rund (als Bogen) beschnitten.
|
Hochformat 3:4 oder 4:5, mindestens 1200 px breit, Gesicht im oberen Drittel. Das Bild wird oben rund (als Bogen) beschnitten.
|
||||||
@@ -33,7 +41,6 @@ Hochformat 3:4 oder 4:5, mindestens 1200 px breit, Gesicht im oberen Drittel. Da
|
|||||||
| Lola Stoll | `team/lola-stoll.jpg` |
|
| Lola Stoll | `team/lola-stoll.jpg` |
|
||||||
| Eileen Kaupp | `team/eileen-kaupp.jpg` |
|
| Eileen Kaupp | `team/eileen-kaupp.jpg` |
|
||||||
| Gabriela Pronkin | `team/gabriela-pronkin.jpg` |
|
| Gabriela Pronkin | `team/gabriela-pronkin.jpg` |
|
||||||
| Stefan Höchtl | `team/stefan-hoechtl.jpg` |
|
|
||||||
| Saskia Sirowatka | `team/saskia-sirowatka.jpg` |
|
| Saskia Sirowatka | `team/saskia-sirowatka.jpg` |
|
||||||
| André Hartshauser | `team/andre-hartshauser.jpg` |
|
| André Hartshauser | `team/andre-hartshauser.jpg` |
|
||||||
| Ante Rejo | `team/ante-rejo.jpg` |
|
| Ante Rejo | `team/ante-rejo.jpg` |
|
||||||
@@ -50,6 +57,21 @@ Hochformat 9:16. Das Video startet erst nach Klick und nie von selbst mit Ton.
|
|||||||
|
|
||||||
Ein Reel erscheint öffentlich erst, wenn das Video vorhanden ist. Namen und Begleittext stehen in `src/content/site.ts` unter `reels.slots`. Sie dürfen nur mit Freigabe der gezeigten Person eingetragen werden.
|
Ein Reel erscheint öffentlich erst, wenn das Video vorhanden ist. Namen und Begleittext stehen in `src/content/site.ts` unter `reels.slots`. Sie dürfen nur mit Freigabe der gezeigten Person eingetragen werden.
|
||||||
|
|
||||||
|
## Vor dem Hochladen: Videos und große Bilder aufbereiten
|
||||||
|
|
||||||
|
Videos direkt aus Kamera oder Schnittprogramm sind oft riesig (ein Reel hatte 1,6 GB in 4K) und haben den Index am Dateiende. Der Browser muss dann sehr viel laden, bevor überhaupt etwas läuft. Deshalb einmal aufbereiten:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm media:optimize C:\Pfad\zu\meinen-medien
|
||||||
|
```
|
||||||
|
|
||||||
|
Das Skript legt daneben einen Ordner `meinen-medien-web` mit gleicher Struktur an:
|
||||||
|
|
||||||
|
- aus jedem Video eine `<name>.web.mp4` (höchstens 1920 px, H.264, sofort abspielbar; `header` ohne Ton) und, falls kein Vorschaubild vorhanden ist, eine `<name>.jpg`
|
||||||
|
- große Bilder verkleinert (Logo 1600 px, sonst 2560 px längste Seite), kleinere unverändert
|
||||||
|
|
||||||
|
Den Inhalt dieses Ordners ins Medienverzeichnis kopieren. Liegt `<name>.web.mp4` neben dem Original, zeigt die Seite automatisch die Web-Fassung; das Original kann dann auch entfernt werden. Bereits aufbereitete Dateien überspringt das Skript beim nächsten Lauf.
|
||||||
|
|
||||||
## Ablage im Cluster
|
## Ablage im Cluster
|
||||||
|
|
||||||
Die Dateien kommen auf die SMB-Freigabe hinter dem Volume (siehe `k8s/03-storage.yaml`), zum Beispiel:
|
Die Dateien kommen auf die SMB-Freigabe hinter dem Volume (siehe `k8s/03-storage.yaml`), zum Beispiel:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Solange die mit **(Freigabe)** markierten Punkte fehlen, bleibt der Live-Verkauf
|
|||||||
| Punkt | Wo eintragen |
|
| Punkt | Wo eintragen |
|
||||||
|---|---|
|
|---|---|
|
||||||
| Logo (`logo.svg`, `logo-hell.svg`) und Headerbild (`header.jpg`) | Medienverzeichnis, Dateinamen in `docs/MEDIEN.md` |
|
| Logo (`logo.svg`, `logo-hell.svg`) und Headerbild (`header.jpg`) | Medienverzeichnis, Dateinamen in `docs/MEDIEN.md` |
|
||||||
| Porträts der neun Teammitglieder | Medienverzeichnis `team/<name>.jpg`, siehe `docs/MEDIEN.md` |
|
| Porträts der acht Teammitglieder | Medienverzeichnis `team/<name>.jpg`, siehe `docs/MEDIEN.md` |
|
||||||
| Freigegebene Kurzbeschreibungen der Teammitglieder | `site.ts` → `team` |
|
| Freigegebene Kurzbeschreibungen der Teammitglieder | `site.ts` → `team` |
|
||||||
| Schriftliche Bestätigung des Vermieters, dass die Booking-Bilder genutzt werden dürfen (Urheber ist der Vermieter bzw. Fotograf) | Ablage beim Veranstalter |
|
| Schriftliche Bestätigung des Vermieters, dass die Booking-Bilder genutzt werden dürfen (Urheber ist der Vermieter bzw. Fotograf) | Ablage beim Veranstalter |
|
||||||
| Link zur ARTISTA-Stammmodel-Seite und daraus abgeleiteter Text „Über ARTISTA“ | `site.ts` → `about` |
|
| Link zur ARTISTA-Stammmodel-Seite und daraus abgeleiteter Text „Über ARTISTA“ | `site.ts` → `about` |
|
||||||
|
|||||||
+3
-1
@@ -49,9 +49,11 @@ Hinweis: Läuft der Testserver nicht unter der Adresse aus `APP_URL`, lehnt der
|
|||||||
- Der Standalone-Build läuft mit Datenbank. Worker-Lauf und `admin:create` funktionieren, eine doppelte Anlage wird abgewiesen.
|
- Der Standalone-Build läuft mit Datenbank. Worker-Lauf und `admin:create` funktionieren, eine doppelte Anlage wird abgewiesen.
|
||||||
- Build, Typprüfung und ESLint laufen ohne Fehler, Kustomize rendert 17 Ressourcen.
|
- Build, Typprüfung und ESLint laufen ohne Fehler, Kustomize rendert 17 Ressourcen.
|
||||||
|
|
||||||
|
Lauf 06.10.2026 nach Umstellung der Folgeraten auf Stripe Billing (inkl. Anhalten bei Prüfung und Schutz vor doppeltem Plan): 88/88 Unit- und Integrationstests, Typprüfung und ESLint ohne Fehler. Zusätzlich `StripeGateway` gegen die echte Stripe-Test-API mit Testuhr geprüft: Zeitplan mit zwei Folgeraten erzeugt genau zwei bezahlte Rechnungen (je 700 €, Metadaten `bookingId`/`kind`, PaymentIntent mit Charge) und endet danach (`completed`); abgelehnte Karte ergibt offene Rechnung mit geplantem Wiederholungsversuch und Zahlungslink; Storno setzt den Zeitplan auf `canceled` und die offene Rechnung auf `void`, auch wiederholt und vor dem Start.
|
||||||
|
|
||||||
## Nicht ausgeführt / Einschränkungen
|
## Nicht ausgeführt / Einschränkungen
|
||||||
|
|
||||||
- **Echte Stripe-Testbuchung** gegen die Stripe-API: Ein Stripe-Testschlüssel lag nicht vor. Die Stripe-Logik ist gegen eine Attrappe mit Stripe-Semantik getestet (Idempotenz, Session-Zustände, Off-Session-Ergebnisse), die Webhook-Signatur mit der echten Stripe-Bibliothek. Mit Schlüssel: Anleitung in der README (`stripe listen`, Testkarten).
|
- **Echte Stripe-Testbuchung** gegen die Stripe-API: Ein Stripe-Testschlüssel lag nicht vor. Die Stripe-Logik ist gegen eine Attrappe mit Stripe-Semantik getestet (Idempotenz, Session-Zustände, Rechnungen des Ratenplans), die Webhook-Signatur mit der echten Stripe-Bibliothek. Mit Schlüssel: Anleitung in der README (`stripe listen`, Testkarten).
|
||||||
- **Docker-Image und Cluster:** Auf dem Entwicklungsrechner gibt es kein Docker und keinen Cluster-Zugang. Das Dockerfile ist nicht gebaut und nicht im Cluster ausgerollt. Geprüft sind der Standalone-Build und das Rendern der Manifeste.
|
- **Docker-Image und Cluster:** Auf dem Entwicklungsrechner gibt es kein Docker und keinen Cluster-Zugang. Das Dockerfile ist nicht gebaut und nicht im Cluster ausgerollt. Geprüft sind der Standalone-Build und das Rendern der Manifeste.
|
||||||
- **SMTP-Versand:** nur über den Datei-Testausgang geprüft.
|
- **SMTP-Versand:** nur über den Datei-Testausgang geprüft.
|
||||||
- **Referenzseite:** nur über eine Textzusammenfassung ausgewertet (siehe ARCHITEKTUR.md).
|
- **Referenzseite:** nur über eine Textzusammenfassung ausgewertet (siehe ARCHITEKTUR.md).
|
||||||
@@ -7,6 +7,9 @@ const nextConfig: NextConfig = {
|
|||||||
images: {
|
images: {
|
||||||
formats: ["image/avif", "image/webp"],
|
formats: ["image/avif", "image/webp"],
|
||||||
qualities: [75, 85],
|
qualities: [75, 85],
|
||||||
|
// Optimierte Bilder 30 Tage im Browser cachen: Medien-URLs tragen ?v=<Aenderungsdatum>,
|
||||||
|
// ein ersetztes Bild hat also ohnehin eine neue Adresse.
|
||||||
|
minimumCacheTTL: 2_592_000,
|
||||||
// Feste Bilder (Unterkunft, Team) liegen in public/images/, austauschbare
|
// Feste Bilder (Unterkunft, Team) liegen in public/images/, austauschbare
|
||||||
// im persistenten Medienverzeichnis unter /media/… (src/app/media/[...path]/route.ts).
|
// im persistenten Medienverzeichnis unter /media/… (src/app/media/[...path]/route.ts).
|
||||||
localPatterns: [{ pathname: "/media/**" }, { pathname: "/images/**" }],
|
localPatterns: [{ pathname: "/media/**" }, { pathname: "/images/**" }],
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"db:seed": "tsx scripts/seed-dev.ts",
|
"db:seed": "tsx scripts/seed-dev.ts",
|
||||||
"admin:create": "tsx scripts/create-admin.ts",
|
"admin:create": "tsx scripts/create-admin.ts",
|
||||||
"worker": "tsx scripts/worker.ts",
|
"worker": "tsx scripts/worker.ts",
|
||||||
|
"media:optimize": "tsx scripts/optimize-media.ts",
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"test:watch": "vitest",
|
"test:watch": "vitest",
|
||||||
"test:e2e": "playwright test"
|
"test:e2e": "playwright test"
|
||||||
@@ -33,6 +34,7 @@
|
|||||||
"react": "19.3.0",
|
"react": "19.3.0",
|
||||||
"react-dom": "19.3.0",
|
"react-dom": "19.3.0",
|
||||||
"server-only": "0.0.1",
|
"server-only": "0.0.1",
|
||||||
|
"sharp": "0.35.4",
|
||||||
"stripe": "22.6.2",
|
"stripe": "22.6.2",
|
||||||
"zod": "4.6.5"
|
"zod": "4.6.5"
|
||||||
},
|
},
|
||||||
@@ -50,6 +52,7 @@
|
|||||||
"embedded-postgres": "18.4.0-beta.17",
|
"embedded-postgres": "18.4.0-beta.17",
|
||||||
"eslint": "^9.39.5",
|
"eslint": "^9.39.5",
|
||||||
"eslint-config-next": "16.3.6",
|
"eslint-config-next": "16.3.6",
|
||||||
|
"ffmpeg-static": "5.3.0",
|
||||||
"prisma": "7.10.0",
|
"prisma": "7.10.0",
|
||||||
"tailwindcss": "4.3.3",
|
"tailwindcss": "4.3.3",
|
||||||
"tsx": "4.23.15",
|
"tsx": "4.23.15",
|
||||||
|
|||||||
Generated
+139
-3
@@ -199,6 +199,9 @@ importers:
|
|||||||
server-only:
|
server-only:
|
||||||
specifier: 0.0.1
|
specifier: 0.0.1
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
sharp:
|
||||||
|
specifier: 0.35.4
|
||||||
|
version: 0.35.4(@types/[email protected])
|
||||||
stripe:
|
stripe:
|
||||||
specifier: 22.6.2
|
specifier: 22.6.2
|
||||||
version: 22.6.2(@types/[email protected])
|
version: 22.6.2(@types/[email protected])
|
||||||
@@ -245,6 +248,9 @@ importers:
|
|||||||
eslint-config-next:
|
eslint-config-next:
|
||||||
specifier: 16.3.6
|
specifier: 16.3.6
|
||||||
version: 16.3.6(@typescript-eslint/[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected]([email protected])([email protected]))([email protected])([email protected])
|
version: 16.3.6(@typescript-eslint/[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected]([email protected])([email protected]))([email protected])([email protected])
|
||||||
|
ffmpeg-static:
|
||||||
|
specifier: 5.3.0
|
||||||
|
version: 5.3.0([email protected])
|
||||||
prisma:
|
prisma:
|
||||||
specifier: 7.10.0
|
specifier: 7.10.0
|
||||||
version: 7.10.0(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])([email protected])
|
version: 7.10.0(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])([email protected])
|
||||||
@@ -418,6 +424,10 @@ packages:
|
|||||||
'@better-fetch/[email protected]':
|
'@better-fetch/[email protected]':
|
||||||
resolution: {integrity: sha512-Gs7n99b5tqUC6cQAPbV0uED3IraHB6xQbHLQ/C3l7ZFafHScOx9pQ+DYmP5blbLFShVWLqxNUlI9wi4xU/X+ow==}
|
resolution: {integrity: sha512-Gs7n99b5tqUC6cQAPbV0uED3IraHB6xQbHLQ/C3l7ZFafHScOx9pQ+DYmP5blbLFShVWLqxNUlI9wi4xU/X+ow==}
|
||||||
|
|
||||||
|
'@derhuerst/[email protected]':
|
||||||
|
resolution: {integrity: sha512-F9rL9k9Xjf5blCz8HsJRO4diy111cayL2vkY2XE4r4t3n0yPXVYy3KD3nJ1qbrSn9743UWSXH4IwuCa/HWlGFw==}
|
||||||
|
engines: {node: '>=6.0.0'}
|
||||||
|
|
||||||
'@electric-sql/[email protected]':
|
'@electric-sql/[email protected]':
|
||||||
resolution: {integrity: sha512-LAciWM0M1dCL8hlsxu2venbVZcdxema0BtDfpWYVqr+Y468UADw0pFWidhKw1M8sfJ8rdLT71tjMmnirf/IZRQ==}
|
resolution: {integrity: sha512-LAciWM0M1dCL8hlsxu2venbVZcdxema0BtDfpWYVqr+Y468UADw0pFWidhKw1M8sfJ8rdLT71tjMmnirf/IZRQ==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
@@ -1385,6 +1395,9 @@ packages:
|
|||||||
'@types/[email protected]':
|
'@types/[email protected]':
|
||||||
resolution: {integrity: sha512-+K1NIO8I+F9/wNulfVvu23QYd0Pe9/OCqRrim4NoYIf1VoEDL90Ve4ClzpyqBLc7NpGGWRvYNCKZ1BE/Jpf8dQ==}
|
resolution: {integrity: sha512-+K1NIO8I+F9/wNulfVvu23QYd0Pe9/OCqRrim4NoYIf1VoEDL90Ve4ClzpyqBLc7NpGGWRvYNCKZ1BE/Jpf8dQ==}
|
||||||
|
|
||||||
|
'@types/[email protected]':
|
||||||
|
resolution: {integrity: sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==}
|
||||||
|
|
||||||
'@types/[email protected]':
|
'@types/[email protected]':
|
||||||
resolution: {integrity: sha512-zJRE40jpHtKqE/C4fgHrAKQLJuSpzEnP9ff9Y7YtoR3Wd2pwqzlekDeEuUQXjRd+QCYnVnNwuJYmhdk9XV8gvA==}
|
resolution: {integrity: sha512-zJRE40jpHtKqE/C4fgHrAKQLJuSpzEnP9ff9Y7YtoR3Wd2pwqzlekDeEuUQXjRd+QCYnVnNwuJYmhdk9XV8gvA==}
|
||||||
|
|
||||||
@@ -1664,6 +1677,10 @@ packages:
|
|||||||
engines: {node: '>=0.4.0'}
|
engines: {node: '>=0.4.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==}
|
||||||
|
engines: {node: '>= 6.0.0'}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==}
|
resolution: {integrity: sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==}
|
||||||
|
|
||||||
@@ -1846,6 +1863,9 @@ packages:
|
|||||||
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
|
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-cM0ApFQSBXuourJejzwv/AuPRvAxordTyParRVcHjjtXirtkzM0uK2L9TTn9s0cXZbG7E55jCivRQzoxYmRAlA==}
|
resolution: {integrity: sha512-cM0ApFQSBXuourJejzwv/AuPRvAxordTyParRVcHjjtXirtkzM0uK2L9TTn9s0cXZbG7E55jCivRQzoxYmRAlA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -1877,6 +1897,9 @@ packages:
|
|||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-qN+QNNBr93TCmFrmte0bBCjSDMuRvt78VlHT99qIGPszm4QsqCX8lnyWUFkHi8B7ZBAPq8SH+UqyXNy/odMdng==}
|
resolution: {integrity: sha512-qN+QNNBr93TCmFrmte0bBCjSDMuRvt78VlHT99qIGPszm4QsqCX8lnyWUFkHi8B7ZBAPq8SH+UqyXNy/odMdng==}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==}
|
resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
@@ -1908,6 +1931,10 @@ packages:
|
|||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
|
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==}
|
||||||
|
engines: {'0': node >= 6.0}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-ysOGlgTFbN2/Y6Cg3Iye8YKulHw+R2fNXHrgSmXISQdMnomY6eNDprVdW9R5xBguEqI954+S6709UyiO7B+6OQ==}
|
resolution: {integrity: sha512-ysOGlgTFbN2/Y6Cg3Iye8YKulHw+R2fNXHrgSmXISQdMnomY6eNDprVdW9R5xBguEqI954+S6709UyiO7B+6OQ==}
|
||||||
|
|
||||||
@@ -2087,6 +2114,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-nGXts5znJzmWPu+mIE9izCOzdg63oJca2mDzGWWTth7sr4aCToKcoyFVBQwN75Ij5Pf6p510EwkTqViTRzDV+w==}
|
resolution: {integrity: sha512-nGXts5znJzmWPu+mIE9izCOzdg63oJca2mDzGWWTth7sr4aCToKcoyFVBQwN75Ij5Pf6p510EwkTqViTRzDV+w==}
|
||||||
engines: {node: '>=10.13.0'}
|
engines: {node: '>=10.13.0'}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==}
|
||||||
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==}
|
resolution: {integrity: sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==}
|
||||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||||
@@ -2312,6 +2343,10 @@ packages:
|
|||||||
picomatch:
|
picomatch:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-H+K6sW6TiIX6VGend0KQwthe+kaceeH/luE8dIZyOP35ik7ahYojDuqlTV1bOrtEwl01sy2HFNGQfi5IDJvotg==}
|
||||||
|
engines: {node: '>=16'}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==}
|
resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==}
|
||||||
engines: {node: '>=16.0.0'}
|
engines: {node: '>=16.0.0'}
|
||||||
@@ -2476,6 +2511,13 @@ packages:
|
|||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA==}
|
resolution: {integrity: sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA==}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-bqX0XTF6fnXSQcEJ2Iuyr75yVakyjIDCqroJQ/aHfSdlM743Cwqoi2nDYMzLGWUcuTWGWy8AAvOKXTfiv6q9RA==}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==}
|
||||||
|
engines: {node: '>= 6'}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==}
|
resolution: {integrity: sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
@@ -2496,6 +2538,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==}
|
resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==}
|
||||||
engines: {node: '>=0.8.19'}
|
engines: {node: '>=0.8.19'}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==}
|
resolution: {integrity: sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
@@ -3040,6 +3085,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
|
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-60zvsJReQPX5/QP0Kzfd/VrpjScIQ7SHBW6bFCYfEP+fp0Eppr1SHhIO5nd1PjZtvclzSzES9D/p5nFJurwfWg==}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
|
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
@@ -3172,6 +3220,10 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==}
|
||||||
|
engines: {node: '>=0.4.0'}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
|
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
|
||||||
|
|
||||||
@@ -3208,6 +3260,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==}
|
resolution: {integrity: sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
|
||||||
|
engines: {node: '>= 6'}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-Kko+Y5XQ6fM+Ce3dq3m9YGxnacYZYl9cA1wZjaF3Vbry2L3i1qVg8+CAgNPsXRArPMUMCaOR7oa9Nqntc43JKA==}
|
resolution: {integrity: sha512-Kko+Y5XQ6fM+Ce3dq3m9YGxnacYZYl9cA1wZjaF3Vbry2L3i1qVg8+CAgNPsXRArPMUMCaOR7oa9Nqntc43JKA==}
|
||||||
engines: {node: '>= 20.19.0'}
|
engines: {node: '>= 20.19.0'}
|
||||||
@@ -3276,6 +3332,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg==}
|
resolution: {integrity: sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg==}
|
||||||
engines: {node: '>=0.4'}
|
engines: {node: '>=0.4'}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==}
|
resolution: {integrity: sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
@@ -3425,6 +3484,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==}
|
resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
|
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
@@ -3530,6 +3592,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-phPGCwqr2+Qo0fwniCE8e4pKnGu/yFb5nD5Y8bf0EEeiI5GklnACYA9GFy/DrAeRrKHXvHn+1SUsOWgJp6RO+g==}
|
resolution: {integrity: sha512-phPGCwqr2+Qo0fwniCE8e4pKnGu/yFb5nD5Y8bf0EEeiI5GklnACYA9GFy/DrAeRrKHXvHn+1SUsOWgJp6RO+g==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-AcWG7KDjZ2THNXsgwttMaGmzVi0VFRlFYfqFHYQRbDpF3owuYbuiL8c7UUrd2k8s3PoSfIQrWfrGXfcElrWLYA==}
|
resolution: {integrity: sha512-AcWG7KDjZ2THNXsgwttMaGmzVi0VFRlFYfqFHYQRbDpF3owuYbuiL8c7UUrd2k8s3PoSfIQrWfrGXfcElrWLYA==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
@@ -3564,6 +3629,9 @@ packages:
|
|||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
|
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-gjdCvJ6d3RyHAneqxMYMW9QMCwYMb3jpOO0IyHZV1bnRHFBHrX3VkIILt5XYR0WhwHiH7Mty8ovuPZ/O3gamrg==}
|
resolution: {integrity: sha512-gjdCvJ6d3RyHAneqxMYMW9QMCwYMb3jpOO0IyHZV1bnRHFBHrX3VkIILt5XYR0WhwHiH7Mty8ovuPZ/O3gamrg==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -3894,6 +3962,13 @@ snapshots:
|
|||||||
|
|
||||||
'@better-fetch/[email protected]': {}
|
'@better-fetch/[email protected]': {}
|
||||||
|
|
||||||
|
'@derhuerst/[email protected]':
|
||||||
|
dependencies:
|
||||||
|
caseless: 0.12.0
|
||||||
|
concat-stream: 2.0.0
|
||||||
|
http-response-object: 3.0.2
|
||||||
|
parse-cache-control: 1.0.1
|
||||||
|
|
||||||
'@electric-sql/[email protected](@electric-sql/[email protected])':
|
'@electric-sql/[email protected](@electric-sql/[email protected])':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@electric-sql/pglite': 0.4.3
|
'@electric-sql/pglite': 0.4.3
|
||||||
@@ -4094,8 +4169,7 @@ snapshots:
|
|||||||
|
|
||||||
'@humanwhocodes/[email protected]': {}
|
'@humanwhocodes/[email protected]': {}
|
||||||
|
|
||||||
'@img/[email protected]':
|
'@img/[email protected]': {}
|
||||||
optional: true
|
|
||||||
|
|
||||||
'@img/[email protected]':
|
'@img/[email protected]':
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
@@ -4624,6 +4698,8 @@ snapshots:
|
|||||||
|
|
||||||
'@types/[email protected]': {}
|
'@types/[email protected]': {}
|
||||||
|
|
||||||
|
'@types/[email protected]': {}
|
||||||
|
|
||||||
'@types/[email protected]':
|
'@types/[email protected]':
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 6.21.0
|
undici-types: 6.21.0
|
||||||
@@ -4945,6 +5021,12 @@ snapshots:
|
|||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
|
[email protected]([email protected]):
|
||||||
|
dependencies:
|
||||||
|
debug: 4.4.3([email protected])
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- supports-color
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
dependencies:
|
dependencies:
|
||||||
fast-deep-equal: 3.1.3
|
fast-deep-equal: 3.1.3
|
||||||
@@ -5123,6 +5205,8 @@ snapshots:
|
|||||||
node-releases: 2.0.57
|
node-releases: 2.0.57
|
||||||
update-browserslist-db: 1.3.3([email protected])
|
update-browserslist-db: 1.3.3([email protected])
|
||||||
|
|
||||||
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
dependencies:
|
dependencies:
|
||||||
chokidar: 5.0.0
|
chokidar: 5.0.0
|
||||||
@@ -5161,6 +5245,8 @@ snapshots:
|
|||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
@@ -5190,6 +5276,13 @@ snapshots:
|
|||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
dependencies:
|
||||||
|
buffer-from: 1.1.2
|
||||||
|
inherits: 2.0.4
|
||||||
|
readable-stream: 3.6.2
|
||||||
|
typedarray: 0.0.6
|
||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
@@ -5364,6 +5457,8 @@ snapshots:
|
|||||||
graceful-fs: 4.2.11
|
graceful-fs: 4.2.11
|
||||||
tapable: 2.3.3
|
tapable: 2.3.3
|
||||||
|
|
||||||
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
@@ -5759,6 +5854,15 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
picomatch: 4.0.7
|
picomatch: 4.0.7
|
||||||
|
|
||||||
|
[email protected]([email protected]):
|
||||||
|
dependencies:
|
||||||
|
'@derhuerst/http-basic': 8.2.4
|
||||||
|
env-paths: 2.2.1
|
||||||
|
https-proxy-agent: 5.0.1([email protected])
|
||||||
|
progress: 2.0.3
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- supports-color
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
dependencies:
|
dependencies:
|
||||||
flat-cache: 4.0.1
|
flat-cache: 4.0.1
|
||||||
@@ -5922,6 +6026,17 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
hermes-estree: 0.25.1
|
hermes-estree: 0.25.1
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
dependencies:
|
||||||
|
'@types/node': 10.17.60
|
||||||
|
|
||||||
|
[email protected]([email protected]):
|
||||||
|
dependencies:
|
||||||
|
agent-base: 6.0.2([email protected])
|
||||||
|
debug: 4.4.3([email protected])
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- supports-color
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
dependencies:
|
dependencies:
|
||||||
safer-buffer: 2.1.2
|
safer-buffer: 2.1.2
|
||||||
@@ -5937,6 +6052,8 @@ snapshots:
|
|||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
dependencies:
|
dependencies:
|
||||||
es-errors: 1.3.0
|
es-errors: 1.3.0
|
||||||
@@ -6434,6 +6551,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
callsites: 3.1.0
|
callsites: 3.1.0
|
||||||
|
|
||||||
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
@@ -6546,6 +6665,8 @@ snapshots:
|
|||||||
- react
|
- react
|
||||||
- react-dom
|
- react-dom
|
||||||
|
|
||||||
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
dependencies:
|
dependencies:
|
||||||
loose-envify: 1.4.0
|
loose-envify: 1.4.0
|
||||||
@@ -6584,6 +6705,12 @@ snapshots:
|
|||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
dependencies:
|
||||||
|
inherits: 2.0.4
|
||||||
|
string_decoder: 1.3.0
|
||||||
|
util-deprecate: 1.0.2
|
||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
@@ -6670,6 +6797,8 @@ snapshots:
|
|||||||
has-symbols: 1.1.0
|
has-symbols: 1.1.0
|
||||||
isarray: 2.0.5
|
isarray: 2.0.5
|
||||||
|
|
||||||
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
dependencies:
|
dependencies:
|
||||||
es-errors: 1.3.0
|
es-errors: 1.3.0
|
||||||
@@ -6755,7 +6884,6 @@ snapshots:
|
|||||||
'@img/sharp-win32-ia32': 0.35.4
|
'@img/sharp-win32-ia32': 0.35.4
|
||||||
'@img/sharp-win32-x64': 0.35.4
|
'@img/sharp-win32-x64': 0.35.4
|
||||||
'@types/node': 22.20.4
|
'@types/node': 22.20.4
|
||||||
optional: true
|
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -6873,6 +7001,10 @@ snapshots:
|
|||||||
define-properties: 1.2.1
|
define-properties: 1.2.1
|
||||||
es-object-atoms: 1.1.2
|
es-object-atoms: 1.1.2
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
dependencies:
|
||||||
|
safe-buffer: 5.2.1
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
dependencies:
|
dependencies:
|
||||||
ansi-regex: 5.0.1
|
ansi-regex: 5.0.1
|
||||||
@@ -6972,6 +7104,8 @@ snapshots:
|
|||||||
possible-typed-array-names: 1.1.0
|
possible-typed-array-names: 1.1.0
|
||||||
reflect.getprototypeof: 1.0.10
|
reflect.getprototypeof: 1.0.10
|
||||||
|
|
||||||
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]):
|
[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/eslint-plugin': 8.70.1(@typescript-eslint/[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected]([email protected])([email protected]))([email protected])([email protected])
|
'@typescript-eslint/eslint-plugin': 8.70.1(@typescript-eslint/[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected]([email protected])([email protected]))([email protected])([email protected])
|
||||||
@@ -7033,6 +7167,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
punycode: 2.3.1
|
punycode: 2.3.1
|
||||||
|
|
||||||
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]([email protected]):
|
[email protected]([email protected]):
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 5.9.3
|
typescript: 5.9.3
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ allowBuilds:
|
|||||||
esbuild: true
|
esbuild: true
|
||||||
prisma: true
|
prisma: true
|
||||||
sharp: true
|
sharp: true
|
||||||
|
ffmpeg-static: true
|
||||||
embedded-postgres: true
|
embedded-postgres: true
|
||||||
'@embedded-postgres/windows-x64': true
|
'@embedded-postgres/windows-x64': true
|
||||||
'@embedded-postgres/linux-x64': true
|
'@embedded-postgres/linux-x64': true
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- Folgeraten ueber Stripe Billing (Subscription Schedule) statt eigenem Off-Session-Einzug.
|
||||||
|
ALTER TABLE "Booking" ADD COLUMN "stripeScheduleId" TEXT;
|
||||||
|
CREATE UNIQUE INDEX "Booking_stripeScheduleId_key" ON "Booking"("stripeScheduleId");
|
||||||
|
|
||||||
|
ALTER TABLE "Installment" ADD COLUMN "stripeInvoiceId" TEXT;
|
||||||
|
CREATE UNIQUE INDEX "Installment_stripeInvoiceId_key" ON "Installment"("stripeInvoiceId");
|
||||||
@@ -191,6 +191,9 @@ model Booking {
|
|||||||
/// Zahlungsmethode. Wird nach der letzten Rate bei Stripe getrennt.
|
/// Zahlungsmethode. Wird nach der letzten Rate bei Stripe getrennt.
|
||||||
stripePaymentMethodId String?
|
stripePaymentMethodId String?
|
||||||
paymentMethodDetachedAt DateTime?
|
paymentMethodDetachedAt DateTime?
|
||||||
|
/// Stripe-Billing-Zeitplan, der die Folgeraten einzieht (nur Ratenzahlung).
|
||||||
|
/// Stripe uebernimmt Einzug, Wiederholungen und Mahnungen.
|
||||||
|
stripeScheduleId String? @unique
|
||||||
|
|
||||||
paidCents Int @default(0)
|
paidCents Int @default(0)
|
||||||
refundedCents Int @default(0)
|
refundedCents Int @default(0)
|
||||||
@@ -246,6 +249,8 @@ model Installment {
|
|||||||
|
|
||||||
stripePaymentIntentId String? @unique
|
stripePaymentIntentId String? @unique
|
||||||
stripeChargeId String? @unique
|
stripeChargeId String? @unique
|
||||||
|
/// Stripe-Rechnung, ueber die Stripe Billing diese Folgerate einzieht.
|
||||||
|
stripeInvoiceId String? @unique
|
||||||
/// Offene Checkout-Session, ueber die die Kundin diese Rate selbst zahlt.
|
/// Offene Checkout-Session, ueber die die Kundin diese Rate selbst zahlt.
|
||||||
checkoutSessionId String? @unique
|
checkoutSessionId String? @unique
|
||||||
checkoutExpiresAt DateTime?
|
checkoutExpiresAt DateTime?
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
/**
|
||||||
|
* Bereitet Bilder und Videos fuer das Medienverzeichnis auf, bevor sie
|
||||||
|
* hochgeladen werden (docs/MEDIEN.md):
|
||||||
|
*
|
||||||
|
* pnpm media:optimize <eingabe-ordner> [ausgabe-ordner]
|
||||||
|
*
|
||||||
|
* - Videos (.mp4, .mov, .m4v, .webm) → "<name>.web.mp4": laengste Seite
|
||||||
|
* hoechstens 1920 px, H.264, Index am Dateianfang (faststart), damit der
|
||||||
|
* Browser sofort abspielen kann statt erst die ganze Datei zu laden.
|
||||||
|
* Headervideos ohne Ton. Fehlt ein Vorschaubild, wird eins erzeugt.
|
||||||
|
* Die Seite nimmt automatisch die .web.mp4, wenn sie daneben liegt.
|
||||||
|
* - Bilder groesser als noetig werden verkleinert (Logo 1600 px, sonst
|
||||||
|
* 2560 px laengste Seite), kleinere unveraendert kopiert.
|
||||||
|
*
|
||||||
|
* Ausgabe standardmaessig in "<eingabe-ordner>-web" mit gleicher
|
||||||
|
* Ordnerstruktur; diesen Inhalt ins Medienverzeichnis kopieren. Bereits
|
||||||
|
* aufbereitete Dateien (neuer als das Original) werden uebersprungen.
|
||||||
|
*/
|
||||||
|
import { spawn } from "node:child_process";
|
||||||
|
import { copyFile, mkdir, readdir, stat } from "node:fs/promises";
|
||||||
|
import path from "node:path";
|
||||||
|
import ffmpegPath from "ffmpeg-static";
|
||||||
|
import sharp from "sharp";
|
||||||
|
|
||||||
|
const VIDEO_EXTS = new Set([".mp4", ".mov", ".m4v", ".webm"]);
|
||||||
|
const IMAGE_EXTS = new Set([".jpg", ".jpeg", ".png", ".webp"]);
|
||||||
|
const MAX_VIDEO_EDGE = 1920;
|
||||||
|
const MAX_IMAGE_EDGE = 2560;
|
||||||
|
const MAX_LOGO_EDGE = 1600;
|
||||||
|
const POSTER_SECOND = 1;
|
||||||
|
|
||||||
|
async function* walk(dir: string): AsyncGenerator<string> {
|
||||||
|
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
||||||
|
const full = path.join(dir, entry.name);
|
||||||
|
if (entry.isDirectory()) yield* walk(full);
|
||||||
|
else if (entry.isFile()) yield full;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function isFresh(output: string, input: string): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
return (await stat(output)).mtimeMs >= (await stat(input)).mtimeMs;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function exists(file: string): Promise<boolean> {
|
||||||
|
return stat(file).then(
|
||||||
|
() => true,
|
||||||
|
() => false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ffmpeg(args: string[]): Promise<void> {
|
||||||
|
const binary = ffmpegPath as unknown as string | null;
|
||||||
|
if (!binary) throw new Error("ffmpeg-static liefert fuer dieses System kein ffmpeg.");
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const child = spawn(binary, ["-hide_banner", "-loglevel", "error", "-stats", "-y", ...args], { stdio: ["ignore", "inherit", "inherit"] });
|
||||||
|
child.on("error", reject);
|
||||||
|
child.on("exit", (code) => (code === 0 ? resolve() : reject(new Error(`ffmpeg endete mit Code ${code}`))));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Laengste Seite auf MAX_VIDEO_EDGE begrenzen, nie vergroessern, gerade Masse fuer H.264. */
|
||||||
|
const SCALE_FILTER = `scale='if(gte(iw,ih),min(${MAX_VIDEO_EDGE},iw),-2)':'if(gte(iw,ih),-2,min(${MAX_VIDEO_EDGE},ih))'`;
|
||||||
|
|
||||||
|
async function hasPoster(input: string, base: string): Promise<boolean> {
|
||||||
|
const dir = path.dirname(input);
|
||||||
|
const name = path.basename(base);
|
||||||
|
for (const ext of IMAGE_EXTS) {
|
||||||
|
if (await exists(path.join(dir, `${name}${ext}`))) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function optimizeVideo(input: string, outDir: string, base: string): Promise<string[]> {
|
||||||
|
const output = path.join(outDir, `${base}.web.mp4`);
|
||||||
|
const written: string[] = [];
|
||||||
|
if (!(await isFresh(output, input))) {
|
||||||
|
const silent = base.toLowerCase() === "header";
|
||||||
|
await ffmpeg([
|
||||||
|
"-i", input,
|
||||||
|
"-vf", SCALE_FILTER,
|
||||||
|
"-c:v", "libx264", "-preset", "slow", "-crf", "23", "-profile:v", "high", "-pix_fmt", "yuv420p",
|
||||||
|
"-maxrate", "6M", "-bufsize", "12M",
|
||||||
|
...(silent ? ["-an"] : ["-c:a", "aac", "-b:a", "128k"]),
|
||||||
|
"-movflags", "+faststart",
|
||||||
|
output,
|
||||||
|
]);
|
||||||
|
written.push(output);
|
||||||
|
}
|
||||||
|
const poster = path.join(outDir, `${base}.jpg`);
|
||||||
|
if (!(await hasPoster(input, base)) && !(await isFresh(poster, input))) {
|
||||||
|
await ffmpeg(["-ss", String(POSTER_SECOND), "-i", input, "-frames:v", "1", "-vf", SCALE_FILTER, "-q:v", "3", poster]);
|
||||||
|
written.push(poster);
|
||||||
|
}
|
||||||
|
return written;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function optimizeImage(input: string, output: string): Promise<string[]> {
|
||||||
|
if (await isFresh(output, input)) return [];
|
||||||
|
const isLogo = path.basename(input).toLowerCase().startsWith("logo");
|
||||||
|
const limit = isLogo ? MAX_LOGO_EDGE : MAX_IMAGE_EDGE;
|
||||||
|
const meta = await sharp(input).metadata();
|
||||||
|
if (Math.max(meta.width ?? 0, meta.height ?? 0) <= limit) {
|
||||||
|
await copyFile(input, output);
|
||||||
|
return [output];
|
||||||
|
}
|
||||||
|
const resized = sharp(input).rotate().resize(limit, limit, { fit: "inside", withoutEnlargement: true });
|
||||||
|
const ext = path.extname(input).toLowerCase();
|
||||||
|
if (ext === ".png") await resized.png({ compressionLevel: 9 }).toFile(output);
|
||||||
|
else if (ext === ".webp") await resized.webp({ quality: 82 }).toFile(output);
|
||||||
|
else await resized.jpeg({ quality: 82, mozjpeg: true }).toFile(output);
|
||||||
|
return [output];
|
||||||
|
}
|
||||||
|
|
||||||
|
function megabytes(bytes: number): string {
|
||||||
|
return `${(bytes / 1_048_576).toFixed(1)} MB`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main(): Promise<void> {
|
||||||
|
const [inputArg, outputArg] = process.argv.slice(2);
|
||||||
|
if (!inputArg) {
|
||||||
|
console.error("Aufruf: pnpm media:optimize <eingabe-ordner> [ausgabe-ordner]");
|
||||||
|
process.exitCode = 2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const inputDir = path.resolve(inputArg);
|
||||||
|
const outputDir = path.resolve(outputArg ?? `${inputDir}-web`);
|
||||||
|
if (outputDir === inputDir) throw new Error("Ausgabe-Ordner muss sich vom Eingabe-Ordner unterscheiden.");
|
||||||
|
|
||||||
|
let before = 0;
|
||||||
|
let after = 0;
|
||||||
|
for await (const input of walk(inputDir)) {
|
||||||
|
const rel = path.relative(inputDir, input);
|
||||||
|
const ext = path.extname(rel).toLowerCase();
|
||||||
|
if (!VIDEO_EXTS.has(ext) && !IMAGE_EXTS.has(ext)) continue;
|
||||||
|
if (rel.toLowerCase().endsWith(".web.mp4")) continue;
|
||||||
|
const outDir = path.join(outputDir, path.dirname(rel));
|
||||||
|
await mkdir(outDir, { recursive: true });
|
||||||
|
console.log(`→ ${rel}`);
|
||||||
|
const written = VIDEO_EXTS.has(ext)
|
||||||
|
? await optimizeVideo(input, outDir, path.basename(rel, path.extname(rel)))
|
||||||
|
: await optimizeImage(input, path.join(outDir, path.basename(rel)));
|
||||||
|
if (written.length === 0) {
|
||||||
|
console.log(" bereits aktuell");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const inSize = (await stat(input)).size;
|
||||||
|
const outSize = (await Promise.all(written.map((f) => stat(f)))).reduce((sum, s) => sum + s.size, 0);
|
||||||
|
before += inSize;
|
||||||
|
after += outSize;
|
||||||
|
console.log(` ${megabytes(inSize)} → ${megabytes(outSize)}: ${written.map((f) => path.relative(outputDir, f)).join(", ")}`);
|
||||||
|
}
|
||||||
|
console.log(`Fertig: ${megabytes(before)} → ${megabytes(after)}. Inhalt von ${outputDir} ins Medienverzeichnis kopieren.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((error: unknown) => {
|
||||||
|
console.error(`Abbruch: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
process.exitCode = 1;
|
||||||
|
});
|
||||||
+5
-1
@@ -25,7 +25,11 @@ try {
|
|||||||
adminEmail: env().ADMIN_NOTIFY_EMAIL ?? null,
|
adminEmail: env().ADMIN_NOTIFY_EMAIL ?? null,
|
||||||
});
|
});
|
||||||
console.log(`[worker] ${new Date().toISOString()} ${JSON.stringify(result)}`);
|
console.log(`[worker] ${new Date().toISOString()} ${JSON.stringify(result)}`);
|
||||||
process.exitCode = result.emails.failed > 0 ? 1 : 0;
|
// Teilfehler (einzelne Buchungen bei Stripe) machen den Job sichtbar
|
||||||
|
// fehlgeschlagen, ohne die uebrigen Aufgaben des Laufs zu verhindern.
|
||||||
|
const partialFailures =
|
||||||
|
result.emails.failed + result.held.failed + result.schedules.failed + result.installments.failed + result.stopped.failed;
|
||||||
|
process.exitCode = partialFailures > 0 ? 1 : 0;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`[worker] Abbruch: ${error instanceof Error ? error.message : "unbekannter Fehler"}`);
|
console.error(`[worker] Abbruch: ${error instanceof Error ? error.message : "unbekannter Fehler"}`);
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ export default async function SettingsPage({ searchParams }: { searchParams: Pro
|
|||||||
name="installmentRuleApproved"
|
name="installmentRuleApproved"
|
||||||
label="Terminregel für Raten freigegeben"
|
label="Terminregel für Raten freigegeben"
|
||||||
defaultChecked={camp.installmentRuleApproved}
|
defaultChecked={camp.installmentRuleApproved}
|
||||||
hint="Letzte Rate am Stichtag, bei drei Raten die zweite in der Mitte; Einzug 9 Uhr."
|
hint="Letzte Rate am Stichtag, bei drei Raten die zweite in der Mitte; Stripe zieht ab 9 Uhr ein."
|
||||||
/>
|
/>
|
||||||
<Checkbox name="installmentsApproved" label="Ratenzahlung für den Live-Verkauf freigegeben" defaultChecked={camp.installmentsApproved} />
|
<Checkbox name="installmentsApproved" label="Ratenzahlung für den Live-Verkauf freigegeben" defaultChecked={camp.installmentsApproved} />
|
||||||
<label className="mt-3 block">
|
<label className="mt-3 block">
|
||||||
|
|||||||
@@ -4,9 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { checkSameOrigin, fail, ok, rateLimited, readJson } from "@/lib/api";
|
import { checkSameOrigin, fail, ok, rateLimited, readJson } from "@/lib/api";
|
||||||
import { abandonCheckout, startInstallmentCheckout } from "@/lib/checkout";
|
import { abandonCheckout, installmentPaymentUrl } from "@/lib/checkout";
|
||||||
import { getDb } from "@/lib/db";
|
import { getDb } from "@/lib/db";
|
||||||
import { requireAppSecret } from "@/lib/env";
|
|
||||||
import { getGateway } from "@/lib/payment-gateway";
|
import { getGateway } from "@/lib/payment-gateway";
|
||||||
import { RATE_LIMITS } from "@/lib/rate-limit";
|
import { RATE_LIMITS } from "@/lib/rate-limit";
|
||||||
import { isWellFormedStatusToken, sha256Hex } from "@/lib/tokens";
|
import { isWellFormedStatusToken, sha256Hex } from "@/lib/tokens";
|
||||||
@@ -37,7 +36,7 @@ export async function POST(request: Request) {
|
|||||||
|
|
||||||
switch (body.data.action) {
|
switch (body.data.action) {
|
||||||
case "pay_installment": {
|
case "pay_installment": {
|
||||||
const result = await startInstallmentCheckout(db, gateway, { bookingId: booking.id, installmentId: body.data.installmentId }, { now, secret: requireAppSecret() });
|
const result = await installmentPaymentUrl(db, gateway, { bookingId: booking.id, installmentId: body.data.installmentId });
|
||||||
if (result.ok) return ok({ url: result.url });
|
if (result.ok) return ok({ url: result.url });
|
||||||
return result.error === "NOT_PAYABLE"
|
return result.error === "NOT_PAYABLE"
|
||||||
? fail(409, { code: "NOT_PAYABLE", message: "Diese Rate kann gerade nicht bezahlt werden. Bitte lade die Seite neu." })
|
? fail(409, { code: "NOT_PAYABLE", message: "Diese Rate kann gerade nicht bezahlt werden. Bitte lade die Seite neu." })
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* Formular "Erstgespraech" (src/components/sections/ContactSection.tsx).
|
||||||
|
* Gleiche Schutzschicht wie die Buchung: nur JSON von der eigenen Seite,
|
||||||
|
* Rate Limit je IP, serverseitige Pruefung aller Felder.
|
||||||
|
*/
|
||||||
|
import { after } from "next/server";
|
||||||
|
import { checkSameOrigin, fail, ok, rateLimited, readJson } from "@/lib/api";
|
||||||
|
import { contactRequestSchema, submitContactRequest } from "@/lib/contact";
|
||||||
|
import { getDb } from "@/lib/db";
|
||||||
|
import { flushEmails } from "@/lib/email";
|
||||||
|
import { requireAppSecret } from "@/lib/env";
|
||||||
|
import { RATE_LIMITS } from "@/lib/rate-limit";
|
||||||
|
|
||||||
|
export async function POST(request: Request) {
|
||||||
|
const blocked = checkSameOrigin(request);
|
||||||
|
if (blocked) return blocked;
|
||||||
|
const limited = await rateLimited(request, RATE_LIMITS.contact);
|
||||||
|
if (limited) return limited;
|
||||||
|
const body = await readJson(request, contactRequestSchema);
|
||||||
|
if (!body.ok) return body.response;
|
||||||
|
|
||||||
|
const db = getDb();
|
||||||
|
const result = await submitContactRequest(db, body.data, { now: new Date(), secret: requireAppSecret() });
|
||||||
|
if (!result.ok) {
|
||||||
|
return fail(503, { code: "NOT_CONFIGURED", message: "Das Formular ist gerade nicht verfügbar. Bitte schreib uns direkt eine E-Mail." });
|
||||||
|
}
|
||||||
|
// Sofort zustellen statt auf den naechsten Worker-Lauf zu warten; schlaegt
|
||||||
|
// das fehl, versucht es der Worker erneut.
|
||||||
|
if (result.delivered) {
|
||||||
|
after(() => flushEmails(db, { limit: 5 }).catch(() => undefined));
|
||||||
|
}
|
||||||
|
return ok({ received: true });
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ export default function DatenschutzPage() {
|
|||||||
<li>Buchungsdaten: Name, E-Mail, Telefon, Land, optionale Anmerkungen, Zeitpunkte der Erklärungen; gespeichert in einer selbst betriebenen PostgreSQL-Datenbank.</li>
|
<li>Buchungsdaten: Name, E-Mail, Telefon, Land, optionale Anmerkungen, Zeitpunkte der Erklärungen; gespeichert in einer selbst betriebenen PostgreSQL-Datenbank.</li>
|
||||||
<li>Zahlungen über Stripe (Stripe Payments Europe Ltd.); Kartendaten gelangen nicht auf unsere Server, gespeichert werden nur Stripe-Objekt-IDs.</li>
|
<li>Zahlungen über Stripe (Stripe Payments Europe Ltd.); Kartendaten gelangen nicht auf unsere Server, gespeichert werden nur Stripe-Objekt-IDs.</li>
|
||||||
<li>E-Mail-Versand über den konfigurierten SMTP-Anbieter.</li>
|
<li>E-Mail-Versand über den konfigurierten SMTP-Anbieter.</li>
|
||||||
|
<li>Formular Erstgespräch: Name, E-Mail, optional Telefon, Erreichbarkeit und Nachricht; wird nicht in einer eigenen Tabelle gespeichert, sondern als E-Mail an den Veranstalter geschickt (Kopie im Postausgang der Datenbank).</li>
|
||||||
<li>Rate Limiting speichert nur einen gehashten IP-Schlüssel, maximal einen Tag.</li>
|
<li>Rate Limiting speichert nur einen gehashten IP-Schlüssel, maximal einen Tag.</li>
|
||||||
<li>Keine Analyse- oder Tracking-Dienste, keine Cookies auf der öffentlichen Seite; Schriften werden selbst ausgeliefert.</li>
|
<li>Keine Analyse- oder Tracking-Dienste, keine Cookies auf der öffentlichen Seite; Schriften werden selbst ausgeliefert.</li>
|
||||||
<li>Externe Videoanbieter nur nach Klick und nur, wenn EXTERNAL_VIDEO_PROVIDER gesetzt ist.</li>
|
<li>Externe Videoanbieter nur nach Klick und nur, wenn EXTERNAL_VIDEO_PROVIDER gesetzt ist.</li>
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ export async function GET(request: Request, { params }: { params: Promise<{ path
|
|||||||
const headers: Record<string, string> = {
|
const headers: Record<string, string> = {
|
||||||
"Content-Type": type,
|
"Content-Type": type,
|
||||||
"Accept-Ranges": "bytes",
|
"Accept-Ranges": "bytes",
|
||||||
"Cache-Control": "public, max-age=86400",
|
// Mit ?v=<Aenderungsdatum> (site-media.ts) aendert sich die Adresse bei
|
||||||
|
// jedem Austausch: dann ein Jahr cachen, sonst einen Tag.
|
||||||
|
"Cache-Control": new URL(request.url).searchParams.has("v") ? "public, max-age=31536000, immutable" : "public, max-age=86400",
|
||||||
"X-Content-Type-Options": "nosniff",
|
"X-Content-Type-Options": "nosniff",
|
||||||
// SVG (Logo) direkt aufgerufen: keine Skripte, keine Nachladungen.
|
// SVG (Logo) direkt aufgerufen: keine Skripte, keine Nachladungen.
|
||||||
...(type === "image/svg+xml" ? { "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox" } : {}),
|
...(type === "image/svg+xml" ? { "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox" } : {}),
|
||||||
|
|||||||
+5
-1
@@ -6,6 +6,8 @@ import { AccommodationSection } from "@/components/sections/CampSections";
|
|||||||
import { ExpectSection, ScheduleSection } from "@/components/sections/ExpectSections";
|
import { ExpectSection, ScheduleSection } from "@/components/sections/ExpectSections";
|
||||||
import { ClosingSection, FaqSection } from "@/components/sections/FaqSection";
|
import { ClosingSection, FaqSection } from "@/components/sections/FaqSection";
|
||||||
import { AboutSection, ReelsSection, TeamSection } from "@/components/sections/PeopleSections";
|
import { AboutSection, ReelsSection, TeamSection } from "@/components/sections/PeopleSections";
|
||||||
|
import { ContactSection } from "@/components/sections/ContactSection";
|
||||||
|
import { IntroVideoSection } from "@/components/sections/IntroVideoSection";
|
||||||
import { PricingSection } from "@/components/sections/PricingSection";
|
import { PricingSection } from "@/components/sections/PricingSection";
|
||||||
import { ReviewsSection } from "@/components/sections/ReviewsSection";
|
import { ReviewsSection } from "@/components/sections/ReviewsSection";
|
||||||
import { SiteFooter } from "@/components/SiteFooter";
|
import { SiteFooter } from "@/components/SiteFooter";
|
||||||
@@ -16,7 +18,7 @@ import { loadPublicPage } from "@/lib/public-page";
|
|||||||
import { loadSiteMedia } from "@/lib/site-media";
|
import { loadSiteMedia } from "@/lib/site-media";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gliederung nach der Filmcamp-Referenz: Headerbild, Termin, was dich
|
* Gliederung nach der Filmcamp-Referenz: Headerbild, Video, Termin, was dich
|
||||||
* erwartet (die Villa), Tagesablauf, Unterkunft, Preis, Team, Reels,
|
* erwartet (die Villa), Tagesablauf, Unterkunft, Preis, Team, Reels,
|
||||||
* Fragen, Abschluss.
|
* Fragen, Abschluss.
|
||||||
*/
|
*/
|
||||||
@@ -37,6 +39,7 @@ export default async function HomePage() {
|
|||||||
<SiteHeader logoLight={media.logoLight} logoDark={media.logoDark} />
|
<SiteHeader logoLight={media.logoLight} logoDark={media.logoDark} />
|
||||||
<main id="inhalt">
|
<main id="inhalt">
|
||||||
<Hero pricing={pricing} media={media.header} video={media.headerVideo} />
|
<Hero pricing={pricing} media={media.header} video={media.headerVideo} />
|
||||||
|
<IntroVideoSection video={media.intro} showDrafts={showDrafts} />
|
||||||
<DateBar facts={facts} />
|
<DateBar facts={facts} />
|
||||||
<ExpectSection />
|
<ExpectSection />
|
||||||
<ScheduleSection facts={facts} />
|
<ScheduleSection facts={facts} />
|
||||||
@@ -47,6 +50,7 @@ export default async function HomePage() {
|
|||||||
<ReviewsSection data={reviews} showDrafts={showDrafts} />
|
<ReviewsSection data={reviews} showDrafts={showDrafts} />
|
||||||
<AboutSection showDrafts={showDrafts} />
|
<AboutSection showDrafts={showDrafts} />
|
||||||
<FaqSection facts={facts} pricing={pricing} />
|
<FaqSection facts={facts} pricing={pricing} />
|
||||||
|
<ContactSection />
|
||||||
<ClosingSection pricing={pricing} />
|
<ClosingSection pricing={pricing} />
|
||||||
</main>
|
</main>
|
||||||
<SiteFooter facts={facts} showDrafts={showDrafts} logo={media.logoDark} />
|
<SiteFooter facts={facts} showDrafts={showDrafts} logo={media.logoDark} />
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export function Hero({ pricing, media, video }: { pricing: PublicPricing; media:
|
|||||||
<div aria-hidden className="absolute inset-0 bg-[linear-gradient(180deg,rgb(35_33_31/0.6)_0%,rgb(35_33_31/0.45)_45%,rgb(35_33_31/0.75)_100%)]" />
|
<div aria-hidden className="absolute inset-0 bg-[linear-gradient(180deg,rgb(35_33_31/0.6)_0%,rgb(35_33_31/0.45)_45%,rgb(35_33_31/0.75)_100%)]" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="container-edge flex flex-col items-center pb-20 pt-36 text-center md:pt-44">
|
<div className="container-edge flex flex-col items-center pb-20 pt-44 text-center md:pt-60">
|
||||||
<h1 id="hero-title" className="hero-fade max-w-4xl text-[clamp(2.75rem,8vw,6.25rem)] font-extrabold leading-[0.98] tracking-[-0.03em]">
|
<h1 id="hero-title" className="hero-fade max-w-4xl text-[clamp(2.75rem,8vw,6.25rem)] font-extrabold leading-[0.98] tracking-[-0.03em]">
|
||||||
<span className="sr-only">ARTISTA </span>
|
<span className="sr-only">ARTISTA </span>
|
||||||
{hero.title}
|
{hero.title}
|
||||||
|
|||||||
+26
-7
@@ -1,12 +1,31 @@
|
|||||||
|
import type { LogoImage } from "@/lib/site-media";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ARTISTA-Logo aus dem Medienverzeichnis (logo.svg/png bzw. logo-hell.*).
|
* Umfaerbung, wenn keine passende Fassung hochgeladen wurde (siehe
|
||||||
* Ohne Datei erscheint ein Schriftzug. Bewusst <img> statt next/image:
|
* resolveLogos in site-media.ts): ein helles Logo wird auf heller Flaeche
|
||||||
* SVG-Logos laufen nicht durch die Bildoptimierung.
|
* dunkel, ein dunkles auf Foto weiss.
|
||||||
*/
|
*/
|
||||||
export function Logo({ src, className = "" }: { src: string | null; className?: string }) {
|
const TONE_FILTER: Record<LogoImage["tone"], string> = {
|
||||||
if (src) {
|
"as-is": "",
|
||||||
// eslint-disable-next-line @next/next/no-img-element
|
darken: "brightness(0.28) contrast(1.2)",
|
||||||
return <img src={src} alt="ARTISTA" className={`h-full w-auto ${className}`} />;
|
lighten: "brightness(0) invert(1)",
|
||||||
|
};
|
||||||
|
/** Ueber dem Foto hebt ein weicher Schatten das Logo vom Bild ab. */
|
||||||
|
const PHOTO_SHADOW = "drop-shadow(0 2px 14px rgb(0 0 0 / 0.55))";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ARTISTA-Logo aus dem Medienverzeichnis (logo.* bzw. logo-hell.*). Ohne
|
||||||
|
* Datei erscheint ein Schriftzug. Bewusst <img> statt next/image: die URL
|
||||||
|
* ist bereits optimiert (Raster) bzw. ein SVG, und die Hoehe kommt vom
|
||||||
|
* Elternelement.
|
||||||
|
*/
|
||||||
|
export function Logo({ logo, onPhoto = false, className = "" }: { logo: LogoImage | null; onPhoto?: boolean; className?: string }) {
|
||||||
|
if (logo) {
|
||||||
|
const filter = [TONE_FILTER[logo.tone], onPhoto ? PHOTO_SHADOW : ""].filter(Boolean).join(" ");
|
||||||
|
return (
|
||||||
|
// eslint-disable-next-line @next/next/no-img-element
|
||||||
|
<img src={logo.src} alt="ARTISTA Modelcamp 2027" style={filter ? { filter } : undefined} className={`h-full w-auto ${className}`} />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return <span className={`font-bold uppercase tracking-[0.32em] ${className}`}>Artista</span>;
|
return <span className={`font-bold uppercase tracking-[0.32em] ${className}`}>Artista</span>;
|
||||||
}
|
}
|
||||||
@@ -1,50 +1,118 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import type { ScheduleItem } from "@/content/site";
|
import type { ScheduleItem } from "@/content/site";
|
||||||
|
|
||||||
export type ScheduleCard = { label: string; date: string | null; title: string; items: ScheduleItem[] };
|
export type ScheduleCard = { label: string; date: string | null; title: string; items: ScheduleItem[] };
|
||||||
|
|
||||||
|
/** Toleranz in Pixeln fuer "ganz am Anfang/Ende" (Rundung beim Einrasten). */
|
||||||
|
const EDGE_TOLERANCE = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tagesablauf als waagerechte Kartenreihe mit Einrasten (scroll-snap).
|
* Tagesablauf als waagerechte Kartenreihe mit Einrasten (scroll-snap).
|
||||||
* Wischen auf dem Smartphone, Pfeile und Punkte auf allen Groessen. Die
|
* Wischen auf dem Smartphone, Pfeile und Punkte auf allen Groessen. Die
|
||||||
* Liste bleibt eine echte Liste: ohne JavaScript scrollt sie trotzdem.
|
* Liste bleibt eine echte Liste: ohne JavaScript scrollt sie trotzdem.
|
||||||
|
*
|
||||||
|
* Positionen werden aus getBoundingClientRect berechnet, nicht aus
|
||||||
|
* offsetLeft: offsetLeft bezieht sich auf das naechste positionierte
|
||||||
|
* Element (hier <body>) und verfehlte den Einrastpunkt, sodass "Weiter"
|
||||||
|
* zwei Tage sprang und "Zurueck" am Ende haengen blieb.
|
||||||
*/
|
*/
|
||||||
export function ScheduleCarousel({ days }: { days: ScheduleCard[] }) {
|
export function ScheduleCarousel({ days }: { days: ScheduleCard[] }) {
|
||||||
const track = useRef<HTMLOListElement>(null);
|
const track = useRef<HTMLOListElement>(null);
|
||||||
const cards = useRef<(HTMLLIElement | null)[]>([]);
|
const cards = useRef<(HTMLLIElement | null)[]>([]);
|
||||||
const [current, setCurrent] = useState(0);
|
const [current, setCurrent] = useState(0);
|
||||||
|
const [atStart, setAtStart] = useState(true);
|
||||||
|
const [atEnd, setAtEnd] = useState(days.length <= 1);
|
||||||
|
|
||||||
|
const snapInset = (root: HTMLElement) => parseFloat(getComputedStyle(root).scrollPaddingLeft) || 0;
|
||||||
|
|
||||||
|
const update = useCallback(() => {
|
||||||
|
const root = track.current;
|
||||||
|
if (!root) return;
|
||||||
|
const anchor = root.getBoundingClientRect().left + snapInset(root);
|
||||||
|
let nearest = 0;
|
||||||
|
let best = Infinity;
|
||||||
|
cards.current.forEach((card, index) => {
|
||||||
|
if (!card) return;
|
||||||
|
const distance = Math.abs(card.getBoundingClientRect().left - anchor);
|
||||||
|
if (distance < best) {
|
||||||
|
best = distance;
|
||||||
|
nearest = index;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setCurrent(nearest);
|
||||||
|
setAtStart(root.scrollLeft <= EDGE_TOLERANCE);
|
||||||
|
setAtEnd(root.scrollLeft >= root.scrollWidth - root.clientWidth - EDGE_TOLERANCE);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const root = track.current;
|
const root = track.current;
|
||||||
if (!root) return;
|
if (!root) return;
|
||||||
const observer = new IntersectionObserver(
|
let frame = 0;
|
||||||
(entries) => {
|
const onScroll = () => {
|
||||||
const visible = entries.filter((e) => e.isIntersecting).map((e) => Number((e.target as HTMLElement).dataset.index));
|
cancelAnimationFrame(frame);
|
||||||
if (visible.length) setCurrent(Math.min(...visible));
|
frame = requestAnimationFrame(update);
|
||||||
},
|
};
|
||||||
{ root, threshold: 0.6 },
|
update();
|
||||||
);
|
root.addEventListener("scroll", onScroll, { passive: true });
|
||||||
cards.current.forEach((card) => card && observer.observe(card));
|
window.addEventListener("resize", onScroll);
|
||||||
return () => observer.disconnect();
|
return () => {
|
||||||
}, []);
|
cancelAnimationFrame(frame);
|
||||||
|
root.removeEventListener("scroll", onScroll);
|
||||||
|
window.removeEventListener("resize", onScroll);
|
||||||
|
};
|
||||||
|
}, [update]);
|
||||||
|
|
||||||
const go = (index: number) => {
|
const go = (index: number) => {
|
||||||
const target = cards.current[Math.max(0, Math.min(days.length - 1, index))];
|
|
||||||
const root = track.current;
|
const root = track.current;
|
||||||
if (!target || !root) return;
|
const target = cards.current[Math.max(0, Math.min(days.length - 1, index))];
|
||||||
|
if (!root || !target) return;
|
||||||
|
const left = root.scrollLeft + target.getBoundingClientRect().left - root.getBoundingClientRect().left - snapInset(root);
|
||||||
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||||
root.scrollTo({ left: target.offsetLeft - root.offsetLeft, behavior: reduce ? "auto" : "smooth" });
|
root.scrollTo({ left, behavior: reduce ? "auto" : "smooth" });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
<div className="mb-6 flex items-center justify-between gap-4">
|
||||||
|
<div className="flex flex-wrap items-center gap-1">
|
||||||
|
{days.map((day, index) => (
|
||||||
|
<button
|
||||||
|
key={day.label}
|
||||||
|
type="button"
|
||||||
|
onClick={() => go(index)}
|
||||||
|
aria-label={`${day.label}${day.date ? `, ${day.date}` : ""} zeigen`}
|
||||||
|
aria-current={index === current ? "true" : undefined}
|
||||||
|
className="grid h-8 w-6 place-items-center"
|
||||||
|
>
|
||||||
|
<span className={`block h-1.5 rounded-full transition-all duration-300 ${index === current ? "w-5 bg-ink" : "w-1.5 bg-ink/30"}`} />
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<button type="button" onClick={() => go(current - 1)} disabled={atStart} aria-label="Vorheriger Tag" className="grid h-11 w-11 place-items-center rounded-full border border-ink/25 hover:border-ink disabled:opacity-35">
|
||||||
|
<svg viewBox="0 0 24 24" className="h-5 w-5" aria-hidden>
|
||||||
|
<path d="M15 6l-6 6 6 6" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<button type="button" onClick={() => go(current + 1)} disabled={atEnd} aria-label="Nächster Tag" className="grid h-11 w-11 place-items-center rounded-full border border-ink/25 hover:border-ink disabled:opacity-35">
|
||||||
|
<svg viewBox="0 0 24 24" className="h-5 w-5" aria-hidden>
|
||||||
|
<path d="M9 6l6 6-6 6" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ol
|
<ol
|
||||||
ref={track}
|
ref={track}
|
||||||
aria-label="Tage im Camp"
|
aria-label="Tage im Camp"
|
||||||
// Per Tastatur scrollbar (Pfeiltasten), WCAG 2.1.1.
|
// Per Tastatur scrollbar (Pfeiltasten), WCAG 2.1.1.
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
className="-mx-4 flex snap-x snap-mandatory scroll-px-4 gap-4 overflow-x-auto px-4 pb-4 md:scroll-px-10 [scrollbar-width:none] md:-mx-10 md:gap-6 md:px-10 [&::-webkit-scrollbar]:hidden"
|
// Smartphone: Karten ragen bis an den Rand, die naechste lugt hervor.
|
||||||
|
// Ab md: Karten passen vollstaendig in den Inhaltsbereich (2 bzw. 3
|
||||||
|
// nebeneinander), nichts wird am Rand abgeschnitten.
|
||||||
|
className="-mx-4 flex snap-x snap-mandatory scroll-px-4 gap-4 overflow-x-auto px-4 pb-4 [scrollbar-width:none] md:mx-0 md:scroll-px-0 md:gap-6 md:px-0 [&::-webkit-scrollbar]:hidden"
|
||||||
>
|
>
|
||||||
{days.map((day, index) => (
|
{days.map((day, index) => (
|
||||||
<li
|
<li
|
||||||
@@ -52,8 +120,7 @@ export function ScheduleCarousel({ days }: { days: ScheduleCard[] }) {
|
|||||||
ref={(el) => {
|
ref={(el) => {
|
||||||
cards.current[index] = el;
|
cards.current[index] = el;
|
||||||
}}
|
}}
|
||||||
data-index={index}
|
className="flex w-[85%] shrink-0 snap-start flex-col rounded-2xl bg-paper p-6 shadow-[0_1px_0_var(--color-line)] sm:w-[62%] md:w-[calc((100%-1.5rem)/2)] md:p-8 lg:w-[calc((100%-3rem)/3)]"
|
||||||
className="flex w-[88%] shrink-0 snap-start flex-col rounded-2xl bg-paper p-6 shadow-[0_1px_0_var(--color-line)] sm:w-[62%] md:w-[46%] md:p-8 lg:w-[34%]"
|
|
||||||
>
|
>
|
||||||
<p className="text-sm font-semibold uppercase tracking-[0.16em] text-rosso">
|
<p className="text-sm font-semibold uppercase tracking-[0.16em] text-rosso">
|
||||||
{day.label} · {day.title}
|
{day.label} · {day.title}
|
||||||
@@ -78,35 +145,6 @@ export function ScheduleCarousel({ days }: { days: ScheduleCard[] }) {
|
|||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<div className="mt-6 flex items-center justify-between gap-4">
|
|
||||||
<div className="flex flex-wrap items-center gap-1">
|
|
||||||
{days.map((day, index) => (
|
|
||||||
<button
|
|
||||||
key={day.label}
|
|
||||||
type="button"
|
|
||||||
onClick={() => go(index)}
|
|
||||||
aria-label={`${day.label}${day.date ? `, ${day.date}` : ""} zeigen`}
|
|
||||||
aria-current={index === current ? "true" : undefined}
|
|
||||||
className="grid h-8 w-6 place-items-center"
|
|
||||||
>
|
|
||||||
<span className={`block h-1.5 rounded-full transition-all duration-300 ${index === current ? "w-5 bg-ink" : "w-1.5 bg-ink/30"}`} />
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<div className="flex gap-2">
|
|
||||||
<button type="button" onClick={() => go(current - 1)} disabled={current === 0} aria-label="Vorheriger Tag" className="grid h-11 w-11 place-items-center rounded-full border border-ink/25 hover:border-ink disabled:opacity-35">
|
|
||||||
<svg viewBox="0 0 24 24" className="h-5 w-5" aria-hidden>
|
|
||||||
<path d="M15 6l-6 6 6 6" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<button type="button" onClick={() => go(current + 1)} disabled={current >= days.length - 1} aria-label="Nächster Tag" className="grid h-11 w-11 place-items-center rounded-full border border-ink/25 hover:border-ink disabled:opacity-35">
|
|
||||||
<svg viewBox="0 0 24 24" className="h-5 w-5" aria-hidden>
|
|
||||||
<path d="M9 6l6 6-6 6" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
import type { PublicCampFacts } from "@/lib/camp";
|
import type { PublicCampFacts } from "@/lib/camp";
|
||||||
|
import type { LogoImage } from "@/lib/site-media";
|
||||||
import { Logo } from "./Logo";
|
import { Logo } from "./Logo";
|
||||||
|
|
||||||
export function SiteFooter({ facts, showDrafts, logo }: { facts: PublicCampFacts; showDrafts: boolean; logo: string | null }) {
|
export function SiteFooter({ facts, showDrafts, logo }: { facts: PublicCampFacts; showDrafts: boolean; logo: LogoImage | null }) {
|
||||||
const organizer = facts.organizer;
|
const organizer = facts.organizer;
|
||||||
return (
|
return (
|
||||||
<footer id="site-footer" className="border-t border-line bg-plaster">
|
<footer id="site-footer" className="border-t border-line bg-plaster">
|
||||||
<div className="container-edge grid gap-10 py-14 md:grid-cols-12">
|
<div className="container-edge grid gap-10 py-14 md:grid-cols-12">
|
||||||
<div className="md:col-span-5">
|
<div className="md:col-span-5">
|
||||||
<p className="flex h-20 items-center text-2xl">
|
<p className="flex h-32 items-center text-2xl">
|
||||||
<Logo src={logo} />
|
<Logo logo={logo} />
|
||||||
</p>
|
</p>
|
||||||
<p className="mt-1 text-stone">Modelcamp 2027</p>
|
<p className="mt-1 text-stone">Modelcamp 2027</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { LazyMotion, domAnimation, m } from "motion/react";
|
import { LazyMotion, domAnimation, m } from "motion/react";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { NAV_ITEMS } from "@/content/site";
|
import { NAV_ITEMS } from "@/content/site";
|
||||||
|
import type { LogoImage } from "@/lib/site-media";
|
||||||
import { Logo } from "./Logo";
|
import { Logo } from "./Logo";
|
||||||
|
|
||||||
const LEFT = NAV_ITEMS.slice(0, 3);
|
const LEFT = NAV_ITEMS.slice(0, 3);
|
||||||
@@ -15,7 +16,7 @@ type NavItem = (typeof NAV_ITEMS)[number];
|
|||||||
* rechts. Ueber dem Headerbild transparent mit heller Schrift, nach dem
|
* rechts. Ueber dem Headerbild transparent mit heller Schrift, nach dem
|
||||||
* Scrollen auf hellem Grund.
|
* Scrollen auf hellem Grund.
|
||||||
*/
|
*/
|
||||||
export function SiteHeader({ logoLight, logoDark }: { logoLight: string | null; logoDark: string | null }) {
|
export function SiteHeader({ logoLight, logoDark }: { logoLight: LogoImage | null; logoDark: LogoImage | null }) {
|
||||||
const [active, setActive] = useState<string | null>(null);
|
const [active, setActive] = useState<string | null>(null);
|
||||||
const [scrolled, setScrolled] = useState(false);
|
const [scrolled, setScrolled] = useState(false);
|
||||||
const [menuOpen, setMenuOpen] = useState(false);
|
const [menuOpen, setMenuOpen] = useState(false);
|
||||||
@@ -83,7 +84,7 @@ export function SiteHeader({ logoLight, logoDark }: { logoLight: string | null;
|
|||||||
</a>
|
</a>
|
||||||
<LazyMotion features={domAnimation}>
|
<LazyMotion features={domAnimation}>
|
||||||
<div
|
<div
|
||||||
className={`container-edge grid grid-cols-[1fr_auto_1fr] items-center gap-4 transition-[height] duration-300 ${solid ? "h-20" : "h-24 md:h-32"}`}
|
className={`container-edge grid grid-cols-[1fr_auto_1fr] items-center gap-4 transition-[height] duration-300 ${solid ? "h-24" : "h-32 md:h-48"}`}
|
||||||
>
|
>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<button
|
<button
|
||||||
@@ -105,9 +106,9 @@ export function SiteHeader({ logoLight, logoDark }: { logoLight: string | null;
|
|||||||
<a
|
<a
|
||||||
href="#top"
|
href="#top"
|
||||||
aria-label="ARTISTA Modelcamp 2027, zum Seitenanfang"
|
aria-label="ARTISTA Modelcamp 2027, zum Seitenanfang"
|
||||||
className={`flex items-center text-xl transition-[height] duration-300 md:text-2xl ${solid ? "h-16" : "h-20 md:h-28"}`}
|
className={`flex items-center text-xl transition-[height] duration-300 md:text-2xl ${solid ? "h-20" : "h-28 md:h-44"}`}
|
||||||
>
|
>
|
||||||
<Logo src={solid ? logoDark : logoLight} />
|
<Logo logo={solid ? logoDark : logoLight} onPhoto={!solid} />
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div className="flex items-center justify-end gap-7">
|
<div className="flex items-center justify-end gap-7">
|
||||||
|
|||||||
@@ -1,17 +1,23 @@
|
|||||||
import type { Media } from "@/content/site";
|
import type { Media } from "@/content/site";
|
||||||
|
import { optimizedImageUrl } from "@/lib/image-url";
|
||||||
import { MediaFrame } from "./MediaFrame";
|
import { MediaFrame } from "./MediaFrame";
|
||||||
|
|
||||||
|
/** Reels sind hoch und hoechstens ein Drittel breit. */
|
||||||
|
const POSTER_WIDTH = 1080;
|
||||||
|
|
||||||
type Slot = { name: string | null; caption: string | null; poster: Media | null; src: string | null };
|
type Slot = { name: string | null; caption: string | null; poster: Media | null; src: string | null };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ein Video aus dem eigenen Medienverzeichnis, im eigenen Seitenverhaeltnis
|
* Ein Video aus dem eigenen Medienverzeichnis, im eigenen Seitenverhaeltnis
|
||||||
* (quer oder hoch). Es startet nie von selbst; geladen werden vorab nur die
|
* (quer oder hoch). Es startet nie von selbst. Mit Vorschaubild laedt vorab
|
||||||
* Metadaten und das erste Bild als Vorschau (#t=0.1), falls kein
|
* nichts vom Video, ohne nur Metadaten und erstes Bild (#t=0.1). Kein
|
||||||
* Vorschaubild hinterlegt ist. Kein externer Anbieter.
|
* externer Anbieter.
|
||||||
*/
|
*/
|
||||||
export function VideoSlot({ slot, index, showDrafts }: { slot: Slot; index: number; showDrafts: boolean }) {
|
export function VideoSlot({ slot, index, showDrafts }: { slot: Slot; index: number; showDrafts: boolean }) {
|
||||||
const label = slot.name ? `Video von ${slot.name}` : `Video ${index + 1}`;
|
const label = slot.name ? `Video von ${slot.name}` : `Video ${index + 1}`;
|
||||||
const poster = slot.poster?.kind === "image" ? slot.poster.src : undefined;
|
// Vorschaubild ueber die Bildoptimierung statt im Original (ein Reel-PNG
|
||||||
|
// hatte 1,3 MB); mit Vorschaubild laedt vom Video vorab nichts.
|
||||||
|
const poster = slot.poster?.kind === "image" ? optimizedImageUrl(slot.poster.src, POSTER_WIDTH) : undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<figure>
|
<figure>
|
||||||
@@ -21,7 +27,7 @@ export function VideoSlot({ slot, index, showDrafts }: { slot: Slot; index: numb
|
|||||||
poster={poster}
|
poster={poster}
|
||||||
controls
|
controls
|
||||||
playsInline
|
playsInline
|
||||||
preload="metadata"
|
preload={poster ? "none" : "metadata"}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
className="mx-auto block max-h-[80vh] w-full rounded-2xl bg-ink object-contain"
|
className="mx-auto block max-h-[80vh] w-full rounded-2xl bg-ink object-contain"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useRef, useState, type FormEvent } from "react";
|
||||||
|
|
||||||
|
type Status = { kind: "idle" } | { kind: "sending" } | { kind: "sent" } | { kind: "error"; message: string };
|
||||||
|
type Fields = Record<string, string>;
|
||||||
|
|
||||||
|
const FIELD_IDS = ["name", "email", "phone", "availability", "message", "privacy"] as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Anfrage fuer ein unverbindliches Erstgespraech (POST /api/contact). Die
|
||||||
|
* Pruefung passiert auf dem Server; Fehler erscheinen am jeweiligen Feld,
|
||||||
|
* der Fokus springt auf das erste fehlerhafte. Das Feld "website" ist eine
|
||||||
|
* fuer Menschen unsichtbare Falle fuer Bots.
|
||||||
|
*/
|
||||||
|
export function ContactSection() {
|
||||||
|
const formRef = useRef<HTMLFormElement>(null);
|
||||||
|
const [status, setStatus] = useState<Status>({ kind: "idle" });
|
||||||
|
const [errors, setErrors] = useState<Fields>({});
|
||||||
|
|
||||||
|
async function submit(event: FormEvent<HTMLFormElement>) {
|
||||||
|
event.preventDefault();
|
||||||
|
const form = new FormData(event.currentTarget);
|
||||||
|
const text = (key: string) => String(form.get(key) ?? "");
|
||||||
|
setStatus({ kind: "sending" });
|
||||||
|
setErrors({});
|
||||||
|
try {
|
||||||
|
const response = await fetch("/api/contact", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({
|
||||||
|
name: text("name"),
|
||||||
|
email: text("email"),
|
||||||
|
phone: text("phone"),
|
||||||
|
availability: text("availability"),
|
||||||
|
message: text("message"),
|
||||||
|
privacy: form.get("privacy") === "on",
|
||||||
|
website: text("website"),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
const result = (await response.json().catch(() => null)) as { success: boolean; error?: { message: string; fields?: Fields } } | null;
|
||||||
|
if (response.ok && result?.success) {
|
||||||
|
setStatus({ kind: "sent" });
|
||||||
|
formRef.current?.reset();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const fields = result?.error?.fields ?? {};
|
||||||
|
setErrors(fields);
|
||||||
|
setStatus({ kind: "error", message: result?.error?.message ?? "Senden hat nicht geklappt. Bitte versuche es erneut." });
|
||||||
|
const first = FIELD_IDS.find((id) => fields[id]);
|
||||||
|
if (first) requestAnimationFrame(() => document.getElementById(`ct-${first}`)?.focus());
|
||||||
|
} catch {
|
||||||
|
setStatus({ kind: "error", message: "Keine Verbindung. Bitte prüfe dein Internet und versuche es erneut." });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const fieldProps = (id: (typeof FIELD_IDS)[number]) => ({
|
||||||
|
id: `ct-${id}`,
|
||||||
|
name: id,
|
||||||
|
"aria-invalid": errors[id] ? true : undefined,
|
||||||
|
"aria-describedby": errors[id] ? `ct-${id}-error` : undefined,
|
||||||
|
});
|
||||||
|
const error = (id: string) =>
|
||||||
|
errors[id] ? (
|
||||||
|
<p id={`ct-${id}-error`} className="mt-1.5 text-sm font-medium text-rosso">
|
||||||
|
{errors[id]}
|
||||||
|
</p>
|
||||||
|
) : null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section id="erstgespraech" aria-labelledby="erstgespraech-title" className="bg-plaster py-24 md:py-32">
|
||||||
|
<div className="container-edge grid gap-12 md:grid-cols-12">
|
||||||
|
<div className="md:col-span-5">
|
||||||
|
<h2 id="erstgespraech-title" className="section-title">
|
||||||
|
Erstgespräch
|
||||||
|
</h2>
|
||||||
|
<p className="mt-6 max-w-md text-lg text-ink/80">
|
||||||
|
Du bist dir noch unsicher, ob das Modelcamp zu dir passt? Lass uns unverbindlich sprechen. Schreib uns kurz, wann du erreichbar bist, wir melden uns bei dir.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="md:col-span-7">
|
||||||
|
{status.kind === "sent" ? (
|
||||||
|
<div role="status" className="rounded-2xl bg-paper p-8 shadow-[0_1px_0_var(--color-line)]">
|
||||||
|
<p className="text-xl font-bold">Danke, deine Anfrage ist angekommen.</p>
|
||||||
|
<p className="mt-2 text-ink/80">Wir melden uns in den nächsten Tagen bei dir.</p>
|
||||||
|
<button type="button" onClick={() => setStatus({ kind: "idle" })} className="btn btn-quiet mt-6">
|
||||||
|
Weitere Anfrage senden
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<form ref={formRef} onSubmit={submit} noValidate className="relative grid gap-5 rounded-2xl bg-paper p-6 shadow-[0_1px_0_var(--color-line)] md:grid-cols-2 md:p-8">
|
||||||
|
<div>
|
||||||
|
<label className="field-label" htmlFor="ct-name">Name</label>
|
||||||
|
<input {...fieldProps("name")} className="field" autoComplete="name" required maxLength={120} />
|
||||||
|
{error("name")}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="field-label" htmlFor="ct-email">E-Mail</label>
|
||||||
|
<input {...fieldProps("email")} className="field" type="email" autoComplete="email" inputMode="email" required maxLength={200} />
|
||||||
|
{error("email")}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="field-label" htmlFor="ct-phone">Telefon (optional)</label>
|
||||||
|
<input {...fieldProps("phone")} className="field" type="tel" autoComplete="tel" maxLength={60} />
|
||||||
|
{error("phone")}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="field-label" htmlFor="ct-availability">Wann bist du erreichbar? (optional)</label>
|
||||||
|
<input {...fieldProps("availability")} className="field" placeholder="z. B. werktags ab 18 Uhr" maxLength={200} />
|
||||||
|
{error("availability")}
|
||||||
|
</div>
|
||||||
|
<div className="md:col-span-2">
|
||||||
|
<label className="field-label" htmlFor="ct-message">Worüber möchtest du sprechen? (optional)</label>
|
||||||
|
<textarea {...fieldProps("message")} className="field min-h-32" rows={4} maxLength={2000} />
|
||||||
|
{error("message")}
|
||||||
|
</div>
|
||||||
|
{/* Falle fuer Bots: nicht sichtbar, nicht per Tab erreichbar. */}
|
||||||
|
<div aria-hidden className="absolute -left-[9999px] h-px w-px overflow-hidden">
|
||||||
|
<label htmlFor="ct-website">Webseite</label>
|
||||||
|
<input id="ct-website" name="website" tabIndex={-1} autoComplete="off" />
|
||||||
|
</div>
|
||||||
|
<div className="md:col-span-2">
|
||||||
|
<label htmlFor="ct-privacy" className="flex cursor-pointer gap-3 text-[0.9375rem] leading-snug">
|
||||||
|
<input {...fieldProps("privacy")} type="checkbox" required className="mt-0.5 h-5 w-5 shrink-0 accent-ink" />
|
||||||
|
<span>
|
||||||
|
Ich bin einverstanden, dass meine Angaben zur Bearbeitung der Anfrage verwendet werden (
|
||||||
|
<a href="/datenschutz" target="_blank" rel="noopener" className="underline">
|
||||||
|
Datenschutzhinweise
|
||||||
|
</a>
|
||||||
|
).
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
{error("privacy")}
|
||||||
|
</div>
|
||||||
|
{status.kind === "error" && (
|
||||||
|
<p role="alert" className="rounded-lg border border-rosso/40 bg-plaster p-4 text-[0.9375rem] font-medium text-rosso md:col-span-2">
|
||||||
|
{status.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
<div className="md:col-span-2">
|
||||||
|
<button type="submit" disabled={status.kind === "sending"} className="btn btn-primary px-8 disabled:opacity-60">
|
||||||
|
{status.kind === "sending" ? "Wird gesendet …" : "Erstgespräch anfragen"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { optimizedImageUrl } from "@/lib/image-url";
|
||||||
|
import type { IntroVideo } from "@/lib/site-media";
|
||||||
|
|
||||||
|
/** Breite des Vorschaubilds: scharf bis zur vollen Inhaltsbreite. */
|
||||||
|
const POSTER_WIDTH = 1920;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Video direkt unter dem Headerbild (intro.mp4 im Medienverzeichnis,
|
||||||
|
* Vorschaubild intro.jpg, docs/MEDIEN.md). Startet nur nach Klick. Mit
|
||||||
|
* Vorschaubild laedt der Browser vorher gar nichts vom Video
|
||||||
|
* (preload="none"); ohne wird nur das erste Bild als Vorschau geholt.
|
||||||
|
*/
|
||||||
|
export function IntroVideoSection({ video, showDrafts }: { video: IntroVideo; showDrafts: boolean }) {
|
||||||
|
if (!video.src) {
|
||||||
|
if (!showDrafts) return null;
|
||||||
|
return (
|
||||||
|
<section aria-label="Video" className="bg-ink py-12 text-paper/70 md:py-16">
|
||||||
|
<p className="container-edge text-center">
|
||||||
|
<span className="draft-flag">Platzhalter:</span> Hier erscheint das Video, sobald <code>intro.mp4</code> im Medienverzeichnis liegt.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const poster = video.poster?.kind === "image" ? optimizedImageUrl(video.poster.src, POSTER_WIDTH) : undefined;
|
||||||
|
return (
|
||||||
|
<section aria-label="Video" className="bg-ink py-12 md:py-20">
|
||||||
|
<div className="container-edge">
|
||||||
|
<video
|
||||||
|
src={poster ? video.src : `${video.src}#t=0.1`}
|
||||||
|
poster={poster}
|
||||||
|
controls
|
||||||
|
playsInline
|
||||||
|
preload={poster ? "none" : "metadata"}
|
||||||
|
aria-label="Video ARTISTA Modelcamp"
|
||||||
|
// Eigenes Seitenverhaeltnis (quer oder hoch), wie bei den Reels.
|
||||||
|
className="mx-auto block max-h-[85vh] w-full rounded-2xl bg-black object-contain"
|
||||||
|
>
|
||||||
|
<track kind="captions" />
|
||||||
|
</video>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
+3
-2
@@ -193,7 +193,8 @@ export const site = {
|
|||||||
"Eigener Außenpool (saisonal)",
|
"Eigener Außenpool (saisonal)",
|
||||||
"Großer Garten mit Terrasse",
|
"Großer Garten mit Terrasse",
|
||||||
"Blick auf die Berge",
|
"Blick auf die Berge",
|
||||||
"Gemeinsames Wohnzimmer und gut ausgestattete Küche",
|
"Gemeinsames Wohnzimmer",
|
||||||
|
"Tennisplatz",
|
||||||
"Bettwäsche und Handtücher",
|
"Bettwäsche und Handtücher",
|
||||||
"WLAN",
|
"WLAN",
|
||||||
],
|
],
|
||||||
@@ -230,7 +231,6 @@ export const site = {
|
|||||||
{ slug: "lola-stoll", name: "Lola Stoll", role: "Editorial Model · UGC · GNTM 2026", bio: null as string | null, portrait: portrait("Lola Stoll", "LS") },
|
{ slug: "lola-stoll", name: "Lola Stoll", role: "Editorial Model · UGC · GNTM 2026", bio: null as string | null, portrait: portrait("Lola Stoll", "LS") },
|
||||||
{ slug: "eileen-kaupp", name: "Eileen Kaupp", role: "Editorial Model · Fashion · GNTM 2026", bio: null as string | null, portrait: portrait("Eileen Kaupp", "EK") },
|
{ slug: "eileen-kaupp", name: "Eileen Kaupp", role: "Editorial Model · Fashion · GNTM 2026", bio: null as string | null, portrait: portrait("Eileen Kaupp", "EK") },
|
||||||
{ slug: "gabriela-pronkin", name: "Gabriela Pronkin", role: "Commercial · Casual Model · UGC", bio: null as string | null, portrait: portrait("Gabriela Pronkin", "GP") },
|
{ slug: "gabriela-pronkin", name: "Gabriela Pronkin", role: "Commercial · Casual Model · UGC", bio: null as string | null, portrait: portrait("Gabriela Pronkin", "GP") },
|
||||||
{ slug: "stefan-hoechtl", name: "Stefan Höchtl", role: "Social Media Content Creator", bio: null as string | null, portrait: portrait("Stefan Höchtl", "SH") },
|
|
||||||
{ slug: "saskia-sirowatka", name: "Saskia Sirowatka", role: "Social Media Managerin", bio: null as string | null, portrait: portrait("Saskia Sirowatka", "SS") },
|
{ slug: "saskia-sirowatka", name: "Saskia Sirowatka", role: "Social Media Managerin", bio: null as string | null, portrait: portrait("Saskia Sirowatka", "SS") },
|
||||||
{ slug: "andre-hartshauser", name: "André Hartshauser", role: "Workshop-Organisation · Assistenz Küche", bio: null as string | null, portrait: portrait("André Hartshauser", "AH") },
|
{ slug: "andre-hartshauser", name: "André Hartshauser", role: "Workshop-Organisation · Assistenz Küche", bio: null as string | null, portrait: portrait("André Hartshauser", "AH") },
|
||||||
{ slug: "ante-rejo", name: "Ante Rejo", role: "Chefkoch", bio: null as string | null, portrait: portrait("Ante Rejo", "AR") },
|
{ slug: "ante-rejo", name: "Ante Rejo", role: "Chefkoch", bio: null as string | null, portrait: portrait("Ante Rejo", "AR") },
|
||||||
@@ -271,4 +271,5 @@ export const NAV_ITEMS = [
|
|||||||
{ id: "preis", label: "Preis" },
|
{ id: "preis", label: "Preis" },
|
||||||
{ id: "team", label: "Team" },
|
{ id: "team", label: "Team" },
|
||||||
{ id: "fragen", label: "Fragen" },
|
{ id: "fragen", label: "Fragen" },
|
||||||
|
{ id: "erstgespraech", label: "Erstgespräch" },
|
||||||
] as const;
|
] as const;
|
||||||
@@ -15,6 +15,7 @@ import { enqueueEmail } from "./email";
|
|||||||
import { bookingConfirmedEmail } from "./email-templates";
|
import { bookingConfirmedEmail } from "./email-templates";
|
||||||
import type { PaymentGateway } from "./payment-gateway";
|
import type { PaymentGateway } from "./payment-gateway";
|
||||||
import { getCamp } from "./camp";
|
import { getCamp } from "./camp";
|
||||||
|
import { stopCanceledInstallmentPlans } from "./installment-billing";
|
||||||
import { addDays, berlinStartOfDay, isoToDbDate } from "./time";
|
import { addDays, berlinStartOfDay, isoToDbDate } from "./time";
|
||||||
import { statusTokenFor } from "./tokens";
|
import { statusTokenFor } from "./tokens";
|
||||||
import { normalizeEmail, normalizeVoucherCode } from "./vouchers";
|
import { normalizeEmail, normalizeVoucherCode } from "./vouchers";
|
||||||
@@ -54,10 +55,17 @@ export async function cancelBooking(
|
|||||||
});
|
});
|
||||||
if (!before) return { ok: false, message: "Buchung nicht gefunden oder bereits storniert." };
|
if (!before) return { ok: false, message: "Buchung nicht gefunden oder bereits storniert." };
|
||||||
|
|
||||||
// Offene Stripe-Sessions schliessen und gespeicherte Zahlungsmethode
|
// Offene Session schliessen, Stripe-Ratenplan beenden und gespeicherte
|
||||||
// trennen: nach einer Stornierung darf nichts mehr abgebucht werden.
|
// Zahlungsmethode trennen: nach einer Stornierung darf nichts mehr
|
||||||
const sessions = [before.stripeCheckoutSessionId, ...before.installments.map((i) => i.checkoutSessionId)].filter(Boolean) as string[];
|
// abgebucht werden.
|
||||||
for (const id of sessions) await gateway.expireCheckoutSession(id).catch(() => undefined);
|
if (before.stripeCheckoutSessionId) await gateway.expireCheckoutSession(before.stripeCheckoutSessionId).catch(() => undefined);
|
||||||
|
const plan = await stopCanceledInstallmentPlans(db, gateway, [before.id], actor);
|
||||||
|
if (plan.failed > 0) {
|
||||||
|
return {
|
||||||
|
ok: false,
|
||||||
|
message: "Buchung storniert, aber der Ratenplan bei Stripe ließ sich noch nicht beenden. Der Hintergrundlauf versucht es alle 10 Minuten erneut.",
|
||||||
|
};
|
||||||
|
}
|
||||||
await detachFinishedPaymentMethods(db, gateway, [before.id]);
|
await detachFinishedPaymentMethods(db, gateway, [before.id]);
|
||||||
return { ok: true, message: "Buchung storniert. Eine Erstattung wird separat ausgelöst." };
|
return { ok: true, message: "Buchung storniert. Eine Erstattung wird separat ausgelöst." };
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-62
@@ -120,77 +120,32 @@ export async function startCheckout(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type InstallmentCheckoutResult =
|
export type InstallmentPaymentResult = { ok: true; url: string } | { ok: false; error: "NOT_PAYABLE" | "PAYMENT_PROVIDER" };
|
||||||
| { ok: true; url: string }
|
|
||||||
| { ok: false; error: "NOT_PAYABLE" | "PAYMENT_PROVIDER" };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kundin zahlt eine Folgerate selbst (nach fehlgeschlagenem Einzug, bei
|
* Kundin zahlt eine Folgerate selbst (nach fehlgeschlagenem Einzug oder bei
|
||||||
* verlangter Authentifizierung oder freiwillig vorzeitig). Die Rate wird
|
* verlangter Bestaetigung). Bezahlt wird die offene Stripe-Rechnung dieser
|
||||||
* fuer die Laufzeit der Session markiert, damit der Worker sie nicht
|
* Rate ueber Stripes Rechnungsseite — auch mit einer anderen Zahlungsmethode.
|
||||||
* gleichzeitig off-session einzieht.
|
* Eine eigene Checkout-Session gibt es bewusst nicht: Stripe wuerde die
|
||||||
|
* Rechnung sonst parallel weiter einziehen.
|
||||||
*/
|
*/
|
||||||
export async function startInstallmentCheckout(
|
export async function installmentPaymentUrl(
|
||||||
db: Db,
|
db: Db,
|
||||||
gateway: PaymentGateway,
|
gateway: PaymentGateway,
|
||||||
params: { bookingId: string; installmentId: string },
|
params: { bookingId: string; installmentId: string },
|
||||||
ctx: { now: Date; secret: string },
|
): Promise<InstallmentPaymentResult> {
|
||||||
): Promise<InstallmentCheckoutResult> {
|
const installment = await db.installment.findFirst({
|
||||||
const sessionExpiresAt = new Date(ctx.now.getTime() + MIN_STRIPE_SESSION_MS + 60_000);
|
where: { id: params.installmentId, bookingId: params.bookingId, seq: { gt: 1 } },
|
||||||
|
include: { booking: { select: { status: true } } },
|
||||||
const claim = await db.$transaction(async (tx) => {
|
|
||||||
await lockBooking(tx, params.bookingId);
|
|
||||||
const booking = await tx.booking.findUniqueOrThrow({
|
|
||||||
where: { id: params.bookingId },
|
|
||||||
include: { installments: true },
|
|
||||||
});
|
|
||||||
const installment = booking.installments.find((i) => i.id === params.installmentId);
|
|
||||||
if (!installment || installment.seq === 1) return null;
|
|
||||||
if (booking.status !== "CONFIRMED" || !booking.stripeCustomerId) return null;
|
|
||||||
if (!["PENDING", "FAILED", "REQUIRES_ACTION"].includes(installment.status)) return null;
|
|
||||||
if (booking.paidCents + installment.amountCents > booking.totalCents) return null;
|
|
||||||
if (installment.checkoutSessionId && installment.checkoutExpiresAt && installment.checkoutExpiresAt > new Date(ctx.now.getTime() + 5 * 60_000)) {
|
|
||||||
return { booking, installment, existingSessionId: installment.checkoutSessionId };
|
|
||||||
}
|
|
||||||
await tx.installment.update({
|
|
||||||
where: { id: installment.id },
|
|
||||||
data: { checkoutExpiresAt: sessionExpiresAt, checkoutSessionId: null },
|
|
||||||
});
|
|
||||||
return { booking, installment, existingSessionId: null as string | null };
|
|
||||||
});
|
});
|
||||||
if (!claim) return { ok: false, error: "NOT_PAYABLE" };
|
if (!installment?.stripeInvoiceId || installment.booking.status !== "CONFIRMED") return { ok: false, error: "NOT_PAYABLE" };
|
||||||
|
if (installment.status !== "FAILED" && installment.status !== "REQUIRES_ACTION") return { ok: false, error: "NOT_PAYABLE" };
|
||||||
const { booking, installment } = claim;
|
|
||||||
try {
|
try {
|
||||||
if (claim.existingSessionId) {
|
const invoice = await gateway.retrieveInvoice(installment.stripeInvoiceId);
|
||||||
const existing = await gateway.retrieveCheckoutSession(claim.existingSessionId);
|
if (invoice.status !== "open" || !invoice.hostedInvoiceUrl) return { ok: false, error: "NOT_PAYABLE" };
|
||||||
if (existing.status === "open" && existing.url) return { ok: true, url: existing.url };
|
return { ok: true, url: invoice.hostedInvoiceUrl };
|
||||||
}
|
|
||||||
const token = statusTokenFor(booking.id, ctx.secret);
|
|
||||||
const session = await gateway.createCheckoutSession(
|
|
||||||
{
|
|
||||||
customerId: booking.stripeCustomerId!,
|
|
||||||
amountCents: installment.amountCents,
|
|
||||||
productName: PRODUCT_NAME,
|
|
||||||
description: `${PRODUCT_DESCRIPTION} · Rate ${installment.seq} von ${booking.installments.length}`,
|
|
||||||
metadata: { kind: "installment", bookingId: booking.id, reference: booking.reference, installmentId: installment.id },
|
|
||||||
saveForFutureUsage: booking.installments.some((i) => i.seq > installment.seq && i.status !== "PAID"),
|
|
||||||
expiresAt: sessionExpiresAt,
|
|
||||||
successUrl: appUrl(`/buchung/status/${token}?checkout=success`),
|
|
||||||
cancelUrl: appUrl(`/buchung/status/${token}`),
|
|
||||||
submitMessage: `Rate ${installment.seq} über ${formatEuro(installment.amountCents)} für Buchung ${booking.reference}.`,
|
|
||||||
},
|
|
||||||
`installment-checkout:${installment.id}:${sessionExpiresAt.getTime()}`,
|
|
||||||
);
|
|
||||||
await db.installment.update({ where: { id: installment.id }, data: { checkoutSessionId: session.id } });
|
|
||||||
await audit(db, CUSTOMER, "checkout.installment_session_created", "Installment", installment.id, { sessionId: session.id });
|
|
||||||
return { ok: true, url: session.url };
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`[checkout] Stripe-Fehler fuer Rate ${installment.id}: ${error instanceof Error ? error.message : "unbekannt"}`);
|
console.error(`[checkout] Rechnung fuer Rate ${installment.id} nicht abrufbar: ${error instanceof Error ? error.message : "unbekannt"}`);
|
||||||
await db.installment.updateMany({
|
|
||||||
where: { id: installment.id, checkoutSessionId: null },
|
|
||||||
data: { checkoutExpiresAt: null },
|
|
||||||
});
|
|
||||||
return { ok: false, error: "PAYMENT_PROVIDER" };
|
return { ok: false, error: "PAYMENT_PROVIDER" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* Anfrage fuer ein unverbindliches Erstgespraech. Kein eigenes Datenmodell:
|
||||||
|
* die Anfrage geht als E-Mail in den Postausgang (EmailMessage, mit
|
||||||
|
* Wiederholungen und Anzeige unzustellbarer Mails im Admin) an den
|
||||||
|
* Veranstalter bzw. ADMIN_NOTIFY_EMAIL.
|
||||||
|
*
|
||||||
|
* Bewusst keine automatische Bestaetigungsmail an die angegebene Adresse:
|
||||||
|
* sonst liesse sich das Formular nutzen, um Dritten Mails zu schicken.
|
||||||
|
*/
|
||||||
|
import "./zod-de";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { audit, CUSTOMER } from "./audit";
|
||||||
|
import { getCamp } from "./camp";
|
||||||
|
import type { Db } from "./db";
|
||||||
|
import { enqueueEmail } from "./email";
|
||||||
|
import { contactInquiryEmail } from "./email-templates";
|
||||||
|
import { env } from "./env";
|
||||||
|
import { hmacHex } from "./tokens";
|
||||||
|
|
||||||
|
const optionalText = (max: number) =>
|
||||||
|
z
|
||||||
|
.string()
|
||||||
|
.trim()
|
||||||
|
.max(max)
|
||||||
|
.optional()
|
||||||
|
.transform((v) => v || null);
|
||||||
|
|
||||||
|
export const contactRequestSchema = z.object({
|
||||||
|
name: z.string().trim().min(2, "Bitte gib deinen Namen an.").max(120),
|
||||||
|
email: z.string().trim().max(200).pipe(z.email("Bitte gib eine gültige E-Mail-Adresse an.")),
|
||||||
|
phone: optionalText(60),
|
||||||
|
availability: optionalText(200),
|
||||||
|
message: optionalText(2000),
|
||||||
|
privacy: z.literal(true, { error: "Bitte bestätige die Datenschutzhinweise." }),
|
||||||
|
/** Honeypot: fuer Menschen unsichtbar, Bots fuellen es aus. */
|
||||||
|
website: z.string().max(200).optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ContactRequest = z.infer<typeof contactRequestSchema>;
|
||||||
|
export type ContactResult = { ok: true; delivered: boolean } | { ok: false; error: "NOT_CONFIGURED" };
|
||||||
|
|
||||||
|
/** Empfaenger: Veranstalter-Adresse aus dem Admin, sonst ADMIN_NOTIFY_EMAIL. */
|
||||||
|
export async function contactRecipient(db: Db): Promise<string | null> {
|
||||||
|
const camp = await getCamp(db);
|
||||||
|
return camp.organizerEmail || env().ADMIN_NOTIFY_EMAIL || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function submitContactRequest(db: Db, input: ContactRequest, ctx: { now: Date; secret: string }): Promise<ContactResult> {
|
||||||
|
// Bot: so tun, als waere alles gut, aber nichts verschicken.
|
||||||
|
if (input.website) return { ok: true, delivered: false };
|
||||||
|
const to = await contactRecipient(db);
|
||||||
|
if (!to) return { ok: false, error: "NOT_CONFIGURED" };
|
||||||
|
|
||||||
|
// Doppelt abgeschicktes Formular (gleiche Angaben in derselben Minute)
|
||||||
|
// ergibt nur eine Mail.
|
||||||
|
const minute = Math.floor(ctx.now.getTime() / 60_000);
|
||||||
|
const fingerprint = hmacHex(ctx.secret, `contact:${input.email.toLowerCase()}:${input.message ?? ""}:${minute}`).slice(0, 32);
|
||||||
|
await enqueueEmail(db, contactInquiryEmail(to, input, `contact:${fingerprint}`, ctx.now));
|
||||||
|
await audit(db, CUSTOMER, "contact.requested", "Contact", fingerprint);
|
||||||
|
return { ok: true, delivered: true };
|
||||||
|
}
|
||||||
@@ -3,12 +3,13 @@
|
|||||||
* bestaetigten Status — eine Teilzahlung heisst nie "vollstaendig bezahlt".
|
* bestaetigten Status — eine Teilzahlung heisst nie "vollstaendig bezahlt".
|
||||||
*/
|
*/
|
||||||
import type { Booking, Installment } from "@/generated/prisma/client";
|
import type { Booking, Installment } from "@/generated/prisma/client";
|
||||||
|
import type { ContactRequest } from "./contact";
|
||||||
import { escapeHtml, type EmailDraft } from "./email";
|
import { escapeHtml, type EmailDraft } from "./email";
|
||||||
import { appUrl } from "./env";
|
import { appUrl } from "./env";
|
||||||
import { formatEuro } from "./money";
|
import { formatEuro } from "./money";
|
||||||
import { PLAN_LABEL } from "./payment-plan";
|
import { PLAN_LABEL } from "./payment-plan";
|
||||||
import { PHASE_LABEL } from "./pricing";
|
import { PHASE_LABEL } from "./pricing";
|
||||||
import { formatDate } from "./time";
|
import { formatDate, formatDateTime } from "./time";
|
||||||
|
|
||||||
type BookingWithInstallments = Booking & { installments: Installment[] };
|
type BookingWithInstallments = Booking & { installments: Installment[] };
|
||||||
|
|
||||||
@@ -163,3 +164,20 @@ export function reviewCustomerEmail(booking: Booking, token: string): EmailDraft
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Anfrage fuer ein Erstgespraech an den Veranstalter (src/lib/contact.ts). */
|
||||||
|
export function contactInquiryEmail(to: string, inquiry: ContactRequest, dedupeKey: string, receivedAt: Date): EmailDraft {
|
||||||
|
const subject = `Anfrage Erstgespräch: ${inquiry.name}`;
|
||||||
|
const lines = [
|
||||||
|
`Über die Webseite kam eine Anfrage für ein Erstgespräch (${formatDateTime(receivedAt)}).`,
|
||||||
|
[
|
||||||
|
`Name: ${inquiry.name}`,
|
||||||
|
`E-Mail: ${inquiry.email}`,
|
||||||
|
`Telefon: ${inquiry.phone ?? "–"}`,
|
||||||
|
`Erreichbar: ${inquiry.availability ?? "–"}`,
|
||||||
|
].join("\n"),
|
||||||
|
inquiry.message ? `Nachricht:\n${inquiry.message}` : "Keine Nachricht angegeben.",
|
||||||
|
];
|
||||||
|
const reply = `mailto:${encodeURIComponent(inquiry.email)}?subject=${encodeURIComponent(`Dein Erstgespräch – ${BRAND}`)}`;
|
||||||
|
return { dedupeKey, to, subject: `${subject} | ${BRAND}`, ...wrap(subject, lines, { href: reply, label: "Antworten" }) };
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* URL eines Bildes ueber die Next.js-Bildoptimierung (AVIF/WebP, passende
|
||||||
|
* Breite) fuer Stellen, an denen kein <Image> moeglich ist, etwa das
|
||||||
|
* poster-Attribut von <video>. Ein 15-MB-Foto aus dem Medienverzeichnis wird
|
||||||
|
* so als wenige Dutzend Kilobyte ausgeliefert statt im Original.
|
||||||
|
*/
|
||||||
|
import { getImageProps } from "next/image";
|
||||||
|
|
||||||
|
/** Liefert eine Variante mit mindestens `width` Pixeln Breite. */
|
||||||
|
export function optimizedImageUrl(src: string, width: number): string {
|
||||||
|
// getImageProps gibt als src die 2x-Variante der angegebenen Breite
|
||||||
|
// zurueck; mit halber Breite entspricht sie der gewuenschten.
|
||||||
|
const half = Math.ceil(width / 2);
|
||||||
|
return getImageProps({ src, alt: "", width: half, height: half, quality: 75 }).props.src;
|
||||||
|
}
|
||||||
@@ -0,0 +1,246 @@
|
|||||||
|
/**
|
||||||
|
* Folgeraten ueber Stripe Billing (docs/ARCHITEKTUR.md, ADR-3).
|
||||||
|
*
|
||||||
|
* Nach der bezahlten ersten Rate wird bei Stripe ein Subscription Schedule
|
||||||
|
* angelegt, der die Folgeraten zu ihren Faelligkeiten einzieht. Ab dann
|
||||||
|
* kuemmert sich Stripe um Einzug, Wiederholungen und Mahnungen; diese
|
||||||
|
* Anwendung verbucht nur die Rechnungen (Webhook, Abgleich im Worker).
|
||||||
|
*
|
||||||
|
* Voraussetzung, die payment-plan.ts garantiert: Alle Folgeraten sind gleich
|
||||||
|
* hoch (ein etwaiger Rest steckt in der ersten Rate). Der Zeitplan besteht
|
||||||
|
* deshalb aus einem einzigen Preis mit dem Ratenabstand in Tagen als
|
||||||
|
* Intervall und endet nach der letzten Rate von selbst.
|
||||||
|
*/
|
||||||
|
import { audit, WORKER, type Actor } from "./audit";
|
||||||
|
import type { Db } from "./db";
|
||||||
|
import { applyInstallmentInvoicePaid, flagBookingForReview, type EventContext } from "./payment-events";
|
||||||
|
import type { InvoiceInfo, PaymentGateway } from "./payment-gateway";
|
||||||
|
import { lockBooking } from "./booking-service";
|
||||||
|
import { CHARGE_HOUR_BERLIN } from "./payment-plan";
|
||||||
|
import { addDays, berlinDateString, berlinStartOfDay, daysBetween } from "./time";
|
||||||
|
|
||||||
|
export const INSTALLMENT_PLAN_KIND = "installment_plan";
|
||||||
|
/** Stripe verlangt einen Start in der Zukunft. */
|
||||||
|
const MIN_START_LEAD_MS = 60_000;
|
||||||
|
|
||||||
|
export type ScheduleOutcome = "created" | "exists" | "skipped" | "needs_review";
|
||||||
|
|
||||||
|
type Ctx = Pick<EventContext, "now" | "secret" | "adminEmail">;
|
||||||
|
|
||||||
|
export async function ensureInstallmentSchedule(
|
||||||
|
db: Db,
|
||||||
|
gateway: PaymentGateway,
|
||||||
|
bookingId: string,
|
||||||
|
ctx: Ctx,
|
||||||
|
actor: Actor,
|
||||||
|
): Promise<ScheduleOutcome> {
|
||||||
|
const booking = await db.booking.findUniqueOrThrow({
|
||||||
|
where: { id: bookingId },
|
||||||
|
include: { installments: { orderBy: { seq: "asc" } } },
|
||||||
|
});
|
||||||
|
if (booking.stripeScheduleId) return "exists";
|
||||||
|
if (booking.planType === "FULL" || booking.status !== "CONFIRMED") return "skipped";
|
||||||
|
if (booking.livemode !== (gateway.mode === "live")) return "skipped";
|
||||||
|
const later = booking.installments.filter((i) => i.seq > 1 && i.status === "PENDING");
|
||||||
|
if (later.length === 0) return "skipped";
|
||||||
|
|
||||||
|
const problem = schedulePlanProblem(booking, later, ctx.now);
|
||||||
|
if (problem) {
|
||||||
|
await db.$transaction((tx) => flagBookingForReview(tx, booking.id, problem, { ...ctx, actor }));
|
||||||
|
return "needs_review";
|
||||||
|
}
|
||||||
|
|
||||||
|
const first = later[0]!;
|
||||||
|
const startAt = scheduleStart(first.dueAt!, ctx.now);
|
||||||
|
const intervalDays =
|
||||||
|
later.length === 1 ? 1 : daysBetween(berlinDateString(startAt), berlinDateString(later.at(-1)!.dueAt!));
|
||||||
|
if (intervalDays < 1) {
|
||||||
|
const reason = "Bis zur letzten Rate bleibt kein Abstand mehr – Ratenplan bei Stripe nicht angelegt.";
|
||||||
|
await db.$transaction((tx) => flagBookingForReview(tx, booking.id, reason, { ...ctx, actor }));
|
||||||
|
return "needs_review";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schutz gegen einen zweiten Plan, auch wenn das Speichern der ID frueher
|
||||||
|
// scheiterte und der Idempotenzschluessel (24 h) abgelaufen ist.
|
||||||
|
const existing = await gateway.findInstallmentSchedule(booking.stripeCustomerId!, booking.id);
|
||||||
|
// Nach einer Pruefung entsteht ein neuer Plan; ohne Generation lieferte
|
||||||
|
// Stripe zum alten Schluessel den bereits beendeten Plan zurueck.
|
||||||
|
const generation = await db.auditLog.count({
|
||||||
|
where: { entityType: "Booking", entityId: booking.id, action: "installments.schedule_held_for_review" },
|
||||||
|
});
|
||||||
|
const schedule =
|
||||||
|
existing ??
|
||||||
|
(await gateway.createInstallmentSchedule(
|
||||||
|
{
|
||||||
|
customerId: booking.stripeCustomerId!,
|
||||||
|
paymentMethodId: booking.stripePaymentMethodId!,
|
||||||
|
startAt,
|
||||||
|
amountCents: first.amountCents,
|
||||||
|
intervalDays,
|
||||||
|
count: later.length,
|
||||||
|
description: `ARTISTA MODELCAMP 2027 · ${booking.reference} · Folgerate`,
|
||||||
|
metadata: { kind: INSTALLMENT_PLAN_KIND, bookingId: booking.id, reference: booking.reference },
|
||||||
|
},
|
||||||
|
// startAt ist fuer alle gleichzeitigen Aufrufer gleich (Faelligkeit
|
||||||
|
// oder naechster 9-Uhr-Termin), der Schluessel also auch.
|
||||||
|
`schedule:${booking.id}:${generation}:${startAt.getTime()}`,
|
||||||
|
));
|
||||||
|
|
||||||
|
const saved = await db.booking.updateMany({
|
||||||
|
where: { id: booking.id, stripeScheduleId: null },
|
||||||
|
data: { stripeScheduleId: schedule.id },
|
||||||
|
});
|
||||||
|
if (saved.count === 0) return "exists";
|
||||||
|
await audit(db, actor, "installments.schedule_created", "Booking", booking.id, {
|
||||||
|
scheduleId: schedule.id,
|
||||||
|
startAt: startAt.toISOString(),
|
||||||
|
intervalDays,
|
||||||
|
count: later.length,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Wurde die Buchung waehrenddessen storniert, sofort wieder beenden.
|
||||||
|
const current = await db.booking.findUniqueOrThrow({ where: { id: booking.id }, select: { status: true } });
|
||||||
|
if (current.status === "CANCELED") await gateway.cancelInstallmentSchedule(schedule.id);
|
||||||
|
return "created";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start des Plans: die Faelligkeit der naechsten Rate. Ist sie schon vorbei
|
||||||
|
* (Buchung erst nach Pruefung bestaetigt), der naechste 9-Uhr-Termin in
|
||||||
|
* Berlin — deterministisch, damit Wiederholungen denselben Plan meinen.
|
||||||
|
*/
|
||||||
|
function scheduleStart(dueAt: Date, now: Date): Date {
|
||||||
|
const earliest = now.getTime() + MIN_START_LEAD_MS;
|
||||||
|
if (dueAt.getTime() >= earliest) return dueAt;
|
||||||
|
const today = berlinDateString(now);
|
||||||
|
const todayAtNine = berlinStartOfDay(today, CHARGE_HOUR_BERLIN);
|
||||||
|
return todayAtNine.getTime() >= earliest ? todayAtNine : berlinStartOfDay(addDays(today, 1), CHARGE_HOUR_BERLIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Haelt den Stripe-Plan an, solange eine Buchung in Pruefung ist (z. B.
|
||||||
|
* Rueckbuchung, Doppelzahlung): Plan beenden, offene Rechnungen stornieren,
|
||||||
|
* unbezahlte Folgeraten wieder auf PENDING. Bestaetigt ein Mensch die
|
||||||
|
* Buchung, legt createMissingSchedules einen neuen Plan fuer die offenen
|
||||||
|
* Raten an; storniert er, bleibt es dabei.
|
||||||
|
*/
|
||||||
|
export async function holdSchedulesInReview(db: Db, gateway: PaymentGateway, bookingIds?: string[], actor: Actor = WORKER) {
|
||||||
|
const candidates = await db.booking.findMany({
|
||||||
|
where: {
|
||||||
|
status: "NEEDS_REVIEW",
|
||||||
|
stripeScheduleId: { not: null },
|
||||||
|
livemode: gateway.mode === "live",
|
||||||
|
...(bookingIds ? { id: { in: bookingIds } } : {}),
|
||||||
|
},
|
||||||
|
select: { id: true, stripeScheduleId: true },
|
||||||
|
take: 50,
|
||||||
|
});
|
||||||
|
const failed = await eachBooking(candidates, "anhalten", async (booking) => {
|
||||||
|
// Erst bei Stripe beenden; scheitert das, bleibt alles wie es ist und der
|
||||||
|
// naechste Lauf versucht es erneut.
|
||||||
|
await gateway.cancelInstallmentSchedule(booking.stripeScheduleId!);
|
||||||
|
await db.$transaction(async (tx) => {
|
||||||
|
await lockBooking(tx, booking.id);
|
||||||
|
await tx.installment.updateMany({
|
||||||
|
where: { bookingId: booking.id, seq: { gt: 1 }, status: { in: ["PENDING", "FAILED", "REQUIRES_ACTION"] } },
|
||||||
|
data: { status: "PENDING", stripeInvoiceId: null, nextAttemptAt: null },
|
||||||
|
});
|
||||||
|
await tx.booking.update({ where: { id: booking.id }, data: { stripeScheduleId: null } });
|
||||||
|
await audit(tx, actor, "installments.schedule_held_for_review", "Booking", booking.id, { scheduleId: booking.stripeScheduleId });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return { held: candidates.length - failed, failed };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Arbeitet Buchungen einzeln ab: ein Stripe-Fehler bei einer Buchung haelt
|
||||||
|
* weder die uebrigen noch den restlichen Worker-Lauf auf. Liefert die Zahl
|
||||||
|
* der Fehlschlaege.
|
||||||
|
*/
|
||||||
|
export async function eachBooking<T extends { id: string }>(items: T[], label: string, fn: (item: T) => Promise<void>): Promise<number> {
|
||||||
|
let failed = 0;
|
||||||
|
for (const item of items) {
|
||||||
|
try {
|
||||||
|
await fn(item);
|
||||||
|
} catch (error) {
|
||||||
|
failed++;
|
||||||
|
console.error(`[ratenplan] ${label} fuer Buchung ${item.id} fehlgeschlagen: ${error instanceof Error ? error.message : "unbekannt"}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
function schedulePlanProblem(
|
||||||
|
booking: { stripeCustomerId: string | null; stripePaymentMethodId: string | null; paymentMethodDetachedAt: Date | null },
|
||||||
|
later: { amountCents: number; dueAt: Date | null }[],
|
||||||
|
now: Date,
|
||||||
|
): string | null {
|
||||||
|
if (!booking.stripeCustomerId || !booking.stripePaymentMethodId || booking.paymentMethodDetachedAt) {
|
||||||
|
return "Keine gespeicherte Zahlungsmethode für die Folgeraten – Ratenplan bei Stripe nicht angelegt.";
|
||||||
|
}
|
||||||
|
if (later.some((i) => !i.dueAt) || later.some((i) => i.amountCents !== later[0]!.amountCents)) {
|
||||||
|
return "Folgeraten passen nicht zu einem Stripe-Ratenplan (Betrag oder Termin) – bitte prüfen.";
|
||||||
|
}
|
||||||
|
if (later.at(-1)!.dueAt! < now) {
|
||||||
|
return "Termin der letzten Rate ist bereits verstrichen – Ratenplan bei Stripe nicht angelegt.";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Beendet die Stripe-Ratenplaene stornierter Buchungen und trennt danach die
|
||||||
|
* gespeicherte Zahlungsmethode. paymentMethodDetachedAt markiert "erledigt";
|
||||||
|
* scheitert Stripe, bleibt die Buchung Kandidat fuer den naechsten Lauf.
|
||||||
|
*/
|
||||||
|
export async function stopCanceledInstallmentPlans(db: Db, gateway: PaymentGateway, bookingIds?: string[], actor: Actor = WORKER) {
|
||||||
|
const candidates = await db.booking.findMany({
|
||||||
|
where: {
|
||||||
|
status: "CANCELED",
|
||||||
|
stripeScheduleId: { not: null },
|
||||||
|
paymentMethodDetachedAt: null,
|
||||||
|
livemode: gateway.mode === "live",
|
||||||
|
...(bookingIds ? { id: { in: bookingIds } } : {}),
|
||||||
|
},
|
||||||
|
take: 50,
|
||||||
|
});
|
||||||
|
const failed = await eachBooking(candidates, "beenden", async (booking) => {
|
||||||
|
await gateway.cancelInstallmentSchedule(booking.stripeScheduleId!);
|
||||||
|
if (booking.stripePaymentMethodId) await gateway.detachPaymentMethod(booking.stripePaymentMethodId);
|
||||||
|
await db.booking.update({ where: { id: booking.id }, data: { paymentMethodDetachedAt: new Date() } });
|
||||||
|
await audit(db, actor, "installments.schedule_canceled", "Booking", booking.id, { scheduleId: booking.stripeScheduleId });
|
||||||
|
});
|
||||||
|
return { stopped: candidates.length - failed, failed };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verbucht eine bezahlte Rechnung des Zeitplans. Genutzt vom Webhook und vom
|
||||||
|
* Abgleich im Worker; mehrfacher Aufruf ist unschaedlich.
|
||||||
|
*/
|
||||||
|
export async function settleInstallmentInvoice(
|
||||||
|
db: Db,
|
||||||
|
gateway: PaymentGateway,
|
||||||
|
invoice: InvoiceInfo,
|
||||||
|
ctx: Ctx,
|
||||||
|
actor: Actor,
|
||||||
|
): Promise<string | null> {
|
||||||
|
const { kind, bookingId } = invoice.metadata;
|
||||||
|
if (kind !== INSTALLMENT_PLAN_KIND || !bookingId) return null;
|
||||||
|
if (invoice.status !== "paid" || !invoice.paymentIntentId) return null;
|
||||||
|
const pi = await gateway.retrievePaymentIntent(invoice.paymentIntentId);
|
||||||
|
await db.$transaction((tx) =>
|
||||||
|
applyInstallmentInvoicePaid(
|
||||||
|
tx,
|
||||||
|
bookingId,
|
||||||
|
invoice.id,
|
||||||
|
{
|
||||||
|
paymentIntentId: pi.id,
|
||||||
|
chargeId: pi.chargeId,
|
||||||
|
paymentMethodId: pi.paymentMethodId,
|
||||||
|
customerId: null,
|
||||||
|
amountCents: invoice.amountPaidCents,
|
||||||
|
},
|
||||||
|
{ ...ctx, actor },
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return bookingId;
|
||||||
|
}
|
||||||
+65
-28
@@ -31,9 +31,6 @@ import {
|
|||||||
import { statusTokenFor } from "./tokens";
|
import { statusTokenFor } from "./tokens";
|
||||||
import { countUsedRedemptions } from "./vouchers";
|
import { countUsedRedemptions } from "./vouchers";
|
||||||
|
|
||||||
export const MAX_OFF_SESSION_ATTEMPTS = 3;
|
|
||||||
export const RETRY_DELAY_DAYS = 3;
|
|
||||||
|
|
||||||
export type EventContext = { now: Date; secret: string; actor: Actor; adminEmail: string | null };
|
export type EventContext = { now: Date; secret: string; actor: Actor; adminEmail: string | null };
|
||||||
|
|
||||||
export type PaymentInfo = {
|
export type PaymentInfo = {
|
||||||
@@ -66,6 +63,11 @@ async function flagForReview(tx: Tx, booking: Booking, reason: string, ctx: Even
|
|||||||
if (ctx.adminEmail) await enqueueEmail(tx, adminReviewEmail(ctx.adminEmail, booking, reason));
|
if (ctx.adminEmail) await enqueueEmail(tx, adminReviewEmail(ctx.adminEmail, booking, reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Fuer Probleme, die ausserhalb eines Zahlungsereignisses auffallen (z. B. Ratenplan bei Stripe). */
|
||||||
|
export async function flagBookingForReview(tx: Tx, bookingId: string, reason: string, ctx: EventContext): Promise<void> {
|
||||||
|
await flagForReview(tx, await loadLocked(tx, bookingId), reason, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
export type FirstPaymentOutcome = "confirmed" | "duplicate" | "needs_review";
|
export type FirstPaymentOutcome = "confirmed" | "duplicate" | "needs_review";
|
||||||
|
|
||||||
/** Erste Rate (bzw. Einmalzahlung) ist bei Stripe erfolgreich eingegangen. */
|
/** Erste Rate (bzw. Einmalzahlung) ist bei Stripe erfolgreich eingegangen. */
|
||||||
@@ -230,7 +232,7 @@ export async function applyCheckoutExpired(
|
|||||||
|
|
||||||
export type InstallmentPaidOutcome = { outcome: "paid" | "duplicate" | "needs_review"; fullyPaid: boolean };
|
export type InstallmentPaidOutcome = { outcome: "paid" | "duplicate" | "needs_review"; fullyPaid: boolean };
|
||||||
|
|
||||||
/** Folgerate bezahlt (Off-Session-Einzug oder selbst bezahlt per Link). */
|
/** Folgerate bezahlt (ueber ihre Stripe-Rechnung, siehe applyInstallmentInvoicePaid). */
|
||||||
export async function applyInstallmentPaid(
|
export async function applyInstallmentPaid(
|
||||||
tx: Tx,
|
tx: Tx,
|
||||||
installmentId: string,
|
installmentId: string,
|
||||||
@@ -294,47 +296,82 @@ export async function applyInstallmentPaid(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Off-Session-Einzug fehlgeschlagen. Greift nur, solange die Rate vom Worker
|
* Ordnet eine Rechnung des Stripe-Zeitplans ihrer Folgerate zu. Stripe
|
||||||
* beansprucht ist (PROCESSING) — so zaehlt ein Fehler nie doppelt, egal ob
|
* erzeugt die Rechnungen nacheinander (die naechste erst im naechsten
|
||||||
* ihn der Worker direkt oder der Webhook zuerst meldet.
|
* Abrechnungszeitraum), deshalb gehoert eine neue Rechnung zur ersten noch
|
||||||
|
* nicht verknuepften, unbezahlten Rate.
|
||||||
*/
|
*/
|
||||||
export async function applyInstallmentFailed(
|
async function installmentForInvoice(tx: Tx, booking: FullBooking, invoiceId: string): Promise<Installment | null> {
|
||||||
|
const linked = booking.installments.find((i) => i.stripeInvoiceId === invoiceId);
|
||||||
|
if (linked) return linked;
|
||||||
|
const next = booking.installments.find((i) => i.seq > 1 && !i.stripeInvoiceId && i.status !== "PAID");
|
||||||
|
if (!next) return null;
|
||||||
|
return tx.installment.update({ where: { id: next.id }, data: { stripeInvoiceId: invoiceId } });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Stripe Billing hat eine Folgerate eingezogen (automatisch oder von der Kundin ueber die Rechnungsseite bezahlt). */
|
||||||
|
export async function applyInstallmentInvoicePaid(
|
||||||
tx: Tx,
|
tx: Tx,
|
||||||
installmentId: string,
|
bookingId: string,
|
||||||
info: { paymentIntentId: string | null; failureCode: string | null; requiresAction: boolean },
|
invoiceId: string,
|
||||||
|
info: PaymentInfo,
|
||||||
|
ctx: EventContext,
|
||||||
|
): Promise<InstallmentPaidOutcome | "unmatched"> {
|
||||||
|
const booking = await loadLocked(tx, bookingId);
|
||||||
|
const installment = await installmentForInvoice(tx, booking, invoiceId);
|
||||||
|
if (!installment) {
|
||||||
|
await flagForReview(tx, booking, `Zahlung über Rechnung ${invoiceId} passt zu keiner offenen Rate – bitte prüfen und ggf. erstatten.`, ctx);
|
||||||
|
return "unmatched";
|
||||||
|
}
|
||||||
|
return applyInstallmentPaid(tx, installment.id, info, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stripe konnte eine Folgerate nicht einziehen. Stripe versucht es selbst
|
||||||
|
* erneut (Smart Retries) und schickt bei verlangter Bestaetigung (3-D
|
||||||
|
* Secure) einen Link. Hier wird nur der Stand festgehalten, die Kundin
|
||||||
|
* informiert und — wenn Stripe aufgibt — ein Mensch eingeschaltet.
|
||||||
|
*/
|
||||||
|
export async function applyInstallmentInvoiceFailed(
|
||||||
|
tx: Tx,
|
||||||
|
bookingId: string,
|
||||||
|
invoice: { id: string; attemptCount: number; nextPaymentAttempt: Date | null },
|
||||||
|
info: { requiresAction: boolean },
|
||||||
ctx: EventContext,
|
ctx: EventContext,
|
||||||
): Promise<"recorded" | "ignored"> {
|
): Promise<"recorded" | "ignored"> {
|
||||||
const target = await tx.installment.findUniqueOrThrow({ where: { id: installmentId } });
|
const booking = await loadLocked(tx, bookingId);
|
||||||
const booking = await loadLocked(tx, target.bookingId);
|
const installment = await installmentForInvoice(tx, booking, invoice.id);
|
||||||
const installment = booking.installments.find((i) => i.id === installmentId)!;
|
if (!installment || installment.status === "PAID" || installment.status === "CANCELED") return "ignored";
|
||||||
if (installment.status !== "PROCESSING") return "ignored";
|
|
||||||
|
const status = info.requiresAction ? "REQUIRES_ACTION" : "FAILED";
|
||||||
|
// Dasselbe Ergebnis desselben Versuchs (doppelt zugestellt oder als
|
||||||
|
// payment_failed UND payment_action_required gemeldet) nur einmal zaehlen.
|
||||||
|
if (installment.attemptCount >= invoice.attemptCount && installment.status === status) return "ignored";
|
||||||
|
|
||||||
const attempt = installment.attemptCount + 1;
|
|
||||||
const retry = !info.requiresAction && attempt < MAX_OFF_SESSION_ATTEMPTS;
|
|
||||||
const updatedInstallment = await tx.installment.update({
|
const updatedInstallment = await tx.installment.update({
|
||||||
where: { id: installmentId },
|
where: { id: installment.id },
|
||||||
data: {
|
data: {
|
||||||
status: info.requiresAction ? "REQUIRES_ACTION" : "FAILED",
|
status,
|
||||||
attemptCount: attempt,
|
attemptCount: Math.max(invoice.attemptCount, installment.attemptCount),
|
||||||
failureCode: info.failureCode,
|
lastAttemptAt: ctx.now,
|
||||||
stripePaymentIntentId: info.paymentIntentId ?? installment.stripePaymentIntentId,
|
failureCode: info.requiresAction ? "authentication_required" : "payment_failed",
|
||||||
nextAttemptAt: retry ? new Date(ctx.now.getTime() + RETRY_DELAY_DAYS * 86_400_000) : null,
|
nextAttemptAt: invoice.nextPaymentAttempt,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await audit(tx, ctx.actor, "payment.installment_failed", "Installment", installmentId, {
|
await audit(tx, ctx.actor, "payment.installment_failed", "Installment", installment.id, {
|
||||||
bookingId: booking.id,
|
bookingId: booking.id,
|
||||||
seq: installment.seq,
|
seq: installment.seq,
|
||||||
attempt,
|
invoiceId: invoice.id,
|
||||||
failureCode: info.failureCode,
|
attempt: invoice.attemptCount,
|
||||||
requiresAction: info.requiresAction,
|
requiresAction: info.requiresAction,
|
||||||
nextAttemptAt: updatedInstallment.nextAttemptAt?.toISOString() ?? null,
|
nextAttemptAt: invoice.nextPaymentAttempt?.toISOString() ?? null,
|
||||||
});
|
});
|
||||||
await enqueueEmail(
|
await enqueueEmail(
|
||||||
tx,
|
tx,
|
||||||
installmentActionEmail(booking, updatedInstallment, statusTokenFor(booking.id, ctx.secret), info.requiresAction),
|
installmentActionEmail(booking, updatedInstallment, statusTokenFor(booking.id, ctx.secret), info.requiresAction),
|
||||||
);
|
);
|
||||||
if (!retry && !info.requiresAction) {
|
if (!info.requiresAction && !invoice.nextPaymentAttempt) {
|
||||||
await flagForReview(tx, booking, `Rate ${installment.seq} ist nach ${attempt} Versuchen nicht eingegangen.`, ctx);
|
await flagForReview(tx, booking, `Rate ${installment.seq} ist nach ${invoice.attemptCount} Versuchen nicht eingegangen.`, ctx);
|
||||||
}
|
}
|
||||||
return "recorded";
|
return "recorded";
|
||||||
}
|
}
|
||||||
|
|||||||
+150
-53
@@ -7,12 +7,12 @@
|
|||||||
* Checkout erfasst sie, hier liegen nur Objekt-IDs.
|
* Checkout erfasst sie, hier liegen nur Objekt-IDs.
|
||||||
*
|
*
|
||||||
* Architekturentscheidung Ratenzahlung (docs/ARCHITEKTUR.md, ADR-3):
|
* Architekturentscheidung Ratenzahlung (docs/ARCHITEKTUR.md, ADR-3):
|
||||||
* Erste Rate ueber Stripe Checkout mit setup_future_usage=off_session,
|
* Erste Rate ueber Stripe Checkout mit setup_future_usage=off_session.
|
||||||
* Folgeraten als einzelne Off-Session-PaymentIntents, ausgeloest durch einen
|
* Die Folgeraten zieht Stripe Billing ein: Nach der ersten Zahlung legt die
|
||||||
* idempotenten Kubernetes-CronJob. Kein Abonnement, kein Subscription
|
* Anwendung einen Subscription Schedule an (Start = Faelligkeit der zweiten
|
||||||
* Schedule: deren Intervalle passen nicht zur Regel "letzte Rate 30 Tage vor
|
* Rate, Intervall = Abstand der Raten in Tagen, end_behavior=cancel). Stripe
|
||||||
* Anreise", und die Planlaenge ist hier durch die Ratenzeilen selbst
|
* uebernimmt Einzug, Wiederholungen (Smart Retries), Bestaetigungslinks bei
|
||||||
* begrenzt.
|
* 3-D Secure und Mahnungen; die Anwendung verbucht nur die Rechnungs-Events.
|
||||||
*/
|
*/
|
||||||
import Stripe from "stripe";
|
import Stripe from "stripe";
|
||||||
import { env, stripeMode } from "./env";
|
import { env, stripeMode } from "./env";
|
||||||
@@ -37,11 +37,32 @@ export type PaymentIntentInfo = {
|
|||||||
metadata: Record<string, string>;
|
metadata: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type OffSessionResult = {
|
export type InvoiceInfo = {
|
||||||
outcome: "succeeded" | "processing" | "requires_action" | "failed";
|
id: string;
|
||||||
|
status: "draft" | "open" | "paid" | "uncollectible" | "void";
|
||||||
|
amountPaidCents: number;
|
||||||
paymentIntentId: string | null;
|
paymentIntentId: string | null;
|
||||||
chargeId: string | null;
|
hostedInvoiceUrl: string | null;
|
||||||
failureCode: string | null;
|
attemptCount: number;
|
||||||
|
/** null = Stripe versucht keinen weiteren automatischen Einzug. */
|
||||||
|
nextPaymentAttempt: Date | null;
|
||||||
|
/** Metadaten des Abonnements zum Rechnungszeitpunkt (bookingId usw.). */
|
||||||
|
metadata: Record<string, string>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type CreateInstallmentScheduleParams = {
|
||||||
|
customerId: string;
|
||||||
|
paymentMethodId: string;
|
||||||
|
/** Faelligkeit der ersten Folgerate. */
|
||||||
|
startAt: Date;
|
||||||
|
/** Betrag je Folgerate (alle Folgeraten sind gleich hoch). */
|
||||||
|
amountCents: number;
|
||||||
|
/** Abstand zwischen den Folgeraten in Tagen. */
|
||||||
|
intervalDays: number;
|
||||||
|
/** Anzahl der Folgeraten. */
|
||||||
|
count: number;
|
||||||
|
description: string;
|
||||||
|
metadata: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CreateCheckoutParams = {
|
export type CreateCheckoutParams = {
|
||||||
@@ -65,10 +86,14 @@ export interface PaymentGateway {
|
|||||||
retrieveCheckoutSession(id: string): Promise<CheckoutSessionInfo>;
|
retrieveCheckoutSession(id: string): Promise<CheckoutSessionInfo>;
|
||||||
expireCheckoutSession(id: string): Promise<void>;
|
expireCheckoutSession(id: string): Promise<void>;
|
||||||
retrievePaymentIntent(id: string): Promise<PaymentIntentInfo>;
|
retrievePaymentIntent(id: string): Promise<PaymentIntentInfo>;
|
||||||
chargeOffSession(
|
createInstallmentSchedule(params: CreateInstallmentScheduleParams, idempotencyKey: string): Promise<{ id: string }>;
|
||||||
params: { customerId: string; paymentMethodId: string; amountCents: number; description: string; metadata: Record<string, string> },
|
/** Laufender oder noch nicht gestarteter Plan dieser Buchung bei Stripe, falls vorhanden. */
|
||||||
idempotencyKey: string,
|
findInstallmentSchedule(customerId: string, bookingId: string): Promise<{ id: string } | null>;
|
||||||
): Promise<OffSessionResult>;
|
/** Beendet den Zeitplan sofort und storniert offene Rechnungen: danach wird nichts mehr eingezogen. */
|
||||||
|
cancelInstallmentSchedule(id: string): Promise<void>;
|
||||||
|
retrieveInvoice(id: string): Promise<InvoiceInfo>;
|
||||||
|
/** Alle Rechnungen, die der Zeitplan bisher erzeugt hat (fuer den Abgleich). */
|
||||||
|
listScheduleInvoices(scheduleId: string): Promise<InvoiceInfo[]>;
|
||||||
detachPaymentMethod(id: string): Promise<void>;
|
detachPaymentMethod(id: string): Promise<void>;
|
||||||
createRefund(
|
createRefund(
|
||||||
params: { paymentIntentId: string; amountCents: number; metadata: Record<string, string> },
|
params: { paymentIntentId: string; amountCents: number; metadata: Record<string, string> },
|
||||||
@@ -174,48 +199,97 @@ export class StripeGateway implements PaymentGateway {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async chargeOffSession(
|
async createInstallmentSchedule(params: CreateInstallmentScheduleParams, idempotencyKey: string) {
|
||||||
params: { customerId: string; paymentMethodId: string; amountCents: number; description: string; metadata: Record<string, string> },
|
const productId = await this.installmentProductId();
|
||||||
idempotencyKey: string,
|
const start = Math.floor(params.startAt.getTime() / 1000);
|
||||||
): Promise<OffSessionResult> {
|
const schedule = await this.stripe.subscriptionSchedules.create(
|
||||||
try {
|
{
|
||||||
const pi = await this.stripe.paymentIntents.create(
|
customer: params.customerId,
|
||||||
{
|
start_date: start,
|
||||||
amount: params.amountCents,
|
// Endet genau mit dem Abrechnungszeitraum der letzten Rate: Stripe
|
||||||
currency: "eur",
|
// kuendigt dann ohne weitere Rechnung (mit Testuhr geprueft).
|
||||||
customer: params.customerId,
|
end_behavior: "cancel",
|
||||||
payment_method: params.paymentMethodId,
|
default_settings: {
|
||||||
off_session: true,
|
collection_method: "charge_automatically",
|
||||||
confirm: true,
|
default_payment_method: params.paymentMethodId,
|
||||||
description: params.description,
|
description: params.description,
|
||||||
metadata: params.metadata,
|
|
||||||
},
|
},
|
||||||
{ idempotencyKey },
|
phases: [
|
||||||
);
|
{
|
||||||
return {
|
end_date: start + params.count * params.intervalDays * DAY_SECONDS,
|
||||||
outcome:
|
proration_behavior: "none",
|
||||||
pi.status === "succeeded"
|
items: [
|
||||||
? "succeeded"
|
{
|
||||||
: pi.status === "processing"
|
price_data: {
|
||||||
? "processing"
|
currency: "eur",
|
||||||
: pi.status === "requires_action"
|
product: productId,
|
||||||
? "requires_action"
|
unit_amount: params.amountCents,
|
||||||
: "failed",
|
recurring: { interval: "day", interval_count: params.intervalDays },
|
||||||
paymentIntentId: pi.id,
|
},
|
||||||
chargeId: idOf(pi.latest_charge),
|
},
|
||||||
failureCode: pi.last_payment_error?.code ?? null,
|
],
|
||||||
};
|
metadata: params.metadata,
|
||||||
} catch (error) {
|
},
|
||||||
if (error instanceof Stripe.errors.StripeCardError) {
|
],
|
||||||
return {
|
metadata: params.metadata,
|
||||||
outcome: error.code === "authentication_required" ? "requires_action" : "failed",
|
},
|
||||||
paymentIntentId: error.payment_intent?.id ?? null,
|
{ idempotencyKey },
|
||||||
chargeId: null,
|
);
|
||||||
failureCode: error.decline_code ?? error.code ?? "card_error",
|
return { id: schedule.id };
|
||||||
};
|
}
|
||||||
}
|
|
||||||
throw error;
|
async findInstallmentSchedule(customerId: string, bookingId: string): Promise<{ id: string } | null> {
|
||||||
|
for await (const schedule of this.stripe.subscriptionSchedules.list({ customer: customerId, limit: 100 })) {
|
||||||
|
const live = schedule.status === "not_started" || schedule.status === "active";
|
||||||
|
if (live && schedule.metadata?.bookingId === bookingId) return { id: schedule.id };
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Feste Produkt-ID: beim ersten Bedarf angelegt, danach wiederverwendet. */
|
||||||
|
private async installmentProductId(): Promise<string> {
|
||||||
|
try {
|
||||||
|
return (await this.stripe.products.retrieve(INSTALLMENT_PRODUCT_ID)).id;
|
||||||
|
} catch (error) {
|
||||||
|
if (!(error instanceof Stripe.errors.StripeInvalidRequestError)) throw error;
|
||||||
|
const product = await this.stripe.products.create(
|
||||||
|
{ id: INSTALLMENT_PRODUCT_ID, name: "ARTISTA MODELCAMP 2027, Folgerate" },
|
||||||
|
{ idempotencyKey: `product:${INSTALLMENT_PRODUCT_ID}` },
|
||||||
|
);
|
||||||
|
return product.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async cancelInstallmentSchedule(id: string): Promise<void> {
|
||||||
|
const schedule = await this.stripe.subscriptionSchedules.retrieve(id);
|
||||||
|
if (schedule.status === "not_started" || schedule.status === "active") {
|
||||||
|
await this.stripe.subscriptionSchedules.cancel(id, { invoice_now: false, prorate: false });
|
||||||
|
}
|
||||||
|
const subscriptionId = idOf(schedule.subscription);
|
||||||
|
if (!subscriptionId) return;
|
||||||
|
// Offene Rechnungen wuerden sonst weiter automatisch eingezogen. Entwuerfe
|
||||||
|
// (Stripe stellt Rechnungen erst ~1 h nach Periodenbeginn fertig) bleiben
|
||||||
|
// laut Testuhr nach dem Beenden zwar liegen, werden aber vorsorglich
|
||||||
|
// geloescht, damit sie nie fertiggestellt und eingezogen werden.
|
||||||
|
for await (const invoice of this.stripe.invoices.list({ subscription: subscriptionId, limit: 100 })) {
|
||||||
|
if (invoice.status === "draft") await this.stripe.invoices.del(invoice.id!);
|
||||||
|
else if (invoice.status === "open") await this.stripe.invoices.voidInvoice(invoice.id!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async retrieveInvoice(id: string): Promise<InvoiceInfo> {
|
||||||
|
return invoiceInfoFromStripe(await this.stripe.invoices.retrieve(id, { expand: ["payments"] }));
|
||||||
|
}
|
||||||
|
|
||||||
|
async listScheduleInvoices(scheduleId: string): Promise<InvoiceInfo[]> {
|
||||||
|
const schedule = await this.stripe.subscriptionSchedules.retrieve(scheduleId);
|
||||||
|
const subscriptionId = idOf(schedule.subscription);
|
||||||
|
if (!subscriptionId) return [];
|
||||||
|
const invoices: InvoiceInfo[] = [];
|
||||||
|
for await (const invoice of this.stripe.invoices.list({ subscription: subscriptionId, limit: 100, expand: ["data.payments"] })) {
|
||||||
|
invoices.push(invoiceInfoFromStripe(invoice));
|
||||||
|
}
|
||||||
|
return invoices;
|
||||||
}
|
}
|
||||||
|
|
||||||
async detachPaymentMethod(id: string): Promise<void> {
|
async detachPaymentMethod(id: string): Promise<void> {
|
||||||
@@ -239,6 +313,29 @@ export class StripeGateway implements PaymentGateway {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DAY_SECONDS = 86_400;
|
||||||
|
const INSTALLMENT_PRODUCT_ID = "artista_modelcamp_2027_folgerate";
|
||||||
|
|
||||||
|
/** Seit API 2025-03-31 haengt die Zahlung einer Rechnung an invoice.payments. */
|
||||||
|
function paidPaymentIntentId(invoice: Stripe.Invoice): string | null {
|
||||||
|
const payments = invoice.payments?.data ?? [];
|
||||||
|
const paid = payments.find((p) => p.status === "paid") ?? payments[0];
|
||||||
|
return idOf(paid?.payment.payment_intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function invoiceInfoFromStripe(invoice: Stripe.Invoice): InvoiceInfo {
|
||||||
|
return {
|
||||||
|
id: invoice.id!,
|
||||||
|
status: (invoice.status ?? "draft") as InvoiceInfo["status"],
|
||||||
|
amountPaidCents: invoice.amount_paid,
|
||||||
|
paymentIntentId: paidPaymentIntentId(invoice),
|
||||||
|
hostedInvoiceUrl: invoice.hosted_invoice_url ?? null,
|
||||||
|
attemptCount: invoice.attempt_count,
|
||||||
|
nextPaymentAttempt: invoice.next_payment_attempt ? new Date(invoice.next_payment_attempt * 1000) : null,
|
||||||
|
metadata: (invoice.parent?.subscription_details?.metadata ?? {}) as Record<string, string>,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let gateway: PaymentGateway | null = null;
|
let gateway: PaymentGateway | null = null;
|
||||||
|
|
||||||
export function getGateway(): PaymentGateway {
|
export function getGateway(): PaymentGateway {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export const RATE_LIMITS = {
|
|||||||
voucher: { action: "voucher", limit: 10, windowSeconds: 900 },
|
voucher: { action: "voucher", limit: 10, windowSeconds: 900 },
|
||||||
checkout: { action: "checkout", limit: 8, windowSeconds: 900 },
|
checkout: { action: "checkout", limit: 8, windowSeconds: 900 },
|
||||||
statusAction: { action: "status-action", limit: 20, windowSeconds: 900 },
|
statusAction: { action: "status-action", limit: 20, windowSeconds: 900 },
|
||||||
|
contact: { action: "contact", limit: 5, windowSeconds: 3600 },
|
||||||
} satisfies Record<string, RateLimitRule>;
|
} satisfies Record<string, RateLimitRule>;
|
||||||
|
|
||||||
export type RateLimitResult = { allowed: boolean; retryAfterSeconds: number };
|
export type RateLimitResult = { allowed: boolean; retryAfterSeconds: number };
|
||||||
|
|||||||
+80
-12
@@ -12,14 +12,16 @@
|
|||||||
*/
|
*/
|
||||||
import { readdir, stat } from "node:fs/promises";
|
import { readdir, stat } from "node:fs/promises";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
import sharp from "sharp";
|
||||||
import { site, type Media } from "@/content/site";
|
import { site, type Media } from "@/content/site";
|
||||||
import { env } from "./env";
|
import { env } from "./env";
|
||||||
|
import { optimizedImageUrl } from "./image-url";
|
||||||
|
|
||||||
const IMAGE_EXTS = [".jpg", ".jpeg", ".webp", ".png", ".avif"];
|
const IMAGE_EXTS = [".jpg", ".jpeg", ".webp", ".png", ".avif"];
|
||||||
const LOGO_EXTS = [".svg", ".png", ".webp"];
|
const LOGO_EXTS = [".svg", ".png", ".webp"];
|
||||||
const VIDEO_EXTS = [".mp4", ".webm"];
|
const VIDEO_EXTS = [".mp4", ".webm"];
|
||||||
|
|
||||||
type Found = { src: string; ext: string };
|
type Found = { src: string; ext: string; file: string };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sucht "<ordner>/<name>.<endung>" ohne Ruecksicht auf Gross- und
|
* Sucht "<ordner>/<name>.<endung>" ohne Ruecksicht auf Gross- und
|
||||||
@@ -44,7 +46,7 @@ async function find(base: string, exts: readonly string[]): Promise<Found | null
|
|||||||
const info = await stat(path.join(dir, match));
|
const info = await stat(path.join(dir, match));
|
||||||
if (!info.isFile()) continue;
|
if (!info.isFile()) continue;
|
||||||
const rel = folder === "." ? match : `${folder}/${match}`;
|
const rel = folder === "." ? match : `${folder}/${match}`;
|
||||||
return { src: `/media/${encodeURI(rel)}?v=${Math.floor(info.mtimeMs)}`, ext };
|
return { src: `/media/${encodeURI(rel)}?v=${Math.floor(info.mtimeMs)}`, ext, file: path.join(dir, match) };
|
||||||
} catch {
|
} catch {
|
||||||
// Datei zwischenzeitlich entfernt: naechste Endung probieren.
|
// Datei zwischenzeitlich entfernt: naechste Endung probieren.
|
||||||
}
|
}
|
||||||
@@ -52,36 +54,100 @@ async function find(base: string, exts: readonly string[]): Promise<Found | null
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Video mit Vorrang fuer die Web-Fassung "<name>.web.mp4" (1080p,
|
||||||
|
* faststart, siehe scripts/optimize-media.ts). Fehlt sie, das Original.
|
||||||
|
*/
|
||||||
|
async function video(base: string): Promise<Found | null> {
|
||||||
|
return (await find(`${base}.web`, VIDEO_EXTS)) ?? find(base, VIDEO_EXTS);
|
||||||
|
}
|
||||||
|
|
||||||
async function image(base: string, alt: string): Promise<Media | null> {
|
async function image(base: string, alt: string): Promise<Media | null> {
|
||||||
const found = await find(base, IMAGE_EXTS);
|
const found = await find(base, IMAGE_EXTS);
|
||||||
return found ? { kind: "image", src: found.src, alt, width: 1200, height: 1500 } : null;
|
return found ? { kind: "image", src: found.src, alt, width: 1200, height: 1500 } : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logo samt Darstellung: "darken" bzw. "lighten" faerbt ein Logo per CSS um,
|
||||||
|
* wenn fuer den Untergrund keine passende Fassung hochgeladen wurde (z. B.
|
||||||
|
* nur ein helles Logo, das auf der hellen Kopfzeile sonst unsichtbar waere).
|
||||||
|
*/
|
||||||
|
export type LogoImage = { src: string; tone: "as-is" | "darken" | "lighten" };
|
||||||
|
|
||||||
|
type Tone = "light" | "dark";
|
||||||
|
/** Mittlere Helligkeit (0–255) der sichtbaren Pixel, ab der ein Logo als hell gilt. */
|
||||||
|
const LIGHT_LOGO_LUMINANCE = 140;
|
||||||
|
/** Breite der ausgelieferten Rastergrafik: scharf bis ~400 px Anzeigebreite auf 2x-Displays. */
|
||||||
|
const LOGO_DELIVERY_WIDTH = 828;
|
||||||
|
const toneCache = new Map<string, Tone>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hell oder dunkel? Gemessen statt am Dateinamen festgemacht: Wird das helle
|
||||||
|
* Logo als logo.png hochgeladen, landet es trotzdem auf dem dunklen Grund.
|
||||||
|
*/
|
||||||
|
async function logoTone(found: Found): Promise<Tone> {
|
||||||
|
const cached = toneCache.get(found.src);
|
||||||
|
if (cached) return cached;
|
||||||
|
const { data } = await sharp(found.file).resize(64, 64, { fit: "inside" }).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
||||||
|
let luminance = 0;
|
||||||
|
let weight = 0;
|
||||||
|
for (let i = 0; i < data.length; i += 4) {
|
||||||
|
const alpha = data[i + 3]! / 255;
|
||||||
|
if (alpha < 0.2) continue;
|
||||||
|
luminance += (0.2126 * data[i]! + 0.7152 * data[i + 1]! + 0.0722 * data[i + 2]!) * alpha;
|
||||||
|
weight += alpha;
|
||||||
|
}
|
||||||
|
const tone: Tone = weight > 0 && luminance / weight >= LIGHT_LOGO_LUMINANCE ? "light" : "dark";
|
||||||
|
toneCache.set(found.src, tone);
|
||||||
|
return tone;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deliver(found: Found): string {
|
||||||
|
// SVG direkt (laeuft nicht durch die Bildoptimierung), Raster verkleinert:
|
||||||
|
// das Original-PNG hatte 5378 px Breite.
|
||||||
|
return found.ext === ".svg" ? found.src : optimizedImageUrl(found.src, LOGO_DELIVERY_WIDTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resolveLogos(candidates: (Found | null)[]): Promise<{ onLight: LogoImage | null; onDark: LogoImage | null }> {
|
||||||
|
const found = candidates.filter((c): c is Found => c !== null);
|
||||||
|
const toned = await Promise.all(found.map(async (f) => ({ f, tone: await logoTone(f).catch((): Tone => "dark") })));
|
||||||
|
const dark = toned.find((t) => t.tone === "dark")?.f;
|
||||||
|
const light = toned.find((t) => t.tone === "light")?.f;
|
||||||
|
const onLight: LogoImage | null = dark ? { src: deliver(dark), tone: "as-is" } : light ? { src: deliver(light), tone: "darken" } : null;
|
||||||
|
const onDark: LogoImage | null = light ? { src: deliver(light), tone: "as-is" } : dark ? { src: deliver(dark), tone: "lighten" } : null;
|
||||||
|
return { onLight, onDark };
|
||||||
|
}
|
||||||
|
|
||||||
export type Reel = { src: string | null; poster: Media | null };
|
export type Reel = { src: string | null; poster: Media | null };
|
||||||
|
export type IntroVideo = { src: string | null; poster: Media | null };
|
||||||
|
|
||||||
export type SiteMedia = {
|
export type SiteMedia = {
|
||||||
/** Logo fuer helle Flaechen (dunkles Logo). */
|
/** Logo fuer helle Flaechen (Kopfzeile nach dem Scrollen, Fussbereich). */
|
||||||
logoDark: string | null;
|
logoDark: LogoImage | null;
|
||||||
/** Logo auf Foto oder dunklem Grund (helles Logo). */
|
/** Logo auf Foto oder dunklem Grund. */
|
||||||
logoLight: string | null;
|
logoLight: LogoImage | null;
|
||||||
header: Media;
|
header: Media;
|
||||||
headerVideo: string | null;
|
headerVideo: string | null;
|
||||||
|
/** Video direkt unter dem Headerbild (intro.mp4, Vorschaubild intro.jpg). */
|
||||||
|
intro: IntroVideo;
|
||||||
portraits: Record<string, Media>;
|
portraits: Record<string, Media>;
|
||||||
reels: Reel[];
|
reels: Reel[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function loadSiteMedia(): Promise<SiteMedia> {
|
export async function loadSiteMedia(): Promise<SiteMedia> {
|
||||||
const people = [site.team.head, ...site.team.people];
|
const people = [site.team.head, ...site.team.people];
|
||||||
const [logoDark, logoLight, header, headerVideo, portraitList, reels] = await Promise.all([
|
const [logoDark, logoLight, header, headerVideo, introVideo, introPoster, portraitList, reels] = await Promise.all([
|
||||||
find("logo", LOGO_EXTS),
|
find("logo", LOGO_EXTS),
|
||||||
find("logo-hell", LOGO_EXTS),
|
find("logo-hell", LOGO_EXTS),
|
||||||
image("header", "ARTISTA Modelcamp in der Toskana"),
|
image("header", "ARTISTA Modelcamp in der Toskana"),
|
||||||
find("header", VIDEO_EXTS),
|
video("header"),
|
||||||
|
video("intro"),
|
||||||
|
image("intro", "Vorschaubild Video ARTISTA Modelcamp"),
|
||||||
Promise.all(people.map((p) => image(`team/${p.slug}`, `Porträt ${p.name}`))),
|
Promise.all(people.map((p) => image(`team/${p.slug}`, `Porträt ${p.name}`))),
|
||||||
Promise.all(
|
Promise.all(
|
||||||
[1, 2, 3].map(async (n): Promise<Reel> => {
|
[1, 2, 3].map(async (n): Promise<Reel> => {
|
||||||
const [video, poster] = await Promise.all([find(`reels/reel-${n}`, VIDEO_EXTS), image(`reels/reel-${n}`, `Vorschaubild Reel ${n}`)]);
|
const [clip, poster] = await Promise.all([video(`reels/reel-${n}`), image(`reels/reel-${n}`, `Vorschaubild Reel ${n}`)]);
|
||||||
return { src: video?.src ?? null, poster };
|
return { src: clip?.src ?? null, poster };
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
@@ -91,11 +157,13 @@ export async function loadSiteMedia(): Promise<SiteMedia> {
|
|||||||
portraits[p.slug] = portraitList[index] ?? p.portrait;
|
portraits[p.slug] = portraitList[index] ?? p.portrait;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const logos = await resolveLogos([logoDark, logoLight]);
|
||||||
return {
|
return {
|
||||||
logoDark: logoDark?.src ?? logoLight?.src ?? null,
|
logoDark: logos.onLight,
|
||||||
logoLight: logoLight?.src ?? logoDark?.src ?? null,
|
logoLight: logos.onDark,
|
||||||
header: header ?? site.hero.media,
|
header: header ?? site.hero.media,
|
||||||
headerVideo: headerVideo?.src ?? null,
|
headerVideo: headerVideo?.src ?? null,
|
||||||
|
intro: { src: introVideo?.src ?? null, poster: introPoster },
|
||||||
portraits,
|
portraits,
|
||||||
reels,
|
reels,
|
||||||
};
|
};
|
||||||
|
|||||||
+76
-91
@@ -13,6 +13,7 @@ import type Stripe from "stripe";
|
|||||||
import { Prisma } from "@/generated/prisma/client";
|
import { Prisma } from "@/generated/prisma/client";
|
||||||
import { STRIPE_ACTOR, type Actor } from "./audit";
|
import { STRIPE_ACTOR, type Actor } from "./audit";
|
||||||
import type { Db } from "./db";
|
import type { Db } from "./db";
|
||||||
|
import { ensureInstallmentSchedule, holdSchedulesInReview, INSTALLMENT_PLAN_KIND, settleInstallmentInvoice } from "./installment-billing";
|
||||||
import { normalizePaymentStatus, type CheckoutSessionInfo, type PaymentGateway } from "./payment-gateway";
|
import { normalizePaymentStatus, type CheckoutSessionInfo, type PaymentGateway } from "./payment-gateway";
|
||||||
import {
|
import {
|
||||||
applyCheckoutExpired,
|
applyCheckoutExpired,
|
||||||
@@ -20,8 +21,7 @@ import {
|
|||||||
applyFirstPaymentFailed,
|
applyFirstPaymentFailed,
|
||||||
applyFirstPaymentProcessing,
|
applyFirstPaymentProcessing,
|
||||||
applyFirstPaymentSucceeded,
|
applyFirstPaymentSucceeded,
|
||||||
applyInstallmentFailed,
|
applyInstallmentInvoiceFailed,
|
||||||
applyInstallmentPaid,
|
|
||||||
applyRefundState,
|
applyRefundState,
|
||||||
type EventContext,
|
type EventContext,
|
||||||
} from "./payment-events";
|
} from "./payment-events";
|
||||||
@@ -61,16 +61,15 @@ export async function settleCheckoutSession(
|
|||||||
ctx: HandlerContext,
|
ctx: HandlerContext,
|
||||||
actor: Actor = STRIPE_ACTOR,
|
actor: Actor = STRIPE_ACTOR,
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
const { kind, bookingId, installmentId } = session.metadata;
|
const { kind, bookingId } = session.metadata;
|
||||||
if (!bookingId || (kind !== "booking" && kind !== "installment")) return null;
|
if (!bookingId || kind !== "booking") return null;
|
||||||
const booking = await db.booking.findUnique({ where: { id: bookingId }, select: { id: true, stripeCheckoutSessionId: true } });
|
const booking = await db.booking.findUnique({ where: { id: bookingId }, select: { id: true, stripeCheckoutSessionId: true } });
|
||||||
if (!booking) return null;
|
if (!booking) return null;
|
||||||
// Eine Buchungs-Session muss zur gespeicherten Session passen (oder es ist
|
// Die Session muss zur gespeicherten Session passen (oder es ist noch keine
|
||||||
// noch keine gespeichert, weil das Speichern nach Stripe scheiterte).
|
// gespeichert, weil das Speichern nach Stripe scheiterte).
|
||||||
if (kind === "booking" && booking.stripeCheckoutSessionId && booking.stripeCheckoutSessionId !== session.id) return null;
|
if (booking.stripeCheckoutSessionId && booking.stripeCheckoutSessionId !== session.id) return null;
|
||||||
|
|
||||||
const paid = session.paymentStatus === "paid";
|
if (session.paymentStatus === "paid") {
|
||||||
if (paid) {
|
|
||||||
if (!session.paymentIntentId) throw new Error(`Bezahlte Session ${session.id} ohne PaymentIntent.`);
|
if (!session.paymentIntentId) throw new Error(`Bezahlte Session ${session.id} ohne PaymentIntent.`);
|
||||||
const pi = await gateway.retrievePaymentIntent(session.paymentIntentId);
|
const pi = await gateway.retrievePaymentIntent(session.paymentIntentId);
|
||||||
const info = {
|
const info = {
|
||||||
@@ -80,29 +79,55 @@ export async function settleCheckoutSession(
|
|||||||
customerId: session.customerId,
|
customerId: session.customerId,
|
||||||
amountCents: pi.amountReceived,
|
amountCents: pi.amountReceived,
|
||||||
};
|
};
|
||||||
if (kind === "booking") {
|
await db.$transaction((tx) => applyFirstPaymentSucceeded(tx, bookingId, info, eventCtx(ctx, actor)));
|
||||||
await db.$transaction((tx) => applyFirstPaymentSucceeded(tx, bookingId, info, eventCtx(ctx, actor)));
|
await startInstallmentSchedule(db, gateway, bookingId, ctx, actor);
|
||||||
} else if (installmentId) {
|
|
||||||
await db.$transaction((tx) => applyInstallmentPaid(tx, installmentId, info, eventCtx(ctx, actor)));
|
|
||||||
}
|
|
||||||
return bookingId;
|
return bookingId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session.status === "complete") {
|
if (session.status === "complete") {
|
||||||
if (kind === "booking") {
|
await db.$transaction((tx) =>
|
||||||
await db.$transaction((tx) =>
|
applyFirstPaymentProcessing(tx, bookingId, { paymentIntentId: session.paymentIntentId, customerId: session.customerId }, eventCtx(ctx, actor)),
|
||||||
applyFirstPaymentProcessing(tx, bookingId, { paymentIntentId: session.paymentIntentId, customerId: session.customerId }, eventCtx(ctx, actor)),
|
);
|
||||||
);
|
|
||||||
} else if (installmentId) {
|
|
||||||
await db.installment.updateMany({
|
|
||||||
where: { id: installmentId, status: { in: ["PENDING", "FAILED", "REQUIRES_ACTION"] } },
|
|
||||||
data: { status: "PROCESSING", stripePaymentIntentId: session.paymentIntentId, lastAttemptAt: ctx.now },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return bookingId;
|
return bookingId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ratenplan bei Stripe anlegen, sobald die erste Rate bezahlt ist. Ein
|
||||||
|
* Fehler hier macht die verbuchte Zahlung nicht rueckgaengig: der Worker
|
||||||
|
* holt das Anlegen beim naechsten Lauf nach.
|
||||||
|
*/
|
||||||
|
async function startInstallmentSchedule(db: Db, gateway: PaymentGateway, bookingId: string, ctx: HandlerContext, actor: Actor) {
|
||||||
|
try {
|
||||||
|
await ensureInstallmentSchedule(db, gateway, bookingId, ctx, actor);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[webhook] Ratenplan fuer Buchung ${bookingId} nicht angelegt: ${error instanceof Error ? error.message : "unbekannt"}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleInstallmentInvoice(db: Db, gateway: PaymentGateway, event: Stripe.Event, ctx: HandlerContext): Promise<string[]> {
|
||||||
|
const object = event.data.object as Stripe.Invoice;
|
||||||
|
// Wahrheit bei Stripe nachladen statt dem Event-Inhalt zu vertrauen.
|
||||||
|
const invoice = await gateway.retrieveInvoice(object.id!);
|
||||||
|
const { kind, bookingId } = invoice.metadata;
|
||||||
|
if (kind !== INSTALLMENT_PLAN_KIND || !bookingId) return [];
|
||||||
|
if (event.type === "invoice.paid") {
|
||||||
|
await settleInstallmentInvoice(db, gateway, invoice, ctx, STRIPE_ACTOR);
|
||||||
|
return [bookingId];
|
||||||
|
}
|
||||||
|
if (invoice.status !== "open") return [];
|
||||||
|
await db.$transaction((tx) =>
|
||||||
|
applyInstallmentInvoiceFailed(
|
||||||
|
tx,
|
||||||
|
bookingId,
|
||||||
|
invoice,
|
||||||
|
{ requiresAction: event.type === "invoice.payment_action_required" },
|
||||||
|
eventCtx(ctx),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return [bookingId];
|
||||||
|
}
|
||||||
|
|
||||||
async function dispatch(db: Db, gateway: PaymentGateway, event: Stripe.Event, ctx: HandlerContext): Promise<string[]> {
|
async function dispatch(db: Db, gateway: PaymentGateway, event: Stripe.Event, ctx: HandlerContext): Promise<string[]> {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "checkout.session.completed":
|
case "checkout.session.completed":
|
||||||
@@ -112,73 +137,22 @@ async function dispatch(db: Db, gateway: PaymentGateway, event: Stripe.Event, ct
|
|||||||
}
|
}
|
||||||
case "checkout.session.async_payment_failed": {
|
case "checkout.session.async_payment_failed": {
|
||||||
const s = sessionInfoFromStripe(event.data.object);
|
const s = sessionInfoFromStripe(event.data.object);
|
||||||
const { kind, bookingId, installmentId } = s.metadata;
|
const { kind, bookingId } = s.metadata;
|
||||||
if (kind === "booking" && bookingId) {
|
if (kind !== "booking" || !bookingId) return [];
|
||||||
await db.$transaction((tx) => applyFirstPaymentFailed(tx, bookingId, eventCtx(ctx)));
|
await db.$transaction((tx) => applyFirstPaymentFailed(tx, bookingId, eventCtx(ctx)));
|
||||||
return [bookingId];
|
return [bookingId];
|
||||||
}
|
|
||||||
if (kind === "installment" && installmentId) {
|
|
||||||
await db.installment.updateMany({
|
|
||||||
where: { id: installmentId, status: "PROCESSING" },
|
|
||||||
data: { status: "FAILED", failureCode: "async_payment_failed", checkoutSessionId: null, checkoutExpiresAt: null },
|
|
||||||
});
|
|
||||||
return bookingId ? [bookingId] : [];
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
case "checkout.session.expired": {
|
case "checkout.session.expired": {
|
||||||
const s = event.data.object;
|
const s = event.data.object;
|
||||||
const { kind, bookingId, installmentId } = (s.metadata ?? {}) as Record<string, string>;
|
const { kind, bookingId } = (s.metadata ?? {}) as Record<string, string>;
|
||||||
if (kind === "booking" && bookingId) {
|
if (kind !== "booking" || !bookingId) return [];
|
||||||
await db.$transaction((tx) => applyCheckoutExpired(tx, bookingId, s.id, eventCtx(ctx)));
|
await db.$transaction((tx) => applyCheckoutExpired(tx, bookingId, s.id, eventCtx(ctx)));
|
||||||
return [bookingId];
|
return [bookingId];
|
||||||
}
|
|
||||||
if (kind === "installment" && installmentId) {
|
|
||||||
await db.installment.updateMany({
|
|
||||||
where: { id: installmentId, checkoutSessionId: s.id },
|
|
||||||
data: { checkoutSessionId: null, checkoutExpiresAt: null },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
case "payment_intent.succeeded": {
|
|
||||||
const pi = event.data.object;
|
|
||||||
if (pi.metadata?.kind !== "installment_offsession" || !pi.metadata.installmentId) return [];
|
|
||||||
const outcome = await db.$transaction((tx) =>
|
|
||||||
applyInstallmentPaid(
|
|
||||||
tx,
|
|
||||||
pi.metadata.installmentId!,
|
|
||||||
{
|
|
||||||
paymentIntentId: pi.id,
|
|
||||||
chargeId: idOf(pi.latest_charge),
|
|
||||||
paymentMethodId: idOf(pi.payment_method),
|
|
||||||
customerId: idOf(pi.customer),
|
|
||||||
amountCents: pi.amount_received,
|
|
||||||
},
|
|
||||||
eventCtx(ctx),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
void outcome;
|
|
||||||
return pi.metadata.bookingId ? [pi.metadata.bookingId] : [];
|
|
||||||
}
|
|
||||||
case "payment_intent.payment_failed": {
|
|
||||||
const pi = event.data.object;
|
|
||||||
if (pi.metadata?.kind !== "installment_offsession" || !pi.metadata.installmentId) return [];
|
|
||||||
const code = pi.last_payment_error?.code ?? null;
|
|
||||||
await db.$transaction((tx) =>
|
|
||||||
applyInstallmentFailed(
|
|
||||||
tx,
|
|
||||||
pi.metadata.installmentId!,
|
|
||||||
{
|
|
||||||
paymentIntentId: pi.id,
|
|
||||||
failureCode: pi.last_payment_error?.decline_code ?? code,
|
|
||||||
requiresAction: code === "authentication_required" || pi.status === "requires_action",
|
|
||||||
},
|
|
||||||
eventCtx(ctx),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return pi.metadata.bookingId ? [pi.metadata.bookingId] : [];
|
|
||||||
}
|
}
|
||||||
|
case "invoice.paid":
|
||||||
|
case "invoice.payment_failed":
|
||||||
|
case "invoice.payment_action_required":
|
||||||
|
return handleInstallmentInvoice(db, gateway, event, ctx);
|
||||||
case "charge.refunded": {
|
case "charge.refunded": {
|
||||||
const charge = event.data.object;
|
const charge = event.data.object;
|
||||||
const piId = idOf(charge.payment_intent);
|
const piId = idOf(charge.payment_intent);
|
||||||
@@ -196,8 +170,10 @@ async function dispatch(db: Db, gateway: PaymentGateway, event: Stripe.Event, ct
|
|||||||
}
|
}
|
||||||
case "charge.dispute.created": {
|
case "charge.dispute.created": {
|
||||||
const piId = idOf(event.data.object.payment_intent);
|
const piId = idOf(event.data.object.payment_intent);
|
||||||
if (piId) await db.$transaction((tx) => applyDispute(tx, piId, eventCtx(ctx)));
|
if (!piId) return [];
|
||||||
return [];
|
await db.$transaction((tx) => applyDispute(tx, piId, eventCtx(ctx)));
|
||||||
|
const disputed = await db.installment.findUnique({ where: { stripePaymentIntentId: piId }, select: { bookingId: true } });
|
||||||
|
return disputed ? [disputed.bookingId] : [];
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
@@ -209,8 +185,9 @@ const HANDLED = new Set<string>([
|
|||||||
"checkout.session.async_payment_succeeded",
|
"checkout.session.async_payment_succeeded",
|
||||||
"checkout.session.async_payment_failed",
|
"checkout.session.async_payment_failed",
|
||||||
"checkout.session.expired",
|
"checkout.session.expired",
|
||||||
"payment_intent.succeeded",
|
"invoice.paid",
|
||||||
"payment_intent.payment_failed",
|
"invoice.payment_failed",
|
||||||
|
"invoice.payment_action_required",
|
||||||
"charge.refunded",
|
"charge.refunded",
|
||||||
"refund.created",
|
"refund.created",
|
||||||
"refund.updated",
|
"refund.updated",
|
||||||
@@ -243,6 +220,14 @@ export async function handleStripeEvent(
|
|||||||
try {
|
try {
|
||||||
const bookingIds = await dispatch(db, gateway, event, ctx);
|
const bookingIds = await dispatch(db, gateway, event, ctx);
|
||||||
await db.stripeEvent.update({ where: { id: event.id }, data: { status: "PROCESSED", processedAt: new Date(), error: null } });
|
await db.stripeEvent.update({ where: { id: event.id }, data: { status: "PROCESSED", processedAt: new Date(), error: null } });
|
||||||
|
// Geriet eine Buchung in Pruefung (Rueckbuchung, Doppelzahlung ...),
|
||||||
|
// zieht Stripe bis zur Entscheidung nichts weiter ein. Scheitert das
|
||||||
|
// hier, erledigt es der Worker.
|
||||||
|
if (bookingIds.length > 0) {
|
||||||
|
await holdSchedulesInReview(db, gateway, bookingIds, STRIPE_ACTOR).catch((error: unknown) => {
|
||||||
|
console.error(`[webhook] Ratenplan nicht angehalten: ${error instanceof Error ? error.message : "unbekannt"}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
return { outcome: "processed", bookingIds };
|
return { outcome: "processed", bookingIds };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message.slice(0, 500) : "unbekannter Fehler";
|
const message = error instanceof Error ? error.message.slice(0, 500) : "unbekannter Fehler";
|
||||||
|
|||||||
+66
-172
@@ -1,25 +1,23 @@
|
|||||||
/**
|
/**
|
||||||
* Hintergrundaufgaben, ausgefuehrt vom Kubernetes-CronJob (scripts/worker.ts).
|
* Hintergrundaufgaben, ausgefuehrt vom Kubernetes-CronJob (scripts/worker.ts).
|
||||||
*
|
*
|
||||||
* Kein In-Process-Timer: Faelligkeiten stehen in der Datenbank, jeder Lauf
|
* Kein In-Process-Timer: jeder Lauf arbeitet den aktuellen Stand ab. Die
|
||||||
* arbeitet den aktuellen Stand ab. Mehrere gleichzeitige Laeufe (z. B. ein
|
* Folgeraten zieht Stripe Billing ein; der Worker legt nur fehlende
|
||||||
* manueller Start waehrend des CronJobs) sind unschaedlich, weil jede Rate
|
* Ratenplaene an und gleicht verlorene Webhooks ab. Mehrere gleichzeitige
|
||||||
* vor dem Einzug atomar beansprucht wird und Stripe-Aufrufe
|
* Laeufe sind unschaedlich, weil Stripe-Aufrufe Idempotenzschluessel tragen
|
||||||
* Idempotenzschluessel tragen.
|
* und jede Verbuchung idempotent ist.
|
||||||
*/
|
*/
|
||||||
import { audit, WORKER } from "./audit";
|
import { audit, WORKER } from "./audit";
|
||||||
import type { Db } from "./db";
|
import type { Db } from "./db";
|
||||||
import { flushEmails } from "./email";
|
import { flushEmails } from "./email";
|
||||||
import { MAX_OFF_SESSION_ATTEMPTS, applyCheckoutExpired, applyFirstPaymentFailed, applyInstallmentFailed, applyInstallmentPaid, type EventContext } from "./payment-events";
|
import { eachBooking, ensureInstallmentSchedule, holdSchedulesInReview, settleInstallmentInvoice, stopCanceledInstallmentPlans } from "./installment-billing";
|
||||||
|
import { applyCheckoutExpired, applyFirstPaymentFailed, type EventContext } from "./payment-events";
|
||||||
import type { PaymentGateway } from "./payment-gateway";
|
import type { PaymentGateway } from "./payment-gateway";
|
||||||
import { purgeRateLimits } from "./rate-limit";
|
import { purgeRateLimits } from "./rate-limit";
|
||||||
import { settleCheckoutSession, type HandlerContext } from "./webhook";
|
import { settleCheckoutSession, type HandlerContext } from "./webhook";
|
||||||
|
|
||||||
/** Stripe-Idempotenzschluessel gelten 24 Stunden; ein haengender Einzug
|
/** Stripe stellt Rechnungen erst rund eine Stunde nach Faelligkeit fertig. */
|
||||||
* wird nur innerhalb dieser Frist automatisch mit demselben Schluessel
|
const RECONCILE_AFTER_MS = 6 * 60 * 60_000;
|
||||||
* wiederholt, danach entscheidet ein Mensch. */
|
|
||||||
const SAFE_RETRY_WINDOW_MS = 20 * 60 * 60_000;
|
|
||||||
const STUCK_AFTER_MS = 2 * 60 * 60_000;
|
|
||||||
|
|
||||||
function eventCtx(ctx: HandlerContext): EventContext {
|
function eventCtx(ctx: HandlerContext): EventContext {
|
||||||
return { ...ctx, actor: WORKER };
|
return { ...ctx, actor: WORKER };
|
||||||
@@ -61,181 +59,71 @@ export async function releaseExpiredReservations(db: Db, gateway: PaymentGateway
|
|||||||
return { released, settled };
|
return { released, settled };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Zieht faellige Folgeraten off-session ein. */
|
/**
|
||||||
export async function chargeDueInstallments(db: Db, gateway: PaymentGateway, ctx: HandlerContext) {
|
* Legt den Stripe-Ratenplan fuer bestaetigte Ratenbuchungen an, falls das
|
||||||
const livemode = gateway.mode === "live";
|
* direkt nach der ersten Zahlung scheiterte oder die Buchung erst spaeter
|
||||||
const due = await db.installment.findMany({
|
* bestaetigt wurde (Pruefung im Adminbereich).
|
||||||
|
*/
|
||||||
|
export async function createMissingSchedules(db: Db, gateway: PaymentGateway, ctx: HandlerContext) {
|
||||||
|
const bookings = await db.booking.findMany({
|
||||||
where: {
|
where: {
|
||||||
seq: { gt: 1 },
|
status: "CONFIRMED",
|
||||||
booking: { status: "CONFIRMED", livemode },
|
planType: { not: "FULL" },
|
||||||
OR: [
|
stripeScheduleId: null,
|
||||||
{ status: "PENDING", dueAt: { lte: ctx.now } },
|
livemode: gateway.mode === "live",
|
||||||
{ status: "FAILED", nextAttemptAt: { lte: ctx.now }, attemptCount: { lt: MAX_OFF_SESSION_ATTEMPTS } },
|
installments: { some: { seq: { gt: 1 }, status: "PENDING" } },
|
||||||
],
|
|
||||||
AND: [{ OR: [{ checkoutExpiresAt: null }, { checkoutExpiresAt: { lt: ctx.now } }] }],
|
|
||||||
},
|
},
|
||||||
orderBy: { dueAt: "asc" },
|
select: { id: true },
|
||||||
take: 50,
|
take: 50,
|
||||||
});
|
});
|
||||||
|
const summary = { created: 0, needsReview: 0, failed: 0 };
|
||||||
const summary = { charged: 0, failed: 0, requiresAction: 0, processing: 0, skipped: 0 };
|
for (const booking of bookings) {
|
||||||
for (const installment of due) {
|
|
||||||
// Atomar beanspruchen: nur ein Lauf darf diese Rate einziehen.
|
|
||||||
const claimed = await db.installment.updateMany({
|
|
||||||
where: {
|
|
||||||
id: installment.id,
|
|
||||||
status: installment.status,
|
|
||||||
OR: [{ checkoutExpiresAt: null }, { checkoutExpiresAt: { lt: ctx.now } }],
|
|
||||||
},
|
|
||||||
data: { status: "PROCESSING", lastAttemptAt: ctx.now },
|
|
||||||
});
|
|
||||||
if (claimed.count === 0) {
|
|
||||||
summary.skipped++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const booking = await db.booking.findUniqueOrThrow({ where: { id: installment.bookingId } });
|
|
||||||
|
|
||||||
// Schutz gegen jede Abbuchung ueber den vereinbarten Gesamtpreis hinaus,
|
|
||||||
// insbesondere nach der letzten Rate.
|
|
||||||
if (booking.paidCents + installment.amountCents > booking.totalCents) {
|
|
||||||
await db.installment.update({ where: { id: installment.id }, data: { status: "CANCELED", failureCode: "plan_already_paid" } });
|
|
||||||
await audit(db, WORKER, "installment.skipped_overpayment_guard", "Installment", installment.id, {
|
|
||||||
paidCents: booking.paidCents,
|
|
||||||
totalCents: booking.totalCents,
|
|
||||||
});
|
|
||||||
summary.skipped++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!booking.stripeCustomerId || !booking.stripePaymentMethodId || booking.paymentMethodDetachedAt) {
|
|
||||||
await db.$transaction((tx) =>
|
|
||||||
applyInstallmentFailed(tx, installment.id, { paymentIntentId: null, failureCode: "no_saved_payment_method", requiresAction: true }, eventCtx(ctx)),
|
|
||||||
);
|
|
||||||
summary.requiresAction++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let result;
|
|
||||||
try {
|
try {
|
||||||
result = await gateway.chargeOffSession(
|
const outcome = await ensureInstallmentSchedule(db, gateway, booking.id, ctx, WORKER);
|
||||||
{
|
if (outcome === "created") summary.created++;
|
||||||
customerId: booking.stripeCustomerId,
|
if (outcome === "needs_review") summary.needsReview++;
|
||||||
paymentMethodId: booking.stripePaymentMethodId,
|
|
||||||
amountCents: installment.amountCents,
|
|
||||||
description: `ARTISTA MODELCAMP 2027 · ${booking.reference} · Rate ${installment.seq}`,
|
|
||||||
metadata: {
|
|
||||||
kind: "installment_offsession",
|
|
||||||
bookingId: booking.id,
|
|
||||||
installmentId: installment.id,
|
|
||||||
reference: booking.reference,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// Gleicher Schluessel bei Wiederholung nach Netzwerkfehler: Stripe
|
|
||||||
// liefert dann das erste Ergebnis statt ein zweites Mal abzubuchen.
|
|
||||||
`offsession:${installment.id}:${installment.attemptCount}`,
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`[worker] Einzug Rate ${installment.id} unterbrochen: ${error instanceof Error ? error.message : "unbekannt"}`);
|
console.error(`[worker] Ratenplan fuer Buchung ${booking.id} nicht angelegt: ${error instanceof Error ? error.message : "unbekannt"}`);
|
||||||
await db.installment.updateMany({
|
|
||||||
where: { id: installment.id, status: "PROCESSING" },
|
|
||||||
data: { status: installment.status, nextAttemptAt: new Date(ctx.now.getTime() + 60 * 60_000) },
|
|
||||||
});
|
|
||||||
summary.failed++;
|
summary.failed++;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.outcome === "succeeded" && result.paymentIntentId) {
|
|
||||||
await db.$transaction((tx) =>
|
|
||||||
applyInstallmentPaid(
|
|
||||||
tx,
|
|
||||||
installment.id,
|
|
||||||
{
|
|
||||||
paymentIntentId: result.paymentIntentId!,
|
|
||||||
chargeId: result.chargeId,
|
|
||||||
paymentMethodId: booking.stripePaymentMethodId,
|
|
||||||
customerId: booking.stripeCustomerId,
|
|
||||||
amountCents: installment.amountCents,
|
|
||||||
},
|
|
||||||
eventCtx(ctx),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
summary.charged++;
|
|
||||||
} else if (result.outcome === "processing") {
|
|
||||||
await db.installment.update({ where: { id: installment.id }, data: { stripePaymentIntentId: result.paymentIntentId } });
|
|
||||||
summary.processing++;
|
|
||||||
} else {
|
|
||||||
await db.$transaction((tx) =>
|
|
||||||
applyInstallmentFailed(
|
|
||||||
tx,
|
|
||||||
installment.id,
|
|
||||||
{
|
|
||||||
paymentIntentId: result.paymentIntentId,
|
|
||||||
failureCode: result.failureCode,
|
|
||||||
requiresAction: result.outcome === "requires_action",
|
|
||||||
},
|
|
||||||
eventCtx(ctx),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (result.outcome === "requires_action") summary.requiresAction++;
|
|
||||||
else summary.failed++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Faengt haengende Einzuege und verlorene Webhooks auf. */
|
/**
|
||||||
export async function reconcileStuck(db: Db, gateway: PaymentGateway, ctx: HandlerContext) {
|
* Faengt verlorene Rechnungs-Webhooks auf: Ist eine Folgerate seit
|
||||||
const stuck = await db.installment.findMany({
|
* RECONCILE_AFTER_MS faellig und nicht verbucht, fragt der Worker Stripe
|
||||||
where: { status: "PROCESSING", lastAttemptAt: { lt: new Date(ctx.now.getTime() - STUCK_AFTER_MS) }, seq: { gt: 1 } },
|
* nach den Rechnungen des Zeitplans und verbucht bezahlte.
|
||||||
include: { booking: { select: { livemode: true } } },
|
*/
|
||||||
|
export async function reconcileInstallmentInvoices(db: Db, gateway: PaymentGateway, ctx: HandlerContext) {
|
||||||
|
const bookings = await db.booking.findMany({
|
||||||
|
where: {
|
||||||
|
stripeScheduleId: { not: null },
|
||||||
|
livemode: gateway.mode === "live",
|
||||||
|
installments: {
|
||||||
|
some: {
|
||||||
|
seq: { gt: 1 },
|
||||||
|
status: { in: ["PENDING", "FAILED", "REQUIRES_ACTION"] },
|
||||||
|
dueAt: { lt: new Date(ctx.now.getTime() - RECONCILE_AFTER_MS) },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
select: { id: true, stripeScheduleId: true },
|
||||||
take: 50,
|
take: 50,
|
||||||
});
|
});
|
||||||
let resolved = 0;
|
let settled = 0;
|
||||||
for (const installment of stuck) {
|
const failed = await eachBooking(bookings, "abgleichen", async (booking) => {
|
||||||
if (installment.booking.livemode !== (gateway.mode === "live")) continue;
|
const invoices = await gateway.listScheduleInvoices(booking.stripeScheduleId!);
|
||||||
if (installment.stripePaymentIntentId) {
|
for (const invoice of invoices.filter((i) => i.status === "paid")) {
|
||||||
const pi = await gateway.retrievePaymentIntent(installment.stripePaymentIntentId);
|
if (await settleInstallmentInvoice(db, gateway, invoice, ctx, WORKER)) settled++;
|
||||||
if (pi.status === "succeeded") {
|
|
||||||
await db.$transaction((tx) =>
|
|
||||||
applyInstallmentPaid(
|
|
||||||
tx,
|
|
||||||
installment.id,
|
|
||||||
{ paymentIntentId: pi.id, chargeId: pi.chargeId, paymentMethodId: pi.paymentMethodId, customerId: null, amountCents: pi.amountReceived },
|
|
||||||
eventCtx(ctx),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
resolved++;
|
|
||||||
} else if (pi.status === "requires_payment_method" || pi.status === "canceled" || pi.status === "requires_action") {
|
|
||||||
await db.$transaction((tx) =>
|
|
||||||
applyInstallmentFailed(
|
|
||||||
tx,
|
|
||||||
installment.id,
|
|
||||||
{ paymentIntentId: pi.id, failureCode: `stuck_${pi.status}`, requiresAction: pi.status === "requires_action" },
|
|
||||||
eventCtx(ctx),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
resolved++;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
// Kein Ergebnis gespeichert (z. B. Absturz waehrend des Aufrufs).
|
});
|
||||||
if (installment.lastAttemptAt && ctx.now.getTime() - installment.lastAttemptAt.getTime() < SAFE_RETRY_WINDOW_MS) {
|
return { checked: bookings.length, settled, failed };
|
||||||
// attemptCount bleibt gleich -> naechster Lauf nutzt denselben
|
}
|
||||||
// Idempotenzschluessel und kann nicht doppelt abbuchen.
|
|
||||||
await db.installment.updateMany({
|
|
||||||
where: { id: installment.id, status: "PROCESSING" },
|
|
||||||
data: { status: "FAILED", nextAttemptAt: ctx.now, failureCode: "worker_interrupted" },
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await db.installment.updateMany({
|
|
||||||
where: { id: installment.id, status: "PROCESSING" },
|
|
||||||
data: { status: "REQUIRES_ACTION", failureCode: "manual_check_required" },
|
|
||||||
});
|
|
||||||
await audit(db, WORKER, "installment.manual_check_required", "Installment", installment.id);
|
|
||||||
}
|
|
||||||
resolved++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/** Faengt verzoegerte erste Zahlungen (SEPA) auf, deren Ergebnis-Webhook ausblieb. */
|
||||||
|
export async function reconcileStuck(db: Db, gateway: PaymentGateway, ctx: HandlerContext) {
|
||||||
|
let resolved = 0;
|
||||||
// Verzoegerte erste Zahlungen (SEPA), deren Ergebnis-Webhook ausblieb.
|
// Verzoegerte erste Zahlungen (SEPA), deren Ergebnis-Webhook ausblieb.
|
||||||
const processing = await db.booking.findMany({
|
const processing = await db.booking.findMany({
|
||||||
where: {
|
where: {
|
||||||
@@ -276,6 +164,9 @@ export async function detachFinishedPaymentMethods(db: Db, gateway: PaymentGatew
|
|||||||
livemode: gateway.mode === "live",
|
livemode: gateway.mode === "live",
|
||||||
...(bookingIds ? { id: { in: bookingIds } } : {}),
|
...(bookingIds ? { id: { in: bookingIds } } : {}),
|
||||||
installments: { none: { status: { in: ["PENDING", "PROCESSING", "FAILED", "REQUIRES_ACTION"] } } },
|
installments: { none: { status: { in: ["PENDING", "PROCESSING", "FAILED", "REQUIRES_ACTION"] } } },
|
||||||
|
// Stornierte Buchungen mit Stripe-Ratenplan: erst den Plan beenden
|
||||||
|
// (stopCanceledInstallmentPlans), sonst zoege Stripe weiter ein.
|
||||||
|
NOT: { status: "CANCELED", stripeScheduleId: { not: null } },
|
||||||
},
|
},
|
||||||
take: 50,
|
take: 50,
|
||||||
});
|
});
|
||||||
@@ -290,9 +181,12 @@ export async function detachFinishedPaymentMethods(db: Db, gateway: PaymentGatew
|
|||||||
export async function runWorker(db: Db, gateway: PaymentGateway, ctx: HandlerContext) {
|
export async function runWorker(db: Db, gateway: PaymentGateway, ctx: HandlerContext) {
|
||||||
const reservations = await releaseExpiredReservations(db, gateway, ctx);
|
const reservations = await releaseExpiredReservations(db, gateway, ctx);
|
||||||
const reconcile = await reconcileStuck(db, gateway, ctx);
|
const reconcile = await reconcileStuck(db, gateway, ctx);
|
||||||
const installments = await chargeDueInstallments(db, gateway, ctx);
|
const held = await holdSchedulesInReview(db, gateway);
|
||||||
|
const schedules = await createMissingSchedules(db, gateway, ctx);
|
||||||
|
const installments = await reconcileInstallmentInvoices(db, gateway, ctx);
|
||||||
|
const stopped = await stopCanceledInstallmentPlans(db, gateway);
|
||||||
const detach = await detachFinishedPaymentMethods(db, gateway);
|
const detach = await detachFinishedPaymentMethods(db, gateway);
|
||||||
const emails = await flushEmails(db, { limit: 200 });
|
const emails = await flushEmails(db, { limit: 200 });
|
||||||
const purged = await purgeRateLimits(db);
|
const purged = await purgeRateLimits(db);
|
||||||
return { reservations, reconcile, installments, detach, emails, purgedRateLimits: purged };
|
return { reservations, reconcile, held, schedules, installments, stopped, detach, emails, purgedRateLimits: purged };
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,8 @@ import { beforeEach, describe, expect, test } from "vitest";
|
|||||||
import { cancelBooking, refundInstallment, saveVoucher, voucherInputSchema } from "@/lib/admin-service";
|
import { cancelBooking, refundInstallment, saveVoucher, voucherInputSchema } from "@/lib/admin-service";
|
||||||
import { startCheckout } from "@/lib/checkout";
|
import { startCheckout } from "@/lib/checkout";
|
||||||
import { handleStripeEvent } from "@/lib/webhook";
|
import { handleStripeEvent } from "@/lib/webhook";
|
||||||
import { chargeDueInstallments } from "@/lib/worker-jobs";
|
import { stopCanceledInstallmentPlans } from "@/lib/installment-billing";
|
||||||
|
import { detachFinishedPaymentMethods } from "@/lib/worker-jobs";
|
||||||
import { bookingRequest, db, EARLY_BIRD_NOW, resetDb, SECRET, setupCamp } from "./support/db";
|
import { bookingRequest, db, EARLY_BIRD_NOW, resetDb, SECRET, setupCamp } from "./support/db";
|
||||||
import { FakeGateway } from "./support/fake-gateway";
|
import { FakeGateway } from "./support/fake-gateway";
|
||||||
|
|
||||||
@@ -33,8 +34,10 @@ async function paidInstallmentBooking() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("Stornierung", () => {
|
describe("Stornierung", () => {
|
||||||
test("stoppt alle weiteren Abbuchungen, gibt Platz frei, trennt die Zahlungsmethode", async () => {
|
test("beendet den Stripe-Ratenplan, storniert offene Rechnungen, gibt Platz frei, trennt die Zahlungsmethode", async () => {
|
||||||
const booking = await paidInstallmentBooking();
|
const booking = await paidInstallmentBooking();
|
||||||
|
const schedule = gateway.schedules.get(booking.stripeScheduleId!)!;
|
||||||
|
const open = gateway.billNextInstallment(schedule.id, "failed");
|
||||||
const result = await cancelBooking(db, gateway, { bookingId: booking.id, reason: "Test" }, admin);
|
const result = await cancelBooking(db, gateway, { bookingId: booking.id, reason: "Test" }, admin);
|
||||||
expect(result.ok).toBe(true);
|
expect(result.ok).toBe(true);
|
||||||
|
|
||||||
@@ -42,14 +45,34 @@ describe("Stornierung", () => {
|
|||||||
expect(after.status).toBe("CANCELED");
|
expect(after.status).toBe("CANCELED");
|
||||||
expect(after.reservation!.status).toBe("RELEASED");
|
expect(after.reservation!.status).toBe("RELEASED");
|
||||||
expect(after.installments.filter((i) => i.seq > 1).every((i) => i.status === "CANCELED")).toBe(true);
|
expect(after.installments.filter((i) => i.seq > 1).every((i) => i.status === "CANCELED")).toBe(true);
|
||||||
|
expect(schedule.status).toBe("canceled");
|
||||||
|
expect((await gateway.retrieveInvoice(open.id)).status).toBe("void");
|
||||||
|
expect(() => gateway.billNextInstallment(schedule.id)).toThrow();
|
||||||
expect(gateway.detached).toEqual([booking.stripePaymentMethodId]);
|
expect(gateway.detached).toEqual([booking.stripePaymentMethodId]);
|
||||||
|
|
||||||
const later = { ...ctx, now: new Date("2027-06-01T12:00:00Z") };
|
|
||||||
await chargeDueInstallments(db, gateway, later);
|
|
||||||
expect(gateway.offSessionCharges).toHaveLength(0);
|
|
||||||
expect(await db.auditLog.count({ where: { action: "booking.canceled", actorId: "admin-test" } })).toBe(1);
|
expect(await db.auditLog.count({ where: { action: "booking.canceled", actorId: "admin-test" } })).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Stripe nicht erreichbar: Storno bleibt, der Worker beendet den Ratenplan spaeter", async () => {
|
||||||
|
const booking = await paidInstallmentBooking();
|
||||||
|
const schedule = gateway.schedules.get(booking.stripeScheduleId!)!;
|
||||||
|
const cancel = gateway.cancelInstallmentSchedule.bind(gateway);
|
||||||
|
gateway.cancelInstallmentSchedule = async () => {
|
||||||
|
throw new Error("Stripe nicht erreichbar (simuliert)");
|
||||||
|
};
|
||||||
|
const result = await cancelBooking(db, gateway, { bookingId: booking.id, reason: "Test" }, admin);
|
||||||
|
expect(result.ok).toBe(false);
|
||||||
|
expect(schedule.status).toBe("active");
|
||||||
|
// Der allgemeine Lauf trennt die Zahlungsmethode nicht, solange der Plan laeuft.
|
||||||
|
await detachFinishedPaymentMethods(db, gateway);
|
||||||
|
expect(gateway.detached).toEqual([]);
|
||||||
|
|
||||||
|
gateway.cancelInstallmentSchedule = cancel;
|
||||||
|
expect((await stopCanceledInstallmentPlans(db, gateway)).stopped).toBe(1);
|
||||||
|
expect(schedule.status).toBe("canceled");
|
||||||
|
expect(gateway.detached).toEqual([booking.stripePaymentMethodId]);
|
||||||
|
expect((await stopCanceledInstallmentPlans(db, gateway)).stopped).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
test("verlangt einen Grund", async () => {
|
test("verlangt einen Grund", async () => {
|
||||||
const booking = await paidInstallmentBooking();
|
const booking = await paidInstallmentBooking();
|
||||||
expect((await cancelBooking(db, gateway, { bookingId: booking.id, reason: " " }, admin)).ok).toBe(false);
|
expect((await cancelBooking(db, gateway, { bookingId: booking.id, reason: " " }, admin)).ok).toBe(false);
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import { beforeEach, describe, expect, test } from "vitest";
|
||||||
|
import { contactRequestSchema, submitContactRequest } from "@/lib/contact";
|
||||||
|
import { resetEnvCache } from "@/lib/env";
|
||||||
|
import { db, resetDb, SECRET, setupCamp } from "./support/db";
|
||||||
|
|
||||||
|
const NOW = new Date("2026-11-15T10:00:00Z");
|
||||||
|
const ctx = { now: NOW, secret: SECRET };
|
||||||
|
|
||||||
|
function request(overrides: Record<string, unknown> = {}) {
|
||||||
|
return contactRequestSchema.parse({
|
||||||
|
name: "Lena Beispiel",
|
||||||
|
email: "[email protected]",
|
||||||
|
phone: "",
|
||||||
|
availability: "abends",
|
||||||
|
message: "Passt das Camp für Einsteigerinnen?",
|
||||||
|
privacy: true,
|
||||||
|
website: "",
|
||||||
|
...overrides,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await resetDb();
|
||||||
|
await setupCamp({ organizerEmail: "[email protected]" });
|
||||||
|
delete process.env.ADMIN_NOTIFY_EMAIL;
|
||||||
|
resetEnvCache();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Erstgespräch", () => {
|
||||||
|
test("Anfrage landet als Mail beim Veranstalter, mit allen Angaben", async () => {
|
||||||
|
expect(await submitContactRequest(db, request(), ctx)).toEqual({ ok: true, delivered: true });
|
||||||
|
const mails = await db.emailMessage.findMany();
|
||||||
|
expect(mails).toHaveLength(1);
|
||||||
|
expect(mails[0]!.toAddress).toBe("[email protected]");
|
||||||
|
expect(mails[0]!.subject).toContain("Lena Beispiel");
|
||||||
|
expect(mails[0]!.textBody).toContain("[email protected]");
|
||||||
|
expect(mails[0]!.textBody).toContain("Passt das Camp für Einsteigerinnen?");
|
||||||
|
expect(mails[0]!.htmlBody).toContain("mailto:lena%40example.org");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("doppelt abgeschickt ergibt nur eine Mail", async () => {
|
||||||
|
await submitContactRequest(db, request(), ctx);
|
||||||
|
await submitContactRequest(db, request(), { ...ctx, now: new Date(NOW.getTime() + 10_000) });
|
||||||
|
expect(await db.emailMessage.count()).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Bot im Honeypot: Erfolg vortäuschen, nichts verschicken", async () => {
|
||||||
|
expect(await submitContactRequest(db, request({ website: "https://spam.example" }), ctx)).toEqual({ ok: true, delivered: false });
|
||||||
|
expect(await db.emailMessage.count()).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("ohne Empfänger nicht verfügbar, mit ADMIN_NOTIFY_EMAIL als Ersatz", async () => {
|
||||||
|
await setupCamp({ organizerEmail: null });
|
||||||
|
expect(await submitContactRequest(db, request(), ctx)).toEqual({ ok: false, error: "NOT_CONFIGURED" });
|
||||||
|
process.env.ADMIN_NOTIFY_EMAIL = "[email protected]";
|
||||||
|
resetEnvCache();
|
||||||
|
await submitContactRequest(db, request(), ctx);
|
||||||
|
expect((await db.emailMessage.findFirstOrThrow()).toAddress).toBe("[email protected]");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Pflichtangaben und Einwilligung werden serverseitig geprüft", () => {
|
||||||
|
expect(contactRequestSchema.safeParse({ name: "L", email: "kein-mail", privacy: false }).success).toBe(false);
|
||||||
|
expect(contactRequestSchema.safeParse({ name: "Lena", email: "[email protected]", privacy: false }).success).toBe(false);
|
||||||
|
expect(request({ phone: " " }).phone).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
import Stripe from "stripe";
|
import Stripe from "stripe";
|
||||||
import { beforeEach, describe, expect, test } from "vitest";
|
import { beforeEach, describe, expect, test } from "vitest";
|
||||||
import { startCheckout, startInstallmentCheckout } from "@/lib/checkout";
|
import { installmentPaymentUrl, startCheckout } from "@/lib/checkout";
|
||||||
import { applyRefundState, MAX_OFF_SESSION_ATTEMPTS } from "@/lib/payment-events";
|
import { applyRefundState } from "@/lib/payment-events";
|
||||||
import { verifyStripeWebhook } from "@/lib/payment-gateway";
|
import { verifyStripeWebhook } from "@/lib/payment-gateway";
|
||||||
import { handleStripeEvent, settleCheckoutSession } from "@/lib/webhook";
|
import { handleStripeEvent, settleCheckoutSession } from "@/lib/webhook";
|
||||||
import { chargeDueInstallments, detachFinishedPaymentMethods, releaseExpiredReservations } from "@/lib/worker-jobs";
|
import { createMissingSchedules, detachFinishedPaymentMethods, reconcileInstallmentInvoices, releaseExpiredReservations } from "@/lib/worker-jobs";
|
||||||
import { STRIPE_ACTOR } from "@/lib/audit";
|
import { STRIPE_ACTOR } from "@/lib/audit";
|
||||||
|
import { confirmReviewedBooking } from "@/lib/admin-service";
|
||||||
import type { PlanType } from "@/lib/payment-plan";
|
import type { PlanType } from "@/lib/payment-plan";
|
||||||
import { bookingRequest, db, EARLY_BIRD_NOW, resetDb, SECRET, setupCamp } from "./support/db";
|
import { bookingRequest, db, EARLY_BIRD_NOW, resetDb, SECRET, setupCamp } from "./support/db";
|
||||||
import { FakeGateway } from "./support/fake-gateway";
|
import { FakeGateway } from "./support/fake-gateway";
|
||||||
@@ -212,113 +213,187 @@ describe("Verzoegerte und verspaetete Zahlung", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Folgeraten", () => {
|
describe("Folgeraten ueber Stripe Billing", () => {
|
||||||
const afterLastDue = (booking: { installments: { dueAt: Date | null }[] }) => ({
|
function invoiceEvent(type: string, invoice: { id: string }, id = `evt_${crypto.randomUUID()}`) {
|
||||||
...ctx,
|
return { id, type, livemode: false, data: { object: { id: invoice.id, object: "invoice" } } } as unknown as Stripe.Event;
|
||||||
now: new Date(Math.max(...booking.installments.map((i) => i.dueAt?.getTime() ?? 0)) + 60_000),
|
}
|
||||||
|
|
||||||
|
async function scheduleOf(bookingId: string) {
|
||||||
|
const booking = await db.booking.findUniqueOrThrow({ where: { id: bookingId } });
|
||||||
|
return gateway.schedules.get(booking.stripeScheduleId!)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function installment(bookingId: string, seq: number) {
|
||||||
|
return db.installment.findFirstOrThrow({ where: { bookingId, seq } });
|
||||||
|
}
|
||||||
|
|
||||||
|
test("erste Rate bezahlt: Stripe-Ratenplan mit Betrag, Start, Abstand und Zahlungsmethode", async () => {
|
||||||
|
const booking = await paidBooking("THREE_INSTALLMENTS");
|
||||||
|
const [, second, third] = booking.installments;
|
||||||
|
const schedule = await scheduleOf(booking.id);
|
||||||
|
expect(schedule.params).toMatchObject({
|
||||||
|
amountCents: 70_000,
|
||||||
|
count: 2,
|
||||||
|
startAt: second!.dueAt,
|
||||||
|
intervalDays: Math.round((third!.dueAt!.getTime() - second!.dueAt!.getTime()) / 86_400_000),
|
||||||
|
paymentMethodId: booking.stripePaymentMethodId,
|
||||||
|
customerId: booking.stripeCustomerId,
|
||||||
|
});
|
||||||
|
expect(schedule.params.metadata).toMatchObject({ kind: "installment_plan", bookingId: booking.id });
|
||||||
|
|
||||||
|
// Erneut zugestelltes Checkout-Event legt keinen zweiten Plan an.
|
||||||
|
const session = await gateway.retrieveCheckoutSession(booking.stripeCheckoutSessionId!);
|
||||||
|
await handleStripeEvent(db, gateway, sessionEvent("checkout.session.async_payment_succeeded", session), ctx);
|
||||||
|
expect(gateway.schedules.size).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Einzug aller Raten, danach keine weitere Abbuchung und Zahlungsmethode getrennt", async () => {
|
test("Einmalzahlung legt keinen Ratenplan an", async () => {
|
||||||
|
await paidBooking("FULL");
|
||||||
|
expect(gateway.schedules.size).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Stripe zieht alle Raten ein; danach keine weitere Rechnung, Zahlungsmethode getrennt", async () => {
|
||||||
const booking = await paidBooking("THREE_INSTALLMENTS");
|
const booking = await paidBooking("THREE_INSTALLMENTS");
|
||||||
const runCtx = afterLastDue(booking);
|
const schedule = await scheduleOf(booking.id);
|
||||||
const summary = await chargeDueInstallments(db, gateway, runCtx);
|
for (let i = 0; i < 2; i++) {
|
||||||
expect(summary.charged).toBe(2);
|
const invoice = gateway.billNextInstallment(schedule.id);
|
||||||
let after = await db.booking.findUniqueOrThrow({ where: { id: booking.id } });
|
await handleStripeEvent(db, gateway, invoiceEvent("invoice.paid", invoice), ctx);
|
||||||
|
}
|
||||||
|
let after = await db.booking.findUniqueOrThrow({ where: { id: booking.id }, include: { installments: { orderBy: { seq: "asc" } } } });
|
||||||
expect(after.paymentStatus).toBe("PAID");
|
expect(after.paymentStatus).toBe("PAID");
|
||||||
expect(after.paidCents).toBe(220_000);
|
expect(after.paidCents).toBe(220_000);
|
||||||
|
expect(after.installments.map((i) => i.status)).toEqual(["PAID", "PAID", "PAID"]);
|
||||||
|
expect(gateway.billedCents).toBe(140_000);
|
||||||
|
expect(() => gateway.billNextInstallment(schedule.id)).toThrow();
|
||||||
|
|
||||||
await detachFinishedPaymentMethods(db, gateway);
|
await detachFinishedPaymentMethods(db, gateway);
|
||||||
after = await db.booking.findUniqueOrThrow({ where: { id: booking.id } });
|
after = await db.booking.findUniqueOrThrow({ where: { id: booking.id }, include: { installments: true } });
|
||||||
expect(after.paymentMethodDetachedAt).not.toBeNull();
|
expect(after.paymentMethodDetachedAt).not.toBeNull();
|
||||||
expect(gateway.detached).toEqual([booking.stripePaymentMethodId]);
|
expect(gateway.detached).toEqual([booking.stripePaymentMethodId]);
|
||||||
|
|
||||||
// Weitere Laeufe buchen nichts mehr ab.
|
|
||||||
await chargeDueInstallments(db, gateway, runCtx);
|
|
||||||
await chargeDueInstallments(db, gateway, { ...runCtx, now: new Date(runCtx.now.getTime() + 30 * 86_400_000) });
|
|
||||||
expect(gateway.offSessionCharges).toHaveLength(2);
|
|
||||||
expect(gateway.offSessionCharges.reduce((s, c) => s + c.amountCents, 0)).toBe(140_000);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("nur faellige Raten werden eingezogen", async () => {
|
test("doppelt zugestelltes invoice.paid wird nur einmal verbucht", async () => {
|
||||||
const booking = await paidBooking("THREE_INSTALLMENTS");
|
|
||||||
const between = { ...ctx, now: new Date(booking.installments[1]!.dueAt!.getTime() + 60_000) };
|
|
||||||
expect((await chargeDueInstallments(db, gateway, between)).charged).toBe(1);
|
|
||||||
const after = await db.booking.findUniqueOrThrow({ where: { id: booking.id } });
|
|
||||||
expect(after.paymentStatus).toBe("PARTIALLY_PAID");
|
|
||||||
expect(after.paidCents).toBe(150_000);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Fehlschlag: Wiederholung nach Wartezeit, nach dem letzten Versuch manuelle Pruefung", async () => {
|
|
||||||
const booking = await paidBooking("TWO_INSTALLMENTS");
|
const booking = await paidBooking("TWO_INSTALLMENTS");
|
||||||
gateway.offSessionOutcomes = ["failed", "failed", "failed"];
|
const invoice = gateway.billNextInstallment((await scheduleOf(booking.id)).id);
|
||||||
let runCtx = afterLastDue(booking);
|
await handleStripeEvent(db, gateway, invoiceEvent("invoice.paid", invoice), ctx);
|
||||||
for (let attempt = 1; attempt <= MAX_OFF_SESSION_ATTEMPTS; attempt++) {
|
await handleStripeEvent(db, gateway, invoiceEvent("invoice.paid", invoice), ctx);
|
||||||
await chargeDueInstallments(db, gateway, runCtx);
|
|
||||||
const inst = await db.installment.findFirstOrThrow({ where: { bookingId: booking.id, seq: 2 } });
|
|
||||||
expect(inst.status).toBe("FAILED");
|
|
||||||
expect(inst.attemptCount).toBe(attempt);
|
|
||||||
// Vor Ablauf der Wartezeit kein erneuter Versuch.
|
|
||||||
await chargeDueInstallments(db, gateway, runCtx);
|
|
||||||
expect((await db.installment.findFirstOrThrow({ where: { id: inst.id } })).attemptCount).toBe(attempt);
|
|
||||||
runCtx = { ...runCtx, now: new Date(runCtx.now.getTime() + 4 * 86_400_000) };
|
|
||||||
}
|
|
||||||
const after = await db.booking.findUniqueOrThrow({ where: { id: booking.id } });
|
|
||||||
expect(after.status).toBe("NEEDS_REVIEW");
|
|
||||||
expect(after.paymentStatus).toBe("PARTIALLY_PAID");
|
|
||||||
expect(gateway.offSessionCharges).toHaveLength(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Bank verlangt Authentifizierung: Kundin bekommt Link und zahlt selbst", async () => {
|
|
||||||
const booking = await paidBooking("TWO_INSTALLMENTS");
|
|
||||||
gateway.offSessionOutcomes = ["requires_action"];
|
|
||||||
const runCtx = afterLastDue(booking);
|
|
||||||
await chargeDueInstallments(db, gateway, runCtx);
|
|
||||||
const inst = await db.installment.findFirstOrThrow({ where: { bookingId: booking.id, seq: 2 } });
|
|
||||||
expect(inst.status).toBe("REQUIRES_ACTION");
|
|
||||||
expect(await db.emailMessage.count({ where: { dedupeKey: { startsWith: `installment-action:${inst.id}` } } })).toBe(1);
|
|
||||||
|
|
||||||
const pay = await startInstallmentCheckout(db, gateway, { bookingId: booking.id, installmentId: inst.id }, runCtx);
|
|
||||||
expect(pay.ok).toBe(true);
|
|
||||||
// Waehrend die Session offen ist, zieht der Worker nicht parallel ein.
|
|
||||||
await chargeDueInstallments(db, gateway, { ...runCtx, now: new Date(runCtx.now.getTime() + 60_000) });
|
|
||||||
expect(gateway.offSessionCharges).toHaveLength(0);
|
|
||||||
|
|
||||||
const sessionId = (await db.installment.findUniqueOrThrow({ where: { id: inst.id } })).checkoutSessionId!;
|
|
||||||
const session = gateway.completeSession(sessionId);
|
|
||||||
await handleStripeEvent(db, gateway, sessionEvent("checkout.session.completed", session), runCtx);
|
|
||||||
const after = await db.booking.findUniqueOrThrow({ where: { id: booking.id } });
|
|
||||||
expect(after.paymentStatus).toBe("PAID");
|
|
||||||
expect(after.paidCents).toBe(220_000);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Webhook und Worker melden denselben Erfolg: nur einmal verbucht", async () => {
|
|
||||||
const booking = await paidBooking("TWO_INSTALLMENTS");
|
|
||||||
const runCtx = afterLastDue(booking);
|
|
||||||
await chargeDueInstallments(db, gateway, runCtx);
|
|
||||||
const inst = await db.installment.findFirstOrThrow({ where: { bookingId: booking.id, seq: 2 } });
|
|
||||||
const pi = await gateway.retrievePaymentIntent(inst.stripePaymentIntentId!);
|
|
||||||
const event = {
|
|
||||||
id: "evt_pi_ok",
|
|
||||||
type: "payment_intent.succeeded",
|
|
||||||
livemode: false,
|
|
||||||
data: {
|
|
||||||
object: {
|
|
||||||
id: pi.id,
|
|
||||||
object: "payment_intent",
|
|
||||||
amount_received: pi.amountReceived,
|
|
||||||
latest_charge: pi.chargeId,
|
|
||||||
payment_method: pi.paymentMethodId,
|
|
||||||
customer: null,
|
|
||||||
metadata: pi.metadata,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as unknown as Stripe.Event;
|
|
||||||
await handleStripeEvent(db, gateway, event, runCtx);
|
|
||||||
const after = await db.booking.findUniqueOrThrow({ where: { id: booking.id } });
|
const after = await db.booking.findUniqueOrThrow({ where: { id: booking.id } });
|
||||||
expect(after.paidCents).toBe(220_000);
|
expect(after.paidCents).toBe(220_000);
|
||||||
expect(after.status).toBe("CONFIRMED");
|
expect(after.status).toBe("CONFIRMED");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("verlorener Rechnungs-Webhook: Worker gleicht mit Stripe ab", async () => {
|
||||||
|
const booking = await paidBooking("TWO_INSTALLMENTS");
|
||||||
|
gateway.billNextInstallment((await scheduleOf(booking.id)).id);
|
||||||
|
const second = await installment(booking.id, 2);
|
||||||
|
// Vor Faelligkeit wird nicht gefragt.
|
||||||
|
expect((await reconcileInstallmentInvoices(db, gateway, ctx)).checked).toBe(0);
|
||||||
|
const later = { ...ctx, now: new Date(second.dueAt!.getTime() + 7 * 60 * 60_000) };
|
||||||
|
expect((await reconcileInstallmentInvoices(db, gateway, later)).settled).toBe(1);
|
||||||
|
const after = await db.booking.findUniqueOrThrow({ where: { id: booking.id } });
|
||||||
|
expect(after.paymentStatus).toBe("PAID");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Fehlschlag: Stripe wiederholt, Kundin wird informiert, nach dem letzten Versuch Pruefung", async () => {
|
||||||
|
const booking = await paidBooking("TWO_INSTALLMENTS");
|
||||||
|
const failed = gateway.billNextInstallment((await scheduleOf(booking.id)).id, "failed");
|
||||||
|
await handleStripeEvent(db, gateway, invoiceEvent("invoice.payment_failed", failed), ctx);
|
||||||
|
await handleStripeEvent(db, gateway, invoiceEvent("invoice.payment_failed", failed), ctx);
|
||||||
|
let second = await installment(booking.id, 2);
|
||||||
|
expect(second.status).toBe("FAILED");
|
||||||
|
expect(second.stripeInvoiceId).toBe(failed.id);
|
||||||
|
expect(second.nextAttemptAt).not.toBeNull();
|
||||||
|
expect(await db.emailMessage.count({ where: { dedupeKey: { startsWith: `installment-action:${second.id}` } } })).toBe(1);
|
||||||
|
expect((await db.booking.findUniqueOrThrow({ where: { id: booking.id } })).status).toBe("CONFIRMED");
|
||||||
|
|
||||||
|
const final = gateway.retryInvoice(failed.id, "failed", { finalAttempt: true });
|
||||||
|
await handleStripeEvent(db, gateway, invoiceEvent("invoice.payment_failed", final), ctx);
|
||||||
|
second = await installment(booking.id, 2);
|
||||||
|
expect(second.attemptCount).toBe(2);
|
||||||
|
expect(second.nextAttemptAt).toBeNull();
|
||||||
|
const after = await db.booking.findUniqueOrThrow({ where: { id: booking.id } });
|
||||||
|
expect(after.status).toBe("NEEDS_REVIEW");
|
||||||
|
expect(after.paymentStatus).toBe("PARTIALLY_PAID");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Bank verlangt Bestaetigung: Kundin zahlt ueber Stripes Rechnungsseite", async () => {
|
||||||
|
const booking = await paidBooking("TWO_INSTALLMENTS");
|
||||||
|
const open = gateway.billNextInstallment((await scheduleOf(booking.id)).id, "requires_action");
|
||||||
|
await handleStripeEvent(db, gateway, invoiceEvent("invoice.payment_action_required", open), ctx);
|
||||||
|
const second = await installment(booking.id, 2);
|
||||||
|
expect(second.status).toBe("REQUIRES_ACTION");
|
||||||
|
|
||||||
|
const pay = await installmentPaymentUrl(db, gateway, { bookingId: booking.id, installmentId: second.id });
|
||||||
|
expect(pay).toEqual({ ok: true, url: `https://invoice.stripe.test/${open.id}` });
|
||||||
|
|
||||||
|
const paid = gateway.retryInvoice(open.id, "paid");
|
||||||
|
await handleStripeEvent(db, gateway, invoiceEvent("invoice.paid", paid), ctx);
|
||||||
|
const after = await db.booking.findUniqueOrThrow({ where: { id: booking.id } });
|
||||||
|
expect(after.paymentStatus).toBe("PAID");
|
||||||
|
expect(after.paidCents).toBe(220_000);
|
||||||
|
// Bezahlte Rate hat keinen Zahlungslink mehr.
|
||||||
|
expect((await installmentPaymentUrl(db, gateway, { bookingId: booking.id, installmentId: second.id })).ok).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Rueckbuchung: Stripe zieht bis zur Entscheidung nichts ein, nach Bestaetigung neuer Plan", async () => {
|
||||||
|
const booking = await paidBooking("THREE_INSTALLMENTS");
|
||||||
|
const first = await scheduleOf(booking.id);
|
||||||
|
const dispute = {
|
||||||
|
id: `evt_${crypto.randomUUID()}`,
|
||||||
|
type: "charge.dispute.created",
|
||||||
|
livemode: false,
|
||||||
|
data: { object: { id: "dp_1", object: "dispute", payment_intent: booking.installments[0]!.stripePaymentIntentId } },
|
||||||
|
} as unknown as Stripe.Event;
|
||||||
|
await handleStripeEvent(db, gateway, dispute, ctx);
|
||||||
|
|
||||||
|
let after = await db.booking.findUniqueOrThrow({ where: { id: booking.id }, include: { installments: { orderBy: { seq: "asc" } } } });
|
||||||
|
expect(after.status).toBe("NEEDS_REVIEW");
|
||||||
|
expect(after.stripeScheduleId).toBeNull();
|
||||||
|
expect(first.status).toBe("canceled");
|
||||||
|
expect(after.installments.map((i) => i.status)).toEqual(["PAID", "PENDING", "PENDING"]);
|
||||||
|
// Waehrend der Pruefung legt der Worker keinen neuen Plan an.
|
||||||
|
expect((await createMissingSchedules(db, gateway, ctx)).created).toBe(0);
|
||||||
|
|
||||||
|
expect((await confirmReviewedBooking(db, booking.id, { type: "ADMIN", id: "admin-test" }, ctx.now)).ok).toBe(true);
|
||||||
|
expect((await createMissingSchedules(db, gateway, ctx)).created).toBe(1);
|
||||||
|
after = await db.booking.findUniqueOrThrow({ where: { id: booking.id }, include: { installments: true } });
|
||||||
|
const second = gateway.schedules.get(after.stripeScheduleId!)!;
|
||||||
|
expect(second.id).not.toBe(first.id);
|
||||||
|
expect(second.params).toMatchObject({ amountCents: 70_000, count: 2 });
|
||||||
|
});
|
||||||
|
|
||||||
|
test("ID des Plans ging verloren: kein zweiter Plan bei Stripe", async () => {
|
||||||
|
const booking = await paidBooking("TWO_INSTALLMENTS");
|
||||||
|
await db.booking.update({ where: { id: booking.id }, data: { stripeScheduleId: null } });
|
||||||
|
expect((await createMissingSchedules(db, gateway, ctx)).created).toBe(1);
|
||||||
|
expect(gateway.schedules.size).toBe(1);
|
||||||
|
const after = await db.booking.findUniqueOrThrow({ where: { id: booking.id } });
|
||||||
|
expect(after.stripeScheduleId).toBe([...gateway.schedules.keys()][0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Faelligkeit schon vorbei: Start am naechsten 9-Uhr-Termin, letzte Rate bleibt am Stichtag", async () => {
|
||||||
|
gateway.failNextSchedule = true;
|
||||||
|
const booking = await paidBooking("THREE_INSTALLMENTS");
|
||||||
|
const [, second, third] = booking.installments;
|
||||||
|
const late = { ...ctx, now: new Date(second!.dueAt!.getTime() + 3 * 86_400_000 + 2 * 60 * 60_000) };
|
||||||
|
expect((await createMissingSchedules(db, gateway, late)).created).toBe(1);
|
||||||
|
const schedule = [...gateway.schedules.values()][0]!;
|
||||||
|
expect(schedule.params.startAt.getTime()).toBeGreaterThan(late.now.getTime());
|
||||||
|
expect(schedule.params.startAt.getTime() - late.now.getTime()).toBeLessThanOrEqual(86_400_000);
|
||||||
|
const end = schedule.params.startAt.getTime() + schedule.params.intervalDays * 86_400_000;
|
||||||
|
expect(Math.abs(end - third!.dueAt!.getTime())).toBeLessThanOrEqual(60 * 60_000);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Ratenplan-Anlage scheitert: Zahlung bleibt verbucht, Worker holt die Anlage nach", async () => {
|
||||||
|
gateway.failNextSchedule = true;
|
||||||
|
const booking = await paidBooking("TWO_INSTALLMENTS");
|
||||||
|
expect(booking.status).toBe("CONFIRMED");
|
||||||
|
expect(booking.stripeScheduleId).toBeNull();
|
||||||
|
expect((await createMissingSchedules(db, gateway, ctx)).created).toBe(1);
|
||||||
|
expect(gateway.schedules.size).toBe(1);
|
||||||
|
expect((await createMissingSchedules(db, gateway, ctx)).created).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
test("Erstattung aktualisiert Zahlungsstatus absolut (ungeordnete Events harmlos)", async () => {
|
test("Erstattung aktualisiert Zahlungsstatus absolut (ungeordnete Events harmlos)", async () => {
|
||||||
const booking = await paidBooking("FULL");
|
const booking = await paidBooking("FULL");
|
||||||
const pi = booking.installments[0]!.stripePaymentIntentId!;
|
const pi = booking.installments[0]!.stripePaymentIntentId!;
|
||||||
|
|||||||
@@ -1,30 +1,32 @@
|
|||||||
import type {
|
import type {
|
||||||
CheckoutSessionInfo,
|
CheckoutSessionInfo,
|
||||||
CreateCheckoutParams,
|
CreateCheckoutParams,
|
||||||
OffSessionResult,
|
CreateInstallmentScheduleParams,
|
||||||
|
InvoiceInfo,
|
||||||
PaymentGateway,
|
PaymentGateway,
|
||||||
PaymentIntentInfo,
|
PaymentIntentInfo,
|
||||||
} from "@/lib/payment-gateway";
|
} from "@/lib/payment-gateway";
|
||||||
import type { StripeMode } from "@/lib/sales-gate";
|
import type { StripeMode } from "@/lib/sales-gate";
|
||||||
|
|
||||||
type StoredSession = CheckoutSessionInfo & { params: CreateCheckoutParams };
|
type StoredSession = CheckoutSessionInfo & { params: CreateCheckoutParams };
|
||||||
|
type StoredSchedule = { id: string; status: "active" | "canceled"; params: CreateInstallmentScheduleParams; invoiceIds: string[] };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stripe-Attrappe im Speicher. Bildet die fuer die Geschaeftslogik
|
* Stripe-Attrappe im Speicher. Bildet die fuer die Geschaeftslogik
|
||||||
* relevanten Eigenschaften nach: Idempotenzschluessel, Session-Zustaende,
|
* relevanten Eigenschaften nach: Idempotenzschluessel, Session-Zustaende,
|
||||||
* PaymentIntents und das Ergebnis von Off-Session-Einzuegen.
|
* PaymentIntents und die Rechnungen eines Stripe-Billing-Ratenplans.
|
||||||
*/
|
*/
|
||||||
export class FakeGateway implements PaymentGateway {
|
export class FakeGateway implements PaymentGateway {
|
||||||
private seq = 0;
|
private seq = 0;
|
||||||
private readonly byKey = new Map<string, unknown>();
|
private readonly byKey = new Map<string, unknown>();
|
||||||
readonly sessions = new Map<string, StoredSession>();
|
readonly sessions = new Map<string, StoredSession>();
|
||||||
readonly paymentIntents = new Map<string, PaymentIntentInfo>();
|
readonly paymentIntents = new Map<string, PaymentIntentInfo>();
|
||||||
readonly offSessionCharges: { key: string; amountCents: number; installmentId: string }[] = [];
|
readonly schedules = new Map<string, StoredSchedule>();
|
||||||
|
readonly invoices = new Map<string, InvoiceInfo>();
|
||||||
readonly detached: string[] = [];
|
readonly detached: string[] = [];
|
||||||
readonly refunds: { id: string; paymentIntentId: string; amountCents: number }[] = [];
|
readonly refunds: { id: string; paymentIntentId: string; amountCents: number }[] = [];
|
||||||
/** Ergebnisse fuer die naechsten Off-Session-Einzuege (Standard: Erfolg). */
|
|
||||||
offSessionOutcomes: OffSessionResult["outcome"][] = [];
|
|
||||||
failNextCheckout = false;
|
failNextCheckout = false;
|
||||||
|
failNextSchedule = false;
|
||||||
|
|
||||||
constructor(readonly mode: StripeMode = "test") {}
|
constructor(readonly mode: StripeMode = "test") {}
|
||||||
|
|
||||||
@@ -101,34 +103,101 @@ export class FakeGateway implements PaymentGateway {
|
|||||||
return { ...pi };
|
return { ...pi };
|
||||||
}
|
}
|
||||||
|
|
||||||
async chargeOffSession(
|
async createInstallmentSchedule(params: CreateInstallmentScheduleParams, key: string) {
|
||||||
params: { customerId: string; paymentMethodId: string; amountCents: number; metadata: Record<string, string> },
|
if (this.failNextSchedule) {
|
||||||
key: string,
|
this.failNextSchedule = false;
|
||||||
): Promise<OffSessionResult> {
|
throw new Error("Stripe nicht erreichbar (simuliert)");
|
||||||
return this.once(`pi:${key}`, () => {
|
}
|
||||||
const outcome = this.offSessionOutcomes.shift() ?? "succeeded";
|
return this.once(`sub_sched:${key}`, () => {
|
||||||
const piId = this.id("pi");
|
const id = this.id("sub_sched");
|
||||||
const chargeId = outcome === "succeeded" ? this.id("ch") : null;
|
this.schedules.set(id, { id, status: "active", params, invoiceIds: [] });
|
||||||
this.paymentIntents.set(piId, {
|
return { id };
|
||||||
id: piId,
|
|
||||||
status: outcome === "succeeded" ? "succeeded" : outcome === "processing" ? "processing" : outcome === "requires_action" ? "requires_action" : "requires_payment_method",
|
|
||||||
amountReceived: outcome === "succeeded" ? params.amountCents : 0,
|
|
||||||
paymentMethodId: params.paymentMethodId,
|
|
||||||
chargeId,
|
|
||||||
metadata: params.metadata,
|
|
||||||
});
|
|
||||||
if (outcome === "succeeded") {
|
|
||||||
this.offSessionCharges.push({ key, amountCents: params.amountCents, installmentId: params.metadata.installmentId! });
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
outcome,
|
|
||||||
paymentIntentId: piId,
|
|
||||||
chargeId,
|
|
||||||
failureCode: outcome === "failed" ? "card_declined" : outcome === "requires_action" ? "authentication_required" : null,
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findInstallmentSchedule(customerId: string, bookingId: string): Promise<{ id: string } | null> {
|
||||||
|
const found = [...this.schedules.values()].find(
|
||||||
|
(s) => s.status === "active" && s.params.customerId === customerId && s.params.metadata.bookingId === bookingId,
|
||||||
|
);
|
||||||
|
return found ? { id: found.id } : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async cancelInstallmentSchedule(id: string): Promise<void> {
|
||||||
|
const schedule = this.schedules.get(id);
|
||||||
|
if (!schedule) throw new Error(`Unbekannter Zeitplan ${id}`);
|
||||||
|
schedule.status = "canceled";
|
||||||
|
for (const invoiceId of schedule.invoiceIds) {
|
||||||
|
const invoice = this.invoices.get(invoiceId)!;
|
||||||
|
if (invoice.status === "open") this.invoices.set(invoiceId, { ...invoice, status: "void", hostedInvoiceUrl: null });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async retrieveInvoice(id: string): Promise<InvoiceInfo> {
|
||||||
|
const invoice = this.invoices.get(id);
|
||||||
|
if (!invoice) throw new Error(`Unbekannte Rechnung ${id}`);
|
||||||
|
return { ...invoice };
|
||||||
|
}
|
||||||
|
|
||||||
|
async listScheduleInvoices(scheduleId: string): Promise<InvoiceInfo[]> {
|
||||||
|
return (this.schedules.get(scheduleId)?.invoiceIds ?? []).map((id) => ({ ...this.invoices.get(id)! }));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simuliert den naechsten Einzug durch Stripe Billing: erzeugt die
|
||||||
|
* naechste Rechnung des Zeitplans, bezahlt oder offen. Ein aktiver Zeitplan
|
||||||
|
* erzeugt nie mehr Rechnungen als Folgeraten.
|
||||||
|
*/
|
||||||
|
billNextInstallment(scheduleId: string, outcome: "paid" | "failed" | "requires_action" = "paid", opts: { finalAttempt?: boolean } = {}): InvoiceInfo {
|
||||||
|
const schedule = this.schedules.get(scheduleId);
|
||||||
|
if (!schedule || schedule.status !== "active") throw new Error(`Zeitplan ${scheduleId} ist nicht aktiv`);
|
||||||
|
if (schedule.invoiceIds.length >= schedule.params.count) throw new Error("Zeitplan hat bereits alle Raten abgerechnet");
|
||||||
|
const id = this.id("in");
|
||||||
|
schedule.invoiceIds.push(id);
|
||||||
|
const invoice = this.invoiceResult(id, schedule, outcome, 1, opts.finalAttempt ?? false);
|
||||||
|
this.invoices.set(id, invoice);
|
||||||
|
return { ...invoice };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Simuliert einen weiteren Versuch (Smart Retry oder Zahlung ueber die Rechnungsseite). */
|
||||||
|
retryInvoice(invoiceId: string, outcome: "paid" | "failed" | "requires_action", opts: { finalAttempt?: boolean } = {}): InvoiceInfo {
|
||||||
|
const current = this.invoices.get(invoiceId)!;
|
||||||
|
if (current.status !== "open") throw new Error(`Rechnung ${invoiceId} ist nicht offen`);
|
||||||
|
const schedule = [...this.schedules.values()].find((s) => s.invoiceIds.includes(invoiceId))!;
|
||||||
|
const invoice = this.invoiceResult(invoiceId, schedule, outcome, current.attemptCount + 1, opts.finalAttempt ?? false);
|
||||||
|
this.invoices.set(invoiceId, invoice);
|
||||||
|
return { ...invoice };
|
||||||
|
}
|
||||||
|
|
||||||
|
private invoiceResult(id: string, schedule: StoredSchedule, outcome: "paid" | "failed" | "requires_action", attempt: number, finalAttempt: boolean): InvoiceInfo {
|
||||||
|
let paymentIntentId: string | null = null;
|
||||||
|
if (outcome === "paid") {
|
||||||
|
paymentIntentId = this.id("pi");
|
||||||
|
this.paymentIntents.set(paymentIntentId, {
|
||||||
|
id: paymentIntentId,
|
||||||
|
status: "succeeded",
|
||||||
|
amountReceived: schedule.params.amountCents,
|
||||||
|
paymentMethodId: schedule.params.paymentMethodId,
|
||||||
|
chargeId: this.id("ch"),
|
||||||
|
metadata: {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
status: outcome === "paid" ? "paid" : "open",
|
||||||
|
amountPaidCents: outcome === "paid" ? schedule.params.amountCents : 0,
|
||||||
|
paymentIntentId,
|
||||||
|
hostedInvoiceUrl: outcome === "paid" ? null : `https://invoice.stripe.test/${id}`,
|
||||||
|
attemptCount: attempt,
|
||||||
|
nextPaymentAttempt: outcome === "failed" && !finalAttempt ? new Date(Date.UTC(2027, 0, 1) + attempt * 86_400_000) : null,
|
||||||
|
metadata: schedule.params.metadata,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Summe aller ueber den Zeitplan eingezogenen Betraege. */
|
||||||
|
get billedCents(): number {
|
||||||
|
return [...this.invoices.values()].reduce((sum, i) => sum + i.amountPaidCents, 0);
|
||||||
|
}
|
||||||
|
|
||||||
async detachPaymentMethod(id: string): Promise<void> {
|
async detachPaymentMethod(id: string): Promise<void> {
|
||||||
this.detached.push(id);
|
this.detached.push(id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user