/** * @param FinancialTransactionInterface $transaction * @param \Vifeed\PaymentBundle\Entity\Order $order * * @return ActionRequiredException */ protected function createRedirectActionException(FinancialTransactionInterface $transaction, Order $order) { $actionRequest = new ActionRequiredException('Redirect to pay'); $actionRequest->setFinancialTransaction($transaction); $url = $this->router->generate('order_bill', ['id' => $order->getId()], false); $actionRequest->setAction(new DownloadFile($url)); return $actionRequest; }
/** * Счёт для скачивания * * @param Order $order * * * @return Response */ public function billAction(Order $order) { if ($this->getUser() !== $order->getUser()) { throw new AccessDeniedHttpException(); } $method = $order->getPaymentInstruction()->getPaymentSystemName(); if (!in_array($method, ['bank_transfer', 'bank_receipt'])) { throw new NotFoundHttpException(); } $billData = $order->getBillData(); if (!isset($billData['bill']) || !isset($billData['template'])) { throw new \Exception('Недостаточно данных о заказе'); } $billGenerator = $this->get('vifeed.payment.bill_generator'); $billGenerator->setOrderDetails($billData['bill'])->setTemplate($billData['template']); $response = new Response(); $response->setContent($billGenerator->generate()); $disposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'Счет-' . $order->getId() . '.pdf', 'Bill-' . $order->getId() . '.pdf'); $response->headers->set('Content-Type', 'application/pdf'); $response->headers->set('Content-Disposition', $disposition); return $response; }