@@ -18,114 +18,114 @@ 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 | |
126 | 126 | if ( ! isset($this->Operation)) |
127 | 127 | { |
128 | - throw new Exception\Structure('There is no Operation type element in the xml request!', -55); |
|
128 | + throw new Exception\Structure('There is no Operation type element in the xml request!', -55); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | // process <Operation> group |
@@ -133,73 +133,73 @@ discard block |
||
133 | 133 | |
134 | 134 | foreach ($r[0]->childNodes as $child) |
135 | 135 | { |
136 | - $this->check_and_parse_request_node($child, 'ServiceId'); |
|
136 | + $this->check_and_parse_request_node($child, 'ServiceId'); |
|
137 | + } |
|
137 | 138 | } |
138 | - } |
|
139 | 139 | |
140 | - /** |
|
141 | - * Check if present node of request and then parse it |
|
142 | - * |
|
143 | - * @param \DOMNode $n |
|
144 | - * @param string $name |
|
145 | - */ |
|
146 | - protected function check_and_parse_request_node($n, $name) |
|
147 | - { |
|
140 | + /** |
|
141 | + * Check if present node of request and then parse it |
|
142 | + * |
|
143 | + * @param \DOMNode $n |
|
144 | + * @param string $name |
|
145 | + */ |
|
146 | + protected function check_and_parse_request_node($n, $name) |
|
147 | + { |
|
148 | 148 | if ($n->nodeName == $name) |
149 | 149 | { |
150 | - $this->parse_request_node($n, $name); |
|
150 | + $this->parse_request_node($n, $name); |
|
151 | + } |
|
151 | 152 | } |
152 | - } |
|
153 | 153 | |
154 | - /** |
|
155 | - * Check if given node is Operation |
|
156 | - * |
|
157 | - * @throws Exception\Structure |
|
158 | - */ |
|
159 | - protected function check_and_parse_operation($n) |
|
160 | - { |
|
154 | + /** |
|
155 | + * Check if given node is Operation |
|
156 | + * |
|
157 | + * @throws Exception\Structure |
|
158 | + */ |
|
159 | + protected function check_and_parse_operation($n) |
|
160 | + { |
|
161 | 161 | if (in_array($n->nodeName, $this->operations)) |
162 | 162 | { |
163 | - if ( ! isset($this->Operation)) |
|
164 | - { |
|
163 | + if ( ! isset($this->Operation)) |
|
164 | + { |
|
165 | 165 | $this->Operation = $n->nodeName; |
166 | - } |
|
167 | - else |
|
168 | - { |
|
166 | + } |
|
167 | + else |
|
168 | + { |
|
169 | 169 | throw new Exception\Structure('There is more than one Operation type element in the xml-query!', -53); |
170 | - } |
|
171 | - } |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * Parse node of request |
|
176 | - * |
|
177 | - * @param \DOMNode $n |
|
178 | - * @param string $name |
|
179 | - * |
|
180 | - * @throws Exception\Structure |
|
181 | - */ |
|
182 | - protected function parse_request_node($n, $name) |
|
183 | - { |
|
170 | + } |
|
171 | + } |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * Parse node of request |
|
176 | + * |
|
177 | + * @param \DOMNode $n |
|
178 | + * @param string $name |
|
179 | + * |
|
180 | + * @throws Exception\Structure |
|
181 | + */ |
|
182 | + protected function parse_request_node($n, $name) |
|
183 | + { |
|
184 | 184 | if ( ! isset($this->$name)) |
185 | 185 | { |
186 | - $this->$name = $n->nodeValue; |
|
186 | + $this->$name = $n->nodeValue; |
|
187 | 187 | } |
188 | 188 | else |
189 | 189 | { |
190 | - throw new Exception\Structure('There is more than one '.$name.' element in the xml-query!', -56); |
|
190 | + throw new Exception\Structure('There is more than one '.$name.' element in the xml-query!', -56); |
|
191 | + } |
|
191 | 192 | } |
192 | - } |
|
193 | 193 | |
194 | - /** |
|
195 | - * "Rough" validation of the received xml request |
|
196 | - * |
|
197 | - * @param array $options |
|
198 | - * @throws Exception\Data |
|
199 | - * @throws Exception\Structure |
|
200 | - */ |
|
201 | - public function validate_request($options) |
|
202 | - { |
|
194 | + /** |
|
195 | + * "Rough" validation of the received xml request |
|
196 | + * |
|
197 | + * @param array $options |
|
198 | + * @throws Exception\Data |
|
199 | + * @throws Exception\Structure |
|
200 | + */ |
|
201 | + public function validate_request($options) |
|
202 | + { |
|
203 | 203 | $this->validate_element('DateTime'); |
204 | 204 | $this->validate_element('Sign'); |
205 | 205 | $this->validate_element('ServiceId'); |
@@ -207,36 +207,36 @@ discard block |
||
207 | 207 | // compare received value ServiceId with option ServiceId |
208 | 208 | if (intval($options['ServiceId']) != intval($this->ServiceId)) |
209 | 209 | { |
210 | - throw new Exception\Data('This request is not for our ServiceId!', -58); |
|
210 | + throw new Exception\Data('This request is not for our ServiceId!', -58); |
|
211 | + } |
|
211 | 212 | } |
212 | - } |
|
213 | 213 | |
214 | - /** |
|
215 | - * Validation of xml-element |
|
216 | - * |
|
217 | - * @param string $name |
|
218 | - */ |
|
219 | - public function validate_element($name) |
|
220 | - { |
|
214 | + /** |
|
215 | + * Validation of xml-element |
|
216 | + * |
|
217 | + * @param string $name |
|
218 | + */ |
|
219 | + public function validate_element($name) |
|
220 | + { |
|
221 | 221 | if ( ! isset($this->$name)) |
222 | 222 | { |
223 | - throw new Exception\Structure('There is no '.$name.' element in the xml request!', -57); |
|
223 | + throw new Exception\Structure('There is no '.$name.' element in the xml request!', -57); |
|
224 | + } |
|
224 | 225 | } |
225 | - } |
|
226 | 226 | |
227 | - /** |
|
228 | - * Verify signature of request |
|
229 | - * |
|
230 | - * @param array $options |
|
231 | - */ |
|
232 | - public function verify_sign($options) |
|
233 | - { |
|
227 | + /** |
|
228 | + * Verify signature of request |
|
229 | + * |
|
230 | + * @param array $options |
|
231 | + */ |
|
232 | + public function verify_sign($options) |
|
233 | + { |
|
234 | 234 | $sign = new Sign(); |
235 | 235 | $sign->verify( |
236 | - $this->raw_request->str(), |
|
237 | - $this->Sign, |
|
238 | - $options |
|
236 | + $this->raw_request->str(), |
|
237 | + $this->Sign, |
|
238 | + $options |
|
239 | 239 | ); |
240 | - } |
|
240 | + } |
|
241 | 241 | |
242 | 242 | } |
@@ -163,8 +163,7 @@ discard block |
||
163 | 163 | if ( ! isset($this->Operation)) |
164 | 164 | { |
165 | 165 | $this->Operation = $n->nodeName; |
166 | - } |
|
167 | - else |
|
166 | + } else |
|
168 | 167 | { |
169 | 168 | throw new Exception\Structure('There is more than one Operation type element in the xml-query!', -53); |
170 | 169 | } |
@@ -184,8 +183,7 @@ discard block |
||
184 | 183 | if ( ! isset($this->$name)) |
185 | 184 | { |
186 | 185 | $this->$name = $n->nodeValue; |
187 | - } |
|
188 | - else |
|
186 | + } else |
|
189 | 187 | { |
190 | 188 | throw new Exception\Structure('There is more than one '.$name.' element in the xml-query!', -56); |
191 | 189 | } |