src/EventSubscriber/RegistrationPaymentSubscriber.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Payment\Event\PaymentSucceededEvent;
  4. use App\Service\Payment\RegistrationPaymentService;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. /**
  7. * A paid registration payment confirms the registration (guardian + child accounts).
  8. * Other payments are not a registration's and are left to their own listeners.
  9. */
  10. readonly class RegistrationPaymentSubscriber implements EventSubscriberInterface
  11. {
  12. public function __construct(
  13. private RegistrationPaymentService $registrationPaymentService,
  14. ) {}
  15. public static function getSubscribedEvents(): array
  16. {
  17. return [
  18. PaymentSucceededEvent::class => 'onPaymentSucceeded',
  19. ];
  20. }
  21. public function onPaymentSucceeded(PaymentSucceededEvent $event): void
  22. {
  23. $this->registrationPaymentService->handlePaid($event->paymentLog);
  24. }
  25. }