app/Plugin/EccubePaymentLite4/EventListener/EventSubscriber/Admin/Order/OrderEditChangePriceEventSubscriber.php line 52

Open in your IDE?
  1. <?php
  2. namespace Plugin\EccubePaymentLite4\EventListener\EventSubscriber\Admin\Order;
  3. use Eccube\Common\EccubeConfig;
  4. use Eccube\Entity\Order;
  5. use Eccube\Event\EccubeEvents;
  6. use Eccube\Event\EventArgs;
  7. use Plugin\EccubePaymentLite4\Service\GmoEpsilonRequest\RequestChangePaymentAmountService;
  8. use Plugin\EccubePaymentLite4\Service\GmoEpsilonRequest\RequestGetEpsilonPaymentInformationService;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  11. class OrderEditChangePriceEventSubscriber implements EventSubscriberInterface
  12. {
  13.     /**
  14.      * @var RequestGetEpsilonPaymentInformationService
  15.      */
  16.     private $requestGetEpsilonPaymentInformationService;
  17.     /**
  18.      * @var RequestChangePaymentAmountService
  19.      */
  20.     private $requestChangePaymentAmountService;
  21.     /**
  22.      * @var EccubeConfig
  23.      */
  24.     private $eccubeConfig;
  25.     /**
  26.      * @var SessionInterface
  27.      */
  28.     private $session;
  29.     public function __construct(
  30.         RequestGetEpsilonPaymentInformationService $requestGetEpsilonPaymentInformationService,
  31.         RequestChangePaymentAmountService $requestChangePaymentAmountService,
  32.         EccubeConfig $eccubeConfig,
  33.         SessionInterface $session
  34.     ) {
  35.         $this->requestGetEpsilonPaymentInformationService $requestGetEpsilonPaymentInformationService;
  36.         $this->requestChangePaymentAmountService $requestChangePaymentAmountService;
  37.         $this->eccubeConfig $eccubeConfig;
  38.         $this->session $session;
  39.     }
  40.     public static function getSubscribedEvents()
  41.     {
  42.         return [
  43.             EccubeEvents::ADMIN_ORDER_EDIT_INDEX_COMPLETE => 'adminOrderEditIndexComplete',
  44.         ];
  45.     }
  46.     public function adminOrderEditIndexComplete(EventArgs $eventArgs)
  47.     {
  48.         /** @var Order $TargetOrder */
  49.         $TargetOrder $eventArgs->getArgument('TargetOrder');
  50.         $results $this
  51.             ->requestChangePaymentAmountService
  52.             ->handle($TargetOrder);
  53.         // 決済金額変更リクエストが成功すれば、successのメッセージを返す。
  54.         if (!is_null($results) && $results['status'] === 'OK') {
  55.             $this
  56.                 ->session
  57.                 ->getFlashBag()
  58.                 ->add('eccube.admin.success'$results['message']);
  59.             return;
  60.         }
  61.         // 決済金額変更リクエストが失敗すれば、warningのメッセージを返す。
  62.         if (!is_null($results)) {
  63.             $this
  64.                 ->session
  65.                 ->getFlashBag()
  66.                 ->add('eccube.admin.warning'$results['message']);
  67.         }
  68.     }
  69. }