Payment methode now selectable
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Domains\Event\Actions\SignUp;
|
||||
|
||||
use App\Enumerations\EatingHabit;
|
||||
use App\Enumerations\EfzStatus;
|
||||
use App\EventPaymentModules\EventPaymentModuleRegistry;
|
||||
use App\ValueObjects\Age;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -14,6 +15,18 @@ class SignUpCommand {
|
||||
public function execute() : SignUpResponse {
|
||||
$response = new SignUpResponse();
|
||||
|
||||
// Teilnehmer-Eingaben der gewählten Zahlungsart gegen das Modul-Schema absichern.
|
||||
$module = $this->request->paymentMethod !== null
|
||||
? EventPaymentModuleRegistry::forSlug($this->request->paymentMethod)
|
||||
: null;
|
||||
$paymentOptions = $module?->sanitizeParticipantOptions($this->request->paymentOptions) ?? [];
|
||||
|
||||
if ($module !== null && !$module->participantOptionsComplete($paymentOptions)) {
|
||||
$response->success = false;
|
||||
$response->message = 'Bitte alle erforderlichen Zahlungsangaben ausfüllen.';
|
||||
return $response;
|
||||
}
|
||||
|
||||
$eatingHabit = match ($this->request->eating_habit) {
|
||||
'vegan' => EatingHabit::EATING_HABIT_VEGAN,
|
||||
'vegetarian' => EatingHabit::EATING_HABIT_VEGETARIAN,
|
||||
@@ -62,6 +75,7 @@ class SignUpCommand {
|
||||
'amount' => $this->request->amount,
|
||||
'payment_purpose' => $this->request->event->name . ' - Beitrag ' . $this->request->firstname . ' ' . $this->request->lastname,
|
||||
'payment_method' => $this->request->paymentMethod,
|
||||
'payment_options' => $paymentOptions,
|
||||
'efz_status' => $participantAge->isfullAged() ? EfzStatus::EFZ_STATUS_NOT_CHECKED : EfzStatus::EFZ_STATUS_NOT_REQUIRED,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Domains\Event\Actions\SignUp;
|
||||
|
||||
use App\Enumerations\ParticipationType;
|
||||
use App\Models\Event;
|
||||
use App\Models\Tenant;
|
||||
use App\ValueObjects\Amount;
|
||||
@@ -46,6 +45,7 @@ class SignUpRequest {
|
||||
public ?string $notes,
|
||||
public Amount $amount,
|
||||
public ?string $paymentMethod,
|
||||
public array $paymentOptions = [],
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Models\EventParticipant;
|
||||
class SignUpResponse {
|
||||
public bool $success;
|
||||
public ?EventParticipant $participant;
|
||||
public ?string $message = null;
|
||||
|
||||
public function __construct() {
|
||||
$this->success = false;
|
||||
|
||||
@@ -26,10 +26,8 @@ class SignupController extends CommonController {
|
||||
|
||||
$eventModel = $this->events->getByIdentifier($eventId, false);
|
||||
$event = $eventModel?->toResource()->toArray($request);
|
||||
// Aktuell ist genau eine aktive Zahlungsmethode je Event vorgesehen; wird bereits beim Start
|
||||
// der Anmeldung ermittelt und ans Frontend durchgereicht, statt erst bei der Erstellung des
|
||||
// Teilnehmenden (siehe SignUpCommand).
|
||||
$paymentMethod = $eventModel?->paymentMethods()->where('active', true)->first();
|
||||
// Die (aktiven) Zahlungsmethoden stehen dem Frontend über $event['paymentMethods'] zur Verfügung;
|
||||
// die Auswahl trifft der/die Teilnehmer\*in im Anmeldeschritt "Zahlungsart".
|
||||
|
||||
$participantData = [
|
||||
'firstname' => '',
|
||||
@@ -67,7 +65,6 @@ class SignupController extends CommonController {
|
||||
'availableEvents' => $availableEvents,
|
||||
'localGroups' => $event['contributingLocalGroups'],
|
||||
'participantData' => $participantData,
|
||||
'paymentMethod' => $paymentMethod?->slug,
|
||||
]);
|
||||
return $inertiaProvider->render();
|
||||
}
|
||||
@@ -144,11 +141,16 @@ class SignupController extends CommonController {
|
||||
$registrationData['anmerkungen'],
|
||||
$amount,
|
||||
$registrationData['paymentMethod'] ?? null,
|
||||
(array)($registrationData['paymentOptions'] ?? []),
|
||||
);
|
||||
|
||||
$signupCommand = new SignUpCommand($signupRequest);
|
||||
$signupResponse = $signupCommand->execute();
|
||||
|
||||
if (!$signupResponse->success) {
|
||||
return response()->json(['status' => 'error', 'message' => $signupResponse->message], 422);
|
||||
}
|
||||
|
||||
// 4. Addons registrieren
|
||||
|
||||
|
||||
@@ -182,14 +184,18 @@ class SignupController extends CommonController {
|
||||
|
||||
$siblingReduction = $request->input('sibling') === 'true';
|
||||
|
||||
return response()->json(['amount' =>
|
||||
$event->calculateAmount(
|
||||
$request->input('participationType'),
|
||||
$request->input('beitrag'),
|
||||
\DateTime::createFromFormat('Y-m-d', $request->input('arrival')),
|
||||
\DateTime::createFromFormat('Y-m-d', $request->input('departure')),
|
||||
$siblingReduction
|
||||
)->toString()
|
||||
$amount = $event->calculateAmount(
|
||||
$request->input('participationType'),
|
||||
$request->input('beitrag'),
|
||||
\DateTime::createFromFormat('Y-m-d', $request->input('arrival')),
|
||||
\DateTime::createFromFormat('Y-m-d', $request->input('departure')),
|
||||
$siblingReduction
|
||||
);
|
||||
|
||||
// amountValue (numerisch) steuert im Frontend das Überspringen des Zahlungsart-Schritts bei 0 €.
|
||||
return response()->json([
|
||||
'amount' => $amount->toString(),
|
||||
'amountValue' => $amount->getAmount(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,9 +73,6 @@ const emit = defineEmits(['close'])
|
||||
if (paymentMethods.value.length === 0) {
|
||||
toast.error('Mindestens eine Zahlungsmöglichkeit muss ausgewählt sein.')
|
||||
return
|
||||
} else if(paymentMethods.value.length > 1) {
|
||||
toast.error('Aktuell wird nur exakt eine Zahlungseinstellung unterstützt.')
|
||||
return
|
||||
}
|
||||
|
||||
const response = await request('/api/v1/event/details/' + props.event.id + '/common-settings', {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { useSignupForm } from './composables/useSignupForm.js'
|
||||
import {useSignupForm} from './composables/useSignupForm.js'
|
||||
import StepAge from './steps/StepAge.vue'
|
||||
import StepContactPerson from './steps/StepContactPerson.vue'
|
||||
import StepPersonalData from './steps/StepPersonalData.vue'
|
||||
@@ -8,6 +8,7 @@ import StepArrival from './steps/StepArrival.vue'
|
||||
import StepAddons from './steps/StepAddons.vue'
|
||||
import StepPhotoPermissions from './steps/StepPhotoPermissions.vue'
|
||||
import StepAllergies from './steps/StepAllergies.vue'
|
||||
import StepPaymentMethod from './steps/StepPaymentMethod.vue'
|
||||
import StepSummary from './steps/StepSummary.vue'
|
||||
import SubmitSuccess from './after-submit/SubmitSuccess.vue'
|
||||
import SubmitAlreadyExists from './after-submit/SubmitAlreadyExists.vue'
|
||||
@@ -16,15 +17,14 @@ const props = defineProps({
|
||||
event: Object,
|
||||
participantData: Object,
|
||||
localGroups: Array,
|
||||
paymentMethod: String,
|
||||
})
|
||||
|
||||
const emit = defineEmits(['registrationDone'])
|
||||
|
||||
const {
|
||||
currentStep, goToStep, formData, selectedAddons,
|
||||
submit, submitting, submitResult, summaryLoading, summaryAmount
|
||||
} = useSignupForm(props.event, props.participantData, props.paymentMethod)
|
||||
submit, submitting, submitResult, summaryLoading, summaryAmount, summaryAmountValue
|
||||
} = useSignupForm(props.event, props.participantData)
|
||||
|
||||
const steps = [
|
||||
{ step: 1, label: 'Alter' },
|
||||
@@ -35,7 +35,8 @@ const steps = [
|
||||
{ step: 6, label: 'Zusatzoptionen' },
|
||||
{ step: 7, label: 'Fotoerlaubnis' },
|
||||
{ step: 8, label: 'Allergien' },
|
||||
{ step: 9, label: 'Zusammenfassung' },
|
||||
{step: 9, label: 'Zahlungsart'},
|
||||
{step: 10, label: 'Zusammenfassung'},
|
||||
]
|
||||
</script>
|
||||
|
||||
@@ -94,11 +95,14 @@ const steps = [
|
||||
<StepAddons v-if="currentStep === 6" :formData="formData" :event="event" :selectedAddons="selectedAddons" @next="goToStep" @back="goToStep" />
|
||||
<StepPhotoPermissions v-if="currentStep === 7" :formData="formData" :event="event" @next="goToStep" @back="goToStep" />
|
||||
<StepAllergies v-if="currentStep === 8" :formData="formData" :event="event" @next="goToStep" @back="goToStep" />
|
||||
<StepPaymentMethod v-if="currentStep === 9" :formData="formData" :event="event" @next="goToStep"
|
||||
@back="goToStep"/>
|
||||
<StepSummary
|
||||
v-if="currentStep === 9"
|
||||
v-if="currentStep === 10"
|
||||
:formData="formData"
|
||||
:event="event"
|
||||
:summaryAmount="summaryAmount"
|
||||
:summaryAmountValue="summaryAmountValue"
|
||||
:summaryLoading="summaryLoading"
|
||||
:submitting="submitting"
|
||||
@back="goToStep"
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<script setup>
|
||||
import TextEditor from "../../../../../../Views/Components/TextEditor.vue";
|
||||
|
||||
// Generische, schema-getriebene Eingabefelder eines Zahlungsmoduls. Wiederverwendbar für künftige
|
||||
// Verfahren (SEPA, PayPal): das jeweilige Modul liefert das Schema, hier wird nur gerendert.
|
||||
const props = defineProps({
|
||||
// [{ name, label, type, required }] -- z.B. aus participantOptionsSchema einer Zahlungsmethode.
|
||||
schema: {type: Array, default: () => []},
|
||||
// v-model: Objekt { optionName: value }
|
||||
modelValue: {type: Object, default: () => ({})},
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
function setValue(name, value) {
|
||||
emit('update:modelValue', {...props.modelValue, [name]: value})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<table class="form-table">
|
||||
<tr v-for="option in schema" :key="option.name">
|
||||
<td>
|
||||
{{ option.label }}<span v-if="option.required" class="required-marker">*</span>:
|
||||
</td>
|
||||
<td>
|
||||
<TextEditor
|
||||
v-if="option.type === 'richtext'"
|
||||
:modelValue="modelValue[option.name] ?? ''"
|
||||
@update:modelValue="value => setValue(option.name, value)"
|
||||
/>
|
||||
<input
|
||||
v-else
|
||||
type="text"
|
||||
:value="modelValue[option.name] ?? ''"
|
||||
@input="event => setValue(option.name, event.target.value)"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.required-marker {
|
||||
color: #ef4444;
|
||||
margin-left: 2px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import {reactive, ref} from 'vue'
|
||||
import axios from 'axios'
|
||||
|
||||
export function useSignupForm(event, participantData, paymentMethod) {
|
||||
export function useSignupForm(event, participantData) {
|
||||
const currentStep = ref(1)
|
||||
const submitting = ref(false)
|
||||
const summaryLoading = ref(false)
|
||||
@@ -9,9 +9,13 @@ export function useSignupForm(event, participantData, paymentMethod) {
|
||||
|
||||
const selectedAddons = reactive({})
|
||||
|
||||
// Für die Aktion freigeschaltete Zahlungsmethoden; ist genau eine aktiv, wird sie vorausgewählt.
|
||||
const activeMethods = (event.paymentMethods ?? []).filter(m => m.active)
|
||||
|
||||
const formData = reactive({
|
||||
eatingHabit: 'EATING_HABIT_VEGAN',
|
||||
paymentMethod: paymentMethod ?? null,
|
||||
paymentMethod: activeMethods.length === 1 ? activeMethods[0].slug : null,
|
||||
paymentOptions: {},
|
||||
userId: participantData.id,
|
||||
eventId: event.id,
|
||||
vorname: participantData.firstname ?? '',
|
||||
@@ -52,33 +56,52 @@ export function useSignupForm(event, participantData, paymentMethod) {
|
||||
})
|
||||
|
||||
const summaryAmount = ref('')
|
||||
const summaryAmountValue = ref(0)
|
||||
|
||||
const fetchAmount = async () => {
|
||||
summaryLoading.value = true
|
||||
try {
|
||||
const res = await axios.post('/api/v1/event/' + event.id + '/calculate-amount', {
|
||||
arrival: formData.arrival,
|
||||
departure: formData.departure,
|
||||
event_id: event.id,
|
||||
participation_group: formData.participant_group,
|
||||
selected_amount: formData.beitrag,
|
||||
addons: selectedAddons,
|
||||
participationType: formData.participationType,
|
||||
beitrag: formData.beitrag,
|
||||
sibling: formData.sibling,
|
||||
})
|
||||
summaryAmount.value = res.data.amount
|
||||
summaryAmountValue.value = Number(res.data.amountValue ?? 0)
|
||||
} finally {
|
||||
summaryLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// Steps: ... 8 Allergien, 9 Zahlungsart, 10 Zusammenfassung.
|
||||
const STEP_PAYMENT = 9
|
||||
const STEP_SUMMARY = 10
|
||||
|
||||
const goToStep = async (step) => {
|
||||
if (step === 9) {
|
||||
summaryLoading.value = true
|
||||
summaryAmount.value = ''
|
||||
try {
|
||||
const res = await axios.post('/api/v1/event/' + event.id + '/calculate-amount', {
|
||||
arrival: formData.arrival,
|
||||
departure: formData.departure,
|
||||
event_id: event.id,
|
||||
participation_group: formData.participant_group,
|
||||
selected_amount: formData.beitrag,
|
||||
addons: selectedAddons,
|
||||
participationType: formData.participationType,
|
||||
beitrag: formData.beitrag,
|
||||
sibling: formData.sibling,
|
||||
})
|
||||
summaryAmount.value = res.data.amount
|
||||
} finally {
|
||||
summaryLoading.value = false
|
||||
if (step === STEP_PAYMENT) {
|
||||
// Betrag ermitteln: Bei 0 € wird die Zahlungsart-Auswahl übersprungen.
|
||||
await fetchAmount()
|
||||
if (summaryAmountValue.value <= 0) {
|
||||
formData.paymentMethod = null
|
||||
formData.paymentOptions = {}
|
||||
currentStep.value = STEP_SUMMARY
|
||||
return
|
||||
}
|
||||
} else if (step === STEP_SUMMARY) {
|
||||
await fetchAmount()
|
||||
}
|
||||
currentStep.value = step
|
||||
}
|
||||
|
||||
const submit = async () => {
|
||||
if (!formData.summary_information_correct || !formData.summary_accept_terms || !formData.legal_accepted || !formData.payment) {
|
||||
// Zahlungs-Bestätigung wird im Summary-Schritt kontextabhängig erzwungen (nur bei Überweisung).
|
||||
if (!formData.summary_information_correct || !formData.summary_accept_terms || !formData.legal_accepted) {
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
@@ -96,5 +119,16 @@ export function useSignupForm(event, participantData, paymentMethod) {
|
||||
}
|
||||
}
|
||||
|
||||
return { currentStep, goToStep, formData, selectedAddons, submit, submitting, submitResult, summaryLoading, summaryAmount }
|
||||
return {
|
||||
currentStep,
|
||||
goToStep,
|
||||
formData,
|
||||
selectedAddons,
|
||||
submit,
|
||||
submitting,
|
||||
submitResult,
|
||||
summaryLoading,
|
||||
summaryAmount,
|
||||
summaryAmountValue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
<script setup>
|
||||
import {computed} from "vue";
|
||||
import PaymentMethodInputs from "../components/PaymentMethodInputs.vue";
|
||||
import Icon from "../../../../../../Views/Components/Icon.vue";
|
||||
|
||||
const props = defineProps({formData: Object, event: Object})
|
||||
const emit = defineEmits(['next', 'back'])
|
||||
|
||||
// Für die Aktion freigeschaltete Zahlungsmethoden.
|
||||
const methods = computed(() => (props.event.paymentMethods ?? []).filter(m => m.active))
|
||||
|
||||
const selectedMethod = computed(() =>
|
||||
methods.value.find(m => m.slug === props.formData.paymentMethod) ?? null
|
||||
)
|
||||
|
||||
const participantSchema = computed(() => selectedMethod.value?.participantOptionsSchema ?? [])
|
||||
|
||||
// Font-Awesome-Icon je Zahlungsart (Fallback: generische Karte).
|
||||
function iconFor(slug) {
|
||||
if (slug === 'PAYMENT_ACCOUNT_TRANSACTION') return 'building-columns'
|
||||
if (slug === 'PAYMENT_NOT_DEFINED') return 'money-bill-wave'
|
||||
return 'credit-card'
|
||||
}
|
||||
|
||||
function selectMethod(slug) {
|
||||
props.formData.paymentMethod = slug
|
||||
// Eingaben zurücksetzen -- pro Methode eigene Felder.
|
||||
props.formData.paymentOptions = {}
|
||||
}
|
||||
|
||||
// "Weiter" ist erst möglich, wenn eine Methode gewählt und alle Pflicht-Eingaben befüllt sind.
|
||||
const canProceed = computed(() => {
|
||||
if (!props.formData.paymentMethod) return false
|
||||
return participantSchema.value
|
||||
.filter(o => o.required)
|
||||
.every(o => {
|
||||
const value = props.formData.paymentOptions[o.name]
|
||||
return value !== undefined && value !== null && String(value).trim() !== ''
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<h3 style="margin: 0 0 6px 0; color: #111827;">Zahlungsweise</h3>
|
||||
<p style="margin: 0 0 24px 0; color: #6b7280; font-size: 0.95rem;">Bitte wähle, wie du deinen Teilnahmebeitrag
|
||||
begleichen möchtest.</p>
|
||||
|
||||
<div class="pay-card-row">
|
||||
<div
|
||||
v-for="method in methods"
|
||||
:key="method.slug"
|
||||
class="pay-card"
|
||||
:class="{ 'pay-card--active': formData.paymentMethod === method.slug }"
|
||||
role="radio"
|
||||
:aria-checked="formData.paymentMethod === method.slug"
|
||||
tabindex="0"
|
||||
@click="selectMethod(method.slug)"
|
||||
@keydown.enter.prevent="selectMethod(method.slug)"
|
||||
@keydown.space.prevent="selectMethod(method.slug)"
|
||||
>
|
||||
<div class="pay-card__badge">
|
||||
<Icon :name="iconFor(method.slug)"/>
|
||||
</div>
|
||||
<div class="pay-card__body">
|
||||
<h4 class="pay-card__title">{{ method.name }}</h4>
|
||||
<p v-if="method.description" class="pay-card__desc">{{ method.description }}</p>
|
||||
</div>
|
||||
<div class="pay-card__check" aria-hidden="true">✓</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="participantSchema.length > 0" class="pay-inputs">
|
||||
<PaymentMethodInputs :schema="participantSchema" v-model="formData.paymentOptions"/>
|
||||
</div>
|
||||
|
||||
<div class="btn-row">
|
||||
<button type="button" class="btn-secondary" @click="emit('back', 8)">← Zurück</button>
|
||||
<button type="button" class="btn-primary" :disabled="!canProceed" @click="emit('next', 10)">Weiter →
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.pay-card-row {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.pay-card {
|
||||
position: relative;
|
||||
flex: 1 1 280px;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
background: #f8fafc;
|
||||
border: 2px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
padding: 28px 20px;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.pay-card:hover {
|
||||
border-color: #2563eb;
|
||||
box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.pay-card--active {
|
||||
border-color: #2563eb;
|
||||
background: #eff6ff;
|
||||
box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12);
|
||||
}
|
||||
|
||||
.pay-card__badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
margin-bottom: 14px;
|
||||
font-size: 1.6rem;
|
||||
color: #2563eb;
|
||||
background: #e0f2fe;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.pay-card--active .pay-card__badge {
|
||||
background: #dbeafe;
|
||||
}
|
||||
|
||||
.pay-card__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.pay-card__title {
|
||||
margin: 0;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 700;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.pay-card__desc {
|
||||
margin: 0;
|
||||
font-size: 0.9rem;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.pay-card__check {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 700;
|
||||
opacity: 0;
|
||||
transform: scale(0.6);
|
||||
transition: opacity 0.12s, transform 0.12s;
|
||||
}
|
||||
|
||||
.pay-card--active .pay-card__check {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
.pay-inputs {
|
||||
margin-top: 20px;
|
||||
padding: 16px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
/* ─── Smartphone ─── */
|
||||
@media (max-width: 639px) {
|
||||
.pay-card-row {
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.pay-card {
|
||||
flex: 1 1 100%;
|
||||
flex-direction: row;
|
||||
text-align: left;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 16px 14px;
|
||||
}
|
||||
|
||||
.pay-card__badge {
|
||||
flex: 0 0 52px;
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
margin-bottom: 0;
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
|
||||
.pay-card__body {
|
||||
flex: 1;
|
||||
align-items: flex-start;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.pay-card__title {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,15 +1,48 @@
|
||||
<script setup>
|
||||
import {computed} from "vue";
|
||||
import {format, parseISO} from "date-fns";
|
||||
|
||||
const PAYMENT_ACCOUNT_TRANSACTION = 'PAYMENT_ACCOUNT_TRANSACTION'
|
||||
|
||||
const props = defineProps({
|
||||
formData: Object,
|
||||
event: Object,
|
||||
summaryAmount: String,
|
||||
summaryAmountValue: {type: Number, default: 0},
|
||||
summaryLoading: Boolean,
|
||||
submitting: Boolean,
|
||||
})
|
||||
const emit = defineEmits(['back', 'submit'])
|
||||
|
||||
const selectedMethod = computed(() =>
|
||||
(props.event.paymentMethods ?? []).find(m => m.slug === props.formData.paymentMethod) ?? null
|
||||
)
|
||||
|
||||
// Die Überweisungs-Bestätigung wird nur bei Banküberweisung verlangt (AC #6).
|
||||
const requiresPaymentConfirmation = computed(() =>
|
||||
props.formData.paymentMethod === PAYMENT_ACCOUNT_TRANSACTION
|
||||
)
|
||||
|
||||
// Bestätigungstext ist ein admin-konfigurierbarer Freitext ({amount}-Platzhalter), sonst Default.
|
||||
const paymentConfirmationText = computed(() => {
|
||||
const configured = selectedMethod.value?.configuration?.summary_confirmation_text
|
||||
const template = (configured && String(configured).trim() !== '')
|
||||
? configured
|
||||
: 'Ich bestätige, den Betrag von {amount} zu überweisen.'
|
||||
return template.replaceAll('{amount}', props.summaryAmount ?? '')
|
||||
})
|
||||
|
||||
// Zurück führt zur Zahlungsart (9), sofern dieser Schritt gezeigt wurde; bei 0 € direkt zu Allergien (8).
|
||||
const backTarget = computed(() => props.summaryAmountValue > 0 ? 9 : 8)
|
||||
|
||||
const canSubmit = computed(() =>
|
||||
props.formData.summary_information_correct
|
||||
&& props.formData.summary_accept_terms
|
||||
&& props.formData.legal_accepted
|
||||
&& (!requiresPaymentConfirmation.value || props.formData.payment)
|
||||
&& !props.submitting
|
||||
)
|
||||
|
||||
function formatDate(dateString) {
|
||||
if (!dateString) return ''
|
||||
return format(parseISO(dateString), 'dd.MM.yyyy')
|
||||
@@ -129,18 +162,18 @@ function eatingHabit() {
|
||||
<input type="checkbox" v-model="formData.legal_accepted" />
|
||||
Ich stimme der Datenschutzerklärung zu.
|
||||
</label>
|
||||
<label style="display: flex; gap: 10px; cursor: pointer;">
|
||||
<label v-if="requiresPaymentConfirmation" style="display: flex; gap: 10px; cursor: pointer;">
|
||||
<input type="checkbox" v-model="formData.payment" />
|
||||
Ich bestätige, den Betrag von <strong>{{ summaryAmount }}</strong> zu überweisen.
|
||||
{{ paymentConfirmationText }}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="btn-row">
|
||||
<button type="button" class="btn-secondary" @click="emit('back', 8)">← Zurück</button>
|
||||
<button type="button" class="btn-secondary" @click="emit('back', backTarget)">← Zurück</button>
|
||||
<button
|
||||
type="submit"
|
||||
class="btn-primary"
|
||||
:disabled="!formData.summary_information_correct || !formData.summary_accept_terms || !formData.legal_accepted || !formData.payment || submitting"
|
||||
:disabled="!canSubmit"
|
||||
style="background: #059669;"
|
||||
>
|
||||
{{ submitting ? 'Wird gesendet…' : 'Jetzt anmelden ✓' }}
|
||||
|
||||
@@ -12,7 +12,6 @@ const props = defineProps({
|
||||
availableEvents: Array,
|
||||
participantData: Object,
|
||||
localGroups: Array,
|
||||
paymentMethod: String,
|
||||
})
|
||||
|
||||
const showSignup = ref(true)
|
||||
@@ -104,7 +103,6 @@ function close() {
|
||||
:event="props.event"
|
||||
:participantData="props.participantData ?? {}"
|
||||
:localGroups="props.localGroups ?? []"
|
||||
:paymentMethod="props.paymentMethod ?? null"
|
||||
/>
|
||||
<p v-else class="signup-closed-notice">
|
||||
Die Anmeldung für diese Veranstaltung ist geschlossen.
|
||||
|
||||
@@ -22,36 +22,83 @@ abstract class AbstractEventPaymentModule implements EventPaymentModule
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Payer-seitige Eingaben, die eine Zahlungsart vom Teilnehmer benötigt (z.B. später SEPA-IBAN,
|
||||
* PayPal-Mail). Standard: keine. Gleiche Form wie getOptions(): [{name,label,type,required}].
|
||||
*
|
||||
* @return array<int, array{name: string, label: string, type: string, required: bool}>
|
||||
*/
|
||||
public function getParticipantOptions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
// Aus getOptions() abgeleitete Helfer (zuvor statisch auf PaymentMethod).
|
||||
// Aus dem jeweiligen Schema abgeleitete Helfer (Admin-Config = getOptions(),
|
||||
// Teilnehmer-Eingaben = getParticipantOptions()).
|
||||
// -----------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Namen aller Pflicht-Optionen dieses Moduls.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
/** @return array<int, string> */
|
||||
public function requiredOptionKeys(): array
|
||||
{
|
||||
return array_values(array_map(
|
||||
static fn (array $option) => $option['name'],
|
||||
array_filter($this->getOptions(), static fn (array $option) => $option['required'] ?? false)
|
||||
));
|
||||
return $this->requiredKeys($this->getOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduziert eine Konfiguration auf die im Schema definierten Options-Keys.
|
||||
* Unbekannte Keys werden verworfen -- getOptions() ist die Autorität.
|
||||
*
|
||||
* @param array<string, mixed> $config
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function sanitizeConfiguration(array $config): array
|
||||
{
|
||||
return $this->sanitizeAgainst($this->getOptions(), $config);
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $config */
|
||||
public function isConfigurationComplete(array $config): bool
|
||||
{
|
||||
return $this->allRequiredFilled($this->getOptions(), $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function sanitizeParticipantOptions(array $input): array
|
||||
{
|
||||
return $this->sanitizeAgainst($this->getParticipantOptions(), $input);
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $input */
|
||||
public function participantOptionsComplete(array $input): bool
|
||||
{
|
||||
return $this->allRequiredFilled($this->getParticipantOptions(), $input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array{name: string, required?: bool}> $schema
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private function requiredKeys(array $schema): array
|
||||
{
|
||||
return array_values(array_map(
|
||||
static fn (array $option) => $option['name'],
|
||||
array_filter($schema, static fn(array $option) => $option['required'] ?? false)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduziert Eingaben auf die im Schema definierten Keys (unbekannte werden verworfen).
|
||||
*
|
||||
* @param array<int, array{name: string}> $schema
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function sanitizeAgainst(array $schema, array $input): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($this->getOptions() as $option) {
|
||||
if (array_key_exists($option['name'], $config)) {
|
||||
$result[$option['name']] = $config[$option['name']];
|
||||
foreach ($schema as $option) {
|
||||
if (array_key_exists($option['name'], $input)) {
|
||||
$result[$option['name']] = $input[$option['name']];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,14 +106,15 @@ abstract class AbstractEventPaymentModule implements EventPaymentModule
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob alle Pflicht-Optionen befüllt (non-empty) sind.
|
||||
* Sind alle Pflichtfelder des Schemas befüllt (non-empty)?
|
||||
*
|
||||
* @param array<string, mixed> $config
|
||||
* @param array<int, array{name: string, required?: bool}> $schema
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function isConfigurationComplete(array $config): bool
|
||||
private function allRequiredFilled(array $schema, array $input): bool
|
||||
{
|
||||
foreach ($this->requiredOptionKeys() as $key) {
|
||||
$value = $config[$key] ?? null;
|
||||
foreach ($this->requiredKeys($schema) as $key) {
|
||||
$value = $input[$key] ?? null;
|
||||
if ($value === null || $value === '' || $value === []) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,16 +19,30 @@ Rechnung) liegt gekapselt in einem Modul pro Zahlungsart. Aufgelöst wird über
|
||||
|
||||
## Kernregeln
|
||||
|
||||
- **Options-Schema lebt im Code**, nicht in der DB (`getOptions()` je Modul). In der DB stehen nur die Werte.
|
||||
Optionsform: `['name', 'label', 'type', 'required']`. `type` ist i.d.R. `'string'`; `'richtext'` wird im Frontend über
|
||||
`Views/Components/TextEditor.vue` (TinyMCE, HTML) gerendert und via `v-html`/`{!! !!}` ausgegeben.
|
||||
- **Zwei getrennte Options-Schemata (beide im Code, gleiche Form `['name','label','type','required']`):**
|
||||
- `getOptions()` = **Admin-Config** (was der/die Veranstalter\*in pflegt, z.B. Empfänger-Konto). Werte in der DB
|
||||
(`configuration`, s.u.).
|
||||
- `getParticipantOptions()` = **Teilnehmer-Eingaben** beim Anmelden (payer-seitig, z.B. künftig
|
||||
SEPA-IBAN/PayPal-Mail; beide Bestandsmodule: `[]`). Werte in `event_participants.payment_options` (JSON).
|
||||
Abgesichert über
|
||||
`sanitizeParticipantOptions()` / `participantOptionsComplete()` (Guard im `SignUpCommand`).
|
||||
- `type` ist i.d.R. `'string'`; `'richtext'` wird über `Views/Components/TextEditor.vue` (TinyMCE, HTML) gerendert
|
||||
und via `v-html`/`{!! !!}` ausgegeben. Teilnehmer-Eingaben rendert die generische
|
||||
`SignUpForm/components/PaymentMethodInputs.vue` schema-getrieben.
|
||||
- **Aktivierungs-Guard:** Eine Tenant-Zahlungsmethode darf nur `active` werden, wenn alle `required`-Optionen befüllt
|
||||
sind (`isConfigurationComplete()`), erzwungen in `UpdateAvailablePaymentMethodAction`.
|
||||
- **Config-Speicherung (JSON):** pro Tenant auf `available_payment_methods.configuration`, pro Event auf dem Pivot
|
||||
`event_payment_methods.configuration`. Beim Zuweisen an ein Event wird die Tenant-Config als **Snapshot kopiert**
|
||||
(Copy-on-Assign, spätere Tenant-Änderungen wirken NICHT nach). Sync erfolgt differenziell in `UpdateEventCommand`.
|
||||
- **`PaymentMethod` ist nur eine Fassade:** `PaymentMethod::optionsFor/requiredOptionKeys/sanitizeConfiguration/`
|
||||
`isConfigurationComplete/defaults()` delegieren an die Registry. Bestehende Aufrufstellen bleiben so stabil.
|
||||
- **`PaymentMethod` ist nur eine Fassade:** `PaymentMethod::optionsFor/participantOptionsFor/requiredOptionKeys/`
|
||||
`sanitizeConfiguration/isConfigurationComplete/defaults()` delegieren an die Registry. Bestehende Aufrufstellen
|
||||
bleiben stabil.
|
||||
- **Zahlungsauswahl im Anmeldeprozess:** Nach „Allergien" wählt der/die Teilnehmer\*in aus den **aktiven**
|
||||
Event-Methoden (`StepPaymentMethod.vue`); bei Beitrag 0 € wird der Schritt übersprungen. Die Wahl landet in
|
||||
`event_participants.payment_method`, die Eingaben in `payment_options`. Der Überweisungs-Bestätigungstext in der
|
||||
Zusammenfassung ist eine Admin-Config-Option `summary_confirmation_text` (`{amount}`-Platzhalter) und erscheint nur
|
||||
bei
|
||||
`PAYMENT_ACCOUNT_TRANSACTION`.
|
||||
- **`PaymentStatus`** ist ein DB-gestütztes Enumerations-Model (`app/Enumerations/PaymentStatus.php`, Tabelle
|
||||
`payment_status`, geseedet in `ProductionDataSeeder`), analog zu `InvoiceStatus`. Reine Steuersignale (z.B. Redirect)
|
||||
gehören NICHT ins Status-Vokabular, sondern als transiente Felder aufs Response-DTO.
|
||||
|
||||
@@ -30,12 +30,19 @@ interface EventPaymentModule
|
||||
public function defaultDescription(): ?string;
|
||||
|
||||
/**
|
||||
* Options-Schema dieses Moduls (welche Konfigurationsfelder es benötigt).
|
||||
* Admin-Options-Schema dieses Moduls (welche Konfigurationsfelder der/die Veranstalter\*in pflegt).
|
||||
*
|
||||
* @return array<int, array{name: string, label: string, type: string, required: bool}>
|
||||
*/
|
||||
public function getOptions(): array;
|
||||
|
||||
/**
|
||||
* Teilnehmer-Eingaben, die diese Zahlungsart beim Anmelden abfragt (payer-seitig; Standard: keine).
|
||||
*
|
||||
* @return array<int, array{name: string, label: string, type: string, required: bool}>
|
||||
*/
|
||||
public function getParticipantOptions(): array;
|
||||
|
||||
/**
|
||||
* Liefert den zahlungsspezifischen Teil der Anmelde-Zusammenfassung.
|
||||
* (In dieser Iteration nur als Stub vorhanden.)
|
||||
|
||||
@@ -33,6 +33,7 @@ class AccountTransferPaymentModule extends AbstractEventPaymentModule implements
|
||||
['name' => 'account_owner', 'label' => 'Kontoinhaber', 'type' => 'string', 'required' => true],
|
||||
['name' => 'iban', 'label' => 'IBAN', 'type' => 'string', 'required' => true],
|
||||
['name' => 'bic', 'label' => 'BIC', 'type' => 'string', 'required' => false],
|
||||
['name' => 'summary_confirmation_text', 'label' => 'Bestätigungstext (Zusammenfassung, {amount} als Platzhalter)', 'type' => 'string', 'required' => false],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ class EventParticipant extends InstancedModel
|
||||
'amount_paid',
|
||||
'payment_purpose',
|
||||
'payment_method',
|
||||
'payment_options',
|
||||
'efz_status',
|
||||
'unregistered_at',
|
||||
];
|
||||
@@ -88,6 +89,7 @@ class EventParticipant extends InstancedModel
|
||||
|
||||
'amount' => AmountCast::class,
|
||||
'amount_paid' => AmountCast::class,
|
||||
'payment_options' => 'array',
|
||||
];
|
||||
|
||||
/*
|
||||
|
||||
@@ -44,7 +44,7 @@ class PaymentMethod extends CommonModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Options-Schema für einen Slug.
|
||||
* Admin-Options-Schema für einen Slug.
|
||||
*
|
||||
* @return array<int, array{name: string, label: string, type: string, required: bool}>
|
||||
*/
|
||||
@@ -53,6 +53,16 @@ class PaymentMethod extends CommonModel
|
||||
return EventPaymentModuleRegistry::forSlug($slug)?->getOptions() ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Teilnehmer-Eingabe-Schema für einen Slug (payer-seitig).
|
||||
*
|
||||
* @return array<int, array{name: string, label: string, type: string, required: bool}>
|
||||
*/
|
||||
public static function participantOptionsFor(string $slug): array
|
||||
{
|
||||
return EventPaymentModuleRegistry::forSlug($slug)?->getParticipantOptions() ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Namen aller Pflicht-Optionen eines Slugs.
|
||||
*
|
||||
|
||||
@@ -10,6 +10,7 @@ class AvailablePaymentMethodResource extends JsonResource {
|
||||
private AvailablePaymentMethod $availablePaymentMethod;
|
||||
|
||||
public function __construct(AvailablePaymentMethod $availablePaymentMethod) {
|
||||
parent::__construct($availablePaymentMethod);
|
||||
$this->availablePaymentMethod = $availablePaymentMethod;
|
||||
}
|
||||
|
||||
@@ -29,6 +30,7 @@ class AvailablePaymentMethodResource extends JsonResource {
|
||||
'active' => $this->availablePaymentMethod->active,
|
||||
'configuration' => (object) $configuration,
|
||||
'optionsSchema' => PaymentMethod::optionsFor($this->availablePaymentMethod->slug),
|
||||
'participantOptionsSchema' => PaymentMethod::participantOptionsFor($this->availablePaymentMethod->slug),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ class EventResource extends JsonResource{
|
||||
fn($eatingHabit) => new EatingHabitResource($eatingHabit))->toArray();
|
||||
|
||||
$returnArray['paymentMethods'] = $this->event->paymentMethods()->get()->map(
|
||||
fn($paymentMethod) => new AvailablePaymentMethodResource($paymentMethod))->toArray();
|
||||
fn($paymentMethod) => new AvailablePaymentMethodResource($paymentMethod)->toArray($request))->toArray();
|
||||
|
||||
|
||||
$returnArray['participationTypes'] = [];
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('event_participants', function (Blueprint $table) {
|
||||
// Payer-seitige Eingaben der gewählten Zahlungsart (Schema je Modul: getParticipantOptions()).
|
||||
$table->json('payment_options')->nullable()->after('payment_method');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('event_participants', function (Blueprint $table) {
|
||||
$table->dropColumn('payment_options');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domains\Event\Actions\SignUp\SignUpCommand;
|
||||
use App\Domains\Event\Actions\SignUp\SignUpRequest;
|
||||
use App\Enumerations\EatingHabit;
|
||||
use App\Enumerations\EfzStatus;
|
||||
use App\Enumerations\FirstAidPermission;
|
||||
use App\Enumerations\ParticipationType;
|
||||
use App\Enumerations\SwimmingPermission;
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
use App\Models\Event;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\Tenant;
|
||||
use App\Resources\AvailablePaymentMethodResource;
|
||||
use App\ValueObjects\Amount;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SignUpPaymentOptionsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private Tenant $tenant;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->tenant = Tenant::create([
|
||||
'slug' => 'tv', 'name' => 'Test', 'email' => 't@example.com', 'email_finance' => 'f@example.com',
|
||||
'url' => 'test.local', 'account_name' => 'Test e.V.', 'account_iban' => 'DE00', 'account_bic' => 'XY',
|
||||
'city' => 'Stadt', 'postcode' => '00000', 'is_active_local_group' => true, 'has_active_instance' => true,
|
||||
]);
|
||||
app()->instance('tenant', $this->tenant);
|
||||
|
||||
PaymentMethod::create(['slug' => PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION]);
|
||||
DB::table('participation_fee_types')->insert(['slug' => 'FIXED', 'name' => 'Fixed', 'created_at' => now(), 'updated_at' => now()]);
|
||||
ParticipationType::create(['slug' => ParticipationType::PARTICIPATION_TYPE_PARTICIPANT, 'name' => 'Teilnehmende']);
|
||||
EfzStatus::create(['slug' => EfzStatus::EFZ_STATUS_NOT_CHECKED, 'name' => 'Nicht geprüft']);
|
||||
EfzStatus::create(['slug' => EfzStatus::EFZ_STATUS_NOT_REQUIRED, 'name' => 'Nicht erforderlich']);
|
||||
SwimmingPermission::create(['slug' => SwimmingPermission::SWIMMING_PERMISSION_ALLOWED, 'name' => 'Darf baden', 'short' => 'Erteilt']);
|
||||
FirstAidPermission::create(['slug' => FirstAidPermission::FIRST_AID_PERMISSION_ALLOWED, 'name' => 'Zugestimmt', 'description' => '']);
|
||||
EatingHabit::create(['slug' => EatingHabit::EATING_HABIT_VEGAN, 'name' => 'Vegan']);
|
||||
}
|
||||
|
||||
private function createEvent(): Event
|
||||
{
|
||||
return Event::create([
|
||||
'tenant' => $this->tenant->slug, 'name' => 'Event', 'identifier' => 'evt-1', 'location' => 'Ort',
|
||||
'postal_code' => '00000', 'email' => 'e@example.com', 'start_date' => '2026-08-01', 'end_date' => '2026-08-05',
|
||||
'early_bird_end' => '2026-07-01', 'registration_final_end' => '2026-07-20', 'early_bird_end_amount_increase' => 0,
|
||||
'account_owner' => 'Owner', 'account_iban' => 'DE00', 'participation_fee_type' => 'FIXED',
|
||||
'pay_per_day' => false, 'pay_direct' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
private function signUpRequest(Event $event, array $paymentOptions): SignUpRequest
|
||||
{
|
||||
return new SignUpRequest(
|
||||
$event, null, 'Hans', 'Muster', null, ParticipationType::PARTICIPATION_TYPE_PARTICIPANT,
|
||||
$this->tenant, new \DateTime('2000-01-01'), 'Weg 1', null, '00000', 'Stadt',
|
||||
'h@example.com', '123', null, null, null, null, null, null, null,
|
||||
'vegan', null, null, false, false, false, false, false,
|
||||
new \DateTime('2026-08-01'), new \DateTime('2026-08-05'), 0, 0, null,
|
||||
new Amount(50.0, ' Euro'), PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION, $paymentOptions,
|
||||
);
|
||||
}
|
||||
|
||||
public function test_payment_options_are_sanitized_and_stored(): void
|
||||
{
|
||||
$event = $this->createEvent();
|
||||
|
||||
// Überweisung hat keine Teilnehmer-Eingaben -> alles wird verworfen, payment_options bleibt leer.
|
||||
$response = new SignUpCommand($this->signUpRequest($event, ['evil' => 'x']))->execute();
|
||||
|
||||
$this->assertTrue($response->success);
|
||||
$this->assertSame([], $response->participant->payment_options);
|
||||
// payment_purpose wird immer erzeugt (AC #4).
|
||||
$this->assertStringContainsString('Beitrag Hans Muster', $response->participant->payment_purpose);
|
||||
}
|
||||
|
||||
public function test_resource_exposes_participant_options_schema(): void
|
||||
{
|
||||
$event = $this->createEvent();
|
||||
AvailablePaymentMethod::create([
|
||||
'tenant' => $this->tenant->slug, 'slug' => PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION,
|
||||
'name' => 'Überweisung', 'active' => true, 'configuration' => ['account_owner' => 'Kasse', 'iban' => 'DE1'],
|
||||
]);
|
||||
|
||||
$method = AvailablePaymentMethod::where('slug', PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION)->first();
|
||||
$array = new AvailablePaymentMethodResource($method)->toArray(request());
|
||||
|
||||
$this->assertArrayHasKey('participantOptionsSchema', $array);
|
||||
$this->assertSame([], $array['participantOptionsSchema']); // Überweisung: keine Teilnehmer-Eingaben
|
||||
}
|
||||
|
||||
public function test_payment_methods_serialize_without_data_wrapper(): void
|
||||
{
|
||||
AvailablePaymentMethod::create([
|
||||
'tenant' => $this->tenant->slug, 'slug' => PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION,
|
||||
'name' => 'Überweisung', 'active' => true, 'configuration' => ['account_owner' => 'Kasse', 'iban' => 'DE1'],
|
||||
]);
|
||||
$method = AvailablePaymentMethod::where('slug', PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION)->first();
|
||||
|
||||
// Exakt so serialisiert EventResource die Methoden fürs Frontend.
|
||||
$serialized = collect([$method])->map(
|
||||
fn($m) => new AvailablePaymentMethodResource($m)->toArray(request())
|
||||
)->toArray();
|
||||
|
||||
// Kein data-Wrapper: slug/active liegen top-level (sonst wäre m.active im Frontend undefined -> leere Liste).
|
||||
$this->assertArrayNotHasKey('data', $serialized[0]);
|
||||
$this->assertSame(PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION, $serialized[0]['slug']);
|
||||
$this->assertTrue($serialized[0]['active']);
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,49 @@ class EventPaymentModuleRegistryTest extends TestCase
|
||||
$this->assertTrue($module->isConfigurationComplete(['iban' => 'DE123', 'account_owner' => 'Kasse']));
|
||||
}
|
||||
|
||||
public function test_existing_modules_have_no_participant_options(): void
|
||||
{
|
||||
$this->assertSame([], (new AccountTransferPaymentModule())->getParticipantOptions());
|
||||
$this->assertSame([], (new UndefinedPaymentModule())->getParticipantOptions());
|
||||
}
|
||||
|
||||
public function test_participant_option_helpers(): void
|
||||
{
|
||||
// Anonymes Modul mit einer Pflicht-Teilnehmereingabe.
|
||||
$module = new class extends \App\EventPaymentModules\AbstractEventPaymentModule {
|
||||
public static function slug(): string
|
||||
{
|
||||
return 'TEST';
|
||||
}
|
||||
|
||||
public function defaultName(): string
|
||||
{
|
||||
return 'Test';
|
||||
}
|
||||
|
||||
public function getOptions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getParticipantOptions(): array
|
||||
{
|
||||
return [['name' => 'iban', 'label' => 'IBAN', 'type' => 'string', 'required' => true]];
|
||||
}
|
||||
|
||||
protected function invoiceClosingStatement(\App\EventPaymentModules\DTO\CreateInvoiceRequest $request): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
// sanitize verwirft unbekannte Keys, complete verlangt Pflichtfeld non-empty.
|
||||
$this->assertSame(['iban' => 'DE1'], $module->sanitizeParticipantOptions(['iban' => 'DE1', 'evil' => 'x']));
|
||||
$this->assertFalse($module->participantOptionsComplete([]));
|
||||
$this->assertFalse($module->participantOptionsComplete(['iban' => '']));
|
||||
$this->assertTrue($module->participantOptionsComplete(['iban' => 'DE1']));
|
||||
}
|
||||
|
||||
public function test_only_account_transfer_provides_giro_code(): void
|
||||
{
|
||||
$this->assertInstanceOf(ProvidesGiroCode::class, new AccountTransferPaymentModule());
|
||||
|
||||
Reference in New Issue
Block a user