Handling SEPA Direct Payment
This commit is contained in:
@@ -42,14 +42,18 @@ class CreateTenantAction
|
||||
$paymentMethodDefaults = PaymentMethod::defaults();
|
||||
foreach (PaymentMethod::all() as $paymentMethod) {
|
||||
$defaults = $paymentMethodDefaults[$paymentMethod->slug] ?? ['name' => $paymentMethod->slug, 'description' => null, 'configuration' => []];
|
||||
$configuration = PaymentMethod::sanitizeConfiguration($paymentMethod->slug, $defaults['configuration'] ?? []);
|
||||
|
||||
// Aktiv nur, was schon vollständig konfiguriert ist -- derselbe Maßstab wie beim Aktivieren
|
||||
// von Hand. Ein neuer Stamm hat noch keine Bankdaten; seine Zahlungsarten schaltet er frei,
|
||||
// sobald sie gepflegt sind.
|
||||
AvailablePaymentMethod::create([
|
||||
'tenant' => $tenant->slug,
|
||||
'slug' => $paymentMethod->slug,
|
||||
'name' => $defaults['name'],
|
||||
'description' => $defaults['description'],
|
||||
'active' => true,
|
||||
'configuration' => PaymentMethod::sanitizeConfiguration($paymentMethod->slug, $defaults['configuration'] ?? []),
|
||||
'active' => PaymentMethod::isConfigurationComplete($paymentMethod->slug, $configuration),
|
||||
'configuration' => $configuration,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -20,10 +20,15 @@ class UpdateAvailablePaymentMethodAction
|
||||
// Nur bekannte Options-Keys übernehmen -- das Options-Schema des Zahlungsmoduls ist die Autorität.
|
||||
$configuration = PaymentMethod::sanitizeConfiguration($paymentMethod->slug, $this->request->configuration);
|
||||
|
||||
// Guard: Aktivierung nur erlaubt, wenn alle Pflicht-Optionen befüllt sind.
|
||||
// Guard: Aktivierung nur erlaubt, wenn alle Pflicht-Optionen befüllt und gültig sind. Inaktiv
|
||||
// gespeichert werden darf auch eine unfertige Konfiguration -- als Entwurf.
|
||||
if ($this->request->active && !PaymentMethod::isConfigurationComplete($paymentMethod->slug, $configuration)) {
|
||||
$errors = PaymentMethod::configurationErrors($paymentMethod->slug, $configuration);
|
||||
|
||||
$response->success = false;
|
||||
$response->message = 'Bitte zuerst alle Pflichtfelder ausfüllen, bevor die Zahlungsmethode aktiviert wird.';
|
||||
$response->message = $errors !== []
|
||||
? implode(' ', $errors) . ' Die Zahlungsmethode kann so nicht aktiviert werden.'
|
||||
: 'Bitte zuerst alle Pflichtfelder ausfüllen, bevor die Zahlungsmethode aktiviert wird.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,12 @@ use App\Scopes\SiteScope;
|
||||
|
||||
class UpdateTenantPaymentAction
|
||||
{
|
||||
/** Zahlungsarten, deren Konto das Konto des Stammes ist (Überweisung: Ziel, Lastschrift: Gläubiger). */
|
||||
private const array BANK_ACCOUNT_SLUGS = [
|
||||
PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION,
|
||||
PaymentMethod::PAYMENT_SEPA_DIRECT_DEBIT,
|
||||
];
|
||||
|
||||
public function __construct(private UpdateTenantPaymentRequest $request)
|
||||
{
|
||||
}
|
||||
@@ -22,7 +28,9 @@ class UpdateTenantPaymentAction
|
||||
'account_name' => $this->request->accountName,
|
||||
]);
|
||||
|
||||
$this->syncTransferPaymentConfiguration();
|
||||
foreach (self::BANK_ACCOUNT_SLUGS as $slug) {
|
||||
$this->syncPaymentConfiguration($slug);
|
||||
}
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'IBAN-Informationen wurden gespeichert.';
|
||||
@@ -31,15 +39,13 @@ class UpdateTenantPaymentAction
|
||||
}
|
||||
|
||||
/**
|
||||
* Übernimmt die eingegebenen IBAN-Daten direkt in die Tenant-Config der Überweisungs-Zahlungsart
|
||||
* Übernimmt die eingegebenen IBAN-Daten direkt in die Tenant-Config der Zahlungsart
|
||||
* (Kontoinhaber/IBAN/BIC), damit sie nicht doppelt gepflegt werden müssen. Bestehende weitere
|
||||
* Config-Werte (z.B. Symbol) bleiben erhalten. Der Ziel-Tenant kann ein verwalteter sein, daher
|
||||
* ohne SiteScope explizit auf den Tenant-Slug gefiltert.
|
||||
* Config-Werte (z.B. Symbol, Gläubiger-ID) bleiben erhalten. Der Ziel-Tenant kann ein verwalteter
|
||||
* sein, daher ohne SiteScope explizit auf den Tenant-Slug gefiltert.
|
||||
*/
|
||||
private function syncTransferPaymentConfiguration(): void
|
||||
private function syncPaymentConfiguration(string $slug): void
|
||||
{
|
||||
$slug = PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION;
|
||||
|
||||
$method = AvailablePaymentMethod::withoutGlobalScope(SiteScope::class)
|
||||
->where('tenant', $this->request->tenant->slug)
|
||||
->where('slug', $slug)
|
||||
|
||||
@@ -107,6 +107,8 @@ async function save() {
|
||||
v-model="form.configuration[option.name]"
|
||||
:defaults="data.statementRulesetDefault ?? {}"
|
||||
:charsets="data.statementRulesetCharsets ?? undefined"/>
|
||||
<input v-else-if="option.type === 'number'" type="number" step="1"
|
||||
v-model="form.configuration[option.name]" class="form-input"/>
|
||||
<input v-else type="text" v-model="form.configuration[option.name]" class="form-input"/>
|
||||
<span v-if="option.hint" class="option-hint">{{ option.hint }}</span>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user