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\Model\TransactionStatus; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class for handling the TransactionStatus forwarding |
31
|
|
|
*/ |
32
|
|
|
class Forwarding |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* PAYONE config helper |
36
|
|
|
* |
37
|
|
|
* @var \Payone\Core\Helper\Config |
38
|
|
|
*/ |
39
|
|
|
protected $configHelper; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Magento 2 Curl library |
43
|
|
|
* |
44
|
|
|
* @var \Magento\Framework\HTTP\Client\Curl |
45
|
|
|
*/ |
46
|
|
|
protected $curl; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Constructor |
50
|
|
|
* |
51
|
|
|
* @param \Payone\Core\Helper\Config $configHelper |
52
|
|
|
*/ |
53
|
|
|
public function __construct(\Payone\Core\Helper\Config $configHelper, \Magento\Framework\HTTP\Client\Curl $curl) |
54
|
|
|
{ |
55
|
|
|
$this->configHelper = $configHelper; |
56
|
|
|
$this->curl = $curl; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Execute TransactionStatus forwarding with curl |
61
|
|
|
* |
62
|
|
|
* @param array $aPostArray |
63
|
|
|
* @param string $sUrl |
64
|
|
|
* @param int $iTimeout |
65
|
|
|
* @return void |
66
|
|
|
*/ |
67
|
|
|
protected function forwardRequest($aPostArray, $sUrl, $iTimeout) |
68
|
|
|
{ |
69
|
|
|
if ($iTimeout == 0) { |
70
|
|
|
$iTimeout = 45; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
$this->curl->setTimeout($iTimeout); |
74
|
|
|
$this->curl->setOption(CURLOPT_SSL_VERIFYPEER, false); |
|
|
|
|
75
|
|
|
$this->curl->setOption(CURLOPT_SSL_VERIFYHOST, false); |
|
|
|
|
76
|
|
|
$this->curl->post($sUrl, $aPostArray); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Handle single TransactionStatus forwarding |
81
|
|
|
* |
82
|
|
|
* @param array $aPostArray |
83
|
|
|
* @param array $aForwardEntry |
84
|
|
|
* @param string $sStatusAction |
85
|
|
|
* @return void |
86
|
|
|
*/ |
87
|
|
|
protected function handleSingleForwarding($aPostArray, $aForwardEntry, $sStatusAction) |
88
|
|
|
{ |
89
|
|
|
foreach ($aForwardEntry['txaction'] as $sForwardAction) { |
90
|
|
|
if ($sForwardAction == $sStatusAction) { |
91
|
|
|
$this->forwardRequest($aPostArray, $aForwardEntry['url'], (int)$aForwardEntry['timeout']); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Handle TransactionStatus forwarding |
98
|
|
|
* |
99
|
|
|
* @param array $aPostArray |
100
|
|
|
* @return void |
101
|
|
|
*/ |
102
|
|
|
public function handleForwardings($aPostArray) |
103
|
|
|
{ |
104
|
|
|
$aForwarding = $this->configHelper->getForwardingUrls(); |
105
|
|
|
$sStatusAction = $aPostArray['txaction']; |
106
|
|
|
foreach ($aForwarding as $aForwardEntry) { |
107
|
|
|
if (isset($aForwardEntry['txaction']) && !empty($aForwardEntry['txaction'])) { |
108
|
|
|
$this->handleSingleForwarding($aPostArray, $aForwardEntry, $sStatusAction); |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: