|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Class Static Factory to build a specific class of request |
|
5
|
|
|
* |
|
6
|
|
|
* @package php_EasyPay |
|
7
|
|
|
* @version 1.1 |
|
8
|
|
|
* @author Dmitry Shovchko <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace EasyPay\Provider31; |
|
13
|
|
|
|
|
14
|
|
|
use EasyPay\Log as Log; |
|
15
|
|
|
|
|
16
|
|
|
final class Request |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* static method to create a specific class of request |
|
20
|
|
|
* |
|
21
|
|
|
* @return Request\General Request class of the appropriate type |
|
22
|
|
|
* @throws \EasyPay\Exception\Structure |
|
23
|
|
|
*/ |
|
24
|
|
|
public static function get() |
|
25
|
|
|
{ |
|
26
|
|
|
//$raw = self::get_http_raw_post_data(); |
|
27
|
|
|
$raw = new Request\RAW(); |
|
28
|
|
|
|
|
29
|
|
|
$r = new Request\General($raw); |
|
30
|
|
|
|
|
31
|
|
|
switch ($r->Operation()) |
|
32
|
|
|
{ |
|
33
|
|
|
case 'Check': |
|
34
|
|
|
return new Request\Check($raw); |
|
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
case 'Payment': |
|
37
|
|
|
return new Request\Payment($raw); |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
case 'Confirm': |
|
40
|
|
|
return new Request\Confirm($raw); |
|
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
case 'Cancel'; |
|
43
|
|
|
return new Request\Cancel($raw); |
|
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
default: |
|
46
|
|
|
throw new \EasyPay\Exception\Structure('There is not supported value of Operation in xml-request!', -99); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Get data from the body of the http request |
|
52
|
|
|
* |
|
53
|
|
|
* - with the appropriate configuration of php.ini they can be found |
|
54
|
|
|
* in the global variable $HTTP_RAW_POST_DATA |
|
55
|
|
|
* |
|
56
|
|
|
* - but it's easier just to read the data from the php://input stream, |
|
57
|
|
|
* which does not depend on the php.ini directives and allows you to read |
|
58
|
|
|
* raw data from the request body |
|
59
|
|
|
* |
|
60
|
|
|
* @return string Http raw post data |
|
61
|
|
|
* |
|
62
|
|
|
*/ |
|
63
|
|
|
/*private static function get_http_raw_post_data() |
|
64
|
|
|
{ |
|
65
|
|
|
Log::instance()->add('request from ' . $_SERVER['REMOTE_ADDR']); |
|
66
|
|
|
|
|
67
|
|
|
$raw_request = file_get_contents('php://input'); |
|
68
|
|
|
|
|
69
|
|
|
Log::instance()->debug('request received: '); |
|
70
|
|
|
Log::instance()->debug($raw_request); |
|
71
|
|
|
Log::instance()->debug(' '); |
|
72
|
|
|
|
|
73
|
|
|
return $raw_request; |
|
74
|
|
|
}*/ |
|
75
|
|
|
} |
|
76
|
|
|
|