1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @license GPLv3, http://www.gnu.org/copyleft/gpl.html |
||
5 | * @copyright Metaways Infosystems GmbH, 2013 |
||
6 | * @copyright Aimeos (aimeos.org), 2014-2016 |
||
7 | * @package TYPO3 |
||
8 | */ |
||
9 | |||
10 | |||
11 | namespace Aimeos\Aimeos\Controller; |
||
12 | |||
13 | |||
14 | use Aimeos\Aimeos\Base; |
||
15 | use TYPO3\CMS\Core\Utility\GeneralUtility; |
||
16 | |||
17 | |||
18 | /** |
||
19 | * Aimeos checkout controller. |
||
20 | * |
||
21 | * @package TYPO3 |
||
22 | */ |
||
23 | class CheckoutController extends AbstractController |
||
24 | { |
||
25 | /** |
||
26 | * Processes requests and renders the checkout process. |
||
27 | */ |
||
28 | public function indexAction() |
||
29 | { |
||
30 | $client = \Aimeos\Client\Html::create($this->context(), 'checkout/standard'); |
||
31 | return $this->getClientOutput($client); |
||
32 | } |
||
33 | |||
34 | |||
35 | /** |
||
36 | * Processes requests and renders the checkout confirmation. |
||
37 | */ |
||
38 | public function confirmAction() |
||
39 | { |
||
40 | $context = $this->context(); |
||
41 | $client = \Aimeos\Client\Html::create($context, 'checkout/confirm'); |
||
42 | |||
43 | $view = $context->view(); |
||
44 | $param = array_merge(GeneralUtility::_GET(), GeneralUtility::_POST()); |
||
45 | $helper = new \Aimeos\Base\View\Helper\Param\Standard($view, $param); |
||
46 | $view->addHelper('param', $helper); |
||
47 | |||
48 | $client->setView($view)->init(); |
||
49 | |||
50 | $header = (string) $client->header(); |
||
51 | $html = (string) $client->body(); |
||
52 | |||
53 | if (!isset($this->responseFactory)) // TYPO3 10 |
||
54 | { |
||
55 | $this->response->addAdditionalHeaderData($header); |
||
56 | return $html; |
||
57 | } |
||
58 | |||
59 | GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class)->addHeaderData($header); |
||
60 | |||
61 | return $this->responseFactory->createResponse() |
||
62 | ->withAddedHeader('Content-Type', 'text/html; charset=utf-8') |
||
63 | ->withBody($this->streamFactory->createStream($html)); |
||
64 | } |
||
65 | |||
66 | |||
67 | /** |
||
68 | * Processes update requests from payment service providers. |
||
69 | */ |
||
70 | public function updateAction() |
||
71 | { |
||
72 | try { |
||
73 | $context = $this->context(); |
||
74 | $client = \Aimeos\Client\Html::create($context, 'checkout/update'); |
||
75 | |||
76 | $view = $context->view(); |
||
77 | $param = array_merge(GeneralUtility::_GET(), GeneralUtility::_POST()); |
||
78 | $helper = new \Aimeos\Base\View\Helper\Param\Standard($view, $param); |
||
79 | $view->addHelper('param', $helper); |
||
80 | |||
81 | $client->setView($view)->init(); |
||
82 | |||
83 | $header = (string) $client->header(); |
||
84 | $html = (string) $client->body(); |
||
85 | |||
86 | if (!isset($this->responseFactory)) // TYPO3 10 |
||
87 | { |
||
88 | $this->response->addAdditionalHeaderData($header); |
||
89 | return $html; |
||
90 | } |
||
91 | |||
92 | GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class)->addHeaderData($header); |
||
93 | |||
94 | return $this->responseFactory->createResponse() |
||
95 | ->withBody($this->streamFactory->createStream($html)); |
||
96 | } catch(\Exception $e) { |
||
97 | if (!isset($this->responseFactory)) // TYPO3 10 |
||
98 | { |
||
99 | @header('HTTP/1.1 500 Internal server error', true, 500); |
||
0 ignored issues
–
show
|
|||
100 | return 'Error: ' . $e->getMessage(); |
||
101 | } |
||
102 | |||
103 | return $this->responseFactory->createResponse()->withStatus(500) |
||
104 | ->withBody($this->streamFactory->createStream('Error: ' . $e->getMessage())); |
||
105 | } |
||
106 | } |
||
107 | } |
||
108 |
If you suppress an error, we recommend checking for the error condition explicitly: