/**
  * Payment execution.
  *
  * @return Response
  */
 public function executeAction()
 {
     /**
      * The execute action will generate the Paypal web
      * checkout form before redirecting.
      */
     $formView = $this->paypalWebCheckoutManager->generatePaypalForm();
     $data = $this->engine->render('PaypalWebCheckoutBundle:Payment:process.html.twig', ['form' => $formView]);
     return new Response($data);
 }
 /**
  * Process Paypal IPN notification.
  *
  * This controller handles the IPN notification.
  * The notification is sent using POST method. However,
  * we expect our internal order_id to be passed as a
  * query parameter 'order_id'. The resulting URL for
  * IPN callback notification will have the following form:
  *
  * http://my-domain.com/payment/paypal_web_checkout/process?order_id=1001
  *
  * No matter what happens here, this controller will
  * always return a 200 status HTTP response, otherwise
  * Paypal notification engine will keep on sending the
  * message.
  *
  * @param Request $request Request element
  *
  * @return Response
  */
 public function processAction(Request $request)
 {
     $orderId = $request->query->get('order_id');
     try {
         $this->paypalWebCheckoutManager->processPaypalIPNMessage($orderId, $request->request->all());
         $this->paymentLogger->log('info', 'Paypal payment success. Order number #' . $orderId, 'paypal-web-checkout');
     } catch (ParameterNotReceivedException $exception) {
         $this->paymentLogger->log('error', 'Parameter ' . $exception->getMessage() . ' not received. Order number #' . $orderId, 'paypal-web-checkout');
     } catch (PaymentException $exception) {
         $this->paymentLogger->log('error', 'Paypal payment error "' . $exception->getMessage() . '". Order number #' . $orderId, 'paypal-web-checkout');
     }
     return new Response('OK', 200);
 }