More improvements

This commit is contained in:
2026-08-05 10:55:06 +02:00
parent e55cdd1988
commit a0d26648ee
20 changed files with 279 additions and 216 deletions
+16 -6
View File
@@ -59,13 +59,23 @@ Beispiel GiroCode (nur Überweisung):
## Anmelde-Zusammenfassung / Mail-Anzeige
- `registrationSummary(RegistrationSummaryRequest): RegistrationSummaryResponse` liefert den zahlungsspezifischen
Anzeige-Block render-agnostisch: entweder `lines` (label/value, z.B. Überweisung) oder `html` (Freitext, z.B.
Barzahlung), plus `hasPaymentInformation` und `showGiroCode`.
Anzeige-Block **fertig als HTML** (`hasPaymentInformation` + `html`). Jedes Modul rendert seinen Block über
eigene Blade-Templates unter `resources/views/payment-modules/{modul}/{web,mail}.blade.php` (Überweisung:
`account-transfer/`, Barzahlung: `undefined/` — Rahmen um den konfigurierten richtext). Die Render-Stellen geben
nur noch `v-html` / `{!! !!}` aus — **keine** zahlart-spezifische Logik im Frontend/Blade.
- **Render-Kontext:** `RegistrationSummaryRequest` trägt einen `RegistrationRenderContext` (`Web`/`Mail`). Das Modul
wählt darüber (a) ein **medien-gerechtes Template**`resources/views/payment-modules/{modul}/{web,mail}.blade.php`
(Web: SPA-Klassen `form-table`/`link`; Mail: E-Mail-taugliche Inline-Styles) und (b) die GiroCode-Bildquelle —
Web: `/print-girocode/{token}` (sessionlos, lazy), Mail: `cid:girocode.png` (inline via `$message->embedData(...)`,
bereitgestellt im dünnen Wrapper `emails/subparts/payment.blade.php`).
Hinweis: Das Web-Template darf globale (un-scoped) SPA-Klassen nutzen, da Vue-`scoped`-Styles nicht auf `v-html`
greifen.
- Zugang über das Teilnehmer-Model: `EventParticipant::paymentModule()`, `paymentConfiguration()` (eager-load-fähig über
`->with('event.paymentMethods')`, kein statischer Cache), `paymentSummary()`.
- Konsumiert von `EventParticipantResource` (`paymentSummary`), `SubmitSuccess.vue`, `emails/subparts/payment.blade.php`
(+ `signup_complete`, `missing_amount`). GiroCode in Mails: **inline per CID** (`$message->embedData(...)`), im Web
über `/print-girocode/{token}` (sessionlos, lazy).
`->with('event.paymentMethods')`, kein statischer Cache), `paymentSummary(RegistrationRenderContext)`.
- Konsumiert von `EventParticipantResource` (`paymentSummary` = `{hasPaymentInformation, html}`, Web-Kontext),
`SubmitSuccess.vue`, den Mails (`EventSignUpSuccessfullMail`/`ParticipantPaymentMissingPaymentMail` rufen
`paymentSummary(Mail)`), sowie `signup_complete`/`missing_amount` (nur umrahmende Prosa, gegated auf
`hasPaymentInformation`).
## Neues Zahlungsmodul hinzufügen
@@ -0,0 +1,13 @@
<?php
namespace App\EventPaymentModules\DTO;
/**
* Render-Kontext der Anmelde-Zusammenfassung. Steuert die kontextabhängige Einbettung des GiroCodes:
* im Web über den Endpoint, in der Mail über eine inline-CID.
*/
enum RegistrationRenderContext
{
case Web;
case Mail;
}
@@ -8,7 +8,8 @@ use App\Models\EventParticipant;
* Eingabe für {@see \App\EventPaymentModules\EventPaymentModule::registrationSummary()}.
*
* Anker ist der (bereits erstellte) Teilnehmer -- daraus leiten die Module Event, Betrag/Restbetrag
* und Verwendungszweck ab. $configuration ist die aufgelöste pro-Event-Config des Zahlungsmoduls.
* und Verwendungszweck ab. $configuration ist die aufgelöste pro-Event-Config des Zahlungsmoduls,
* $context steuert die kontextabhängige Ausgabe (z.B. GiroCode-Einbettung Web vs. Mail).
*/
final class RegistrationSummaryRequest
{
@@ -18,6 +19,7 @@ final class RegistrationSummaryRequest
public function __construct(
public readonly EventParticipant $participant,
public readonly array $configuration = [],
public readonly RegistrationRenderContext $context = RegistrationRenderContext::Web,
) {
}
}
@@ -5,22 +5,14 @@ namespace App\EventPaymentModules\DTO;
/**
* Ausgabe von {@see \App\EventPaymentModules\EventPaymentModule::registrationSummary()}.
*
* Render-agnostisch: speist den Zahlungs-Abschnitt sowohl im Anmeldeabschluss (Vue) als auch in den Mails.
* Zwei Darstellungsformen:
* - strukturierte $lines (label/value) -- z.B. Überweisung (Kontoinhaber, IBAN, Verwendungszweck, Betrag),
* - $html -- frei konfigurierter Text (z.B. Barzahlung).
* Das Modul erzeugt seinen Zahlungs-Block vollständig als HTML; die Render-Stellen (Anmeldeabschluss,
* Mails) geben ihn nur noch per `v-html` / `{!! !!}` aus.
*/
final class RegistrationSummaryResponse
{
/** Gibt es überhaupt einen Zahlungs-Info-Block darzustellen? */
/** Gibt es überhaupt einen Zahlungs-Block darzustellen? */
public bool $hasPaymentInformation = false;
/** @var array<int, array{label: string, value: string}> */
public array $lines = [];
/** Frei konfigurierter HTML-Text (alternativ zu $lines). */
public ?string $html = null;
/** Soll der GiroCode (QR) angezeigt werden? */
public bool $showGiroCode = false;
/** Fertig gerenderter HTML-Block der Zahlungsinformationen. */
public string $html = '';
}
@@ -4,6 +4,7 @@ namespace App\EventPaymentModules\Modules;
use App\EventPaymentModules\AbstractEventPaymentModule;
use App\EventPaymentModules\DTO\CreateInvoiceRequest;
use App\EventPaymentModules\DTO\RegistrationRenderContext;
use App\EventPaymentModules\DTO\RegistrationSummaryRequest;
use App\EventPaymentModules\DTO\RegistrationSummaryResponse;
use App\EventPaymentModules\ProvidesGiroCode;
@@ -45,15 +46,32 @@ class AccountTransferPaymentModule extends AbstractEventPaymentModule implements
$amountLeft->subtractAmount($participant->amount_paid);
}
$hasPaymentInformation = $amountLeft->getAmount() > 0;
// GiroCode nur bei offenem Betrag; Bildquelle je Render-Kontext (Web-Endpoint vs. Mail-CID).
$giroCodeSrc = null;
if ($hasPaymentInformation) {
$giroCodeSrc = $request->context === RegistrationRenderContext::Mail
? 'cid:girocode.png'
: '/print-girocode/' . $participant->identifier;
}
// Medien-gerechtes Template je Render-Kontext (Web: SPA-Klassen, Mail: E-Mail-tauglich).
$view = $request->context === RegistrationRenderContext::Mail
? 'payment-modules.account-transfer.mail'
: 'payment-modules.account-transfer.web';
$response = new RegistrationSummaryResponse();
$response->hasPaymentInformation = $amountLeft->getAmount() > 0;
$response->showGiroCode = $response->hasPaymentInformation;
$response->lines = [
['label' => 'Kontoinhaber', 'value' => (string)($config['account_owner'] ?? '')],
['label' => 'IBAN', 'value' => (string)($config['iban'] ?? '')],
['label' => 'Verwendungszweck', 'value' => (string)$participant->payment_purpose],
['label' => 'Betrag', 'value' => $amountLeft->toString()],
];
$response->hasPaymentInformation = $hasPaymentInformation;
$response->html = view($view, [
'accountOwner' => (string)($config['account_owner'] ?? ''),
'iban' => (string)($config['iban'] ?? ''),
'paymentPurpose' => (string)$participant->payment_purpose,
'amount' => $amountLeft->toString(),
'giroCodeSrc' => $giroCodeSrc,
'reminderUrl' => url('/api/v1/event/participant/' . $participant->identifier . '/ical-payment'),
'paymentDeadline' => $participant->event?->registration_final_end?->format('d.m.Y'),
])->render();
return $response;
}
@@ -4,6 +4,7 @@ namespace App\EventPaymentModules\Modules;
use App\EventPaymentModules\AbstractEventPaymentModule;
use App\EventPaymentModules\DTO\CreateInvoiceRequest;
use App\EventPaymentModules\DTO\RegistrationRenderContext;
use App\EventPaymentModules\DTO\RegistrationSummaryRequest;
use App\EventPaymentModules\DTO\RegistrationSummaryResponse;
use App\Models\PaymentMethod;
@@ -33,12 +34,19 @@ class UndefinedPaymentModule extends AbstractEventPaymentModule
public function registrationSummary(RegistrationSummaryRequest $request): RegistrationSummaryResponse
{
$html = (string)($request->configuration['payment_information'] ?? '');
$paymentInformation = (string)($request->configuration['payment_information'] ?? '');
$response = new RegistrationSummaryResponse();
$response->hasPaymentInformation = trim($html) !== '';
$response->html = $html;
$response->showGiroCode = false;
$response->hasPaymentInformation = trim($paymentInformation) !== '';
if ($response->hasPaymentInformation) {
// Medien-gerechtes Template je Render-Kontext (Web: SPA, Mail: E-Mail-tauglich).
$view = $request->context === RegistrationRenderContext::Mail
? 'payment-modules.undefined.mail'
: 'payment-modules.undefined.web';
$response->html = view($view, ['paymentInformation' => $paymentInformation])->render();
}
return $response;
}