|
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\Controller\Onepage; |
|
28
|
|
|
|
|
29
|
|
|
use Magento\Framework\View\Result\Page; |
|
|
|
|
|
|
30
|
|
|
use Magento\Framework\Controller\ResultFactory; |
|
|
|
|
|
|
31
|
|
|
use Payone\Core\Model\PayoneConfig; |
|
32
|
|
|
use Magento\Quote\Model\Quote; |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Controller for mandate management with debit payment |
|
36
|
|
|
*/ |
|
37
|
|
|
class Amazon extends \Magento\Framework\App\Action\Action |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
|
|
/** |
|
40
|
|
|
* Page result factory |
|
41
|
|
|
* |
|
42
|
|
|
* @var \Magento\Framework\View\Result\PageFactory |
|
|
|
|
|
|
43
|
|
|
*/ |
|
44
|
|
|
protected $pageFactory; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Checkout session |
|
48
|
|
|
* |
|
49
|
|
|
* @var \Magento\Checkout\Model\Session |
|
|
|
|
|
|
50
|
|
|
*/ |
|
51
|
|
|
protected $checkoutSession; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Customer session |
|
55
|
|
|
* |
|
56
|
|
|
* @var \Magento\Customer\Model\Session |
|
|
|
|
|
|
57
|
|
|
*/ |
|
58
|
|
|
protected $customerSession; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* PAYONE payment helper |
|
62
|
|
|
* |
|
63
|
|
|
* @var \Payone\Core\Helper\Payment |
|
64
|
|
|
*/ |
|
65
|
|
|
protected $paymentHelper; |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Checkout helper |
|
69
|
|
|
* |
|
70
|
|
|
* @var \Magento\Checkout\Helper\Data |
|
|
|
|
|
|
71
|
|
|
*/ |
|
72
|
|
|
protected $checkoutHelper; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Constructor |
|
76
|
|
|
* |
|
77
|
|
|
* @param \Magento\Framework\App\Action\Context $context |
|
78
|
|
|
* @param \Magento\Framework\View\Result\PageFactory $pageFactory |
|
79
|
|
|
* @param \Magento\Checkout\Model\Session $checkoutSession |
|
80
|
|
|
* @param \Magento\Customer\Model\Session $customerSession |
|
81
|
|
|
* @param \Payone\Core\Helper\Payment $paymentHelper |
|
82
|
|
|
* @param \Magento\Checkout\Helper\Data $checkoutHelper |
|
83
|
|
|
*/ |
|
84
|
|
|
public function __construct( |
|
85
|
|
|
\Magento\Framework\App\Action\Context $context, |
|
|
|
|
|
|
86
|
|
|
\Magento\Framework\View\Result\PageFactory $pageFactory, |
|
87
|
|
|
\Magento\Checkout\Model\Session $checkoutSession, |
|
88
|
|
|
\Magento\Customer\Model\Session $customerSession, |
|
89
|
|
|
\Payone\Core\Helper\Payment $paymentHelper, |
|
90
|
|
|
\Magento\Checkout\Helper\Data $checkoutHelper |
|
91
|
|
|
) { |
|
92
|
|
|
parent::__construct($context); |
|
93
|
|
|
$this->pageFactory = $pageFactory; |
|
94
|
|
|
$this->checkoutSession = $checkoutSession; |
|
95
|
|
|
$this->customerSession = $customerSession; |
|
96
|
|
|
$this->paymentHelper = $paymentHelper; |
|
97
|
|
|
$this->checkoutHelper = $checkoutHelper; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Determine if a logged in customer is required for an express checkout |
|
102
|
|
|
* For example needed for virtual products ( download-products etc. ) |
|
103
|
|
|
* |
|
104
|
|
|
* @param Quote $oQuote |
|
105
|
|
|
* @return bool |
|
106
|
|
|
*/ |
|
107
|
|
|
protected function isLoginNeeded(Quote $oQuote) |
|
108
|
|
|
{ |
|
109
|
|
|
$oCustomer = $this->customerSession->getCustomerDataObject(); |
|
110
|
|
|
if (!$oCustomer->getId()) { |
|
111
|
|
|
$sCheckoutMethod = $oQuote->getCheckoutMethod(); |
|
112
|
|
|
if ((!$sCheckoutMethod || $sCheckoutMethod != \Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER) |
|
|
|
|
|
|
113
|
|
|
&& !$this->checkoutHelper->isAllowedGuestCheckout($oQuote, $oQuote->getStoreId()) |
|
114
|
|
|
) { |
|
115
|
|
|
return true; |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
return false; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Display AmazonPay checkout |
|
123
|
|
|
* |
|
124
|
|
|
* @return Page |
|
125
|
|
|
*/ |
|
126
|
|
|
public function execute() |
|
127
|
|
|
{ |
|
128
|
|
|
$oQuote = $this->checkoutSession->getQuote(); |
|
129
|
|
|
if (!$this->paymentHelper->isPaymentMethodActive(PayoneConfig::METHOD_AMAZONPAY) || !$oQuote || !$oQuote->hasItems()) { |
|
130
|
|
|
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); |
|
131
|
|
|
return $resultRedirect->setPath('checkout/cart'); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
if ($this->isLoginNeeded($oQuote)) { |
|
135
|
|
|
$this->messageManager->addNoticeMessage(__('Please sign in to check out.')); |
|
|
|
|
|
|
136
|
|
|
|
|
137
|
|
|
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); |
|
138
|
|
|
return $resultRedirect->setPath('customer/account/login'); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
$oPageObject = $this->pageFactory->create(); |
|
142
|
|
|
return $oPageObject; |
|
143
|
|
|
} |
|
144
|
|
|
} |
|
145
|
|
|
|
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