vendor/abap/payment-bundle/src/Controller/NotifyController.php line 30

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Abap\PaymentBundle\Controller;
  4. use Abap\PaymentBundle\Handler\NotifyRequest\CompositeNotifyRequestHandler;
  5. use Abap\PaymentBundle\Handler\NotifyRequest\NotifyRequestHandlerInterface;
  6. use Abap\PaymentBundle\Handler\NotifyRequest\NotifyRequestHandlersRegistry;
  7. use Payum\Core\Payum;
  8. use Payum\Core\Request\Notify;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  12. final class NotifyController
  13. {
  14.     private Payum $payum;
  15.     private CompositeNotifyRequestHandler $notifyRequestHandler;
  16.     public function __construct(
  17.         Payum $payum,
  18.         CompositeNotifyRequestHandler $notifyRequestHandler,
  19.     ) {
  20.         $this->payum $payum;
  21.         $this->notifyRequestHandler $notifyRequestHandler;
  22.     }
  23.     public function notifyAction(Request $request): Response
  24.     {
  25.         $gatewayName $request->get('gateway');
  26.         $gateway $this->payum->getGateway($gatewayName);
  27.         try {
  28.             // if there is token in request, then use default behavior
  29.             $token $this->payum->getHttpRequestVerifier()->verify($request);
  30.             $gateway->execute(new Notify($token));
  31.         } catch (NotFoundHttpException $e) {
  32.             // if not then use custom notify request handler
  33.             $this->notifyRequestHandler->handle($gatewayName);
  34.         }
  35.         return new Response(''204);
  36.     }
  37. }