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 - 2024 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\Amazon; |
||
28 | |||
29 | use Magento\Framework\View\Element\Template; |
||
0 ignored issues
–
show
|
|||
30 | use Payone\Core\Model\Methods\AmazonPayV2; |
||
31 | use Payone\Core\Model\PayoneConfig; |
||
32 | |||
33 | /** |
||
34 | * Block class for the Amazon Pay V2 button |
||
35 | */ |
||
36 | class ButtonV2 extends Template implements \Magento\Catalog\Block\ShortcutInterface |
||
0 ignored issues
–
show
The type
Magento\Catalog\Block\ShortcutInterface 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
37 | { |
||
38 | /** |
||
39 | * Shortcut alias |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $alias = 'payone.block.amazon.buttonv2'; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $name; |
||
49 | |||
50 | /** |
||
51 | * @var \Payone\Core\Helper\Api |
||
52 | */ |
||
53 | protected $apiHelper; |
||
54 | |||
55 | /** |
||
56 | * @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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
57 | */ |
||
58 | protected $checkoutSession; |
||
59 | |||
60 | /** |
||
61 | * @var \Payone\Core\Model\Methods\AmazonPayV2 |
||
62 | */ |
||
63 | protected $amazonPayment; |
||
64 | |||
65 | /** |
||
66 | * Constructor |
||
67 | * |
||
68 | * @param \Magento\Framework\View\Element\Template\Context $context |
||
69 | * @param \Payone\Core\Helper\Api $apiHelper |
||
70 | * @param \Magento\Checkout\Model\Session $checkoutSession |
||
71 | * @param \Payone\Core\Model\Methods\AmazonPayV2 $amazonPayment |
||
72 | * @param array $data |
||
73 | */ |
||
74 | public function __construct( |
||
75 | \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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
76 | \Payone\Core\Helper\Api $apiHelper, |
||
77 | \Magento\Checkout\Model\Session $checkoutSession, |
||
78 | \Payone\Core\Model\Methods\AmazonPayV2 $amazonPayment, |
||
79 | array $data = [] |
||
80 | ) { |
||
81 | parent::__construct($context, $data); |
||
82 | $this->apiHelper = $apiHelper; |
||
83 | $this->checkoutSession = $checkoutSession; |
||
84 | $this->amazonPayment = $amazonPayment; |
||
85 | $this->setTemplate('amazon/buttonv2.phtml'); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Get shortcut alias |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | public function getAlias() |
||
94 | { |
||
95 | return $this->alias; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * @param string $name |
||
100 | * @return void |
||
101 | */ |
||
102 | public function setName($name) |
||
103 | { |
||
104 | $this->name = $name; |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * @return string |
||
109 | */ |
||
110 | public function getName() |
||
111 | { |
||
112 | return $this->name; |
||
113 | } |
||
114 | |||
115 | /** |
||
116 | * @return int |
||
117 | */ |
||
118 | public function getQuoteId() |
||
119 | { |
||
120 | return $this->getQuote()->getId(); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * @return string |
||
125 | */ |
||
126 | public function getStoreCode() |
||
127 | { |
||
128 | return $this->getQuote()->getStore()->getCode(); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @return string |
||
133 | */ |
||
134 | public function getButtonId() |
||
135 | { |
||
136 | $buttonId = "AmazonPayButton"; |
||
137 | if (strpos($this->getName() ?? '', "checkout.cart.shortcut.buttons") !== false) { |
||
138 | $buttonId = "AmazonPayButtonBasket"; |
||
139 | } elseif (strpos($this->getName() ?? '', "shortcutbuttons") !== false) { |
||
140 | $buttonId = "AmazonPayButtonMiniBasket"; |
||
141 | } |
||
142 | return $buttonId; |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * @return mixed |
||
147 | */ |
||
148 | public function getQuote() |
||
149 | { |
||
150 | return $this->checkoutSession->getQuote(); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * @return string |
||
155 | */ |
||
156 | public function getPublicKeyId() |
||
157 | { |
||
158 | return AmazonPayV2::BUTTON_PUBLIC_KEY; |
||
159 | } |
||
160 | |||
161 | /** |
||
162 | * Get Amazon merchant id from config |
||
163 | * |
||
164 | * @return string |
||
165 | */ |
||
166 | public function getMerchantId() |
||
167 | { |
||
168 | return $this->amazonPayment->getMerchantId(); |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * @return bool |
||
173 | */ |
||
174 | public function isTestMode() |
||
175 | { |
||
176 | return $this->amazonPayment->useSandbox(); |
||
177 | } |
||
178 | |||
179 | /** |
||
180 | * @return string |
||
181 | */ |
||
182 | public function getCurrency() |
||
183 | { |
||
184 | return $this->apiHelper->getCurrencyFromQuote($this->getQuote()); |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * @return float |
||
189 | */ |
||
190 | public function getAmount() |
||
191 | { |
||
192 | return $this->apiHelper->getQuoteAmount($this->getQuote()); |
||
193 | } |
||
194 | |||
195 | /** |
||
196 | * @return string |
||
197 | */ |
||
198 | public function getProductType() |
||
199 | { |
||
200 | $oQuote = $this->getQuote(); |
||
201 | if ($oQuote->isVirtual() === true) { |
||
202 | return "PayOnly"; |
||
203 | } |
||
204 | return "PayAndShip"; |
||
205 | /** |
||
206 | * 'PayAndShip' - Offer checkout using buyer's Amazon wallet and address book. Select this product type if you need the buyer's shipping details |
||
207 | * 'PayOnly' - Offer checkout using only the buyer's Amazon wallet. Select this product type if you do not need the buyer's shipping details |
||
208 | * 'SignIn' - Offer Amazon Sign-in. Select this product type if you need buyer details before the buyer starts Amazon Pay checkout. See Amazon Sign-in for more information. |
||
209 | * Default value: 'PayAndShip' |
||
210 | */ |
||
211 | } |
||
212 | |||
213 | /** |
||
214 | * @return string |
||
215 | */ |
||
216 | public function getPlacement() |
||
217 | { |
||
218 | if ($this->getButtonId() == "AmazonPayButtonBasket") { |
||
219 | return "Cart"; |
||
220 | } |
||
221 | return "Home"; |
||
222 | /** |
||
223 | * 'Home' - Initial or main page |
||
224 | * 'Product' - Product details page |
||
225 | * 'Cart' - Cart review page before buyer starts checkout |
||
226 | * 'Checkout' - Any page after buyer starts checkout |
||
227 | * 'Other' - Any page that doesn't fit the previous descriptions |
||
228 | */ |
||
229 | } |
||
230 | |||
231 | /** |
||
232 | * Get Amazon button color from config |
||
233 | * |
||
234 | * @return string |
||
235 | */ |
||
236 | public function getButtonColor() |
||
237 | { |
||
238 | return $this->amazonPayment->getButtonColor(); |
||
239 | } |
||
240 | |||
241 | /** |
||
242 | * Get Amazon button language from config |
||
243 | * |
||
244 | * @return string |
||
245 | */ |
||
246 | public function getButtonLanguage() |
||
247 | { |
||
248 | return $this->amazonPayment->getButtonLanguage(); |
||
249 | } |
||
250 | } |
||
251 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths