app/Plugin/EccubePaymentLite42/Controller/Front/Shopping/CreditCardForTokenPaymentController.php line 57

Open in your IDE?
  1. <?php
  2. namespace Plugin\EccubePaymentLite42\Controller\Front\Shopping;
  3. use Eccube\Controller\AbstractController;
  4. use Eccube\Form\Type\Shopping\OrderType;
  5. use Eccube\Service\CartService;
  6. use Eccube\Service\OrderHelper;
  7. use Plugin\EccubePaymentLite42\Form\Type\Front\CreditCardForTokenPaymentType;
  8. use Plugin\EccubePaymentLite42\Service\GmoEpsilonRequestService;
  9. use Plugin\EccubePaymentLite42\Service\GmoEpsilonUrlService;
  10. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. class CreditCardForTokenPaymentController extends AbstractController
  14. {
  15.     /**
  16.      * @var GmoEpsilonUrlService
  17.      */
  18.     private $gmoEpsilonUrlService;
  19.     /**
  20.      * @var CartService
  21.      */
  22.     private $cartService;
  23.     /**
  24.      * @var OrderHelper
  25.      */
  26.     private $orderHelper;
  27.     /**
  28.      * @var GmoEpsilonRequestService
  29.      */
  30.     private $gmoEpsilonRequestService;
  31.     public function __construct(
  32.         GmoEpsilonUrlService $gmoEpsilonUrlService,
  33.         CartService $cartService,
  34.         OrderHelper $orderHelper,
  35.         GmoEpsilonRequestService $gmoEpsilonRequestService
  36.     ) {
  37.         $this->gmoEpsilonUrlService $gmoEpsilonUrlService;
  38.         $this->cartService $cartService;
  39.         $this->orderHelper $orderHelper;
  40.         $this->gmoEpsilonRequestService $gmoEpsilonRequestService;
  41.     }
  42.     /**
  43.      * @Route(
  44.      *     "/shopping/eccube_payment_lite/credit_card",
  45.      *     name="eccube_payment_lite42_credit_card_for_token_payment"
  46.      * )
  47.      * @Template("@EccubePaymentLite42/default/Shopping/credit_card_for_token_payment.twig")
  48.      */
  49.     public function index(Request $request)
  50.     {
  51.         // ログイン状態のチェック.
  52.         if ($this->orderHelper->isLoginRequired()) {
  53.             log_info('[注文確認] 未ログインもしくはRememberMeログインのため, ログイン画面に遷移します.');
  54.             return $this->redirectToRoute('shopping_login');
  55.         }
  56.         // 受注の存在チェック
  57.         $preOrderId $this->cartService->getPreOrderId();
  58.         $Order $this->orderHelper->getPurchaseProcessingOrder($preOrderId);
  59.         if (!$Order) {
  60.             log_info('[注文確認] 購入処理中の受注が存在しません.', [$preOrderId]);
  61.             return $this->redirectToRoute('shopping_error');
  62.         }
  63.         $form $this->createForm(CreditCardForTokenPaymentType::class);
  64.         $form->handleRequest($request);
  65.         if ($form->isSubmitted() && $form->isValid()) {
  66.             $checkoutForm $this->createForm(OrderType::class, $Order);
  67.             return [
  68.                 'url_token_js' => $this->gmoEpsilonUrlService->getUrl('token'),
  69.                 'form' => $form->createView(),
  70.                 'checkoutForm' => $checkoutForm->createView(),
  71.                 'token' => $form->getData()['token'],
  72.             ];
  73.         }
  74.         return [
  75.             'url_token_js' => $this->gmoEpsilonUrlService->getUrl('token'),
  76.             'form' => $form->createView(),
  77.         ];
  78.     }
  79. }