@@ -18,109 +18,109 @@ discard block |
||
18 | 18 | |
19 | 19 | class General |
20 | 20 | { |
21 | - /** |
|
22 | - * @var EasyPay\Provider31\Request\RAW raw request |
|
23 | - */ |
|
24 | - protected $raw_request; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var string 'DateTime' node |
|
28 | - */ |
|
29 | - protected $DateTime; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var string 'Sign' node |
|
33 | - */ |
|
34 | - protected $Sign; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var string 'Operation' type |
|
38 | - */ |
|
39 | - protected $Operation; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var string 'ServiceId' node |
|
43 | - */ |
|
44 | - protected $ServiceId; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var array list of possible operations |
|
48 | - */ |
|
49 | - protected $operations = array('Check','Payment','Confirm','Cancel'); |
|
50 | - |
|
51 | - /** |
|
52 | - * General constructor |
|
53 | - * |
|
54 | - * @param \EasyPay\Provider31\Request\RAW $raw Raw request data |
|
55 | - */ |
|
56 | - public function __construct($raw) |
|
57 | - { |
|
21 | + /** |
|
22 | + * @var EasyPay\Provider31\Request\RAW raw request |
|
23 | + */ |
|
24 | + protected $raw_request; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var string 'DateTime' node |
|
28 | + */ |
|
29 | + protected $DateTime; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var string 'Sign' node |
|
33 | + */ |
|
34 | + protected $Sign; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var string 'Operation' type |
|
38 | + */ |
|
39 | + protected $Operation; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var string 'ServiceId' node |
|
43 | + */ |
|
44 | + protected $ServiceId; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var array list of possible operations |
|
48 | + */ |
|
49 | + protected $operations = array('Check','Payment','Confirm','Cancel'); |
|
50 | + |
|
51 | + /** |
|
52 | + * General constructor |
|
53 | + * |
|
54 | + * @param \EasyPay\Provider31\Request\RAW $raw Raw request data |
|
55 | + */ |
|
56 | + public function __construct($raw) |
|
57 | + { |
|
58 | 58 | $this->raw_request = $raw; |
59 | 59 | |
60 | 60 | $this->parse_request_data(); |
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Get DateTime |
|
65 | - * |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function DateTime() |
|
69 | - { |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Get DateTime |
|
65 | + * |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function DateTime() |
|
69 | + { |
|
70 | 70 | return $this->DateTime; |
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Get Sign |
|
75 | - * |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function Sign() |
|
79 | - { |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Get Sign |
|
75 | + * |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function Sign() |
|
79 | + { |
|
80 | 80 | return $this->Sign; |
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Get Operation type |
|
85 | - * |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - public function Operation() |
|
89 | - { |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Get Operation type |
|
85 | + * |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + public function Operation() |
|
89 | + { |
|
90 | 90 | return $this->Operation; |
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Get ServiceId |
|
95 | - * |
|
96 | - * @return string |
|
97 | - */ |
|
98 | - public function ServiceId() |
|
99 | - { |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Get ServiceId |
|
95 | + * |
|
96 | + * @return string |
|
97 | + */ |
|
98 | + public function ServiceId() |
|
99 | + { |
|
100 | 100 | return $this->ServiceId; |
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Parse xml-request, which was previously "extracted" from the body of the http request |
|
105 | - * |
|
106 | - * @throws Exception\Structure |
|
107 | - */ |
|
108 | - protected function parse_request_data() |
|
109 | - { |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Parse xml-request, which was previously "extracted" from the body of the http request |
|
105 | + * |
|
106 | + * @throws Exception\Structure |
|
107 | + */ |
|
108 | + protected function parse_request_data() |
|
109 | + { |
|
110 | 110 | // process <Request> group |
111 | 111 | $r = $this->raw_request->get_nodes_from_request('Request'); |
112 | 112 | |
113 | 113 | if (count($r) < 1) |
114 | 114 | { |
115 | - throw new Exception\Structure('The xml-query does not contain any element Request!', -52); |
|
115 | + throw new Exception\Structure('The xml-query does not contain any element Request!', -52); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | foreach ($r[0]->childNodes as $child) |
119 | 119 | { |
120 | - $this->check_and_parse_request_node($child, 'DateTime'); |
|
121 | - $this->check_and_parse_request_node($child, 'Sign'); |
|
120 | + $this->check_and_parse_request_node($child, 'DateTime'); |
|
121 | + $this->check_and_parse_request_node($child, 'Sign'); |
|
122 | 122 | |
123 | - $this->check_and_parse_operation($child); |
|
123 | + $this->check_and_parse_operation($child); |
|
124 | 124 | } |
125 | 125 | $this->check_presence_operation(); |
126 | 126 | |
@@ -129,86 +129,86 @@ discard block |
||
129 | 129 | |
130 | 130 | foreach ($r[0]->childNodes as $child) |
131 | 131 | { |
132 | - $this->check_and_parse_request_node($child, 'ServiceId'); |
|
132 | + $this->check_and_parse_request_node($child, 'ServiceId'); |
|
133 | + } |
|
133 | 134 | } |
134 | - } |
|
135 | 135 | |
136 | - /** |
|
137 | - * Check if present node of request and then parse it |
|
138 | - * |
|
139 | - * @param \DOMNode $n |
|
140 | - * @param string $name |
|
141 | - */ |
|
142 | - protected function check_and_parse_request_node($n, $name) |
|
143 | - { |
|
136 | + /** |
|
137 | + * Check if present node of request and then parse it |
|
138 | + * |
|
139 | + * @param \DOMNode $n |
|
140 | + * @param string $name |
|
141 | + */ |
|
142 | + protected function check_and_parse_request_node($n, $name) |
|
143 | + { |
|
144 | 144 | if ($n->nodeName == $name) |
145 | 145 | { |
146 | - $this->parse_request_node($n, $name); |
|
146 | + $this->parse_request_node($n, $name); |
|
147 | + } |
|
147 | 148 | } |
148 | - } |
|
149 | 149 | |
150 | - /** |
|
151 | - * Check if given node is Operation |
|
152 | - * |
|
153 | - * @throws Exception\Structure |
|
154 | - */ |
|
155 | - protected function check_and_parse_operation($n) |
|
156 | - { |
|
150 | + /** |
|
151 | + * Check if given node is Operation |
|
152 | + * |
|
153 | + * @throws Exception\Structure |
|
154 | + */ |
|
155 | + protected function check_and_parse_operation($n) |
|
156 | + { |
|
157 | 157 | if (in_array($n->nodeName, $this->operations)) |
158 | 158 | { |
159 | - if ( ! isset($this->Operation)) |
|
160 | - { |
|
159 | + if ( ! isset($this->Operation)) |
|
160 | + { |
|
161 | 161 | $this->Operation = $n->nodeName; |
162 | - } |
|
163 | - else |
|
164 | - { |
|
162 | + } |
|
163 | + else |
|
164 | + { |
|
165 | 165 | throw new Exception\Structure('There is more than one Operation type element in the xml-query!', -53); |
166 | - } |
|
166 | + } |
|
167 | + } |
|
167 | 168 | } |
168 | - } |
|
169 | 169 | |
170 | - /** |
|
171 | - * Check if Operation present in request |
|
172 | - * |
|
173 | - * @throws Exception\Structure |
|
174 | - */ |
|
175 | - protected function check_presence_operation() |
|
176 | - { |
|
170 | + /** |
|
171 | + * Check if Operation present in request |
|
172 | + * |
|
173 | + * @throws Exception\Structure |
|
174 | + */ |
|
175 | + protected function check_presence_operation() |
|
176 | + { |
|
177 | 177 | if ( ! isset($this->Operation)) |
178 | 178 | { |
179 | - throw new Exception\Structure('There is no Operation type element in the xml request!', -55); |
|
179 | + throw new Exception\Structure('There is no Operation type element in the xml request!', -55); |
|
180 | + } |
|
180 | 181 | } |
181 | - } |
|
182 | 182 | |
183 | - /** |
|
184 | - * Parse node of request |
|
185 | - * |
|
186 | - * @param \DOMNode $n |
|
187 | - * @param string $name |
|
188 | - * |
|
189 | - * @throws Exception\Structure |
|
190 | - */ |
|
191 | - protected function parse_request_node($n, $name) |
|
192 | - { |
|
183 | + /** |
|
184 | + * Parse node of request |
|
185 | + * |
|
186 | + * @param \DOMNode $n |
|
187 | + * @param string $name |
|
188 | + * |
|
189 | + * @throws Exception\Structure |
|
190 | + */ |
|
191 | + protected function parse_request_node($n, $name) |
|
192 | + { |
|
193 | 193 | if ( ! isset($this->$name)) |
194 | 194 | { |
195 | - $this->$name = $n->nodeValue; |
|
195 | + $this->$name = $n->nodeValue; |
|
196 | 196 | } |
197 | 197 | else |
198 | 198 | { |
199 | - throw new Exception\Structure('There is more than one '.$name.' element in the xml-query!', -56); |
|
199 | + throw new Exception\Structure('There is more than one '.$name.' element in the xml-query!', -56); |
|
200 | + } |
|
200 | 201 | } |
201 | - } |
|
202 | 202 | |
203 | - /** |
|
204 | - * "Rough" validation of the received xml request |
|
205 | - * |
|
206 | - * @param array $options |
|
207 | - * @throws Exception\Data |
|
208 | - * @throws Exception\Structure |
|
209 | - */ |
|
210 | - public function validate_request($options) |
|
211 | - { |
|
203 | + /** |
|
204 | + * "Rough" validation of the received xml request |
|
205 | + * |
|
206 | + * @param array $options |
|
207 | + * @throws Exception\Data |
|
208 | + * @throws Exception\Structure |
|
209 | + */ |
|
210 | + public function validate_request($options) |
|
211 | + { |
|
212 | 212 | $this->validate_element('DateTime'); |
213 | 213 | $this->validate_element('Sign'); |
214 | 214 | $this->validate_element('ServiceId'); |
@@ -216,36 +216,36 @@ discard block |
||
216 | 216 | // compare received value ServiceId with option ServiceId |
217 | 217 | if (intval($options['ServiceId']) != intval($this->ServiceId)) |
218 | 218 | { |
219 | - throw new Exception\Data('This request is not for our ServiceId!', -58); |
|
219 | + throw new Exception\Data('This request is not for our ServiceId!', -58); |
|
220 | + } |
|
220 | 221 | } |
221 | - } |
|
222 | 222 | |
223 | - /** |
|
224 | - * Validation of xml-element |
|
225 | - * |
|
226 | - * @param string $name |
|
227 | - */ |
|
228 | - public function validate_element($name) |
|
229 | - { |
|
223 | + /** |
|
224 | + * Validation of xml-element |
|
225 | + * |
|
226 | + * @param string $name |
|
227 | + */ |
|
228 | + public function validate_element($name) |
|
229 | + { |
|
230 | 230 | if ( ! isset($this->$name)) |
231 | 231 | { |
232 | - throw new Exception\Structure('There is no '.$name.' element in the xml request!', -57); |
|
232 | + throw new Exception\Structure('There is no '.$name.' element in the xml request!', -57); |
|
233 | + } |
|
233 | 234 | } |
234 | - } |
|
235 | 235 | |
236 | - /** |
|
237 | - * Verify signature of request |
|
238 | - * |
|
239 | - * @param array $options |
|
240 | - */ |
|
241 | - public function verify_sign($options) |
|
242 | - { |
|
236 | + /** |
|
237 | + * Verify signature of request |
|
238 | + * |
|
239 | + * @param array $options |
|
240 | + */ |
|
241 | + public function verify_sign($options) |
|
242 | + { |
|
243 | 243 | $sign = new Sign(); |
244 | 244 | $sign->verify( |
245 | - $this->raw_request->str(), |
|
246 | - $this->Sign, |
|
247 | - $options |
|
245 | + $this->raw_request->str(), |
|
246 | + $this->Sign, |
|
247 | + $options |
|
248 | 248 | ); |
249 | - } |
|
249 | + } |
|
250 | 250 | |
251 | 251 | } |