@@ -15,36 +15,36 @@ |
||
15 | 15 | |
16 | 16 | final class Payment extends Response |
17 | 17 | { |
18 | - /** |
|
19 | - * @var \DOMElement |
|
20 | - */ |
|
21 | - protected $PaymentId; |
|
22 | - |
|
23 | - /** |
|
24 | - * Payment constructor |
|
25 | - * |
|
26 | - * @param string $paymentid |
|
27 | - */ |
|
28 | - public function __construct($paymentid) |
|
29 | - { |
|
30 | - parent::__construct(); |
|
31 | - |
|
32 | - $this->setElementValue('StatusCode', 0); |
|
33 | - $this->setElementValue('StatusDetail', 'checked'); |
|
34 | - |
|
35 | - $this->create_PaymentId($paymentid); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * Create PaymentId node |
|
40 | - * |
|
41 | - * @param string $paymentid |
|
42 | - */ |
|
43 | - public function create_PaymentId($paymentid) |
|
44 | - { |
|
45 | - if (isset($this->PaymentId)) return; |
|
46 | - |
|
47 | - $this->PaymentId = $this->createElement('PaymentId', $paymentid); |
|
48 | - $this->Response->appendChild($this->PaymentId); |
|
49 | - } |
|
18 | + /** |
|
19 | + * @var \DOMElement |
|
20 | + */ |
|
21 | + protected $PaymentId; |
|
22 | + |
|
23 | + /** |
|
24 | + * Payment constructor |
|
25 | + * |
|
26 | + * @param string $paymentid |
|
27 | + */ |
|
28 | + public function __construct($paymentid) |
|
29 | + { |
|
30 | + parent::__construct(); |
|
31 | + |
|
32 | + $this->setElementValue('StatusCode', 0); |
|
33 | + $this->setElementValue('StatusDetail', 'checked'); |
|
34 | + |
|
35 | + $this->create_PaymentId($paymentid); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * Create PaymentId node |
|
40 | + * |
|
41 | + * @param string $paymentid |
|
42 | + */ |
|
43 | + public function create_PaymentId($paymentid) |
|
44 | + { |
|
45 | + if (isset($this->PaymentId)) return; |
|
46 | + |
|
47 | + $this->PaymentId = $this->createElement('PaymentId', $paymentid); |
|
48 | + $this->Response->appendChild($this->PaymentId); |
|
49 | + } |
|
50 | 50 | } |
@@ -42,7 +42,9 @@ |
||
42 | 42 | */ |
43 | 43 | public function create_PaymentId($paymentid) |
44 | 44 | { |
45 | - if (isset($this->PaymentId)) return; |
|
45 | + if (isset($this->PaymentId)) { |
|
46 | + return; |
|
47 | + } |
|
46 | 48 | |
47 | 49 | $this->PaymentId = $this->createElement('PaymentId', $paymentid); |
48 | 50 | $this->Response->appendChild($this->PaymentId); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @var array list of possible operations |
47 | 47 | */ |
48 | - protected $operations = array('Check','Payment','Confirm','Cancel'); |
|
48 | + protected $operations = array('Check', 'Payment', 'Confirm', 'Cancel'); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * General constructor |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $doc = new \DOMDocument(); |
116 | 116 | if ( ! $doc->loadXML($this->raw_request)) |
117 | 117 | { |
118 | - foreach(libxml_get_errors() as $e){ |
|
118 | + foreach (libxml_get_errors() as $e) { |
|
119 | 119 | Log::instance()->error($e->message); |
120 | 120 | } |
121 | 121 | throw new Exception\Structure('The wrong XML is received', -51); |
@@ -313,9 +313,9 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @return array nodes with the name |
315 | 315 | */ |
316 | - protected function getNodes($dom, $name, $ret=array()) |
|
316 | + protected function getNodes($dom, $name, $ret = array()) |
|
317 | 317 | { |
318 | - foreach($dom->childNodes as $child) |
|
318 | + foreach ($dom->childNodes as $child) |
|
319 | 319 | { |
320 | 320 | if ($child->nodeName == $name) |
321 | 321 | { |
@@ -140,8 +140,7 @@ discard block |
||
140 | 140 | if ( ! isset($this->Operation)) |
141 | 141 | { |
142 | 142 | $this->Operation = $child->nodeName; |
143 | - } |
|
144 | - else |
|
143 | + } else |
|
145 | 144 | { |
146 | 145 | throw new Exception\Structure('There is more than one Operation type element in the xml-query!', -53); |
147 | 146 | } |
@@ -189,8 +188,7 @@ discard block |
||
189 | 188 | if ( ! isset($this->$name)) |
190 | 189 | { |
191 | 190 | $this->$name = $n->nodeValue; |
192 | - } |
|
193 | - else |
|
191 | + } else |
|
194 | 192 | { |
195 | 193 | throw new Exception\Structure('There is more than one '.$name.' element in the xml-query!', -56); |
196 | 194 | } |
@@ -276,8 +274,7 @@ discard block |
||
276 | 274 | if ($result == -1) |
277 | 275 | { |
278 | 276 | throw new Exception\Sign('Error verify signature of request!', -96); |
279 | - } |
|
280 | - elseif ($result == 0) |
|
277 | + } elseif ($result == 0) |
|
281 | 278 | { |
282 | 279 | throw new Exception\Sign('Signature of request is incorrect!', -95); |
283 | 280 | } |
@@ -299,8 +296,7 @@ discard block |
||
299 | 296 | if ($child->nodeName == $name) |
300 | 297 | { |
301 | 298 | array_push($ret, $child); |
302 | - } |
|
303 | - else |
|
299 | + } else |
|
304 | 300 | { |
305 | 301 | if (count($child->childNodes) > 0) |
306 | 302 | { |
@@ -18,95 +18,95 @@ discard block |
||
18 | 18 | |
19 | 19 | class General |
20 | 20 | { |
21 | - /** |
|
22 | - * @var string 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 string $raw Raw request data |
|
55 | - */ |
|
56 | - public function __construct($raw) |
|
57 | - { |
|
21 | + /** |
|
22 | + * @var string 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 string $raw Raw request data |
|
55 | + */ |
|
56 | + public function __construct($raw) |
|
57 | + { |
|
58 | 58 | $this->raw_request = strval($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 | $this->check_presence_request(); |
111 | 111 | |
112 | 112 | // process <Request> group |
@@ -114,30 +114,30 @@ discard block |
||
114 | 114 | |
115 | 115 | if (count($r) < 1) |
116 | 116 | { |
117 | - throw new Exception\Structure('The xml-query does not contain any element Request!', -52); |
|
117 | + throw new Exception\Structure('The xml-query does not contain any element Request!', -52); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | foreach ($r[0]->childNodes as $child) |
121 | 121 | { |
122 | - $this->check_and_parse_request_node($child, 'DateTime'); |
|
123 | - $this->check_and_parse_request_node($child, 'Sign'); |
|
122 | + $this->check_and_parse_request_node($child, 'DateTime'); |
|
123 | + $this->check_and_parse_request_node($child, 'Sign'); |
|
124 | 124 | |
125 | - if (in_array($child->nodeName, $this->operations)) |
|
126 | - { |
|
125 | + if (in_array($child->nodeName, $this->operations)) |
|
126 | + { |
|
127 | 127 | if ( ! isset($this->Operation)) |
128 | 128 | { |
129 | - $this->Operation = $child->nodeName; |
|
129 | + $this->Operation = $child->nodeName; |
|
130 | 130 | } |
131 | 131 | else |
132 | 132 | { |
133 | - throw new Exception\Structure('There is more than one Operation type element in the xml-query!', -53); |
|
133 | + throw new Exception\Structure('There is more than one Operation type element in the xml-query!', -53); |
|
134 | + } |
|
134 | 135 | } |
135 | - } |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | if ( ! isset($this->Operation)) |
139 | 139 | { |
140 | - throw new Exception\Structure('There is no Operation type element in the xml request!', -55); |
|
140 | + throw new Exception\Structure('There is no Operation type element in the xml request!', -55); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | // process <Operation> group |
@@ -145,87 +145,87 @@ discard block |
||
145 | 145 | |
146 | 146 | foreach ($r[0]->childNodes as $child) |
147 | 147 | { |
148 | - $this->check_and_parse_request_node($child, 'ServiceId'); |
|
148 | + $this->check_and_parse_request_node($child, 'ServiceId'); |
|
149 | + } |
|
149 | 150 | } |
150 | - } |
|
151 | 151 | |
152 | - /** |
|
153 | - * Check if presence request |
|
154 | - * |
|
155 | - * @throws Exception\Structure |
|
156 | - */ |
|
157 | - protected function check_presence_request() |
|
158 | - { |
|
152 | + /** |
|
153 | + * Check if presence request |
|
154 | + * |
|
155 | + * @throws Exception\Structure |
|
156 | + */ |
|
157 | + protected function check_presence_request() |
|
158 | + { |
|
159 | 159 | if (empty($this->raw_request)) |
160 | 160 | { |
161 | - throw new Exception\Structure('An empty xml request', -50); |
|
161 | + throw new Exception\Structure('An empty xml request', -50); |
|
162 | + } |
|
162 | 163 | } |
163 | - } |
|
164 | 164 | |
165 | - /** |
|
166 | - * Get group of nodes from XML-request |
|
167 | - * |
|
168 | - * @param string $name |
|
169 | - * @return array |
|
170 | - */ |
|
171 | - protected function get_nodes_from_request($name) |
|
172 | - { |
|
165 | + /** |
|
166 | + * Get group of nodes from XML-request |
|
167 | + * |
|
168 | + * @param string $name |
|
169 | + * @return array |
|
170 | + */ |
|
171 | + protected function get_nodes_from_request($name) |
|
172 | + { |
|
173 | 173 | libxml_use_internal_errors(true); |
174 | 174 | $doc = new \DOMDocument(); |
175 | 175 | if ( ! $doc->loadXML($this->raw_request)) |
176 | 176 | { |
177 | - foreach(libxml_get_errors() as $e){ |
|
177 | + foreach(libxml_get_errors() as $e){ |
|
178 | 178 | Log::instance()->error($e->message); |
179 | - } |
|
180 | - throw new Exception\Structure('The wrong XML is received', -51); |
|
179 | + } |
|
180 | + throw new Exception\Structure('The wrong XML is received', -51); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | return $this->getNodes($doc, $name); |
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Check if present node of request and then parse it |
|
188 | - * |
|
189 | - * @param \DOMNode $n |
|
190 | - * @param string $name |
|
191 | - */ |
|
192 | - protected function check_and_parse_request_node($n, $name) |
|
193 | - { |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Check if present node of request and then parse it |
|
188 | + * |
|
189 | + * @param \DOMNode $n |
|
190 | + * @param string $name |
|
191 | + */ |
|
192 | + protected function check_and_parse_request_node($n, $name) |
|
193 | + { |
|
194 | 194 | if ($n->nodeName == $name) |
195 | 195 | { |
196 | - $this->parse_request_node($n, $name); |
|
196 | + $this->parse_request_node($n, $name); |
|
197 | + } |
|
197 | 198 | } |
198 | - } |
|
199 | 199 | |
200 | - /** |
|
201 | - * Parse node of request |
|
202 | - * |
|
203 | - * @param \DOMNode $n |
|
204 | - * @param string $name |
|
205 | - * |
|
206 | - * @throws Exception\Structure |
|
207 | - */ |
|
208 | - protected function parse_request_node($n, $name) |
|
209 | - { |
|
200 | + /** |
|
201 | + * Parse node of request |
|
202 | + * |
|
203 | + * @param \DOMNode $n |
|
204 | + * @param string $name |
|
205 | + * |
|
206 | + * @throws Exception\Structure |
|
207 | + */ |
|
208 | + protected function parse_request_node($n, $name) |
|
209 | + { |
|
210 | 210 | if ( ! isset($this->$name)) |
211 | 211 | { |
212 | - $this->$name = $n->nodeValue; |
|
212 | + $this->$name = $n->nodeValue; |
|
213 | 213 | } |
214 | 214 | else |
215 | 215 | { |
216 | - throw new Exception\Structure('There is more than one '.$name.' element in the xml-query!', -56); |
|
216 | + throw new Exception\Structure('There is more than one '.$name.' element in the xml-query!', -56); |
|
217 | + } |
|
217 | 218 | } |
218 | - } |
|
219 | 219 | |
220 | - /** |
|
221 | - * "Rough" validation of the received xml request |
|
222 | - * |
|
223 | - * @param array $options |
|
224 | - * @throws Exception\Data |
|
225 | - * @throws Exception\Structure |
|
226 | - */ |
|
227 | - public function validate_request($options) |
|
228 | - { |
|
220 | + /** |
|
221 | + * "Rough" validation of the received xml request |
|
222 | + * |
|
223 | + * @param array $options |
|
224 | + * @throws Exception\Data |
|
225 | + * @throws Exception\Structure |
|
226 | + */ |
|
227 | + public function validate_request($options) |
|
228 | + { |
|
229 | 229 | $this->validate_element('DateTime'); |
230 | 230 | $this->validate_element('Sign'); |
231 | 231 | $this->validate_element('ServiceId'); |
@@ -233,104 +233,104 @@ discard block |
||
233 | 233 | // compare received value ServiceId with option ServiceId |
234 | 234 | if (intval($options['ServiceId']) != intval($this->ServiceId)) |
235 | 235 | { |
236 | - throw new Exception\Data('This request is not for our ServiceId!', -58); |
|
236 | + throw new Exception\Data('This request is not for our ServiceId!', -58); |
|
237 | + } |
|
237 | 238 | } |
238 | - } |
|
239 | 239 | |
240 | - /** |
|
241 | - * Validation of xml-element |
|
242 | - * |
|
243 | - * @param string $name |
|
244 | - */ |
|
245 | - public function validate_element($name) |
|
246 | - { |
|
240 | + /** |
|
241 | + * Validation of xml-element |
|
242 | + * |
|
243 | + * @param string $name |
|
244 | + */ |
|
245 | + public function validate_element($name) |
|
246 | + { |
|
247 | 247 | if ( ! isset($this->$name)) |
248 | 248 | { |
249 | - throw new Exception\Structure('There is no '.$name.' element in the xml request!', -57); |
|
249 | + throw new Exception\Structure('There is no '.$name.' element in the xml request!', -57); |
|
250 | + } |
|
250 | 251 | } |
251 | - } |
|
252 | 252 | |
253 | - /** |
|
254 | - * Verify signature of request |
|
255 | - * |
|
256 | - * @param array $options |
|
257 | - */ |
|
258 | - public function verify_sign($options) |
|
259 | - { |
|
253 | + /** |
|
254 | + * Verify signature of request |
|
255 | + * |
|
256 | + * @param array $options |
|
257 | + */ |
|
258 | + public function verify_sign($options) |
|
259 | + { |
|
260 | 260 | if (isset($options['UseSign']) && ($options['UseSign'] === true)) |
261 | 261 | { |
262 | - $this->check_verify_sign_result( |
|
262 | + $this->check_verify_sign_result( |
|
263 | 263 | $result = (new OpenSSL())->verify( |
264 | - str_replace($this->Sign, '', $this->raw_request), |
|
265 | - pack("H*", $this->Sign), |
|
266 | - (new OpenSSL())->get_pub_key($this->get_pub_key($options)) |
|
264 | + str_replace($this->Sign, '', $this->raw_request), |
|
265 | + pack("H*", $this->Sign), |
|
266 | + (new OpenSSL())->get_pub_key($this->get_pub_key($options)) |
|
267 | 267 | ) |
268 | - ); |
|
269 | - } |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
273 | - * load file with easysoft public key |
|
274 | - * |
|
275 | - * @param array $options |
|
276 | - * @throws Exception\Runtime |
|
277 | - * @return string |
|
278 | - */ |
|
279 | - protected function get_pub_key($options) |
|
280 | - { |
|
268 | + ); |
|
269 | + } |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | + * load file with easysoft public key |
|
274 | + * |
|
275 | + * @param array $options |
|
276 | + * @throws Exception\Runtime |
|
277 | + * @return string |
|
278 | + */ |
|
279 | + protected function get_pub_key($options) |
|
280 | + { |
|
281 | 281 | if ( ! isset($options['EasySoftPKey'])) |
282 | 282 | { |
283 | - throw new Exception\Runtime('The parameter EasySoftPKey is not set!', -94); |
|
283 | + throw new Exception\Runtime('The parameter EasySoftPKey is not set!', -94); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | return (new Key())->get($options['EasySoftPKey'], 'public'); |
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * check result of openssl verify signature |
|
291 | - * |
|
292 | - * @param integer $result |
|
293 | - * @throws Exception\Sign |
|
294 | - */ |
|
295 | - protected function check_verify_sign_result($result) |
|
296 | - { |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * check result of openssl verify signature |
|
291 | + * |
|
292 | + * @param integer $result |
|
293 | + * @throws Exception\Sign |
|
294 | + */ |
|
295 | + protected function check_verify_sign_result($result) |
|
296 | + { |
|
297 | 297 | if ($result == -1) |
298 | 298 | { |
299 | - throw new Exception\Sign('Error verify signature of request!', -96); |
|
299 | + throw new Exception\Sign('Error verify signature of request!', -96); |
|
300 | 300 | } |
301 | 301 | elseif ($result == 0) |
302 | 302 | { |
303 | - throw new Exception\Sign('Signature of request is incorrect!', -95); |
|
304 | - } |
|
305 | - } |
|
306 | - |
|
307 | - /** |
|
308 | - * Selects nodes by name |
|
309 | - * |
|
310 | - * @param \DOMDocument $dom |
|
311 | - * @param string $name |
|
312 | - * @param array $ret |
|
313 | - * |
|
314 | - * @return array nodes with the name |
|
315 | - */ |
|
316 | - protected function getNodes($dom, $name, $ret=array()) |
|
317 | - { |
|
303 | + throw new Exception\Sign('Signature of request is incorrect!', -95); |
|
304 | + } |
|
305 | + } |
|
306 | + |
|
307 | + /** |
|
308 | + * Selects nodes by name |
|
309 | + * |
|
310 | + * @param \DOMDocument $dom |
|
311 | + * @param string $name |
|
312 | + * @param array $ret |
|
313 | + * |
|
314 | + * @return array nodes with the name |
|
315 | + */ |
|
316 | + protected function getNodes($dom, $name, $ret=array()) |
|
317 | + { |
|
318 | 318 | foreach($dom->childNodes as $child) |
319 | 319 | { |
320 | - if ($child->nodeName == $name) |
|
321 | - { |
|
320 | + if ($child->nodeName == $name) |
|
321 | + { |
|
322 | 322 | array_push($ret, $child); |
323 | - } |
|
324 | - else |
|
325 | - { |
|
323 | + } |
|
324 | + else |
|
325 | + { |
|
326 | 326 | if (count($child->childNodes) > 0) |
327 | 327 | { |
328 | - $ret = $this->getNodes($child, $name, $ret); |
|
328 | + $ret = $this->getNodes($child, $name, $ret); |
|
329 | + } |
|
329 | 330 | } |
330 | - } |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | return $ret; |
334 | - } |
|
334 | + } |
|
335 | 335 | |
336 | 336 | } |
@@ -4,76 +4,76 @@ |
||
4 | 4 | |
5 | 5 | class OpenSSL |
6 | 6 | { |
7 | - public function __construct() {} |
|
7 | + public function __construct() {} |
|
8 | 8 | |
9 | - /** |
|
10 | - * verify signature of xml |
|
11 | - * |
|
12 | - * @param string $xml |
|
13 | - * @param string $bin_sign |
|
14 | - * @param resource $pub_key |
|
15 | - * |
|
16 | - * @return integer result of checking |
|
17 | - */ |
|
18 | - public function verify($xml, $bin_sign, $pub_key) |
|
19 | - { |
|
9 | + /** |
|
10 | + * verify signature of xml |
|
11 | + * |
|
12 | + * @param string $xml |
|
13 | + * @param string $bin_sign |
|
14 | + * @param resource $pub_key |
|
15 | + * |
|
16 | + * @return integer result of checking |
|
17 | + */ |
|
18 | + public function verify($xml, $bin_sign, $pub_key) |
|
19 | + { |
|
20 | 20 | return @openssl_verify($xml, $bin_sign, $pub_key); |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * generate signature of xml |
|
25 | - * |
|
26 | - * @param string $xml |
|
27 | - * @param string $sign |
|
28 | - * @param resource $priv_key |
|
29 | - * |
|
30 | - * @return bool result of signing |
|
31 | - */ |
|
32 | - public function sign($xml, &$sign, $priv_key) |
|
33 | - { |
|
23 | + /** |
|
24 | + * generate signature of xml |
|
25 | + * |
|
26 | + * @param string $xml |
|
27 | + * @param string $sign |
|
28 | + * @param resource $priv_key |
|
29 | + * |
|
30 | + * @return bool result of signing |
|
31 | + */ |
|
32 | + public function sign($xml, &$sign, $priv_key) |
|
33 | + { |
|
34 | 34 | return @openssl_sign($xml, $sign, $priv_key); |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * get public key |
|
39 | - * |
|
40 | - * @param mixed $certificate |
|
41 | - * @return resource |
|
42 | - */ |
|
43 | - public function get_pub_key($certificate) |
|
44 | - { |
|
37 | + /** |
|
38 | + * get public key |
|
39 | + * |
|
40 | + * @param mixed $certificate |
|
41 | + * @return resource |
|
42 | + */ |
|
43 | + public function get_pub_key($certificate) |
|
44 | + { |
|
45 | 45 | $pub_key = @openssl_pkey_get_public($certificate); |
46 | 46 | $this->is_key($pub_key); |
47 | 47 | |
48 | 48 | return $pub_key; |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * get private key |
|
53 | - * |
|
54 | - * @param mixed $certificate |
|
55 | - * @return resource |
|
56 | - */ |
|
57 | - public function get_priv_key($certificate) |
|
58 | - { |
|
51 | + /** |
|
52 | + * get private key |
|
53 | + * |
|
54 | + * @param mixed $certificate |
|
55 | + * @return resource |
|
56 | + */ |
|
57 | + public function get_priv_key($certificate) |
|
58 | + { |
|
59 | 59 | $priv_key = @openssl_pkey_get_private($certificate); |
60 | 60 | $this->is_key($priv_key); |
61 | 61 | |
62 | 62 | return $priv_key; |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * check key |
|
67 | - * |
|
68 | - * @param resource $key |
|
69 | - * @throws Exception\Runtime |
|
70 | - */ |
|
71 | - public function is_key($key) |
|
72 | - { |
|
65 | + /** |
|
66 | + * check key |
|
67 | + * |
|
68 | + * @param resource $key |
|
69 | + * @throws Exception\Runtime |
|
70 | + */ |
|
71 | + public function is_key($key) |
|
72 | + { |
|
73 | 73 | if ($key === FALSE) |
74 | 74 | { |
75 | - throw new Exception\Runtime('Can not extract key from certificate!', -97); |
|
75 | + throw new Exception\Runtime('Can not extract key from certificate!', -97); |
|
76 | + } |
|
76 | 77 | } |
77 | - } |
|
78 | 78 | |
79 | 79 | } |
@@ -16,91 +16,91 @@ |
||
16 | 16 | |
17 | 17 | class Payment extends General |
18 | 18 | { |
19 | - /** |
|
20 | - * @var string 'Account' node |
|
21 | - */ |
|
22 | - protected $Account; |
|
19 | + /** |
|
20 | + * @var string 'Account' node |
|
21 | + */ |
|
22 | + protected $Account; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var string 'OrderId' node |
|
26 | - */ |
|
27 | - protected $OrderId; |
|
24 | + /** |
|
25 | + * @var string 'OrderId' node |
|
26 | + */ |
|
27 | + protected $OrderId; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @var string 'Amount' node |
|
31 | - */ |
|
32 | - protected $Amount; |
|
29 | + /** |
|
30 | + * @var string 'Amount' node |
|
31 | + */ |
|
32 | + protected $Amount; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Payment constructor |
|
36 | - * |
|
37 | - * @param string $raw Raw request data |
|
38 | - */ |
|
39 | - public function __construct($raw) |
|
40 | - { |
|
34 | + /** |
|
35 | + * Payment constructor |
|
36 | + * |
|
37 | + * @param string $raw Raw request data |
|
38 | + */ |
|
39 | + public function __construct($raw) |
|
40 | + { |
|
41 | 41 | parent::__construct($raw); |
42 | - } |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Get Account |
|
46 | - * |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function Account() |
|
50 | - { |
|
44 | + /** |
|
45 | + * Get Account |
|
46 | + * |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function Account() |
|
50 | + { |
|
51 | 51 | return $this->Account; |
52 | - } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Get OrderId |
|
56 | - * |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function OrderId() |
|
60 | - { |
|
54 | + /** |
|
55 | + * Get OrderId |
|
56 | + * |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function OrderId() |
|
60 | + { |
|
61 | 61 | return $this->OrderId; |
62 | - } |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Get Amount |
|
66 | - * |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public function Amount() |
|
70 | - { |
|
64 | + /** |
|
65 | + * Get Amount |
|
66 | + * |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public function Amount() |
|
70 | + { |
|
71 | 71 | return $this->Amount; |
72 | - } |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Parse xml-request, which was previously "extracted" from the body of the http request |
|
76 | - * |
|
77 | - */ |
|
78 | - protected function parse_request_data() |
|
79 | - { |
|
74 | + /** |
|
75 | + * Parse xml-request, which was previously "extracted" from the body of the http request |
|
76 | + * |
|
77 | + */ |
|
78 | + protected function parse_request_data() |
|
79 | + { |
|
80 | 80 | parent::parse_request_data(); |
81 | 81 | |
82 | 82 | $r = $this->get_nodes_from_request('Payment'); |
83 | 83 | |
84 | 84 | foreach ($r[0]->childNodes as $child) |
85 | 85 | { |
86 | - $this->check_and_parse_request_node($child, 'Account'); |
|
87 | - $this->check_and_parse_request_node($child, 'OrderId'); |
|
88 | - $this->check_and_parse_request_node($child, 'Amount'); |
|
86 | + $this->check_and_parse_request_node($child, 'Account'); |
|
87 | + $this->check_and_parse_request_node($child, 'OrderId'); |
|
88 | + $this->check_and_parse_request_node($child, 'Amount'); |
|
89 | + } |
|
89 | 90 | } |
90 | - } |
|
91 | 91 | |
92 | - /** |
|
93 | - * validate Payment request |
|
94 | - * |
|
95 | - * @param array $options |
|
96 | - * @throws Exception\Structure |
|
97 | - */ |
|
98 | - public function validate_request($options) |
|
99 | - { |
|
92 | + /** |
|
93 | + * validate Payment request |
|
94 | + * |
|
95 | + * @param array $options |
|
96 | + * @throws Exception\Structure |
|
97 | + */ |
|
98 | + public function validate_request($options) |
|
99 | + { |
|
100 | 100 | parent::validate_request($options); |
101 | 101 | |
102 | 102 | $this->validate_element('Account'); |
103 | 103 | $this->validate_element('OrderId'); |
104 | 104 | $this->validate_element('Amount'); |
105 | - } |
|
105 | + } |
|
106 | 106 | } |
@@ -16,57 +16,57 @@ |
||
16 | 16 | |
17 | 17 | class Cancel extends General |
18 | 18 | { |
19 | - /** |
|
20 | - * @var string 'PaymentId' node |
|
21 | - */ |
|
22 | - protected $PaymentId; |
|
19 | + /** |
|
20 | + * @var string 'PaymentId' node |
|
21 | + */ |
|
22 | + protected $PaymentId; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Check constructor |
|
26 | - * |
|
27 | - * @param string $raw Raw request data |
|
28 | - */ |
|
29 | - public function __construct($raw) |
|
30 | - { |
|
24 | + /** |
|
25 | + * Check constructor |
|
26 | + * |
|
27 | + * @param string $raw Raw request data |
|
28 | + */ |
|
29 | + public function __construct($raw) |
|
30 | + { |
|
31 | 31 | parent::__construct($raw); |
32 | - } |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Get PaymentId |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function PaymentId() |
|
40 | - { |
|
34 | + /** |
|
35 | + * Get PaymentId |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function PaymentId() |
|
40 | + { |
|
41 | 41 | return $this->PaymentId; |
42 | - } |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Parse xml-request, which was previously "extracted" from the body of the http request |
|
46 | - * |
|
47 | - */ |
|
48 | - protected function parse_request_data() |
|
49 | - { |
|
44 | + /** |
|
45 | + * Parse xml-request, which was previously "extracted" from the body of the http request |
|
46 | + * |
|
47 | + */ |
|
48 | + protected function parse_request_data() |
|
49 | + { |
|
50 | 50 | parent::parse_request_data(); |
51 | 51 | |
52 | 52 | $r = $this->get_nodes_from_request('Cancel'); |
53 | 53 | |
54 | 54 | foreach ($r[0]->childNodes as $child) |
55 | 55 | { |
56 | - $this->check_and_parse_request_node($child, 'PaymentId'); |
|
56 | + $this->check_and_parse_request_node($child, 'PaymentId'); |
|
57 | + } |
|
57 | 58 | } |
58 | - } |
|
59 | 59 | |
60 | - /** |
|
61 | - * validate Cancel request |
|
62 | - * |
|
63 | - * @param array $options |
|
64 | - * @throws Exception\Structure |
|
65 | - */ |
|
66 | - public function validate_request($options) |
|
67 | - { |
|
60 | + /** |
|
61 | + * validate Cancel request |
|
62 | + * |
|
63 | + * @param array $options |
|
64 | + * @throws Exception\Structure |
|
65 | + */ |
|
66 | + public function validate_request($options) |
|
67 | + { |
|
68 | 68 | parent::validate_request($options); |
69 | 69 | |
70 | 70 | $this->validate_element('PaymentId'); |
71 | - } |
|
71 | + } |
|
72 | 72 | } |
@@ -16,57 +16,57 @@ |
||
16 | 16 | |
17 | 17 | class Confirm extends General |
18 | 18 | { |
19 | - /** |
|
20 | - * @var string 'PaymentId' node |
|
21 | - */ |
|
22 | - protected $PaymentId; |
|
19 | + /** |
|
20 | + * @var string 'PaymentId' node |
|
21 | + */ |
|
22 | + protected $PaymentId; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Check constructor |
|
26 | - * |
|
27 | - * @param string $raw Raw request data |
|
28 | - */ |
|
29 | - public function __construct($raw) |
|
30 | - { |
|
24 | + /** |
|
25 | + * Check constructor |
|
26 | + * |
|
27 | + * @param string $raw Raw request data |
|
28 | + */ |
|
29 | + public function __construct($raw) |
|
30 | + { |
|
31 | 31 | parent::__construct($raw); |
32 | - } |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Get PaymentId |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function PaymentId() |
|
40 | - { |
|
34 | + /** |
|
35 | + * Get PaymentId |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function PaymentId() |
|
40 | + { |
|
41 | 41 | return $this->PaymentId; |
42 | - } |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Parse xml-request, which was previously "extracted" from the body of the http request |
|
46 | - * |
|
47 | - */ |
|
48 | - protected function parse_request_data() |
|
49 | - { |
|
44 | + /** |
|
45 | + * Parse xml-request, which was previously "extracted" from the body of the http request |
|
46 | + * |
|
47 | + */ |
|
48 | + protected function parse_request_data() |
|
49 | + { |
|
50 | 50 | parent::parse_request_data(); |
51 | 51 | |
52 | 52 | $r = $this->get_nodes_from_request('Confirm'); |
53 | 53 | |
54 | 54 | foreach ($r[0]->childNodes as $child) |
55 | 55 | { |
56 | - $this->check_and_parse_request_node($child, 'PaymentId'); |
|
56 | + $this->check_and_parse_request_node($child, 'PaymentId'); |
|
57 | + } |
|
57 | 58 | } |
58 | - } |
|
59 | 59 | |
60 | - /** |
|
61 | - * validate Confirm request |
|
62 | - * |
|
63 | - * @param array $options |
|
64 | - * @throws Exception\Structure |
|
65 | - */ |
|
66 | - public function validate_request($options) |
|
67 | - { |
|
60 | + /** |
|
61 | + * validate Confirm request |
|
62 | + * |
|
63 | + * @param array $options |
|
64 | + * @throws Exception\Structure |
|
65 | + */ |
|
66 | + public function validate_request($options) |
|
67 | + { |
|
68 | 68 | parent::validate_request($options); |
69 | 69 | |
70 | 70 | $this->validate_element('PaymentId'); |
71 | - } |
|
71 | + } |
|
72 | 72 | } |
@@ -16,57 +16,57 @@ |
||
16 | 16 | |
17 | 17 | class Check extends General |
18 | 18 | { |
19 | - /** |
|
20 | - * @var string 'Account' node |
|
21 | - */ |
|
22 | - protected $Account; |
|
19 | + /** |
|
20 | + * @var string 'Account' node |
|
21 | + */ |
|
22 | + protected $Account; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Check constructor |
|
26 | - * |
|
27 | - * @param string $raw Raw request data |
|
28 | - */ |
|
29 | - public function __construct($raw) |
|
30 | - { |
|
24 | + /** |
|
25 | + * Check constructor |
|
26 | + * |
|
27 | + * @param string $raw Raw request data |
|
28 | + */ |
|
29 | + public function __construct($raw) |
|
30 | + { |
|
31 | 31 | parent::__construct($raw); |
32 | - } |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Get Account |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function Account() |
|
40 | - { |
|
34 | + /** |
|
35 | + * Get Account |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function Account() |
|
40 | + { |
|
41 | 41 | return $this->Account; |
42 | - } |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Parse xml-request, which was previously "extracted" from the body of the http request |
|
46 | - * |
|
47 | - */ |
|
48 | - protected function parse_request_data() |
|
49 | - { |
|
44 | + /** |
|
45 | + * Parse xml-request, which was previously "extracted" from the body of the http request |
|
46 | + * |
|
47 | + */ |
|
48 | + protected function parse_request_data() |
|
49 | + { |
|
50 | 50 | parent::parse_request_data(); |
51 | 51 | |
52 | 52 | $r = $this->get_nodes_from_request('Check'); |
53 | 53 | |
54 | 54 | foreach ($r[0]->childNodes as $child) |
55 | 55 | { |
56 | - $this->check_and_parse_request_node($child, 'Account'); |
|
56 | + $this->check_and_parse_request_node($child, 'Account'); |
|
57 | + } |
|
57 | 58 | } |
58 | - } |
|
59 | 59 | |
60 | - /** |
|
61 | - * validate Check request |
|
62 | - * |
|
63 | - * @param array $options |
|
64 | - * @throws Exception\Structure |
|
65 | - */ |
|
66 | - public function validate_request($options) |
|
67 | - { |
|
60 | + /** |
|
61 | + * validate Check request |
|
62 | + * |
|
63 | + * @param array $options |
|
64 | + * @throws Exception\Structure |
|
65 | + */ |
|
66 | + public function validate_request($options) |
|
67 | + { |
|
68 | 68 | parent::validate_request($options); |
69 | 69 | |
70 | 70 | $this->validate_element('Account'); |
71 | - } |
|
71 | + } |
|
72 | 72 | } |