<?php
namespace App\EventSubscriber;
use App\Payment\Event\PaymentSucceededEvent;
use App\Service\Payment\RegistrationPaymentService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* A paid registration payment confirms the registration (guardian + child accounts).
* Other payments are not a registration's and are left to their own listeners.
*/
readonly class RegistrationPaymentSubscriber implements EventSubscriberInterface
{
public function __construct(
private RegistrationPaymentService $registrationPaymentService,
) {}
public static function getSubscribedEvents(): array
{
return [
PaymentSucceededEvent::class => 'onPaymentSucceeded',
];
}
public function onPaymentSucceeded(PaymentSucceededEvent $event): void
{
$this->registrationPaymentService->handlePaid($event->paymentLog);
}
}