/** * (1)選擇使用歐付寶付款 * 購物車結帳頁面,選擇歐付寶付款前往歐付寶頁面 * * @Route("/payment/checkout", name="front_payment_checkout", options={"expose"=true}) * @Method("GET") * @Template() */ public function checkoutAction(Request $request) { $mobileDetector = $this->get('resolver.device'); if ($mobileDetector->isM()) { return $this->redirect($this->generateUrl('mobile_front_cart')); } $paymentHelper = new PaymentHelper(); $em = $this->getDoctrine()->getManager(); /** * 購物車存放的商品索引陣列 * * @var array */ $ids = json_decode($request->cookies->get('avenueCart', '[]')); /** * 購物車商品陣列 * * @var array */ $products = !empty($ids) ? $em->getRepository('WoojinGoodsBundle:GoodsPassport')->findByIds($ids) : array(); /** * 購物車總金額 * * @var integer */ $total = $paymentHelper->getCartTotalCost($products); /** * Symfony session object * * @var \Symfony\Component\HttpFoundation\Session\Session; */ $session = $this->get('avenue.session')->get(); /** * Custom object * * @var \stdClass */ $custom = json_decode($session->get('custom'), true); return array('custom' => $custom, 'products' => $products, 'total' => $total); }