|
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\ResourceModel; |
|
28
|
|
|
|
|
29
|
|
|
use Payone\Core\Helper\Toolkit; |
|
30
|
|
|
use Magento\Framework\App\Action\Context; |
|
|
|
|
|
|
31
|
|
|
use Magento\Sales\Model\Order; |
|
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* TransactionStatus resource model |
|
35
|
|
|
*/ |
|
36
|
|
|
class TransactionStatus extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb |
|
|
|
|
|
|
37
|
|
|
{ |
|
38
|
|
|
/** |
|
39
|
|
|
* TransactionStatus POST request |
|
40
|
|
|
* |
|
41
|
|
|
* @var array |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $request = []; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Store manager object |
|
47
|
|
|
* |
|
48
|
|
|
* @var \Magento\Store\Model\StoreManagerInterface |
|
|
|
|
|
|
49
|
|
|
*/ |
|
50
|
|
|
protected $storeManager; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Toolkit helper object |
|
54
|
|
|
* |
|
55
|
|
|
* @var Toolkit |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $toolkitHelper; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Constructor |
|
61
|
|
|
* |
|
62
|
|
|
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context |
|
63
|
|
|
* @param \Magento\Store\Model\StoreManagerInterface $storeManager |
|
64
|
|
|
* @param \Payone\Core\Helper\Toolkit $toolkitHelper |
|
65
|
|
|
* @param string $connectionName |
|
66
|
|
|
*/ |
|
67
|
|
|
public function __construct( |
|
68
|
|
|
\Magento\Framework\Model\ResourceModel\Db\Context $context, |
|
|
|
|
|
|
69
|
|
|
\Magento\Store\Model\StoreManagerInterface $storeManager, |
|
70
|
|
|
\Payone\Core\Helper\Toolkit $toolkitHelper, |
|
71
|
|
|
$connectionName = null |
|
72
|
|
|
) { |
|
73
|
|
|
parent::__construct($context, $connectionName); |
|
74
|
|
|
$this->storeManager = $storeManager; |
|
75
|
|
|
$this->toolkitHelper = $toolkitHelper; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Initialize connection and table |
|
80
|
|
|
* |
|
81
|
|
|
* @return void |
|
82
|
|
|
*/ |
|
83
|
|
|
protected function _construct() |
|
84
|
|
|
{ |
|
85
|
|
|
$this->_init('payone_protocol_transactionstatus', 'id'); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Set request property |
|
90
|
|
|
* |
|
91
|
|
|
* @param array $request |
|
92
|
|
|
* @return void |
|
93
|
|
|
*/ |
|
94
|
|
|
public function setRequest($request) |
|
95
|
|
|
{ |
|
96
|
|
|
if (is_array($request)) { |
|
|
|
|
|
|
97
|
|
|
$this->request = $request; |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Get request property |
|
103
|
|
|
* |
|
104
|
|
|
* @return array |
|
105
|
|
|
*/ |
|
106
|
|
|
public function getRequest() |
|
107
|
|
|
{ |
|
108
|
|
|
return $this->request; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Get request-parameter value or a given default if not set |
|
113
|
|
|
* |
|
114
|
|
|
* @param string $sKey |
|
115
|
|
|
* @param string $sDefault |
|
116
|
|
|
* @return string |
|
117
|
|
|
*/ |
|
118
|
|
|
public function getParam($sKey, $sDefault = '') |
|
119
|
|
|
{ |
|
120
|
|
|
if (isset($this->request[$sKey])) { |
|
121
|
|
|
$sParam = $this->request[$sKey]; |
|
122
|
|
|
if (!$this->toolkitHelper->isUTF8($sParam)) { |
|
123
|
|
|
$sParam = mb_convert_encoding($sParam, 'UTF-8'); |
|
124
|
|
|
} |
|
125
|
|
|
return $sParam; |
|
126
|
|
|
} |
|
127
|
|
|
return $sDefault; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Write TransactionStatus entry to database |
|
132
|
|
|
* |
|
133
|
|
|
* @param array $aRequest |
|
134
|
|
|
* @param Order $oOrder |
|
135
|
|
|
* @param bool $blHasBeenHandled |
|
136
|
|
|
* @return $this |
|
137
|
|
|
*/ |
|
138
|
|
|
public function addTransactionLogEntry($aRequest, ?Order $oOrder = null, $blHasBeenHandled = true) |
|
139
|
|
|
{ |
|
140
|
|
|
$this->setRequest($aRequest); |
|
141
|
|
|
|
|
142
|
|
|
$aRequestForLog = $this->getRequest(); |
|
143
|
|
|
if (!empty($aRequestForLog['customer_iban'])) { |
|
144
|
|
|
$aRequestForLog['customer_iban'] = $this->toolkitHelper->maskIban($aRequestForLog['customer_iban']); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
$sRawStatus = serialize($aRequestForLog); |
|
148
|
|
|
if (!$this->toolkitHelper->isUTF8($sRawStatus)) { |
|
149
|
|
|
$sRawStatus = mb_convert_encoding($sRawStatus, 'UTF-8'); // needed for serializing the array |
|
150
|
|
|
} |
|
151
|
|
|
$sOrderId = $oOrder !== null ? $oOrder->getIncrementId() : ''; |
|
152
|
|
|
$this->getConnection()->insert( |
|
153
|
|
|
$this->getMainTable(), |
|
154
|
|
|
[ |
|
155
|
|
|
'order_id' => $sOrderId, |
|
156
|
|
|
'store_id' => $this->storeManager->getStore()->getId(), |
|
157
|
|
|
'reference' => $this->getParam('reference'), |
|
158
|
|
|
'txid' => $this->getParam('txid'), |
|
159
|
|
|
'txaction' => $this->getParam('txaction'), |
|
160
|
|
|
'sequencenumber' => $this->getParam('sequencenumber'), |
|
161
|
|
|
'clearingtype' => $this->getParam('clearingtype'), |
|
162
|
|
|
'txtime' => date('Y-m-d H:i:s', $this->getParam('txtime')), |
|
|
|
|
|
|
163
|
|
|
'price' => $this->getParam('price'), |
|
164
|
|
|
'balance' => $this->getParam('balance'), |
|
165
|
|
|
'receivable' => $this->getParam('receivable'), |
|
166
|
|
|
'currency' => $this->getParam('currency'), |
|
167
|
|
|
'aid' => $this->getParam('aid'), |
|
168
|
|
|
'portalid' => $this->getParam('portalid'), |
|
169
|
|
|
'key' => $this->getParam('key'), |
|
170
|
|
|
'mode' => $this->getParam('mode'), |
|
171
|
|
|
'userid' => $this->getParam('userid'), |
|
172
|
|
|
'customerid' => $this->getParam('customerid'), |
|
173
|
|
|
'company' => $this->getParam('company'), |
|
174
|
|
|
'firstname' => $this->getParam('firstname'), |
|
175
|
|
|
'lastname' => $this->getParam('lastname'), |
|
176
|
|
|
'street' => $this->getParam('street'), |
|
177
|
|
|
'zip' => $this->getParam('zip'), |
|
178
|
|
|
'city' => $this->getParam('city'), |
|
179
|
|
|
'email' => $this->getParam('email'), |
|
180
|
|
|
'country' => $this->getParam('country'), |
|
181
|
|
|
'shipping_company' => $this->getParam('shipping_company'), |
|
182
|
|
|
'shipping_firstname' => $this->getParam('shipping_firstname'), |
|
183
|
|
|
'shipping_lastname' => $this->getParam('shipping_lastname'), |
|
184
|
|
|
'shipping_street' => $this->getParam('shipping_street'), |
|
185
|
|
|
'shipping_zip' => $this->getParam('shipping_zip'), |
|
186
|
|
|
'shipping_city' => $this->getParam('shipping_city'), |
|
187
|
|
|
'shipping_country' => $this->getParam('shipping_country'), |
|
188
|
|
|
'param' => $this->getParam('param'), |
|
189
|
|
|
'accessname' => $this->getParam('accessname'), |
|
190
|
|
|
'accesscode' => $this->getParam('accesscode'), |
|
191
|
|
|
'bankcountry' => $this->getParam('bankcountry'), |
|
192
|
|
|
'bankaccount' => $this->getParam('bankaccount'), |
|
193
|
|
|
'bankcode' => $this->getParam('bankcode'), |
|
194
|
|
|
'bankaccountholder' => $this->getParam('bankaccountholder'), |
|
195
|
|
|
'cardexpiredate' => $this->getParam('cardexpiredate'), |
|
196
|
|
|
'cardtype' => $this->getParam('cardtype'), |
|
197
|
|
|
'cardpan' => $this->getParam('cardpan'), |
|
198
|
|
|
'clearing_bankaccountholder' => $this->getParam('clearing_bankaccountholder'), |
|
199
|
|
|
'clearing_bankaccount' => $this->getParam('clearing_bankaccount'), |
|
200
|
|
|
'clearing_bankcode' => $this->getParam('clearing_bankcode'), |
|
201
|
|
|
'clearing_bankname' => $this->getParam('clearing_bankname'), |
|
202
|
|
|
'clearing_bankbic' => $this->getParam('clearing_bankbic'), |
|
203
|
|
|
'clearing_bankiban' => $this->getParam('clearing_bankiban'), |
|
204
|
|
|
'clearing_bankcountry' => $this->getParam('clearing_bankcountry'), |
|
205
|
|
|
'clearing_bankcity' => $this->getParam('clearing_bankcity'), |
|
206
|
|
|
'clearing_legalnote' => $this->getParam('clearing_legalnote'), |
|
207
|
|
|
'clearing_duedate' => $this->getParam('clearing_duedate'), |
|
208
|
|
|
'clearing_reference' => $this->getParam('clearing_reference'), |
|
209
|
|
|
'clearing_instructionnote' => $this->getParam('clearing_instructionnote'), |
|
210
|
|
|
'raw_status' => $sRawStatus, |
|
211
|
|
|
'has_been_handled' => $blHasBeenHandled |
|
212
|
|
|
] |
|
213
|
|
|
); |
|
214
|
|
|
return $this; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* Get TransactionStatus id be txid |
|
219
|
|
|
* |
|
220
|
|
|
* @param string $sTxid |
|
221
|
|
|
* @return string |
|
222
|
|
|
*/ |
|
223
|
|
|
public function getAppointedIdByTxid($sTxid) |
|
224
|
|
|
{ |
|
225
|
|
|
$oConn = $this->getConnection(); |
|
226
|
|
|
|
|
227
|
|
|
$oSelect = $oConn->select()->from($this->getMainTable()) |
|
228
|
|
|
->where('txid = :txid') |
|
229
|
|
|
->where('txaction = :txaction'); |
|
230
|
|
|
|
|
231
|
|
|
return $oConn->fetchOne($oSelect, ['txid' => $sTxid, 'txaction' => 'appointed']); |
|
232
|
|
|
} |
|
233
|
|
|
} |
|
234
|
|
|
|
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