src/PaymentBundle/Listener/PaymentReceivedListener.php line 36

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of SolidInvoice project.
  5.  *
  6.  * (c) Pierre du Plessis <open-source@solidworx.co>
  7.  *
  8.  * This source file is subject to the MIT license that is bundled
  9.  * with this source code in the file LICENSE.
  10.  */
  11. namespace SolidInvoice\PaymentBundle\Listener;
  12. use SolidInvoice\NotificationBundle\Notification\NotificationManager;
  13. use SolidInvoice\PaymentBundle\Event\PaymentCompleteEvent;
  14. use SolidInvoice\PaymentBundle\Event\PaymentEvents;
  15. use SolidInvoice\PaymentBundle\Notification\PaymentReceivedNotification;
  16. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  17. class PaymentReceivedListener implements EventSubscriberInterface
  18. {
  19.     public static function getSubscribedEvents()
  20.     {
  21.         return [
  22.             PaymentEvents::PAYMENT_COMPLETE => 'onPaymentCapture',
  23.         ];
  24.     }
  25.     public function __construct(
  26.         private readonly NotificationManager $notification
  27.     ) {
  28.     }
  29.     public function onPaymentCapture(PaymentCompleteEvent $event): void
  30.     {
  31.         $notification = new PaymentReceivedNotification(['payment' => $event->getPayment()]);
  32.         $this->notification->sendNotification('payment_made'$notification);
  33.     }
  34. }