src/Payum/PayumHipay/Controller/NotifyController.php line 32

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the HipaySyliusPlugin
  4.  *
  5.  * (c) Smile <dirtech@smile.fr>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace App\Payum\PayumHipay\Controller;
  12. use Payum\Core\Model\ArrayObject;
  13. use Payum\Core\Request\Notify;
  14. use Sylius\Bundle\PayumBundle\Request\GetStatus;
  15. use Sylius\Component\Core\Model\Payment;
  16. use Sylius\Component\Core\Model\Order;
  17. use Payum\Bundle\PayumBundle\Controller\PayumController;
  18. use Payum\Bundle\PayumBundle\Controller\NotifyController as PayumControllerNotifyController;
  19. use Sylius\Component\Core\Repository\OrderRepositoryInterface;
  20. use Sylius\Component\Core\Repository\PaymentRepositoryInterface;
  21. use Symfony\Component\HttpFoundation\Request;
  22. use Symfony\Component\HttpFoundation\Response;
  23. class NotifyController extends PayumController
  24. {
  25.     // Here you can change the fields which contains order id in the Request
  26.     private const FIELDS_ORDER_ID 'order.id';
  27.     public function doAction(Request $requestPaymentRepositoryInterface $paymentRepositoryOrderRepositoryInterface $orderRepository)
  28.     {
  29.         // $orderId = explode('-', $request->request->get('order')['id'])[0];
  30.         
  31.         $orderId explode('-'$request->request->get('order')['id']);
  32.         $order $orderRepository->findOneBy(
  33.             ['id' => $orderId[0]]
  34.         );
  35.         if (!$order instanceof Order) {
  36.             throw new \LogicException(sprintf('Undefined order with number %s'$orderId));
  37.         }
  38.         $payment $paymentRepository->findOneBy(
  39.             ['order' => $order->getId()]
  40.         );
  41.         if (!$payment instanceof Payment) {
  42.             throw new \LogicException(sprintf('Undefined payment with order_id %s'$orderId));
  43.         }
  44.         $gateway $this->getPayum()->getGateway($request->get('gateway'));
  45.         $gateway->execute(new GetStatus($payment));
  46.         if($payment->getState() === Payment::STATE_COMPLETED) {
  47.             
  48.         }
  49.         return new Response('OK'200);
  50.     }
  51. }