Issues (1092)

Block/Onepage/Success.php (3 issues)

Labels
Severity
1
<?php
2
3
/**
4
 * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16
 *
17
 * PHP version 5
18
 *
19
 * @category  Payone
20
 * @package   Payone_Magento2_Plugin
21
 * @author    FATCHIP GmbH <[email protected]>
22
 * @copyright 2003 - 2016 Payone GmbH
23
 * @license   <http://www.gnu.org/licenses/> GNU Lesser General Public License
24
 * @link      http://www.payone.de
25
 */
26
27
namespace Payone\Core\Block\Onepage;
28
29
use Magento\Framework\View\Element\Template;
0 ignored issues
show
The type Magento\Framework\View\Element\Template was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
31
/**
32
 * Block class for success-page extension which displays the mandate-link
33
 */
34
class Success extends Template
35
{
36
    /**
37
     * Checkout session
38
     *
39
     * @var \Magento\Checkout\Model\Session
0 ignored issues
show
The type Magento\Checkout\Model\Session was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
40
     */
41
    protected $checkoutSession;
42
43
    /**
44
     * PAYONE payment helper
45
     *
46
     * @var \Payone\Core\Helper\Payment
47
     */
48
    protected $paymentHelper;
49
50
    /**
51
     * Is mandate link to be shown?
52
     *
53
     * @var bool|null
54
     */
55
    protected $blShowMandateLink = null;
56
57
    /**
58
     * Instruction notes
59
     *
60
     * @var string|bool
61
     */
62
    protected $sInstructionNotes = false;
63
64
    /**
65
     * Constructor
66
     *
67
     * @param \Magento\Checkout\Model\Session                  $checkoutSession
68
     * @param \Magento\Framework\View\Element\Template\Context $context
69
     * @param \Payone\Core\Helper\Payment                      $paymentHelper
70
     * @param array                                            $data
71
     */
72
    public function __construct(
73
        \Magento\Checkout\Model\Session $checkoutSession,
74
        \Magento\Framework\View\Element\Template\Context $context,
0 ignored issues
show
The type Magento\Framework\View\Element\Template\Context was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
75
        \Payone\Core\Helper\Payment $paymentHelper,
76
        array $data = []
77
    ) {
78
        parent::__construct($context, $data);
79
        $this->checkoutSession = $checkoutSession;
80
        $this->paymentHelper = $paymentHelper;
81
    }
82
83
    /**
84
     * Determine if mandate-link has to be shown or not
85
     *
86
     * @return bool
87
     */
88
    public function showMandateLink()
89
    {
90
        if ($this->blShowMandateLink === null) {
91
            $this->blShowMandateLink = false;
92
            if ($this->paymentHelper->isMandateManagementDownloadActive()) {
93
                $order = $this->checkoutSession->getLastRealOrder();
94
                if ($order->getPayoneMandateId()) {
95
                    $this->blShowMandateLink = true;
96
                }
97
            }
98
        }
99
        return $this->blShowMandateLink;
100
    }
101
102
    /**
103
     * Return instruction notes
104
     *
105
     * @return string
106
     */
107
    public function getInstructionNotes()
108
    {
109
        if ($this->sInstructionNotes === false) {
110
            $this->sInstructionNotes = $this->checkoutSession->getPayoneInstructionNotes();
111
            $this->checkoutSession->unsPayoneInstructionNotes();
112
        }
113
        return $this->sInstructionNotes;
114
    }
115
116
    /**
117
     * Return if amazon order is pending message needs to be shown
118
     *
119
     * @return bool
120
     */
121
    public function showAmazonPendingMessage()
122
    {
123
        if ($this->checkoutSession->getShowAmazonPendingNotice() === true) {
124
            return true;
125
        }
126
        return false;
127
    }
128
129
    /**
130
     * Determine if extra info has to be shown on success page
131
     *
132
     * @return bool
133
     */
134
    protected function pageRenderNeeded()
135
    {
136
        if ($this->showMandateLink() || $this->getInstructionNotes() || $this->showAmazonPendingMessage()) {
137
            return true;
138
        }
139
        return false;
140
    }
141
142
    /**
143
     * Return block-content if it has to be shown or empty string if not
144
     *
145
     * @return string
146
     */
147
    public function toHtml()
148
    {
149
        if ($this->pageRenderNeeded() === true) {
150
            $sReturn = parent::toHtml();
151
            $this->checkoutSession->unsShowAmazonPendingNotice();
152
            return $sReturn;
153
        }
154
        return '';
155
    }
156
157
    /**
158
     * Return URL to the mandate-download-page
159
     *
160
     * @return string
161
     */
162
    public function getMandateDownloadUrl()
163
    {
164
        return $this->getUrl('payone/mandate/download');
165
    }
166
}
167