src/EventSubscriber/SmsGateway/WhenSmsValidationFailCancelPaymentIntentSubscriber.php line 21

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\EventSubscriber\SmsGateway;
  3. use App\DependencyInjection\Service\Data\Client\ClientServiceDI;
  4. use App\Entity\Payment\PaymentIntent;
  5. use App\Event\SmsGateway\SmsIntentErroredEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. final class WhenSmsValidationFailCancelPaymentIntentSubscriber implements EventSubscriberInterface
  8. {
  9.     use ClientServiceDI;
  10.     public static function getSubscribedEvents(): array
  11.     {
  12.         return [
  13.             SmsIntentErroredEvent::class => ['failedPaymentIntent', 9],
  14.         ];
  15.     }
  16.     public function failedPaymentIntent(SmsIntentErroredEvent $event): void
  17.     {
  18.         $paymentIntent = $event->getSmsIntent()
  19.             ->getPaymentIntent();
  20.         if (! $paymentIntent instanceof PaymentIntent) {
  21.             return;
  22.         }
  23.         $this->clientService->createPaymentIntentFailedEvent($paymentIntent);
  24.     }
  25. }