Controller/CartController.php
public function paymentAction(Request $request)
    {
        if (null !== $redirect = $this->validateStep('payment')) {
            return $redirect;
        }

        $cart = $this->getCart();

        $amount = $this
            ->get('ekyna_order.order.calculator')
            ->calculateOrderRemainingTotal($cart)
        ;

        $paymentClass = $this->container->getParameter('ekyna_order.order_payment.class');
        /** @var \Ekyna\Component\Sale\Order\OrderPaymentInterface $payment */
        $payment = new $paymentClass;
        $payment->setAmount($amount);
        $cart->addPayment($payment);

        $form = $this->createForm('ekyna_cart_payment', $payment);

        $form->handleRequest($request);
        if ($form->isValid()) {
            $event = new PaymentEvent($payment);
            $this->getDispatcher()->dispatch(PaymentEvents::PREPARE, $event);
            if ($event->isPropagationStopped()) {
                $event->toFlashes($this->getFlashBag());
            } elseif (null !== $response = $event->getResponse()) {
                return $response;
            }
        }

        return $this->render('EkynaCartBundle:Cart:payment.html.twig', [
            'cart' => $cart,
            'form' => $form->createView(),
        ]);
    }
public function paymentAction(Request $request)
    {
        if (null !== $redirect = $this->validateStep('payment')) {
            return $redirect;
        }

        $cart = $this->getCart();

        $amount = $this
            ->get('ekyna_order.order.calculator')
            ->calculateOrderRemainingTotal($cart)
        ;

        $paymentClass = $this->container->getParameter('ekyna_order.order_payment.class');
        /** @var \Ekyna\Component\Sale\Order\OrderPaymentInterface $payment */
        $payment = new $paymentClass;
        $payment->setAmount($amount);
        $cart->addPayment($payment);

        $form = $this->createForm('ekyna_cart_payment', $payment);

        $form->handleRequest($request);
        if ($form->isValid()) {
            $event = new PaymentEvent($payment);
            $this->getDispatcher()->dispatch(PaymentEvents::PREPARE, $event);
            if ($event->isPropagationStopped()) {
                $event->toFlashes($this->getFlashBag());
            } elseif (null !== $response = $event->getResponse()) {
                return $response;
            }
        }

        return $this->render('EkynaCartBundle:Cart:payment.html.twig', [
            'cart' => $cart,
            'form' => $form->createView(),
        ]);
    }
public function paymentAction ( Request $ request ) { if ( null !== $ redirect = $ this -> validateStep ( 'payment' ) ) { return $ redirect ; } $ cart = $ this -> getCart ( ) ; $ amount = $ this -> get ( 'ekyna_order.order.calculator' ) -> calculateOrderRemainingTotal ( $ cart ) ; $ paymentClass = $ this -> container -> getParameter ( 'ekyna_order.order_payment.class' ) ; /** @var \Ekyna\Component\Sale\Order\OrderPaymentInterface $payment */ $ payment = new $ paymentClass ; $ payment -> setAmount ( $ amount ) ; $ cart -> addPayment ( $ payment ) ; $ form = $ this -> createForm ( 'ekyna_cart_payment' , $ payment ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ event = new PaymentEvent ( $ payment ) ; $ this -> getDispatcher ( ) -> dispatch ( PaymentEvents :: PREPARE , $ event ) ; if ( $ event -> isPropagationStopped ( ) ) { $ event -> toFlashes ( $ this -> getFlashBag ( ) ) ; } elseif ( null !== $ response = $ event -> getResponse ( ) ) { return $ response ; } } return $ this -> render ( 'EkynaCartBundle:Cart:payment.html.twig' , [ 'cart' => $ cart , 'form' => $ form -> createView ( ) , ] ) ; }
Payment action.

@param Request $request
@return \Symfony\Component\HttpFoundation\RedirectResponse|Response
Payment action .