Issues (1092)

Block/Onepage/Amazon.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 - 2017 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
use Payone\Core\Model\PayoneConfig;
31
32
/**
33
 * Block class for Amazon Pay checkout
34
 */
35
class Amazon extends Template
36
{
37
    /**
38
     * Checkout session object
39
     *
40
     * @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...
41
     */
42
    protected $checkoutSession;
43
44
    /**
45
     * @var \Payone\Core\Helper\Payment
46
     */
47
    protected $paymentHelper;
48
49
    /**
50
     * PAYONE api helper
51
     *
52
     * @var \Payone\Core\Helper\Api
53
     */
54
    protected $apiHelper;
55
56
    /**
57
     * Constructor
58
     *
59
     * @param \Magento\Checkout\Model\Session                  $checkoutSession
60
     * @param \Magento\Framework\View\Element\Template\Context $context
61
     * @param \Payone\Core\Helper\Payment                      $paymentHelper
62
     * @param \Payone\Core\Helper\Api                          $apiHelper
63
     * @param array                                            $data
64
     */
65
    public function __construct(
66
        \Magento\Checkout\Model\Session $checkoutSession,
67
        \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...
68
        \Payone\Core\Helper\Payment $paymentHelper,
69
        \Payone\Core\Helper\Api $apiHelper,
70
        array $data = []
71
    ) {
72
        parent::__construct($context, $data);
73
        $this->checkoutSession = $checkoutSession;
74
        $this->paymentHelper = $paymentHelper;
75
        $this->apiHelper = $apiHelper;
76
    }
77
78
    /**
79
     * Get Amazon client id from config
80
     *
81
     * @return string
82
     */
83
    public function getClientId()
84
    {
85
        return $this->paymentHelper->getConfigParam('client_id', PayoneConfig::METHOD_AMAZONPAY, 'payone_payment');
86
    }
87
88
    /**
89
     * Get Amazon seller id from config
90
     *
91
     * @return string
92
     */
93
    public function getSellerId()
94
    {
95
        return $this->paymentHelper->getConfigParam('seller_id', PayoneConfig::METHOD_AMAZONPAY, 'payone_payment');
96
    }
97
98
    /**
99
     * Returns currency
100
     *
101
     * @return string
102
     */
103
    public function getCurrency()
104
    {
105
        return $this->apiHelper->getCurrencyFromQuote($this->checkoutSession->getQuote());
106
    }
107
108
    /**
109
     * Get redirect url of the checkout controller
110
     *
111
     * @return string
112
     */
113
    public function getCartUrl()
114
    {
115
        return $this->_urlBuilder->getUrl("checkout/cart", ['_secure' => true]);
116
    }
117
118
    /**
119
     * Get url of the loadReview ajax controller
120
     *
121
     * @return string
122
     */
123
    public function getLoadReviewUrl()
124
    {
125
        return $this->_urlBuilder->getUrl("payone/amazon/loadReview", ['_secure' => true]);
126
    }
127
128
    /**
129
     * Returns error url
130
     *
131
     * @return string
132
     */
133
    public function getErrorUrl()
134
    {
135
        return $this->_urlBuilder->getUrl('payone/amazon/confirmOrderError');
136
    }
137
138
    /**
139
     * Get amazon widget url
140
     *
141
     * @return string
142
     */
143
    public function getWidgetUrl()
144
    {
145
        return $this->paymentHelper->getAmazonPayWidgetUrl();
146
    }
147
148
    /**
149
     * Check if request param invalidPayment is set
150
     *
151
     * @return bool
152
     */
153
    public function isInvalidPaymentTriggered()
154
    {
155
        if ($this->getRequest()->getParam('invalidPayment')) {
156
            return true;
157
        }
158
        return false;
159
    }
160
161
    /**
162
     * Returns amazon order reference id
163
     *
164
     * @return string
165
     */
166
    public function getOrderReferenceId()
167
    {
168
        return $this->checkoutSession->getAmazonReferenceId();
169
    }
170
171
    /**
172
     * Returns if invalidPayment javascript method has to be started after initialization
173
     *
174
     * @return bool
175
     */
176
    public function triggerInvalidPayment()
177
    {
178
        return !empty($this->checkoutSession->getTriggerInvalidPayment());
179
    }
180
}
181