Handling SEPA Direct Payment
This commit is contained in:
@@ -13,15 +13,18 @@ use App\Models\AvailablePaymentMethod;
|
||||
use App\Models\Event;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\Tenant;
|
||||
use App\RelationModels\EventPaymentMethods;
|
||||
use App\Resources\AvailablePaymentMethodResource;
|
||||
use App\ValueObjects\Amount;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\Concerns\OffersAccountTransfer;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SignUpPaymentOptionsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
use OffersAccountTransfer;
|
||||
|
||||
private Tenant $tenant;
|
||||
|
||||
@@ -75,6 +78,7 @@ class SignUpPaymentOptionsTest extends TestCase
|
||||
public function test_payment_options_are_sanitized_and_stored(): void
|
||||
{
|
||||
$event = $this->createEvent();
|
||||
$this->offerAccountTransfer($event);
|
||||
|
||||
// Überweisung hat keine Teilnehmer-Eingaben -> alles wird verworfen, payment_options bleibt leer.
|
||||
$response = new SignUpCommand($this->signUpRequest($event, ['evil' => 'x']))->execute();
|
||||
@@ -85,6 +89,38 @@ class SignUpPaymentOptionsTest extends TestCase
|
||||
$this->assertStringContainsString('Beitrag Hans Muster', $response->participant->payment_purpose);
|
||||
}
|
||||
|
||||
public function test_sign_up_is_rejected_for_a_payment_method_not_offered_by_the_event(): 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'],
|
||||
]);
|
||||
|
||||
// Beim Mandanten aktiv, aber der Veranstaltung nicht zugewiesen.
|
||||
$response = new SignUpCommand($this->signUpRequest($event, []))->execute();
|
||||
|
||||
$this->assertFalse($response->success);
|
||||
$this->assertSame(0, $event->participants()->count());
|
||||
}
|
||||
|
||||
public function test_sign_up_is_rejected_when_the_method_is_inactive_or_incomplete(): void
|
||||
{
|
||||
$event = $this->createEvent();
|
||||
$this->offerAccountTransfer($event);
|
||||
|
||||
// Zugewiesen, aber am Event unvollständig konfiguriert (z.B. per Override ohne IBAN).
|
||||
EventPaymentMethods::where('event_id', $event->id)->update(['configuration' => json_encode(['account_owner' => 'Kasse'])]);
|
||||
$this->assertFalse(new SignUpCommand($this->signUpRequest($event, []))->execute()->success);
|
||||
|
||||
// Vollständig, aber beim Mandanten deaktiviert.
|
||||
EventPaymentMethods::where('event_id', $event->id)->update(['configuration' => json_encode(['account_owner' => 'Kasse', 'iban' => 'DE1'])]);
|
||||
AvailablePaymentMethod::where('slug', PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION)->update(['active' => false]);
|
||||
$this->assertFalse(new SignUpCommand($this->signUpRequest($event, []))->execute()->success);
|
||||
|
||||
$this->assertSame(0, $event->participants()->count());
|
||||
}
|
||||
|
||||
public function test_resource_exposes_participant_options_schema(): void
|
||||
{
|
||||
$event = $this->createEvent();
|
||||
|
||||
Reference in New Issue
Block a user