Files
mareike/app/EventPaymentModules/Modules/UndefinedPaymentModule.php
2026-08-05 10:55:06 +02:00

59 lines
1.9 KiB
PHP

<?php
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;
/**
* Sonstiges (Barzahlung, Zahlung vor Ort) -- die anzuzeigende Zahlungsinformation ist nutzerdefiniert
* (mehrzeiliger Freitext) und wird als Option gepflegt.
*/
class UndefinedPaymentModule extends AbstractEventPaymentModule
{
public static function slug(): string
{
return PaymentMethod::PAYMENT_NOT_DEFINED;
}
public function defaultName(): string
{
return 'Sonstiges (Barzahlung, Zahlung vor Ort)';
}
public function getOptions(): array
{
return [
['name' => 'payment_information', 'label' => 'Zahlungsinformationen', 'type' => 'richtext', 'required' => true],
];
}
public function registrationSummary(RegistrationSummaryRequest $request): RegistrationSummaryResponse
{
$paymentInformation = (string)($request->configuration['payment_information'] ?? '');
$response = new RegistrationSummaryResponse();
$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;
}
protected function invoiceClosingStatement(CreateInvoiceRequest $request): string
{
return '';
}
}