1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* NOTICE OF LICENSE |
5
|
|
|
* |
6
|
|
|
* This source file is subject to the GNU General Public License (GPL 3) |
7
|
|
|
* that is bundled with this package in the file LICENSE.txt |
8
|
|
|
* |
9
|
|
|
* DISCLAIMER |
10
|
|
|
* |
11
|
|
|
* Do not edit or add to this file if you wish to upgrade Payone to newer |
12
|
|
|
* versions in the future. If you wish to customize Payone for your |
13
|
|
|
* needs please refer to http://www.payone.de for more information. |
14
|
|
|
* |
15
|
|
|
* @category Payone |
16
|
|
|
* @package Payone_Api |
17
|
|
|
* @subpackage Mapper |
18
|
|
|
* @copyright Copyright (c) 2012 <[email protected]> - www.noovias.com |
19
|
|
|
* @author Matthias Walter <[email protected]> |
20
|
|
|
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3) |
21
|
|
|
* @link http://www.noovias.com |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* |
26
|
|
|
* @category Payone |
27
|
|
|
* @package Payone_Api |
28
|
|
|
* @subpackage Mapper |
29
|
|
|
* @copyright Copyright (c) 2012 <[email protected]> - www.noovias.com |
30
|
|
|
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3) |
31
|
|
|
* @link http://www.noovias.com |
32
|
|
|
*/ |
33
|
|
|
abstract class Payone_Api_Mapper_Response_Abstract extends Payone_Api_Mapper_Abstract |
|
|
|
|
34
|
|
|
{ |
35
|
|
|
// @todo hs: Introduce constants for the various status´ , where? Settings? |
36
|
|
|
/** |
37
|
|
|
* @var array |
38
|
|
|
*/ |
39
|
|
|
protected $params = null; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return bool |
43
|
|
|
*/ |
44
|
|
|
protected function isApproved() |
45
|
|
|
{ |
46
|
|
|
$status = $this->getParam('status'); |
47
|
|
|
if ($status === 'APPROVED') { |
48
|
|
|
return true; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return false; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
protected function isPending() |
55
|
|
|
{ |
56
|
|
|
$status = $this->getParam('status'); |
57
|
|
|
if ($status === 'PENDING') { |
58
|
|
|
return true; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return false; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return bool |
66
|
|
|
*/ |
67
|
|
|
protected function isRedirect() |
68
|
|
|
{ |
69
|
|
|
$status = $this->getParam('status'); |
70
|
|
|
if ($status === 'REDIRECT') { |
71
|
|
|
return true; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return false; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return bool |
79
|
|
|
*/ |
80
|
|
|
protected function isValid() |
81
|
|
|
{ |
82
|
|
|
$status = $this->getParam('status'); |
83
|
|
|
if ($status === 'VALID') { |
84
|
|
|
return true; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
return false; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return bool |
92
|
|
|
*/ |
93
|
|
|
protected function isInvalid() |
94
|
|
|
{ |
95
|
|
|
$status = $this->getParam('status'); |
96
|
|
|
if ($status === 'INVALID') { |
97
|
|
|
return true; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
return false; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return bool |
105
|
|
|
*/ |
106
|
|
|
protected function isBlocked() |
107
|
|
|
{ |
108
|
|
|
$status = $this->getParam('status'); |
109
|
|
|
if ($status === 'BLOCKED') { |
110
|
|
|
return true; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
return false; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return bool |
118
|
|
|
*/ |
119
|
|
|
protected function isEnrolled() |
120
|
|
|
{ |
121
|
|
|
$status = $this->getParam('status'); |
122
|
|
|
if ($status === 'ENROLLED') { |
123
|
|
|
return true; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
return false; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return bool |
131
|
|
|
*/ |
132
|
|
|
protected function isError() |
133
|
|
|
{ |
134
|
|
|
$status = $this->getParam('status'); |
135
|
|
|
if ($status === 'ERROR') { |
136
|
|
|
return true; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
return false; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @return bool |
144
|
|
|
*/ |
145
|
|
|
protected function isOk() |
146
|
|
|
{ |
147
|
|
|
$status = $this->getParam('status'); |
148
|
|
|
if ($status === 'OK') { |
149
|
|
|
return true; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
return false; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param array $responseRaw |
157
|
|
|
*/ |
158
|
|
|
protected function setParams($responseRaw) |
159
|
|
|
{ |
160
|
|
|
$this->params = $responseRaw; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @return array |
165
|
|
|
*/ |
166
|
|
|
protected function getParams() |
167
|
|
|
{ |
168
|
|
|
return $this->params; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @param $key |
173
|
|
|
* @return mixed |
174
|
|
|
*/ |
175
|
|
|
protected function getParam($key) |
176
|
|
|
{ |
177
|
|
|
if (is_array($this->params) and array_key_exists($key, $this->params)) { |
|
|
|
|
178
|
|
|
return $this->params[$key]; |
179
|
|
|
} |
180
|
|
|
else |
181
|
|
|
{ |
182
|
|
|
return null; |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
} |
186
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.