forked from PAYONE-GmbH/oxid-6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
statusforward.php
111 lines (95 loc) · 3.34 KB
/
statusforward.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
* PAYONE OXID Connector is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAYONE OXID Connector is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PAYONE OXID Connector. If not, see <http://www.gnu.org/licenses/>.
*
* @link http://www.payone.de
* @copyright (C) Payone GmbH
* @version OXID eShop CE
*/
set_time_limit(0);
ini_set('memory_limit', '1024M');
ini_set('log_errors', 1);
ini_set('error_log', '../../../log/fcpoErrors.log');
include_once dirname(__FILE__) . "/../../../bootstrap.php";
class fcPayOneTransactionStatusForwarder extends oxBase {
protected $_aShopList = null;
/**
* Check and return post parameter
*
* @param string $sKey
* @return string
*/
public function fcGetPostParam( $sKey )
{
$sReturn = '';
$mValue = filter_input(INPUT_GET, $sKey);
if (!$mValue) {
$mValue = filter_input(INPUT_POST, $sKey);
}
if ($mValue ) {
if($this->getConfig()->isUtf() ) {
$mValue = utf8_encode($mValue);
}
$sReturn = $mValue;
}
return $sReturn;
}
protected function _addParam($sKey, $mValue)
{
$sParams = '';
if(is_array($mValue)) {
foreach ($mValue as $sKey2 => $mValue2) {
$sParams .= $this->_addParam($sKey.'['.$sKey2.']', $mValue2);
}
} else {
$sParams .= "&".$sKey."=".urlencode($mValue);
}
return $sParams;
}
protected function _forwardRequest($sUrl, $iTimeout) {
if ($iTimeout == 0) {
$iTimeout = 45;
}
$sParams = '';
foreach($_POST as $sKey => $mValue) {
$sParams .= $this->_addParam($sKey, $mValue);
}
$sParams = substr($sParams,1);
$oCurl = curl_init($sUrl);
curl_setopt($oCurl, CURLOPT_POST, 1);
curl_setopt($oCurl, CURLOPT_POSTFIELDS, $sParams);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($oCurl, CURLOPT_TIMEOUT, $iTimeout);
try {
$oResult = curl_exec($oCurl);
} catch (Exception $e) {
// do nothing
}
curl_close($oCurl);
}
public function handleForwarding() {
$sPayoneStatus = $this->fcGetPostParam('txaction');
$sQuery = "SELECT fcpo_url, fcpo_timeout FROM fcpostatusforwarding WHERE fcpo_payonestatus = '{$sPayoneStatus}'";
$oResult = oxDb::getDb()->Execute($sQuery);
if ($oResult != false && $oResult->recordCount() > 0) {
while (!$oResult->EOF) {
$this->_forwardRequest($oResult->fields[0], $oResult->fields[1]);
$oResult->moveNext();
}
}
}
}
$oScript = oxNew('fcPayOneTransactionStatusForwarder');
$oScript->handleForwarding();