Handling SEPA Direct Payment

This commit is contained in:
2026-10-04 16:47:15 +02:00
parent 9e9ea0cfd5
commit d511dbdd66
25 changed files with 801 additions and 43 deletions
@@ -4,6 +4,7 @@ namespace Tests\Unit;
use App\EventPaymentModules\EventPaymentModuleRegistry;
use App\EventPaymentModules\Modules\AccountTransferPaymentModule;
use App\EventPaymentModules\Modules\SepaDirectDebitPaymentModule;
use App\EventPaymentModules\Modules\UndefinedPaymentModule;
use App\EventPaymentModules\ProvidesGiroCode;
use App\Models\PaymentMethod;
@@ -21,6 +22,55 @@ class EventPaymentModuleRegistryTest extends TestCase
UndefinedPaymentModule::class,
EventPaymentModuleRegistry::forSlug(PaymentMethod::PAYMENT_NOT_DEFINED)
);
$this->assertInstanceOf(
SepaDirectDebitPaymentModule::class,
EventPaymentModuleRegistry::forSlug(PaymentMethod::PAYMENT_SEPA_DIRECT_DEBIT)
);
}
public function test_sepa_direct_debit_requires_a_valid_configuration(): void
{
$module = new SepaDirectDebitPaymentModule();
$valid = [
'account_owner' => 'Test e.V.',
'iban' => 'DE02120300000000202051',
'creditor_id' => 'DE98ZZZ09999999999',
'pre_notification_days' => '5',
];
$this->assertSame(['account_owner', 'iban', 'creditor_id', 'pre_notification_days'], $module->requiredOptionKeys());
$this->assertSame([], $module->configurationErrors($valid));
$this->assertTrue($module->isConfigurationComplete($valid));
// Befüllt, aber ungültig -- reicht nicht.
foreach ([
'iban' => 'DE02120300000000202015',
'creditor_id' => 'DE97ZZZ09999999999',
'pre_notification_days' => '1',
] as $key => $value) {
$config = array_merge($valid, [$key => $value]);
$this->assertArrayHasKey($key, $module->configurationErrors($config), $key);
$this->assertFalse($module->isConfigurationComplete($config), $key);
}
foreach (['15', '2.5', 'fünf'] as $days) {
$this->assertArrayHasKey('pre_notification_days', $module->configurationErrors(
array_merge($valid, ['pre_notification_days' => $days])
), $days);
}
// Leere Felder sind Sache der Pflichtfeld-Prüfung, nicht der Inhaltsprüfung.
$this->assertSame([], $module->configurationErrors([]));
$this->assertFalse($module->isConfigurationComplete(array_merge($valid, ['creditor_id' => ''])));
}
public function test_sepa_direct_debit_defaults(): void
{
$defaults = PaymentMethod::defaults()[PaymentMethod::PAYMENT_SEPA_DIRECT_DEBIT];
$this->assertSame('SEPA-Lastschrift', $defaults['name']);
$this->assertSame(5, $defaults['configuration']['pre_notification_days']);
$this->assertSame('file-signature', $defaults['configuration']['icon']);
}
public function test_for_slug_returns_null_for_unknown(): void
@@ -34,6 +84,7 @@ class EventPaymentModuleRegistryTest extends TestCase
$this->assertContains(PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION, $slugs);
$this->assertContains(PaymentMethod::PAYMENT_NOT_DEFINED, $slugs);
$this->assertContains(PaymentMethod::PAYMENT_SEPA_DIRECT_DEBIT, $slugs);
}
public function test_module_option_helpers(): void