src/EventSubscriber/PrzlelewyOrderPayed.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Env;
  4. use App\Event\OrderPayedEvent;
  5. use App\Service\Pay\Przelewy;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class PrzlelewyOrderPayed implements EventSubscriberInterface
  8. {
  9.     public function __construct(
  10.         private Przelewy $Pay        
  11.     )
  12.     {
  13.         
  14.     }
  15.     public function onOrderPayed(OrderPayedEvent $event): void
  16.     {        
  17.         if (Env::site() != Env::MIX && Env::site() != Env::OPT_MIX) {
  18.             return;
  19.         }
  20.         $this->Pay->verify($event->getOrder()->getId(), $event->getOrder()->getAmount());
  21.     }
  22.     public static function getSubscribedEvents(): array
  23.     {
  24.         return [
  25.             OrderPayedEvent::NAME => 'onOrderPayed',
  26.         ];
  27.     }
  28. }