@@ -15,125 +15,125 @@ |
||
15 | 15 | interface LegacyRequestInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @return array |
|
20 | - */ |
|
21 | - public function get_params(); |
|
18 | + /** |
|
19 | + * @return array |
|
20 | + */ |
|
21 | + public function get_params(); |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * @return array |
|
26 | - */ |
|
27 | - public function post_params(); |
|
24 | + /** |
|
25 | + * @return array |
|
26 | + */ |
|
27 | + public function post_params(); |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function cookie_params(); |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function cookie_params(); |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function server_params(); |
|
36 | + /** |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function server_params(); |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * returns contents of $_REQUEST |
|
44 | - * |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function params(); |
|
42 | + /** |
|
43 | + * returns contents of $_REQUEST |
|
44 | + * |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function params(); |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param $key |
|
52 | - * @param $value |
|
53 | - * @param bool $override_ee |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public function set($key, $value, $override_ee = false); |
|
50 | + /** |
|
51 | + * @param $key |
|
52 | + * @param $value |
|
53 | + * @param bool $override_ee |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public function set($key, $value, $override_ee = false); |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * returns the value for a request param if the given key exists |
|
61 | - * |
|
62 | - * @param $key |
|
63 | - * @param null $default |
|
64 | - * @return mixed |
|
65 | - */ |
|
66 | - public function get($key, $default = null); |
|
59 | + /** |
|
60 | + * returns the value for a request param if the given key exists |
|
61 | + * |
|
62 | + * @param $key |
|
63 | + * @param null $default |
|
64 | + * @return mixed |
|
65 | + */ |
|
66 | + public function get($key, $default = null); |
|
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * check if param exists |
|
71 | - * |
|
72 | - * @param $key |
|
73 | - * @return bool |
|
74 | - */ |
|
75 | - public function is_set($key); |
|
69 | + /** |
|
70 | + * check if param exists |
|
71 | + * |
|
72 | + * @param $key |
|
73 | + * @return bool |
|
74 | + */ |
|
75 | + public function is_set($key); |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * remove param |
|
80 | - * |
|
81 | - * @param $key |
|
82 | - * @param bool $unset_from_global_too |
|
83 | - */ |
|
84 | - public function un_set($key, $unset_from_global_too = false); |
|
78 | + /** |
|
79 | + * remove param |
|
80 | + * |
|
81 | + * @param $key |
|
82 | + * @param bool $unset_from_global_too |
|
83 | + */ |
|
84 | + public function un_set($key, $unset_from_global_too = false); |
|
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function ip_address(); |
|
87 | + /** |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function ip_address(); |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * @return bool |
|
95 | - */ |
|
96 | - public function isAdmin(); |
|
93 | + /** |
|
94 | + * @return bool |
|
95 | + */ |
|
96 | + public function isAdmin(); |
|
97 | 97 | |
98 | 98 | |
99 | - /** |
|
100 | - * @return mixed |
|
101 | - */ |
|
102 | - public function isAjax(); |
|
99 | + /** |
|
100 | + * @return mixed |
|
101 | + */ |
|
102 | + public function isAjax(); |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * @return mixed |
|
107 | - */ |
|
108 | - public function isFrontAjax(); |
|
105 | + /** |
|
106 | + * @return mixed |
|
107 | + */ |
|
108 | + public function isFrontAjax(); |
|
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * @return mixed|string |
|
113 | - */ |
|
114 | - public function requestUri(); |
|
111 | + /** |
|
112 | + * @return mixed|string |
|
113 | + */ |
|
114 | + public function requestUri(); |
|
115 | 115 | |
116 | 116 | |
117 | - /** |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - public function userAgent(); |
|
117 | + /** |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + public function userAgent(); |
|
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * @param string $user_agent |
|
125 | - */ |
|
126 | - public function setUserAgent($user_agent = ''); |
|
123 | + /** |
|
124 | + * @param string $user_agent |
|
125 | + */ |
|
126 | + public function setUserAgent($user_agent = ''); |
|
127 | 127 | |
128 | 128 | |
129 | - /** |
|
130 | - * @return bool |
|
131 | - */ |
|
132 | - public function isBot(); |
|
129 | + /** |
|
130 | + * @return bool |
|
131 | + */ |
|
132 | + public function isBot(); |
|
133 | 133 | |
134 | 134 | |
135 | - /** |
|
136 | - * @param bool $is_bot |
|
137 | - */ |
|
138 | - public function setIsBot($is_bot); |
|
135 | + /** |
|
136 | + * @param bool $is_bot |
|
137 | + */ |
|
138 | + public function setIsBot($is_bot); |
|
139 | 139 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function setNotice($key, $value) |
60 | 60 | { |
61 | - $this->notice[ $key ] = $value; |
|
61 | + $this->notice[$key] = $value; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function getNotice($key) |
71 | 71 | { |
72 | - return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null; |
|
72 | + return isset($this->notice[$key]) ? $this->notice[$key] : null; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function addOutput($string, $append = true) |
92 | 92 | { |
93 | - $this->output = $append ? $this->output . $string : $string . $this->output; |
|
93 | + $this->output = $append ? $this->output.$string : $string.$this->output; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 |
@@ -16,119 +16,119 @@ |
||
16 | 16 | class Response implements ResponseInterface, ReservedInstanceInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var array $notice |
|
21 | - */ |
|
22 | - protected $notice = array(); |
|
23 | - |
|
24 | - /** |
|
25 | - * rendered output to be returned to WP |
|
26 | - * |
|
27 | - * @var string $output |
|
28 | - */ |
|
29 | - protected $output = ''; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var bool |
|
33 | - */ |
|
34 | - protected $request_terminated = false; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var bool $deactivate_plugin |
|
38 | - */ |
|
39 | - protected $deactivate_plugin = false; |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * EE_Response constructor. |
|
44 | - */ |
|
45 | - public function __construct() |
|
46 | - { |
|
47 | - $this->terminateRequest(false); |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * @param $key |
|
53 | - * @param $value |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public function setNotice($key, $value) |
|
57 | - { |
|
58 | - $this->notice[ $key ] = $value; |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @param $key |
|
64 | - * @return mixed |
|
65 | - */ |
|
66 | - public function getNotice($key) |
|
67 | - { |
|
68 | - return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null; |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - public function getNotices() |
|
76 | - { |
|
77 | - return $this->notice; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * @param string $string |
|
83 | - * @param bool $append |
|
84 | - */ |
|
85 | - public function addOutput($string, $append = true) |
|
86 | - { |
|
87 | - $this->output = $append ? $this->output . $string : $string . $this->output; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function getOutput() |
|
95 | - { |
|
96 | - return $this->output; |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * @return boolean |
|
102 | - */ |
|
103 | - public function requestTerminated() |
|
104 | - { |
|
105 | - return $this->request_terminated; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * @param boolean $request_terminated |
|
111 | - */ |
|
112 | - public function terminateRequest($request_terminated = true) |
|
113 | - { |
|
114 | - $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @return boolean |
|
120 | - */ |
|
121 | - public function pluginDeactivated() |
|
122 | - { |
|
123 | - return $this->deactivate_plugin; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * sets $deactivate_plugin to true |
|
129 | - */ |
|
130 | - public function deactivatePlugin() |
|
131 | - { |
|
132 | - $this->deactivate_plugin = true; |
|
133 | - } |
|
19 | + /** |
|
20 | + * @var array $notice |
|
21 | + */ |
|
22 | + protected $notice = array(); |
|
23 | + |
|
24 | + /** |
|
25 | + * rendered output to be returned to WP |
|
26 | + * |
|
27 | + * @var string $output |
|
28 | + */ |
|
29 | + protected $output = ''; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var bool |
|
33 | + */ |
|
34 | + protected $request_terminated = false; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var bool $deactivate_plugin |
|
38 | + */ |
|
39 | + protected $deactivate_plugin = false; |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * EE_Response constructor. |
|
44 | + */ |
|
45 | + public function __construct() |
|
46 | + { |
|
47 | + $this->terminateRequest(false); |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * @param $key |
|
53 | + * @param $value |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public function setNotice($key, $value) |
|
57 | + { |
|
58 | + $this->notice[ $key ] = $value; |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @param $key |
|
64 | + * @return mixed |
|
65 | + */ |
|
66 | + public function getNotice($key) |
|
67 | + { |
|
68 | + return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null; |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + public function getNotices() |
|
76 | + { |
|
77 | + return $this->notice; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * @param string $string |
|
83 | + * @param bool $append |
|
84 | + */ |
|
85 | + public function addOutput($string, $append = true) |
|
86 | + { |
|
87 | + $this->output = $append ? $this->output . $string : $string . $this->output; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function getOutput() |
|
95 | + { |
|
96 | + return $this->output; |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * @return boolean |
|
102 | + */ |
|
103 | + public function requestTerminated() |
|
104 | + { |
|
105 | + return $this->request_terminated; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * @param boolean $request_terminated |
|
111 | + */ |
|
112 | + public function terminateRequest($request_terminated = true) |
|
113 | + { |
|
114 | + $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @return boolean |
|
120 | + */ |
|
121 | + public function pluginDeactivated() |
|
122 | + { |
|
123 | + return $this->deactivate_plugin; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * sets $deactivate_plugin to true |
|
129 | + */ |
|
130 | + public function deactivatePlugin() |
|
131 | + { |
|
132 | + $this->deactivate_plugin = true; |
|
133 | + } |
|
134 | 134 | } |
@@ -78,7 +78,7 @@ |
||
78 | 78 | public function preProductionVersionAdminNotice() |
79 | 79 | { |
80 | 80 | new PersistentAdminNotice( |
81 | - 'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION, |
|
81 | + 'preProductionVersionAdminNotice_'.EVENT_ESPRESSO_VERSION, |
|
82 | 82 | $this->warningNotice() |
83 | 83 | ); |
84 | 84 | } |
@@ -18,91 +18,91 @@ |
||
18 | 18 | class PreProductionVersionWarning extends Middleware |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * converts a Request to a Response |
|
23 | - * |
|
24 | - * @param RequestInterface $request |
|
25 | - * @param ResponseInterface $response |
|
26 | - * @return ResponseInterface |
|
27 | - */ |
|
28 | - public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
29 | - { |
|
30 | - $this->request = $request; |
|
31 | - $this->response = $response; |
|
32 | - $this->displayPreProductionVersionWarning(); |
|
33 | - $this->response = $this->processRequestStack($this->request, $this->response); |
|
34 | - return $this->response; |
|
35 | - } |
|
21 | + /** |
|
22 | + * converts a Request to a Response |
|
23 | + * |
|
24 | + * @param RequestInterface $request |
|
25 | + * @param ResponseInterface $response |
|
26 | + * @return ResponseInterface |
|
27 | + */ |
|
28 | + public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
29 | + { |
|
30 | + $this->request = $request; |
|
31 | + $this->response = $response; |
|
32 | + $this->displayPreProductionVersionWarning(); |
|
33 | + $this->response = $this->processRequestStack($this->request, $this->response); |
|
34 | + return $this->response; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode |
|
40 | - * |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - public function displayPreProductionVersionWarning() |
|
44 | - { |
|
45 | - // skip AJAX requests |
|
46 | - if ($this->request->isAjax()) { |
|
47 | - return; |
|
48 | - } |
|
49 | - // skip stable releases |
|
50 | - if (substr(EVENT_ESPRESSO_VERSION, -5) !== '.beta') { |
|
51 | - return; |
|
52 | - } |
|
53 | - // site admin has authorized use of non-stable release candidate for production |
|
54 | - if (defined('ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE') && ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE) { |
|
55 | - return; |
|
56 | - } |
|
57 | - // post release candidate warning |
|
58 | - if ($this->request->isAdmin()) { |
|
59 | - add_action('admin_notices', array($this, 'preProductionVersionAdminNotice'), -999); |
|
60 | - } else { |
|
61 | - add_action('shutdown', array($this, 'preProductionVersionWarningNotice'), 10); |
|
62 | - } |
|
63 | - } |
|
38 | + /** |
|
39 | + * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode |
|
40 | + * |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + public function displayPreProductionVersionWarning() |
|
44 | + { |
|
45 | + // skip AJAX requests |
|
46 | + if ($this->request->isAjax()) { |
|
47 | + return; |
|
48 | + } |
|
49 | + // skip stable releases |
|
50 | + if (substr(EVENT_ESPRESSO_VERSION, -5) !== '.beta') { |
|
51 | + return; |
|
52 | + } |
|
53 | + // site admin has authorized use of non-stable release candidate for production |
|
54 | + if (defined('ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE') && ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE) { |
|
55 | + return; |
|
56 | + } |
|
57 | + // post release candidate warning |
|
58 | + if ($this->request->isAdmin()) { |
|
59 | + add_action('admin_notices', array($this, 'preProductionVersionAdminNotice'), -999); |
|
60 | + } else { |
|
61 | + add_action('shutdown', array($this, 'preProductionVersionWarningNotice'), 10); |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * displays admin notice that current version of EE is not a stable release |
|
68 | - * |
|
69 | - * @return void |
|
70 | - * @throws InvalidDataTypeException |
|
71 | - */ |
|
72 | - public function preProductionVersionAdminNotice() |
|
73 | - { |
|
74 | - new PersistentAdminNotice( |
|
75 | - 'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION, |
|
76 | - $this->warningNotice() |
|
77 | - ); |
|
78 | - } |
|
66 | + /** |
|
67 | + * displays admin notice that current version of EE is not a stable release |
|
68 | + * |
|
69 | + * @return void |
|
70 | + * @throws InvalidDataTypeException |
|
71 | + */ |
|
72 | + public function preProductionVersionAdminNotice() |
|
73 | + { |
|
74 | + new PersistentAdminNotice( |
|
75 | + 'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION, |
|
76 | + $this->warningNotice() |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * displays message on frontend of site notifying admin that current version of EE is not a stable release |
|
83 | - * |
|
84 | - * @return void |
|
85 | - */ |
|
86 | - public function preProductionVersionWarningNotice() |
|
87 | - { |
|
88 | - echo '<div id="ee-release-candidate-notice-dv" class="ee-really-important-notice-dv"><p>'; |
|
89 | - echo $this->warningNotice(); |
|
90 | - echo '</p></div>'; |
|
91 | - } |
|
81 | + /** |
|
82 | + * displays message on frontend of site notifying admin that current version of EE is not a stable release |
|
83 | + * |
|
84 | + * @return void |
|
85 | + */ |
|
86 | + public function preProductionVersionWarningNotice() |
|
87 | + { |
|
88 | + echo '<div id="ee-release-candidate-notice-dv" class="ee-really-important-notice-dv"><p>'; |
|
89 | + echo $this->warningNotice(); |
|
90 | + echo '</p></div>'; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - private function warningNotice() |
|
98 | - { |
|
99 | - return sprintf( |
|
100 | - esc_html__( |
|
101 | - 'This version of Event Espresso is for testing and/or evaluation purposes only. It is %1$snot%2$s considered a stable release and should therefore %1$snot%2$s be activated on a live or production website.', |
|
102 | - 'event_espresso' |
|
103 | - ), |
|
104 | - '<strong>', |
|
105 | - '</strong>' |
|
106 | - ); |
|
107 | - } |
|
94 | + /** |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + private function warningNotice() |
|
98 | + { |
|
99 | + return sprintf( |
|
100 | + esc_html__( |
|
101 | + 'This version of Event Espresso is for testing and/or evaluation purposes only. It is %1$snot%2$s considered a stable release and should therefore %1$snot%2$s be activated on a live or production website.', |
|
102 | + 'event_espresso' |
|
103 | + ), |
|
104 | + '<strong>', |
|
105 | + '</strong>' |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | } |
@@ -83,7 +83,7 @@ |
||
83 | 83 | { |
84 | 84 | espresso_load_required( |
85 | 85 | 'EE_Request', |
86 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
86 | + EE_CORE.'request_stack'.DS.'EE_Request.core.php' |
|
87 | 87 | ); |
88 | 88 | $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER); |
89 | 89 | $this->legacy_request->setRequest($this->request); |
@@ -25,80 +25,80 @@ |
||
25 | 25 | class BootstrapRequestResponseObjects |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @type LegacyRequestInterface $legacy_request |
|
30 | - */ |
|
31 | - protected $legacy_request; |
|
28 | + /** |
|
29 | + * @type LegacyRequestInterface $legacy_request |
|
30 | + */ |
|
31 | + protected $legacy_request; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @type LoaderInterface $loader |
|
35 | - */ |
|
36 | - protected $loader; |
|
33 | + /** |
|
34 | + * @type LoaderInterface $loader |
|
35 | + */ |
|
36 | + protected $loader; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var RequestInterface $request |
|
40 | - */ |
|
41 | - protected $request; |
|
38 | + /** |
|
39 | + * @var RequestInterface $request |
|
40 | + */ |
|
41 | + protected $request; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var ResponseInterface $response |
|
45 | - */ |
|
46 | - protected $response; |
|
43 | + /** |
|
44 | + * @var ResponseInterface $response |
|
45 | + */ |
|
46 | + protected $response; |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * BootstrapRequestResponseObjects constructor. |
|
51 | - * |
|
52 | - * @param LoaderInterface $loader |
|
53 | - */ |
|
54 | - public function __construct(LoaderInterface $loader) |
|
55 | - { |
|
56 | - $this->loader = $loader; |
|
57 | - } |
|
49 | + /** |
|
50 | + * BootstrapRequestResponseObjects constructor. |
|
51 | + * |
|
52 | + * @param LoaderInterface $loader |
|
53 | + */ |
|
54 | + public function __construct(LoaderInterface $loader) |
|
55 | + { |
|
56 | + $this->loader = $loader; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * @return void |
|
62 | - */ |
|
63 | - public function buildRequestResponse() |
|
64 | - { |
|
65 | - // load our Request and Response objects |
|
66 | - $this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES); |
|
67 | - $this->response = new Response(); |
|
68 | - } |
|
60 | + /** |
|
61 | + * @return void |
|
62 | + */ |
|
63 | + public function buildRequestResponse() |
|
64 | + { |
|
65 | + // load our Request and Response objects |
|
66 | + $this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES); |
|
67 | + $this->response = new Response(); |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @return void |
|
73 | - * @throws InvalidArgumentException |
|
74 | - */ |
|
75 | - public function shareRequestResponse() |
|
76 | - { |
|
77 | - $this->loader->share('EventEspresso\core\services\request\Request', $this->request); |
|
78 | - $this->loader->share('EventEspresso\core\services\request\Response', $this->response); |
|
79 | - EE_Dependency_Map::instance()->setRequest($this->request); |
|
80 | - EE_Dependency_Map::instance()->setResponse($this->response); |
|
81 | - } |
|
71 | + /** |
|
72 | + * @return void |
|
73 | + * @throws InvalidArgumentException |
|
74 | + */ |
|
75 | + public function shareRequestResponse() |
|
76 | + { |
|
77 | + $this->loader->share('EventEspresso\core\services\request\Request', $this->request); |
|
78 | + $this->loader->share('EventEspresso\core\services\request\Response', $this->response); |
|
79 | + EE_Dependency_Map::instance()->setRequest($this->request); |
|
80 | + EE_Dependency_Map::instance()->setResponse($this->response); |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * @return void |
|
86 | - * @throws InvalidArgumentException |
|
87 | - * @throws EE_Error |
|
88 | - */ |
|
89 | - public function setupLegacyRequest() |
|
90 | - { |
|
91 | - espresso_load_required( |
|
92 | - 'EE_Request', |
|
93 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
94 | - ); |
|
95 | - $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
96 | - $this->legacy_request->setRequest($this->request); |
|
97 | - $this->legacy_request->admin = $this->request->isAdmin(); |
|
98 | - $this->legacy_request->ajax = $this->request->isAjax(); |
|
99 | - $this->legacy_request->front_ajax = $this->request->isFrontAjax(); |
|
100 | - EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request); |
|
101 | - $this->loader->share('EE_Request', $this->legacy_request); |
|
102 | - $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request); |
|
103 | - } |
|
84 | + /** |
|
85 | + * @return void |
|
86 | + * @throws InvalidArgumentException |
|
87 | + * @throws EE_Error |
|
88 | + */ |
|
89 | + public function setupLegacyRequest() |
|
90 | + { |
|
91 | + espresso_load_required( |
|
92 | + 'EE_Request', |
|
93 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
94 | + ); |
|
95 | + $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
96 | + $this->legacy_request->setRequest($this->request); |
|
97 | + $this->legacy_request->admin = $this->request->isAdmin(); |
|
98 | + $this->legacy_request->ajax = $this->request->isAjax(); |
|
99 | + $this->legacy_request->front_ajax = $this->request->isFrontAjax(); |
|
100 | + EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request); |
|
101 | + $this->loader->share('EE_Request', $this->legacy_request); |
|
102 | + $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request); |
|
103 | + } |
|
104 | 104 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @deprecated 4.9.53 |
183 | 183 | * @param $key |
184 | - * @param null $default |
|
184 | + * @param null|string $default |
|
185 | 185 | * @return mixed |
186 | 186 | * @throws InvalidArgumentException |
187 | 187 | * @throws InvalidDataTypeException |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | /** |
258 | 258 | * @deprecated 4.9.53 |
259 | - * @return mixed |
|
259 | + * @return boolean |
|
260 | 260 | * @throws InvalidArgumentException |
261 | 261 | * @throws InvalidDataTypeException |
262 | 262 | * @throws InvalidInterfaceException |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | |
270 | 270 | /** |
271 | 271 | * @deprecated 4.9.53 |
272 | - * @return mixed |
|
272 | + * @return boolean |
|
273 | 273 | * @throws InvalidArgumentException |
274 | 274 | * @throws InvalidDataTypeException |
275 | 275 | * @throws InvalidInterfaceException |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | /** |
284 | 284 | * @deprecated 4.9.53 |
285 | - * @return mixed|string |
|
285 | + * @return string |
|
286 | 286 | * @throws InvalidArgumentException |
287 | 287 | * @throws InvalidDataTypeException |
288 | 288 | * @throws InvalidInterfaceException |
@@ -18,359 +18,359 @@ |
||
18 | 18 | class EE_Request implements LegacyRequestInterface, InterminableInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var RequestInterface $request |
|
23 | - */ |
|
24 | - private $request; |
|
25 | - |
|
26 | - /** |
|
27 | - * whether current request is for the admin but NOT via AJAX |
|
28 | - * |
|
29 | - * @var boolean $admin |
|
30 | - */ |
|
31 | - public $admin = false; |
|
32 | - |
|
33 | - /** |
|
34 | - * whether current request is via AJAX |
|
35 | - * |
|
36 | - * @var boolean $ajax |
|
37 | - */ |
|
38 | - public $ajax = false; |
|
39 | - |
|
40 | - /** |
|
41 | - * whether current request is via AJAX from the frontend of the site |
|
42 | - * |
|
43 | - * @var boolean $front_ajax |
|
44 | - */ |
|
45 | - public $front_ajax = false; |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @deprecated 4.9.53 |
|
50 | - * @param array $get |
|
51 | - * @param array $post |
|
52 | - * @param array $cookie |
|
53 | - * @param array $server |
|
54 | - */ |
|
55 | - public function __construct( |
|
56 | - array $get = array(), |
|
57 | - array $post = array(), |
|
58 | - array $cookie = array(), |
|
59 | - array $server = array() |
|
60 | - ) { |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * @return RequestInterface |
|
66 | - * @throws InvalidArgumentException |
|
67 | - * @throws InvalidInterfaceException |
|
68 | - * @throws InvalidDataTypeException |
|
69 | - */ |
|
70 | - private function request() |
|
71 | - { |
|
72 | - if ($this->request instanceof RequestInterface) { |
|
73 | - return $this->request; |
|
74 | - } |
|
75 | - $loader = LoaderFactory::getLoader(); |
|
76 | - $this->request = $loader->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
77 | - return $this->request; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * @param RequestInterface $request |
|
83 | - */ |
|
84 | - public function setRequest(RequestInterface $request) |
|
85 | - { |
|
86 | - $this->request = $request; |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * @deprecated 4.9.53 |
|
92 | - * @return array |
|
93 | - * @throws InvalidArgumentException |
|
94 | - * @throws InvalidDataTypeException |
|
95 | - * @throws InvalidInterfaceException |
|
96 | - */ |
|
97 | - public function get_params() |
|
98 | - { |
|
99 | - return $this->request()->getParams(); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * @deprecated 4.9.53 |
|
105 | - * @return array |
|
106 | - * @throws InvalidArgumentException |
|
107 | - * @throws InvalidDataTypeException |
|
108 | - * @throws InvalidInterfaceException |
|
109 | - */ |
|
110 | - public function post_params() |
|
111 | - { |
|
112 | - return $this->request()->postParams(); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @deprecated 4.9.53 |
|
118 | - * @return array |
|
119 | - * @throws InvalidArgumentException |
|
120 | - * @throws InvalidDataTypeException |
|
121 | - * @throws InvalidInterfaceException |
|
122 | - */ |
|
123 | - public function cookie_params() |
|
124 | - { |
|
125 | - return $this->request()->cookieParams(); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * @deprecated 4.9.53 |
|
131 | - * @return array |
|
132 | - * @throws InvalidArgumentException |
|
133 | - * @throws InvalidDataTypeException |
|
134 | - * @throws InvalidInterfaceException |
|
135 | - */ |
|
136 | - public function server_params() |
|
137 | - { |
|
138 | - return $this->request()->serverParams(); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * returns contents of $_REQUEST |
|
144 | - * |
|
145 | - * @deprecated 4.9.53 |
|
146 | - * @return array |
|
147 | - * @throws InvalidArgumentException |
|
148 | - * @throws InvalidDataTypeException |
|
149 | - * @throws InvalidInterfaceException |
|
150 | - */ |
|
151 | - public function params() |
|
152 | - { |
|
153 | - return $this->request()->requestParams(); |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * @deprecated 4.9.53 |
|
159 | - * @param $key |
|
160 | - * @param $value |
|
161 | - * @param bool $override_ee |
|
162 | - * @return void |
|
163 | - * @throws InvalidArgumentException |
|
164 | - * @throws InvalidDataTypeException |
|
165 | - * @throws InvalidInterfaceException |
|
166 | - */ |
|
167 | - public function set($key, $value, $override_ee = false) |
|
168 | - { |
|
169 | - $this->request()->setRequestParam($key, $value, $override_ee); |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * returns the value for a request param if the given key exists |
|
175 | - * |
|
176 | - * @deprecated 4.9.53 |
|
177 | - * @param $key |
|
178 | - * @param null $default |
|
179 | - * @return mixed |
|
180 | - * @throws InvalidArgumentException |
|
181 | - * @throws InvalidDataTypeException |
|
182 | - * @throws InvalidInterfaceException |
|
183 | - */ |
|
184 | - public function get($key, $default = null) |
|
185 | - { |
|
186 | - return $this->request()->getRequestParam($key, $default); |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * check if param exists |
|
192 | - * |
|
193 | - * @deprecated 4.9.53 |
|
194 | - * @param $key |
|
195 | - * @return bool |
|
196 | - * @throws InvalidArgumentException |
|
197 | - * @throws InvalidDataTypeException |
|
198 | - * @throws InvalidInterfaceException |
|
199 | - */ |
|
200 | - public function is_set($key) |
|
201 | - { |
|
202 | - return $this->request()->requestParamIsSet($key); |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * remove param |
|
208 | - * |
|
209 | - * @deprecated 4.9.53 |
|
210 | - * @param $key |
|
211 | - * @param bool $unset_from_global_too |
|
212 | - * @throws InvalidArgumentException |
|
213 | - * @throws InvalidDataTypeException |
|
214 | - * @throws InvalidInterfaceException |
|
215 | - */ |
|
216 | - public function un_set($key, $unset_from_global_too = false) |
|
217 | - { |
|
218 | - $this->request()->unSetRequestParam($key, $unset_from_global_too); |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * @deprecated 4.9.53 |
|
224 | - * @return string |
|
225 | - * @throws InvalidArgumentException |
|
226 | - * @throws InvalidDataTypeException |
|
227 | - * @throws InvalidInterfaceException |
|
228 | - */ |
|
229 | - public function ip_address() |
|
230 | - { |
|
231 | - return $this->request()->ipAddress(); |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * @deprecated 4.9.53 |
|
237 | - * @return bool |
|
238 | - * @throws InvalidArgumentException |
|
239 | - * @throws InvalidDataTypeException |
|
240 | - * @throws InvalidInterfaceException |
|
241 | - */ |
|
242 | - public function isAdmin() |
|
243 | - { |
|
244 | - return $this->request()->isAdmin(); |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * @deprecated 4.9.53 |
|
250 | - * @return mixed |
|
251 | - * @throws InvalidArgumentException |
|
252 | - * @throws InvalidDataTypeException |
|
253 | - * @throws InvalidInterfaceException |
|
254 | - */ |
|
255 | - public function isAjax() |
|
256 | - { |
|
257 | - return $this->request()->isAjax(); |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * @deprecated 4.9.53 |
|
263 | - * @return mixed |
|
264 | - * @throws InvalidArgumentException |
|
265 | - * @throws InvalidDataTypeException |
|
266 | - * @throws InvalidInterfaceException |
|
267 | - */ |
|
268 | - public function isFrontAjax() |
|
269 | - { |
|
270 | - return $this->request()->isFrontAjax(); |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - /** |
|
275 | - * @deprecated 4.9.53 |
|
276 | - * @return mixed|string |
|
277 | - * @throws InvalidArgumentException |
|
278 | - * @throws InvalidDataTypeException |
|
279 | - * @throws InvalidInterfaceException |
|
280 | - */ |
|
281 | - public function requestUri() |
|
282 | - { |
|
283 | - return $this->request()->requestUri(); |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * @deprecated 4.9.53 |
|
289 | - * @return string |
|
290 | - * @throws InvalidArgumentException |
|
291 | - * @throws InvalidDataTypeException |
|
292 | - * @throws InvalidInterfaceException |
|
293 | - */ |
|
294 | - public function userAgent() |
|
295 | - { |
|
296 | - return $this->request()->userAgent(); |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * @deprecated 4.9.53 |
|
302 | - * @param string $user_agent |
|
303 | - * @throws InvalidArgumentException |
|
304 | - * @throws InvalidDataTypeException |
|
305 | - * @throws InvalidInterfaceException |
|
306 | - */ |
|
307 | - public function setUserAgent($user_agent = '') |
|
308 | - { |
|
309 | - $this->request()->setUserAgent($user_agent); |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * @deprecated 4.9.53 |
|
315 | - * @return bool |
|
316 | - * @throws InvalidArgumentException |
|
317 | - * @throws InvalidDataTypeException |
|
318 | - * @throws InvalidInterfaceException |
|
319 | - */ |
|
320 | - public function isBot() |
|
321 | - { |
|
322 | - return $this->request()->isBot(); |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * @deprecated 4.9.53 |
|
328 | - * @param bool $is_bot |
|
329 | - * @throws InvalidArgumentException |
|
330 | - * @throws InvalidDataTypeException |
|
331 | - * @throws InvalidInterfaceException |
|
332 | - */ |
|
333 | - public function setIsBot($is_bot) |
|
334 | - { |
|
335 | - $this->request()->setIsBot($is_bot); |
|
336 | - } |
|
337 | - |
|
338 | - |
|
339 | - /** |
|
340 | - * check if a request parameter exists whose key that matches the supplied wildcard pattern |
|
341 | - * and return the value for the first match found |
|
342 | - * wildcards can be either of the following: |
|
343 | - * ? to represent a single character of any type |
|
344 | - * * to represent one or more characters of any type |
|
345 | - * |
|
346 | - * @param string $pattern |
|
347 | - * @param null|mixed $default |
|
348 | - * @return false|int |
|
349 | - * @throws InvalidArgumentException |
|
350 | - * @throws InvalidInterfaceException |
|
351 | - * @throws InvalidDataTypeException |
|
352 | - */ |
|
353 | - public function getMatch($pattern, $default = null) |
|
354 | - { |
|
355 | - return $this->request()->getMatch($pattern, $default); |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * check if a request parameter exists whose key matches the supplied wildcard pattern |
|
361 | - * wildcards can be either of the following: |
|
362 | - * ? to represent a single character of any type |
|
363 | - * * to represent one or more characters of any type |
|
364 | - * returns true if a match is found or false if not |
|
365 | - * |
|
366 | - * @param string $pattern |
|
367 | - * @return false|int |
|
368 | - * @throws InvalidArgumentException |
|
369 | - * @throws InvalidInterfaceException |
|
370 | - * @throws InvalidDataTypeException |
|
371 | - */ |
|
372 | - public function matches($pattern) |
|
373 | - { |
|
374 | - return $this->request()->matches($pattern); |
|
375 | - } |
|
21 | + /** |
|
22 | + * @var RequestInterface $request |
|
23 | + */ |
|
24 | + private $request; |
|
25 | + |
|
26 | + /** |
|
27 | + * whether current request is for the admin but NOT via AJAX |
|
28 | + * |
|
29 | + * @var boolean $admin |
|
30 | + */ |
|
31 | + public $admin = false; |
|
32 | + |
|
33 | + /** |
|
34 | + * whether current request is via AJAX |
|
35 | + * |
|
36 | + * @var boolean $ajax |
|
37 | + */ |
|
38 | + public $ajax = false; |
|
39 | + |
|
40 | + /** |
|
41 | + * whether current request is via AJAX from the frontend of the site |
|
42 | + * |
|
43 | + * @var boolean $front_ajax |
|
44 | + */ |
|
45 | + public $front_ajax = false; |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @deprecated 4.9.53 |
|
50 | + * @param array $get |
|
51 | + * @param array $post |
|
52 | + * @param array $cookie |
|
53 | + * @param array $server |
|
54 | + */ |
|
55 | + public function __construct( |
|
56 | + array $get = array(), |
|
57 | + array $post = array(), |
|
58 | + array $cookie = array(), |
|
59 | + array $server = array() |
|
60 | + ) { |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * @return RequestInterface |
|
66 | + * @throws InvalidArgumentException |
|
67 | + * @throws InvalidInterfaceException |
|
68 | + * @throws InvalidDataTypeException |
|
69 | + */ |
|
70 | + private function request() |
|
71 | + { |
|
72 | + if ($this->request instanceof RequestInterface) { |
|
73 | + return $this->request; |
|
74 | + } |
|
75 | + $loader = LoaderFactory::getLoader(); |
|
76 | + $this->request = $loader->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
77 | + return $this->request; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * @param RequestInterface $request |
|
83 | + */ |
|
84 | + public function setRequest(RequestInterface $request) |
|
85 | + { |
|
86 | + $this->request = $request; |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * @deprecated 4.9.53 |
|
92 | + * @return array |
|
93 | + * @throws InvalidArgumentException |
|
94 | + * @throws InvalidDataTypeException |
|
95 | + * @throws InvalidInterfaceException |
|
96 | + */ |
|
97 | + public function get_params() |
|
98 | + { |
|
99 | + return $this->request()->getParams(); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * @deprecated 4.9.53 |
|
105 | + * @return array |
|
106 | + * @throws InvalidArgumentException |
|
107 | + * @throws InvalidDataTypeException |
|
108 | + * @throws InvalidInterfaceException |
|
109 | + */ |
|
110 | + public function post_params() |
|
111 | + { |
|
112 | + return $this->request()->postParams(); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @deprecated 4.9.53 |
|
118 | + * @return array |
|
119 | + * @throws InvalidArgumentException |
|
120 | + * @throws InvalidDataTypeException |
|
121 | + * @throws InvalidInterfaceException |
|
122 | + */ |
|
123 | + public function cookie_params() |
|
124 | + { |
|
125 | + return $this->request()->cookieParams(); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * @deprecated 4.9.53 |
|
131 | + * @return array |
|
132 | + * @throws InvalidArgumentException |
|
133 | + * @throws InvalidDataTypeException |
|
134 | + * @throws InvalidInterfaceException |
|
135 | + */ |
|
136 | + public function server_params() |
|
137 | + { |
|
138 | + return $this->request()->serverParams(); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * returns contents of $_REQUEST |
|
144 | + * |
|
145 | + * @deprecated 4.9.53 |
|
146 | + * @return array |
|
147 | + * @throws InvalidArgumentException |
|
148 | + * @throws InvalidDataTypeException |
|
149 | + * @throws InvalidInterfaceException |
|
150 | + */ |
|
151 | + public function params() |
|
152 | + { |
|
153 | + return $this->request()->requestParams(); |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * @deprecated 4.9.53 |
|
159 | + * @param $key |
|
160 | + * @param $value |
|
161 | + * @param bool $override_ee |
|
162 | + * @return void |
|
163 | + * @throws InvalidArgumentException |
|
164 | + * @throws InvalidDataTypeException |
|
165 | + * @throws InvalidInterfaceException |
|
166 | + */ |
|
167 | + public function set($key, $value, $override_ee = false) |
|
168 | + { |
|
169 | + $this->request()->setRequestParam($key, $value, $override_ee); |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * returns the value for a request param if the given key exists |
|
175 | + * |
|
176 | + * @deprecated 4.9.53 |
|
177 | + * @param $key |
|
178 | + * @param null $default |
|
179 | + * @return mixed |
|
180 | + * @throws InvalidArgumentException |
|
181 | + * @throws InvalidDataTypeException |
|
182 | + * @throws InvalidInterfaceException |
|
183 | + */ |
|
184 | + public function get($key, $default = null) |
|
185 | + { |
|
186 | + return $this->request()->getRequestParam($key, $default); |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * check if param exists |
|
192 | + * |
|
193 | + * @deprecated 4.9.53 |
|
194 | + * @param $key |
|
195 | + * @return bool |
|
196 | + * @throws InvalidArgumentException |
|
197 | + * @throws InvalidDataTypeException |
|
198 | + * @throws InvalidInterfaceException |
|
199 | + */ |
|
200 | + public function is_set($key) |
|
201 | + { |
|
202 | + return $this->request()->requestParamIsSet($key); |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * remove param |
|
208 | + * |
|
209 | + * @deprecated 4.9.53 |
|
210 | + * @param $key |
|
211 | + * @param bool $unset_from_global_too |
|
212 | + * @throws InvalidArgumentException |
|
213 | + * @throws InvalidDataTypeException |
|
214 | + * @throws InvalidInterfaceException |
|
215 | + */ |
|
216 | + public function un_set($key, $unset_from_global_too = false) |
|
217 | + { |
|
218 | + $this->request()->unSetRequestParam($key, $unset_from_global_too); |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * @deprecated 4.9.53 |
|
224 | + * @return string |
|
225 | + * @throws InvalidArgumentException |
|
226 | + * @throws InvalidDataTypeException |
|
227 | + * @throws InvalidInterfaceException |
|
228 | + */ |
|
229 | + public function ip_address() |
|
230 | + { |
|
231 | + return $this->request()->ipAddress(); |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * @deprecated 4.9.53 |
|
237 | + * @return bool |
|
238 | + * @throws InvalidArgumentException |
|
239 | + * @throws InvalidDataTypeException |
|
240 | + * @throws InvalidInterfaceException |
|
241 | + */ |
|
242 | + public function isAdmin() |
|
243 | + { |
|
244 | + return $this->request()->isAdmin(); |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * @deprecated 4.9.53 |
|
250 | + * @return mixed |
|
251 | + * @throws InvalidArgumentException |
|
252 | + * @throws InvalidDataTypeException |
|
253 | + * @throws InvalidInterfaceException |
|
254 | + */ |
|
255 | + public function isAjax() |
|
256 | + { |
|
257 | + return $this->request()->isAjax(); |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * @deprecated 4.9.53 |
|
263 | + * @return mixed |
|
264 | + * @throws InvalidArgumentException |
|
265 | + * @throws InvalidDataTypeException |
|
266 | + * @throws InvalidInterfaceException |
|
267 | + */ |
|
268 | + public function isFrontAjax() |
|
269 | + { |
|
270 | + return $this->request()->isFrontAjax(); |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + /** |
|
275 | + * @deprecated 4.9.53 |
|
276 | + * @return mixed|string |
|
277 | + * @throws InvalidArgumentException |
|
278 | + * @throws InvalidDataTypeException |
|
279 | + * @throws InvalidInterfaceException |
|
280 | + */ |
|
281 | + public function requestUri() |
|
282 | + { |
|
283 | + return $this->request()->requestUri(); |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * @deprecated 4.9.53 |
|
289 | + * @return string |
|
290 | + * @throws InvalidArgumentException |
|
291 | + * @throws InvalidDataTypeException |
|
292 | + * @throws InvalidInterfaceException |
|
293 | + */ |
|
294 | + public function userAgent() |
|
295 | + { |
|
296 | + return $this->request()->userAgent(); |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * @deprecated 4.9.53 |
|
302 | + * @param string $user_agent |
|
303 | + * @throws InvalidArgumentException |
|
304 | + * @throws InvalidDataTypeException |
|
305 | + * @throws InvalidInterfaceException |
|
306 | + */ |
|
307 | + public function setUserAgent($user_agent = '') |
|
308 | + { |
|
309 | + $this->request()->setUserAgent($user_agent); |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * @deprecated 4.9.53 |
|
315 | + * @return bool |
|
316 | + * @throws InvalidArgumentException |
|
317 | + * @throws InvalidDataTypeException |
|
318 | + * @throws InvalidInterfaceException |
|
319 | + */ |
|
320 | + public function isBot() |
|
321 | + { |
|
322 | + return $this->request()->isBot(); |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * @deprecated 4.9.53 |
|
328 | + * @param bool $is_bot |
|
329 | + * @throws InvalidArgumentException |
|
330 | + * @throws InvalidDataTypeException |
|
331 | + * @throws InvalidInterfaceException |
|
332 | + */ |
|
333 | + public function setIsBot($is_bot) |
|
334 | + { |
|
335 | + $this->request()->setIsBot($is_bot); |
|
336 | + } |
|
337 | + |
|
338 | + |
|
339 | + /** |
|
340 | + * check if a request parameter exists whose key that matches the supplied wildcard pattern |
|
341 | + * and return the value for the first match found |
|
342 | + * wildcards can be either of the following: |
|
343 | + * ? to represent a single character of any type |
|
344 | + * * to represent one or more characters of any type |
|
345 | + * |
|
346 | + * @param string $pattern |
|
347 | + * @param null|mixed $default |
|
348 | + * @return false|int |
|
349 | + * @throws InvalidArgumentException |
|
350 | + * @throws InvalidInterfaceException |
|
351 | + * @throws InvalidDataTypeException |
|
352 | + */ |
|
353 | + public function getMatch($pattern, $default = null) |
|
354 | + { |
|
355 | + return $this->request()->getMatch($pattern, $default); |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * check if a request parameter exists whose key matches the supplied wildcard pattern |
|
361 | + * wildcards can be either of the following: |
|
362 | + * ? to represent a single character of any type |
|
363 | + * * to represent one or more characters of any type |
|
364 | + * returns true if a match is found or false if not |
|
365 | + * |
|
366 | + * @param string $pattern |
|
367 | + * @return false|int |
|
368 | + * @throws InvalidArgumentException |
|
369 | + * @throws InvalidInterfaceException |
|
370 | + * @throws InvalidDataTypeException |
|
371 | + */ |
|
372 | + public function matches($pattern) |
|
373 | + { |
|
374 | + return $this->request()->matches($pattern); |
|
375 | + } |
|
376 | 376 | } |
@@ -19,59 +19,59 @@ |
||
19 | 19 | class RequestStack |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var RequestDecoratorInterface $request_stack_app |
|
24 | - */ |
|
25 | - protected $request_stack_app; |
|
22 | + /** |
|
23 | + * @var RequestDecoratorInterface $request_stack_app |
|
24 | + */ |
|
25 | + protected $request_stack_app; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var RequestStackCoreAppInterface $core_app |
|
29 | - */ |
|
30 | - protected $core_app; |
|
27 | + /** |
|
28 | + * @var RequestStackCoreAppInterface $core_app |
|
29 | + */ |
|
30 | + protected $core_app; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @var RequestInterface $request |
|
34 | - */ |
|
35 | - protected $request; |
|
32 | + /** |
|
33 | + * @var RequestInterface $request |
|
34 | + */ |
|
35 | + protected $request; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @var ResponseInterface $response |
|
39 | - */ |
|
40 | - protected $response; |
|
37 | + /** |
|
38 | + * @var ResponseInterface $response |
|
39 | + */ |
|
40 | + protected $response; |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @param RequestDecoratorInterface $request_stack_app |
|
45 | - * @param RequestStackCoreAppInterface $core_app |
|
46 | - */ |
|
47 | - public function __construct(RequestDecoratorInterface $request_stack_app, RequestStackCoreAppInterface $core_app) |
|
48 | - { |
|
49 | - $this->request_stack_app = $request_stack_app; |
|
50 | - $this->core_app = $core_app; |
|
51 | - } |
|
43 | + /** |
|
44 | + * @param RequestDecoratorInterface $request_stack_app |
|
45 | + * @param RequestStackCoreAppInterface $core_app |
|
46 | + */ |
|
47 | + public function __construct(RequestDecoratorInterface $request_stack_app, RequestStackCoreAppInterface $core_app) |
|
48 | + { |
|
49 | + $this->request_stack_app = $request_stack_app; |
|
50 | + $this->core_app = $core_app; |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * @param RequestInterface $request |
|
56 | - * @param ResponseInterface $response |
|
57 | - * @return ResponseInterface |
|
58 | - */ |
|
59 | - public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
60 | - { |
|
61 | - $this->request = $request; |
|
62 | - $this->response = $response; |
|
63 | - return $this->request_stack_app->handleRequest($request, $response); |
|
64 | - } |
|
54 | + /** |
|
55 | + * @param RequestInterface $request |
|
56 | + * @param ResponseInterface $response |
|
57 | + * @return ResponseInterface |
|
58 | + */ |
|
59 | + public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
60 | + { |
|
61 | + $this->request = $request; |
|
62 | + $this->response = $response; |
|
63 | + return $this->request_stack_app->handleRequest($request, $response); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * handle_response |
|
69 | - * executes the handle_response() method on the RequestStackCoreAppInterface object |
|
70 | - * after the request stack has been fully processed |
|
71 | - */ |
|
72 | - public function handleResponse() |
|
73 | - { |
|
74 | - $this->core_app->handleResponse($this->request, $this->response); |
|
75 | - } |
|
67 | + /** |
|
68 | + * handle_response |
|
69 | + * executes the handle_response() method on the RequestStackCoreAppInterface object |
|
70 | + * after the request stack has been fully processed |
|
71 | + */ |
|
72 | + public function handleResponse() |
|
73 | + { |
|
74 | + $this->core_app->handleResponse($this->request, $this->response); |
|
75 | + } |
|
76 | 76 | } |
77 | 77 | // Location: RequestStack.php |
@@ -47,7 +47,7 @@ |
||
47 | 47 | public function __construct(RequestDecoratorInterface $request_stack_app, RequestStackCoreAppInterface $core_app) |
48 | 48 | { |
49 | 49 | $this->request_stack_app = $request_stack_app; |
50 | - $this->core_app = $core_app; |
|
50 | + $this->core_app = $core_app; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 |
@@ -9,51 +9,51 @@ |
||
9 | 9 | class CollectionFilterCallbackIterator extends FilterIterator |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * Used for determining whether the iterated object in the Collection is "valid" or not. |
|
14 | - * @var Closure |
|
15 | - */ |
|
16 | - private $acceptance_callback; |
|
17 | - |
|
18 | - |
|
19 | - /** |
|
20 | - * CollectionFilterCallbackIterator constructor. |
|
21 | - * |
|
22 | - * @param Collection $collection |
|
23 | - * @param Closure $acceptance_callback The closure will receive an instance of whatever object is stored on the |
|
24 | - * collection when iterating over the collection and should return boolean. |
|
25 | - */ |
|
26 | - public function __construct(Collection $collection, Closure $acceptance_callback) |
|
27 | - { |
|
28 | - $this->acceptance_callback = $acceptance_callback; |
|
29 | - parent::__construct($collection); |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * Check whether the current element of the iterator is acceptable |
|
34 | - * |
|
35 | - * @link http://php.net/manual/en/filteriterator.accept.php |
|
36 | - * @return bool true if the current element is acceptable, otherwise false. |
|
37 | - */ |
|
38 | - public function accept() |
|
39 | - { |
|
40 | - $acceptance_callback = $this->acceptance_callback; |
|
41 | - return $acceptance_callback($this->getInnerIterator()->current()); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * Returns a filtered array of objects from the collection using the provided acceptance callback |
|
48 | - * @return array |
|
49 | - */ |
|
50 | - public function getFiltered() |
|
51 | - { |
|
52 | - $filtered_array = array(); |
|
53 | - $this->rewind(); |
|
54 | - foreach ($this as $filtered_object) { |
|
55 | - $filtered_array[] = $filtered_object; |
|
56 | - } |
|
57 | - return $filtered_array; |
|
58 | - } |
|
12 | + /** |
|
13 | + * Used for determining whether the iterated object in the Collection is "valid" or not. |
|
14 | + * @var Closure |
|
15 | + */ |
|
16 | + private $acceptance_callback; |
|
17 | + |
|
18 | + |
|
19 | + /** |
|
20 | + * CollectionFilterCallbackIterator constructor. |
|
21 | + * |
|
22 | + * @param Collection $collection |
|
23 | + * @param Closure $acceptance_callback The closure will receive an instance of whatever object is stored on the |
|
24 | + * collection when iterating over the collection and should return boolean. |
|
25 | + */ |
|
26 | + public function __construct(Collection $collection, Closure $acceptance_callback) |
|
27 | + { |
|
28 | + $this->acceptance_callback = $acceptance_callback; |
|
29 | + parent::__construct($collection); |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * Check whether the current element of the iterator is acceptable |
|
34 | + * |
|
35 | + * @link http://php.net/manual/en/filteriterator.accept.php |
|
36 | + * @return bool true if the current element is acceptable, otherwise false. |
|
37 | + */ |
|
38 | + public function accept() |
|
39 | + { |
|
40 | + $acceptance_callback = $this->acceptance_callback; |
|
41 | + return $acceptance_callback($this->getInnerIterator()->current()); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * Returns a filtered array of objects from the collection using the provided acceptance callback |
|
48 | + * @return array |
|
49 | + */ |
|
50 | + public function getFiltered() |
|
51 | + { |
|
52 | + $filtered_array = array(); |
|
53 | + $this->rewind(); |
|
54 | + foreach ($this as $filtered_object) { |
|
55 | + $filtered_array[] = $filtered_object; |
|
56 | + } |
|
57 | + return $filtered_array; |
|
58 | + } |
|
59 | 59 | } |
@@ -362,7 +362,7 @@ |
||
362 | 362 | /** |
363 | 363 | * Posts the request to AuthorizeNet & returns response. |
364 | 364 | * |
365 | - * @param $payment |
|
365 | + * @param EEI_Payment $payment |
|
366 | 366 | * @return \EE_AuthorizeNetAIM_Response |
367 | 367 | */ |
368 | 368 | private function _sendRequest($payment) |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | // invoice_num would be nice to have it be unique per SPCO page-load, that way if users |
249 | 249 | // press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page |
250 | 250 | // in which case, we need to generate teh invoice num per request right here... |
251 | - $this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
251 | + $this->setField('invoice_num', wp_generate_password(12, false)); // $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
252 | 252 | // tell AIM that any duplicates sent in the next 5 minutes are to be ignored |
253 | 253 | $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS); |
254 | 254 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | // Capture response |
260 | 260 | $this->type = "AUTH_CAPTURE"; |
261 | 261 | $response = $this->_sendRequest($payment); |
262 | - if (! empty($response)) { |
|
262 | + if ( ! empty($response)) { |
|
263 | 263 | if ($response->error_message) { |
264 | 264 | $payment->set_status($this->_pay_model->failed_status()); |
265 | 265 | $payment->set_gateway_response($response->error_message); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | protected function _set_sensitive_billing_data($billing_info) |
306 | 306 | { |
307 | 307 | $this->setField('card_num', $billing_info['credit_card']); |
308 | - $this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']); |
|
308 | + $this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']); |
|
309 | 309 | $this->setField('card_code', $billing_info['cvv']); |
310 | 310 | } |
311 | 311 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | protected function setField($name, $value) |
346 | 346 | { |
347 | 347 | if (in_array($name, $this->_all_aim_fields)) { |
348 | - $this->_x_post_fields[ $name ] = $value; |
|
348 | + $this->_x_post_fields[$name] = $value; |
|
349 | 349 | } else { |
350 | 350 | throw new AuthorizeNetException("Error: no field $name exists in the AIM API. |
351 | 351 | To set a custom field use setCustomField('field','value') instead."); |
@@ -365,11 +365,11 @@ discard block |
||
365 | 365 | $this->_x_post_fields['tran_key'] = $this->_transaction_key; |
366 | 366 | $x_keys = array(); |
367 | 367 | foreach ($this->_x_post_fields as $key => $value) { |
368 | - $x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value)); |
|
368 | + $x_keys[] = "x_$key=".urlencode($this->_get_unsupported_character_remover()->format($value)); |
|
369 | 369 | } |
370 | 370 | // Add line items |
371 | 371 | foreach ($this->_additional_line_items as $key => $value) { |
372 | - $x_keys[] = "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value)); |
|
372 | + $x_keys[] = "x_line_item=".urlencode($this->_get_unsupported_character_remover()->format($value)); |
|
373 | 373 | } |
374 | 374 | $this->_log_clean_request($x_keys, $payment); |
375 | 375 | $post_url = $this->_get_server_url(); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); |
382 | 382 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); |
383 | 383 | if ($this->VERIFY_PEER) { |
384 | - curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem'); |
|
384 | + curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__).'/ssl/cert.pem'); |
|
385 | 385 | } else { |
386 | 386 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); |
387 | 387 | } |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | $response = curl_exec($curl_request); |
394 | 394 | |
395 | 395 | curl_close($curl_request); |
396 | - $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
396 | + $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
397 | 397 | |
398 | 398 | return $this->_log_and_clean_response($response_obj, $payment); |
399 | 399 | } |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | if (strpos($keyvaltogether, $key) === 0) { |
414 | 414 | // found it at the first character |
415 | 415 | // so its one of them |
416 | - unset($request_array[ $index ]); |
|
416 | + unset($request_array[$index]); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | } |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | // Split Array |
540 | 540 | $this->response = $response; |
541 | 541 | if ($encap_char) { |
542 | - $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
542 | + $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); |
|
543 | 543 | } else { |
544 | 544 | $this->_response_array = explode($delimiter, $response); |
545 | 545 | } |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | } |
622 | 622 | } |
623 | 623 | |
624 | -if (! class_exists('AuthorizeNetException')) { |
|
624 | +if ( ! class_exists('AuthorizeNetException')) { |
|
625 | 625 | /** |
626 | 626 | * Class AuthorizeNetException |
627 | 627 | * |
@@ -25,427 +25,427 @@ discard block |
||
25 | 25 | class EEG_Aim extends EE_Onsite_Gateway |
26 | 26 | { |
27 | 27 | |
28 | - const LIVE_URL = 'https://secure2.authorize.net/gateway/transact.dll'; // Authnet URL |
|
29 | - |
|
30 | - const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll'; |
|
31 | - |
|
32 | - protected $_login_id; |
|
33 | - |
|
34 | - protected $_transaction_key; |
|
35 | - |
|
36 | - protected $_server; |
|
37 | - |
|
38 | - protected $_currencies_supported = array( |
|
39 | - 'AUD', |
|
40 | - 'USD', |
|
41 | - 'CAD', |
|
42 | - 'EUR', |
|
43 | - 'GBP', |
|
44 | - 'NZD', |
|
45 | - ); |
|
46 | - |
|
47 | - /** |
|
48 | - * Whether to send test transactions (even to live site) |
|
49 | - * |
|
50 | - * @var boolean |
|
51 | - */ |
|
52 | - protected $_test_transactions; |
|
53 | - |
|
54 | - private $VERIFY_PEER = false; |
|
55 | - |
|
56 | - private $_x_post_fields = array( |
|
57 | - "version" => "3.1", |
|
58 | - "delim_char" => ",", |
|
59 | - "delim_data" => "TRUE", |
|
60 | - "relay_response" => "FALSE", |
|
61 | - "encap_char" => "|", |
|
62 | - ); |
|
63 | - |
|
64 | - private $_additional_line_items = array(); |
|
65 | - |
|
66 | - /** |
|
67 | - * A list of all fields in the AIM API. |
|
68 | - * Used to warn user if they try to set a field not offered in the API. |
|
69 | - */ |
|
70 | - private $_all_aim_fields = array( |
|
71 | - "address", |
|
72 | - "allow_partial_auth", |
|
73 | - "amount", |
|
74 | - "auth_code", |
|
75 | - "authentication_indicator", |
|
76 | - "bank_aba_code", |
|
77 | - "bank_acct_name", |
|
78 | - "bank_acct_num", |
|
79 | - "bank_acct_type", |
|
80 | - "bank_check_number", |
|
81 | - "bank_name", |
|
82 | - "card_code", |
|
83 | - "card_num", |
|
84 | - "cardholder_authentication_value", |
|
85 | - "city", |
|
86 | - "company", |
|
87 | - "country", |
|
88 | - "cust_id", |
|
89 | - "customer_ip", |
|
90 | - "delim_char", |
|
91 | - "delim_data", |
|
92 | - "description", |
|
93 | - "duplicate_window", |
|
94 | - "duty", |
|
95 | - "echeck_type", |
|
96 | - "email", |
|
97 | - "email_customer", |
|
98 | - "encap_char", |
|
99 | - "exp_date", |
|
100 | - "fax", |
|
101 | - "first_name", |
|
102 | - "footer_email_receipt", |
|
103 | - "freight", |
|
104 | - "header_email_receipt", |
|
105 | - "invoice_num", |
|
106 | - "last_name", |
|
107 | - "line_item", |
|
108 | - "login", |
|
109 | - "method", |
|
110 | - "phone", |
|
111 | - "po_num", |
|
112 | - "recurring_billing", |
|
113 | - "relay_response", |
|
114 | - "ship_to_address", |
|
115 | - "ship_to_city", |
|
116 | - "ship_to_company", |
|
117 | - "ship_to_country", |
|
118 | - "ship_to_first_name", |
|
119 | - "ship_to_last_name", |
|
120 | - "ship_to_state", |
|
121 | - "ship_to_zip", |
|
122 | - "split_tender_id", |
|
123 | - "state", |
|
124 | - "tax", |
|
125 | - "tax_exempt", |
|
126 | - "test_request", |
|
127 | - "tran_key", |
|
128 | - "trans_id", |
|
129 | - "type", |
|
130 | - "version", |
|
131 | - "zip", |
|
132 | - "solution_id", |
|
133 | - "currency_code" |
|
134 | - ); |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * Gets the URL where the request should go. This is filterable |
|
139 | - * |
|
140 | - * @return string |
|
141 | - */ |
|
142 | - protected function _get_server_url() |
|
143 | - { |
|
144 | - return apply_filters( |
|
145 | - 'FHEE__EEG_Aim___get_server_url', |
|
146 | - $this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL, |
|
147 | - $this |
|
148 | - ); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * TEMPORARY CALLBACK! Do not use |
|
154 | - * Callback which filters the server url. This is added so site admins can revert to using |
|
155 | - * the old AIM server in case Akamai service breaks their integration. |
|
156 | - * Using Akamai will, however, be mandatory on June 30th 2016 Authorize.net |
|
157 | - * (see http://www.authorize.net/support/akamaifaqs/#firewall?utm_campaign=April%202016%20Technical%20Updates%20for%20Merchants.html&utm_medium=email&utm_source=Eloqua&elqTrackId=46103bdc375c411a979c2f658fc99074&elq=7026706360154fee9b6d588b27d8eb6a&elqaid=506&elqat=1&elqCampaignId=343) |
|
158 | - * Once that happens, this will be obsolete and WILL BE REMOVED. |
|
159 | - * |
|
160 | - * @param string $url |
|
161 | - * @param EEG_Aim $gateway_object |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object) |
|
165 | - { |
|
166 | - if ($gateway_object->_server === 'authorize.net' && ! $gateway_object->_debug_mode) { |
|
167 | - return 'https://secure.authorize.net/gateway/transact.dll'; |
|
168 | - } else { |
|
169 | - return $url; |
|
170 | - } |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * Asks the gateway to do whatever it does to process the payment. Onsite gateways will |
|
176 | - * usually send a request directly to the payment provider and update the payment's status based on that; |
|
177 | - * whereas offsite gateways will usually just update the payment with the URL and query parameters to use |
|
178 | - * for sending the request via http_remote_request() |
|
179 | - * |
|
180 | - * @param EEI_Payment $payment |
|
181 | - * @param array $billing_info { |
|
182 | - * @type $credit_card string |
|
183 | - * @type $cvv string |
|
184 | - * @type $exp_month string |
|
185 | - * @type $exp_year string |
|
186 | - * @see parent::do_direct_payment |
|
187 | - * } |
|
188 | - * @return EEI_Payment updated |
|
189 | - */ |
|
190 | - public function do_direct_payment($payment, $billing_info = null) |
|
191 | - { |
|
192 | - add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2); |
|
193 | - // Enable test mode if needed |
|
194 | - // 4007000000027 <-- test successful visa |
|
195 | - // 4222222222222 <-- test failure card number |
|
196 | - |
|
197 | - $item_num = 1; |
|
198 | - $transaction = $payment->transaction(); |
|
199 | - $gateway_formatter = $this->_get_gateway_formatter(); |
|
200 | - $order_description = $gateway_formatter->formatOrderDescription($payment); |
|
201 | - $primary_registrant = $transaction->primary_registration(); |
|
202 | - // if we're are charging for the full amount, show the normal line items |
|
203 | - // and the itemized total adds up properly |
|
204 | - if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
205 | - $total_line_item = $transaction->total_line_item(); |
|
206 | - foreach ($total_line_item->get_items() as $line_item) { |
|
207 | - if ($line_item->quantity() == 0) { |
|
208 | - continue; |
|
209 | - } |
|
210 | - $this->addLineItem( |
|
211 | - $item_num++, |
|
212 | - $gateway_formatter->formatLineItemName($line_item, $payment), |
|
213 | - $gateway_formatter->formatLineItemDesc($line_item, $payment), |
|
214 | - $line_item->quantity(), |
|
215 | - $line_item->unit_price(), |
|
216 | - 'N' |
|
217 | - ); |
|
218 | - $order_description .= $line_item->desc().', '; |
|
219 | - } |
|
220 | - foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
221 | - $this->addLineItem( |
|
222 | - $item_num++, |
|
223 | - $tax_line_item->name(), |
|
224 | - $tax_line_item->desc(), |
|
225 | - 1, |
|
226 | - $tax_line_item->total(), |
|
227 | - 'N' |
|
228 | - ); |
|
229 | - } |
|
230 | - } |
|
231 | - |
|
232 | - // start transaction |
|
233 | - // if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id |
|
234 | - $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363'; |
|
235 | - $this->setField('solution_id', $partner_id); |
|
236 | - $this->setField('amount', $gateway_formatter->formatCurrency($payment->amount())); |
|
237 | - $this->setField('description', substr(rtrim($order_description, ', '), 0, 255)); |
|
238 | - $this->_set_sensitive_billing_data($billing_info); |
|
239 | - $this->setField('first_name', $billing_info['first_name']); |
|
240 | - $this->setField('last_name', $billing_info['last_name']); |
|
241 | - $this->setField('email', $billing_info['email']); |
|
242 | - $this->setField('company', $billing_info['company']); |
|
243 | - $this->setField('address', $billing_info['address'].' '.$billing_info['address2']); |
|
244 | - $this->setField('city', $billing_info['city']); |
|
245 | - $this->setField('state', $billing_info['state']); |
|
246 | - $this->setField('country', $billing_info['country']); |
|
247 | - $this->setField('zip', $billing_info['zip']); |
|
248 | - $this->setField('fax', $billing_info['fax']); |
|
249 | - $this->setField('cust_id', $primary_registrant->ID()); |
|
250 | - $this->setField('phone', $billing_info['phone']); |
|
251 | - $currency_config = LoaderFactory::getLoader()->load('EE_Currency_Config'); |
|
252 | - $this->setField('currency_code', $currency_config->code); |
|
253 | - // invoice_num would be nice to have it be unique per SPCO page-load, that way if users |
|
254 | - // press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page |
|
255 | - // in which case, we need to generate teh invoice num per request right here... |
|
256 | - $this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
257 | - // tell AIM that any duplicates sent in the next 5 minutes are to be ignored |
|
258 | - $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS); |
|
259 | - |
|
260 | - if ($this->_test_transactions) { |
|
261 | - $this->test_request = "true"; |
|
262 | - } |
|
263 | - |
|
264 | - // Capture response |
|
265 | - $this->type = "AUTH_CAPTURE"; |
|
266 | - $response = $this->_sendRequest($payment); |
|
267 | - if (! empty($response)) { |
|
268 | - if ($response->error_message) { |
|
269 | - $payment->set_status($this->_pay_model->failed_status()); |
|
270 | - $payment->set_gateway_response($response->error_message); |
|
271 | - } else { |
|
272 | - $payment_status = $response->approved |
|
273 | - ? $this->_pay_model->approved_status() |
|
274 | - : $this->_pay_model->declined_status(); |
|
275 | - $payment->set_status($payment_status); |
|
276 | - // make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
|
277 | - $payment->set_amount((float) $response->amount); |
|
278 | - $payment->set_gateway_response( |
|
279 | - sprintf( |
|
280 | - esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'), |
|
281 | - $response->response_reason_text, |
|
282 | - $response->response_reason_code |
|
283 | - ) |
|
284 | - ); |
|
285 | - if ($this->_debug_mode) { |
|
286 | - $txn_id = $response->invoice_number; |
|
287 | - } else { |
|
288 | - $txn_id = $response->transaction_id; |
|
289 | - } |
|
290 | - $payment->set_txn_id_chq_nmbr($txn_id); |
|
291 | - } |
|
292 | - $payment->set_extra_accntng($primary_registrant->reg_code()); |
|
293 | - $payment->set_details(print_r($response, true)); |
|
294 | - } else { |
|
295 | - $payment->set_status($this->_pay_model->failed_status()); |
|
296 | - $payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso')); |
|
297 | - $payment->set_details(print_r($response, true)); |
|
298 | - } |
|
299 | - return $payment; |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * Sets billing data for the upcoming request to AIM that is considered sensitive; |
|
305 | - * also this method can be overridden by children classes to easily change |
|
306 | - * what billing data gets sent |
|
307 | - * |
|
308 | - * @param array $billing_info |
|
309 | - */ |
|
310 | - protected function _set_sensitive_billing_data($billing_info) |
|
311 | - { |
|
312 | - $this->setField('card_num', $billing_info['credit_card']); |
|
313 | - $this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']); |
|
314 | - $this->setField('card_code', $billing_info['cvv']); |
|
315 | - } |
|
316 | - |
|
317 | - |
|
318 | - /** |
|
319 | - * Add a line item. |
|
320 | - * |
|
321 | - * @param string $item_id |
|
322 | - * @param string $item_name |
|
323 | - * @param string $item_description |
|
324 | - * @param string $item_quantity |
|
325 | - * @param string $item_unit_price |
|
326 | - * @param string $item_taxable |
|
327 | - */ |
|
328 | - public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable) |
|
329 | - { |
|
330 | - $args = array( |
|
331 | - substr($item_id, 0, 31), |
|
332 | - substr($item_name, 0, 31), |
|
333 | - substr($item_description, 0, 255), |
|
334 | - number_format(abs($item_quantity), 2, '.', ''), |
|
335 | - number_format(abs($item_unit_price), 2, '.', ''), |
|
336 | - $item_taxable === 'N' ? 'N' : 'Y' |
|
337 | - ); |
|
338 | - $this->_additional_line_items[] = implode('<|>', $args); |
|
339 | - } |
|
340 | - |
|
341 | - |
|
342 | - /** |
|
343 | - * Set an individual name/value pair. This will append x_ to the name |
|
344 | - * before posting. |
|
345 | - * |
|
346 | - * @param string $name |
|
347 | - * @param string $value |
|
348 | - * @throws AuthorizeNetException |
|
349 | - */ |
|
350 | - protected function setField($name, $value) |
|
351 | - { |
|
352 | - if (in_array($name, $this->_all_aim_fields)) { |
|
353 | - $this->_x_post_fields[ $name ] = $value; |
|
354 | - } else { |
|
355 | - throw new AuthorizeNetException("Error: no field $name exists in the AIM API. |
|
28 | + const LIVE_URL = 'https://secure2.authorize.net/gateway/transact.dll'; // Authnet URL |
|
29 | + |
|
30 | + const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll'; |
|
31 | + |
|
32 | + protected $_login_id; |
|
33 | + |
|
34 | + protected $_transaction_key; |
|
35 | + |
|
36 | + protected $_server; |
|
37 | + |
|
38 | + protected $_currencies_supported = array( |
|
39 | + 'AUD', |
|
40 | + 'USD', |
|
41 | + 'CAD', |
|
42 | + 'EUR', |
|
43 | + 'GBP', |
|
44 | + 'NZD', |
|
45 | + ); |
|
46 | + |
|
47 | + /** |
|
48 | + * Whether to send test transactions (even to live site) |
|
49 | + * |
|
50 | + * @var boolean |
|
51 | + */ |
|
52 | + protected $_test_transactions; |
|
53 | + |
|
54 | + private $VERIFY_PEER = false; |
|
55 | + |
|
56 | + private $_x_post_fields = array( |
|
57 | + "version" => "3.1", |
|
58 | + "delim_char" => ",", |
|
59 | + "delim_data" => "TRUE", |
|
60 | + "relay_response" => "FALSE", |
|
61 | + "encap_char" => "|", |
|
62 | + ); |
|
63 | + |
|
64 | + private $_additional_line_items = array(); |
|
65 | + |
|
66 | + /** |
|
67 | + * A list of all fields in the AIM API. |
|
68 | + * Used to warn user if they try to set a field not offered in the API. |
|
69 | + */ |
|
70 | + private $_all_aim_fields = array( |
|
71 | + "address", |
|
72 | + "allow_partial_auth", |
|
73 | + "amount", |
|
74 | + "auth_code", |
|
75 | + "authentication_indicator", |
|
76 | + "bank_aba_code", |
|
77 | + "bank_acct_name", |
|
78 | + "bank_acct_num", |
|
79 | + "bank_acct_type", |
|
80 | + "bank_check_number", |
|
81 | + "bank_name", |
|
82 | + "card_code", |
|
83 | + "card_num", |
|
84 | + "cardholder_authentication_value", |
|
85 | + "city", |
|
86 | + "company", |
|
87 | + "country", |
|
88 | + "cust_id", |
|
89 | + "customer_ip", |
|
90 | + "delim_char", |
|
91 | + "delim_data", |
|
92 | + "description", |
|
93 | + "duplicate_window", |
|
94 | + "duty", |
|
95 | + "echeck_type", |
|
96 | + "email", |
|
97 | + "email_customer", |
|
98 | + "encap_char", |
|
99 | + "exp_date", |
|
100 | + "fax", |
|
101 | + "first_name", |
|
102 | + "footer_email_receipt", |
|
103 | + "freight", |
|
104 | + "header_email_receipt", |
|
105 | + "invoice_num", |
|
106 | + "last_name", |
|
107 | + "line_item", |
|
108 | + "login", |
|
109 | + "method", |
|
110 | + "phone", |
|
111 | + "po_num", |
|
112 | + "recurring_billing", |
|
113 | + "relay_response", |
|
114 | + "ship_to_address", |
|
115 | + "ship_to_city", |
|
116 | + "ship_to_company", |
|
117 | + "ship_to_country", |
|
118 | + "ship_to_first_name", |
|
119 | + "ship_to_last_name", |
|
120 | + "ship_to_state", |
|
121 | + "ship_to_zip", |
|
122 | + "split_tender_id", |
|
123 | + "state", |
|
124 | + "tax", |
|
125 | + "tax_exempt", |
|
126 | + "test_request", |
|
127 | + "tran_key", |
|
128 | + "trans_id", |
|
129 | + "type", |
|
130 | + "version", |
|
131 | + "zip", |
|
132 | + "solution_id", |
|
133 | + "currency_code" |
|
134 | + ); |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * Gets the URL where the request should go. This is filterable |
|
139 | + * |
|
140 | + * @return string |
|
141 | + */ |
|
142 | + protected function _get_server_url() |
|
143 | + { |
|
144 | + return apply_filters( |
|
145 | + 'FHEE__EEG_Aim___get_server_url', |
|
146 | + $this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL, |
|
147 | + $this |
|
148 | + ); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * TEMPORARY CALLBACK! Do not use |
|
154 | + * Callback which filters the server url. This is added so site admins can revert to using |
|
155 | + * the old AIM server in case Akamai service breaks their integration. |
|
156 | + * Using Akamai will, however, be mandatory on June 30th 2016 Authorize.net |
|
157 | + * (see http://www.authorize.net/support/akamaifaqs/#firewall?utm_campaign=April%202016%20Technical%20Updates%20for%20Merchants.html&utm_medium=email&utm_source=Eloqua&elqTrackId=46103bdc375c411a979c2f658fc99074&elq=7026706360154fee9b6d588b27d8eb6a&elqaid=506&elqat=1&elqCampaignId=343) |
|
158 | + * Once that happens, this will be obsolete and WILL BE REMOVED. |
|
159 | + * |
|
160 | + * @param string $url |
|
161 | + * @param EEG_Aim $gateway_object |
|
162 | + * @return string |
|
163 | + */ |
|
164 | + public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object) |
|
165 | + { |
|
166 | + if ($gateway_object->_server === 'authorize.net' && ! $gateway_object->_debug_mode) { |
|
167 | + return 'https://secure.authorize.net/gateway/transact.dll'; |
|
168 | + } else { |
|
169 | + return $url; |
|
170 | + } |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * Asks the gateway to do whatever it does to process the payment. Onsite gateways will |
|
176 | + * usually send a request directly to the payment provider and update the payment's status based on that; |
|
177 | + * whereas offsite gateways will usually just update the payment with the URL and query parameters to use |
|
178 | + * for sending the request via http_remote_request() |
|
179 | + * |
|
180 | + * @param EEI_Payment $payment |
|
181 | + * @param array $billing_info { |
|
182 | + * @type $credit_card string |
|
183 | + * @type $cvv string |
|
184 | + * @type $exp_month string |
|
185 | + * @type $exp_year string |
|
186 | + * @see parent::do_direct_payment |
|
187 | + * } |
|
188 | + * @return EEI_Payment updated |
|
189 | + */ |
|
190 | + public function do_direct_payment($payment, $billing_info = null) |
|
191 | + { |
|
192 | + add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2); |
|
193 | + // Enable test mode if needed |
|
194 | + // 4007000000027 <-- test successful visa |
|
195 | + // 4222222222222 <-- test failure card number |
|
196 | + |
|
197 | + $item_num = 1; |
|
198 | + $transaction = $payment->transaction(); |
|
199 | + $gateway_formatter = $this->_get_gateway_formatter(); |
|
200 | + $order_description = $gateway_formatter->formatOrderDescription($payment); |
|
201 | + $primary_registrant = $transaction->primary_registration(); |
|
202 | + // if we're are charging for the full amount, show the normal line items |
|
203 | + // and the itemized total adds up properly |
|
204 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
205 | + $total_line_item = $transaction->total_line_item(); |
|
206 | + foreach ($total_line_item->get_items() as $line_item) { |
|
207 | + if ($line_item->quantity() == 0) { |
|
208 | + continue; |
|
209 | + } |
|
210 | + $this->addLineItem( |
|
211 | + $item_num++, |
|
212 | + $gateway_formatter->formatLineItemName($line_item, $payment), |
|
213 | + $gateway_formatter->formatLineItemDesc($line_item, $payment), |
|
214 | + $line_item->quantity(), |
|
215 | + $line_item->unit_price(), |
|
216 | + 'N' |
|
217 | + ); |
|
218 | + $order_description .= $line_item->desc().', '; |
|
219 | + } |
|
220 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
221 | + $this->addLineItem( |
|
222 | + $item_num++, |
|
223 | + $tax_line_item->name(), |
|
224 | + $tax_line_item->desc(), |
|
225 | + 1, |
|
226 | + $tax_line_item->total(), |
|
227 | + 'N' |
|
228 | + ); |
|
229 | + } |
|
230 | + } |
|
231 | + |
|
232 | + // start transaction |
|
233 | + // if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id |
|
234 | + $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363'; |
|
235 | + $this->setField('solution_id', $partner_id); |
|
236 | + $this->setField('amount', $gateway_formatter->formatCurrency($payment->amount())); |
|
237 | + $this->setField('description', substr(rtrim($order_description, ', '), 0, 255)); |
|
238 | + $this->_set_sensitive_billing_data($billing_info); |
|
239 | + $this->setField('first_name', $billing_info['first_name']); |
|
240 | + $this->setField('last_name', $billing_info['last_name']); |
|
241 | + $this->setField('email', $billing_info['email']); |
|
242 | + $this->setField('company', $billing_info['company']); |
|
243 | + $this->setField('address', $billing_info['address'].' '.$billing_info['address2']); |
|
244 | + $this->setField('city', $billing_info['city']); |
|
245 | + $this->setField('state', $billing_info['state']); |
|
246 | + $this->setField('country', $billing_info['country']); |
|
247 | + $this->setField('zip', $billing_info['zip']); |
|
248 | + $this->setField('fax', $billing_info['fax']); |
|
249 | + $this->setField('cust_id', $primary_registrant->ID()); |
|
250 | + $this->setField('phone', $billing_info['phone']); |
|
251 | + $currency_config = LoaderFactory::getLoader()->load('EE_Currency_Config'); |
|
252 | + $this->setField('currency_code', $currency_config->code); |
|
253 | + // invoice_num would be nice to have it be unique per SPCO page-load, that way if users |
|
254 | + // press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page |
|
255 | + // in which case, we need to generate teh invoice num per request right here... |
|
256 | + $this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
257 | + // tell AIM that any duplicates sent in the next 5 minutes are to be ignored |
|
258 | + $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS); |
|
259 | + |
|
260 | + if ($this->_test_transactions) { |
|
261 | + $this->test_request = "true"; |
|
262 | + } |
|
263 | + |
|
264 | + // Capture response |
|
265 | + $this->type = "AUTH_CAPTURE"; |
|
266 | + $response = $this->_sendRequest($payment); |
|
267 | + if (! empty($response)) { |
|
268 | + if ($response->error_message) { |
|
269 | + $payment->set_status($this->_pay_model->failed_status()); |
|
270 | + $payment->set_gateway_response($response->error_message); |
|
271 | + } else { |
|
272 | + $payment_status = $response->approved |
|
273 | + ? $this->_pay_model->approved_status() |
|
274 | + : $this->_pay_model->declined_status(); |
|
275 | + $payment->set_status($payment_status); |
|
276 | + // make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
|
277 | + $payment->set_amount((float) $response->amount); |
|
278 | + $payment->set_gateway_response( |
|
279 | + sprintf( |
|
280 | + esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'), |
|
281 | + $response->response_reason_text, |
|
282 | + $response->response_reason_code |
|
283 | + ) |
|
284 | + ); |
|
285 | + if ($this->_debug_mode) { |
|
286 | + $txn_id = $response->invoice_number; |
|
287 | + } else { |
|
288 | + $txn_id = $response->transaction_id; |
|
289 | + } |
|
290 | + $payment->set_txn_id_chq_nmbr($txn_id); |
|
291 | + } |
|
292 | + $payment->set_extra_accntng($primary_registrant->reg_code()); |
|
293 | + $payment->set_details(print_r($response, true)); |
|
294 | + } else { |
|
295 | + $payment->set_status($this->_pay_model->failed_status()); |
|
296 | + $payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso')); |
|
297 | + $payment->set_details(print_r($response, true)); |
|
298 | + } |
|
299 | + return $payment; |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * Sets billing data for the upcoming request to AIM that is considered sensitive; |
|
305 | + * also this method can be overridden by children classes to easily change |
|
306 | + * what billing data gets sent |
|
307 | + * |
|
308 | + * @param array $billing_info |
|
309 | + */ |
|
310 | + protected function _set_sensitive_billing_data($billing_info) |
|
311 | + { |
|
312 | + $this->setField('card_num', $billing_info['credit_card']); |
|
313 | + $this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']); |
|
314 | + $this->setField('card_code', $billing_info['cvv']); |
|
315 | + } |
|
316 | + |
|
317 | + |
|
318 | + /** |
|
319 | + * Add a line item. |
|
320 | + * |
|
321 | + * @param string $item_id |
|
322 | + * @param string $item_name |
|
323 | + * @param string $item_description |
|
324 | + * @param string $item_quantity |
|
325 | + * @param string $item_unit_price |
|
326 | + * @param string $item_taxable |
|
327 | + */ |
|
328 | + public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable) |
|
329 | + { |
|
330 | + $args = array( |
|
331 | + substr($item_id, 0, 31), |
|
332 | + substr($item_name, 0, 31), |
|
333 | + substr($item_description, 0, 255), |
|
334 | + number_format(abs($item_quantity), 2, '.', ''), |
|
335 | + number_format(abs($item_unit_price), 2, '.', ''), |
|
336 | + $item_taxable === 'N' ? 'N' : 'Y' |
|
337 | + ); |
|
338 | + $this->_additional_line_items[] = implode('<|>', $args); |
|
339 | + } |
|
340 | + |
|
341 | + |
|
342 | + /** |
|
343 | + * Set an individual name/value pair. This will append x_ to the name |
|
344 | + * before posting. |
|
345 | + * |
|
346 | + * @param string $name |
|
347 | + * @param string $value |
|
348 | + * @throws AuthorizeNetException |
|
349 | + */ |
|
350 | + protected function setField($name, $value) |
|
351 | + { |
|
352 | + if (in_array($name, $this->_all_aim_fields)) { |
|
353 | + $this->_x_post_fields[ $name ] = $value; |
|
354 | + } else { |
|
355 | + throw new AuthorizeNetException("Error: no field $name exists in the AIM API. |
|
356 | 356 | To set a custom field use setCustomField('field','value') instead."); |
357 | - } |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * Posts the request to AuthorizeNet & returns response. |
|
363 | - * |
|
364 | - * @param $payment |
|
365 | - * @return \EE_AuthorizeNetAIM_Response |
|
366 | - */ |
|
367 | - private function _sendRequest($payment) |
|
368 | - { |
|
369 | - $this->_x_post_fields['login'] = $this->_login_id; |
|
370 | - $this->_x_post_fields['tran_key'] = $this->_transaction_key; |
|
371 | - $x_keys = array(); |
|
372 | - foreach ($this->_x_post_fields as $key => $value) { |
|
373 | - $x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value)); |
|
374 | - } |
|
375 | - // Add line items |
|
376 | - foreach ($this->_additional_line_items as $key => $value) { |
|
377 | - $x_keys[] = "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value)); |
|
378 | - } |
|
379 | - $this->_log_clean_request($x_keys, $payment); |
|
380 | - $post_url = $this->_get_server_url(); |
|
381 | - $curl_request = curl_init($post_url); |
|
382 | - $post_body = implode("&", $x_keys); |
|
383 | - curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body); |
|
384 | - curl_setopt($curl_request, CURLOPT_HEADER, 0); |
|
385 | - curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); |
|
386 | - curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); |
|
387 | - curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); |
|
388 | - if ($this->VERIFY_PEER) { |
|
389 | - curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem'); |
|
390 | - } else { |
|
391 | - curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); |
|
392 | - } |
|
393 | - |
|
394 | - if (preg_match('/xml/', $post_url)) { |
|
395 | - curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); |
|
396 | - } |
|
397 | - |
|
398 | - $response = curl_exec($curl_request); |
|
399 | - |
|
400 | - curl_close($curl_request); |
|
401 | - $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
402 | - |
|
403 | - return $this->_log_and_clean_response($response_obj, $payment); |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - /** |
|
408 | - * Logs the clean data only |
|
409 | - * |
|
410 | - * @param array $request_array |
|
411 | - * @param EEI_Payment $payment |
|
412 | - */ |
|
413 | - protected function _log_clean_request($request_array, $payment) |
|
414 | - { |
|
415 | - $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date'); |
|
416 | - foreach ($request_array as $index => $keyvaltogether) { |
|
417 | - foreach ($keys_to_filter_out as $key) { |
|
418 | - if (strpos($keyvaltogether, $key) === 0) { |
|
419 | - // found it at the first character |
|
420 | - // so its one of them |
|
421 | - unset($request_array[ $index ]); |
|
422 | - } |
|
423 | - } |
|
424 | - } |
|
425 | - $this->log( |
|
426 | - array( |
|
427 | - 'AIM Request sent:' => $request_array, |
|
428 | - 'Server URL' => $this->_get_server_url() |
|
429 | - ), |
|
430 | - $payment |
|
431 | - ); |
|
432 | - } |
|
433 | - |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * Logs the response and cleans it |
|
438 | - * |
|
439 | - * @param EE_AuthorizeNetAIM_Response $response_obj |
|
440 | - * @param EE_Payment $payment |
|
441 | - * @return \EE_AuthorizeNetAIM_Response |
|
442 | - */ |
|
443 | - private function _log_and_clean_response($response_obj, $payment) |
|
444 | - { |
|
445 | - $response_obj->account_number = ''; |
|
446 | - $this->log(array('AIM Response received:' => (array) $response_obj), $payment); |
|
447 | - return $response_obj; |
|
448 | - } |
|
357 | + } |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * Posts the request to AuthorizeNet & returns response. |
|
363 | + * |
|
364 | + * @param $payment |
|
365 | + * @return \EE_AuthorizeNetAIM_Response |
|
366 | + */ |
|
367 | + private function _sendRequest($payment) |
|
368 | + { |
|
369 | + $this->_x_post_fields['login'] = $this->_login_id; |
|
370 | + $this->_x_post_fields['tran_key'] = $this->_transaction_key; |
|
371 | + $x_keys = array(); |
|
372 | + foreach ($this->_x_post_fields as $key => $value) { |
|
373 | + $x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value)); |
|
374 | + } |
|
375 | + // Add line items |
|
376 | + foreach ($this->_additional_line_items as $key => $value) { |
|
377 | + $x_keys[] = "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value)); |
|
378 | + } |
|
379 | + $this->_log_clean_request($x_keys, $payment); |
|
380 | + $post_url = $this->_get_server_url(); |
|
381 | + $curl_request = curl_init($post_url); |
|
382 | + $post_body = implode("&", $x_keys); |
|
383 | + curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body); |
|
384 | + curl_setopt($curl_request, CURLOPT_HEADER, 0); |
|
385 | + curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); |
|
386 | + curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); |
|
387 | + curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); |
|
388 | + if ($this->VERIFY_PEER) { |
|
389 | + curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem'); |
|
390 | + } else { |
|
391 | + curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); |
|
392 | + } |
|
393 | + |
|
394 | + if (preg_match('/xml/', $post_url)) { |
|
395 | + curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); |
|
396 | + } |
|
397 | + |
|
398 | + $response = curl_exec($curl_request); |
|
399 | + |
|
400 | + curl_close($curl_request); |
|
401 | + $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
402 | + |
|
403 | + return $this->_log_and_clean_response($response_obj, $payment); |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + /** |
|
408 | + * Logs the clean data only |
|
409 | + * |
|
410 | + * @param array $request_array |
|
411 | + * @param EEI_Payment $payment |
|
412 | + */ |
|
413 | + protected function _log_clean_request($request_array, $payment) |
|
414 | + { |
|
415 | + $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date'); |
|
416 | + foreach ($request_array as $index => $keyvaltogether) { |
|
417 | + foreach ($keys_to_filter_out as $key) { |
|
418 | + if (strpos($keyvaltogether, $key) === 0) { |
|
419 | + // found it at the first character |
|
420 | + // so its one of them |
|
421 | + unset($request_array[ $index ]); |
|
422 | + } |
|
423 | + } |
|
424 | + } |
|
425 | + $this->log( |
|
426 | + array( |
|
427 | + 'AIM Request sent:' => $request_array, |
|
428 | + 'Server URL' => $this->_get_server_url() |
|
429 | + ), |
|
430 | + $payment |
|
431 | + ); |
|
432 | + } |
|
433 | + |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * Logs the response and cleans it |
|
438 | + * |
|
439 | + * @param EE_AuthorizeNetAIM_Response $response_obj |
|
440 | + * @param EE_Payment $payment |
|
441 | + * @return \EE_AuthorizeNetAIM_Response |
|
442 | + */ |
|
443 | + private function _log_and_clean_response($response_obj, $payment) |
|
444 | + { |
|
445 | + $response_obj->account_number = ''; |
|
446 | + $this->log(array('AIM Response received:' => (array) $response_obj), $payment); |
|
447 | + return $response_obj; |
|
448 | + } |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | |
@@ -461,192 +461,192 @@ discard block |
||
461 | 461 | class EE_AuthorizeNetAIM_Response |
462 | 462 | { |
463 | 463 | |
464 | - const APPROVED = '1'; |
|
465 | - const DECLINED = '2'; |
|
466 | - const ERROR = '3'; |
|
467 | - const HELD = '4'; |
|
468 | - |
|
469 | - protected $_x_post_fields = array( |
|
470 | - "version" => "3.1", |
|
471 | - "delim_char" => ",", |
|
472 | - "delim_data" => "TRUE", |
|
473 | - "relay_response" => "FALSE", |
|
474 | - "encap_char" => "|", |
|
475 | - ); |
|
476 | - public $approved; |
|
477 | - public $declined; |
|
478 | - public $error; |
|
479 | - public $held; |
|
480 | - public $response_code; |
|
481 | - public $response_subcode; |
|
482 | - public $response_reason_code; |
|
483 | - public $response_reason_text; |
|
484 | - public $authorization_code; |
|
485 | - public $avs_response; |
|
486 | - public $transaction_id; |
|
487 | - public $invoice_number; |
|
488 | - public $description; |
|
489 | - public $amount; |
|
490 | - public $method; |
|
491 | - public $transaction_type; |
|
492 | - public $customer_id; |
|
493 | - public $first_name; |
|
494 | - public $last_name; |
|
495 | - public $company; |
|
496 | - public $address; |
|
497 | - public $city; |
|
498 | - public $state; |
|
499 | - public $zip_code; |
|
500 | - public $country; |
|
501 | - public $phone; |
|
502 | - public $fax; |
|
503 | - public $email_address; |
|
504 | - public $ship_to_first_name; |
|
505 | - public $ship_to_last_name; |
|
506 | - public $ship_to_company; |
|
507 | - public $ship_to_address; |
|
508 | - public $ship_to_city; |
|
509 | - public $ship_to_state; |
|
510 | - public $ship_to_zip_code; |
|
511 | - public $ship_to_country; |
|
512 | - public $tax; |
|
513 | - public $duty; |
|
514 | - public $freight; |
|
515 | - public $tax_exempt; |
|
516 | - public $purchase_order_number; |
|
517 | - public $md5_hash; |
|
518 | - public $card_code_response; |
|
519 | - public $cavv_response; // cardholder_authentication_verification_response |
|
520 | - public $account_number; |
|
521 | - public $card_type; |
|
522 | - public $split_tender_id; |
|
523 | - public $requested_amount; |
|
524 | - public $balance_on_card; |
|
525 | - public $response; // The response string from AuthorizeNet. |
|
526 | - public $error_message; |
|
527 | - private $_response_array = array(); // An array with the split response. |
|
528 | - |
|
529 | - |
|
530 | - /** |
|
531 | - * Constructor. Parses the AuthorizeNet response string |
|
532 | - * |
|
533 | - * @param string $response The response from the AuthNet server. |
|
534 | - * @var string $delimiter The delimiter used (default is ",") |
|
535 | - * @var string $encap_char The encap_char used (default is "|") |
|
536 | - * @var array $custom_fields Any custom fields set in the request. |
|
537 | - */ |
|
538 | - |
|
539 | - public function __construct($response) |
|
540 | - { |
|
541 | - $encap_char = $this->_x_post_fields['encap_char']; |
|
542 | - $delimiter = $this->_x_post_fields['delim_char']; |
|
543 | - if ($response) { |
|
544 | - // Split Array |
|
545 | - $this->response = $response; |
|
546 | - if ($encap_char) { |
|
547 | - $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
548 | - } else { |
|
549 | - $this->_response_array = explode($delimiter, $response); |
|
550 | - } |
|
551 | - |
|
552 | - /** |
|
553 | - * If AuthorizeNet doesn't return a delimited response. |
|
554 | - */ |
|
555 | - if (count($this->_response_array) < 10) { |
|
556 | - $this->approved = false; |
|
557 | - $this->error = true; |
|
558 | - $this->error_message = sprintf( |
|
559 | - esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'), |
|
560 | - esc_html($response) |
|
561 | - ); |
|
562 | - return; |
|
563 | - } |
|
564 | - |
|
565 | - |
|
566 | - |
|
567 | - // Set all fields |
|
568 | - $this->response_code = $this->_response_array[0]; |
|
569 | - $this->response_subcode = $this->_response_array[1]; |
|
570 | - $this->response_reason_code = $this->_response_array[2]; |
|
571 | - $this->response_reason_text = $this->_response_array[3]; |
|
572 | - $this->authorization_code = $this->_response_array[4]; |
|
573 | - $this->avs_response = $this->_response_array[5]; |
|
574 | - $this->transaction_id = $this->_response_array[6]; |
|
575 | - $this->invoice_number = $this->_response_array[7]; |
|
576 | - $this->description = $this->_response_array[8]; |
|
577 | - $this->amount = $this->_response_array[9]; |
|
578 | - $this->method = $this->_response_array[10]; |
|
579 | - $this->transaction_type = $this->_response_array[11]; |
|
580 | - $this->customer_id = $this->_response_array[12]; |
|
581 | - $this->first_name = $this->_response_array[13]; |
|
582 | - $this->last_name = $this->_response_array[14]; |
|
583 | - $this->company = $this->_response_array[15]; |
|
584 | - $this->address = $this->_response_array[16]; |
|
585 | - $this->city = $this->_response_array[17]; |
|
586 | - $this->state = $this->_response_array[18]; |
|
587 | - $this->zip_code = $this->_response_array[19]; |
|
588 | - $this->country = $this->_response_array[20]; |
|
589 | - $this->phone = $this->_response_array[21]; |
|
590 | - $this->fax = $this->_response_array[22]; |
|
591 | - $this->email_address = $this->_response_array[23]; |
|
592 | - $this->ship_to_first_name = $this->_response_array[24]; |
|
593 | - $this->ship_to_last_name = $this->_response_array[25]; |
|
594 | - $this->ship_to_company = $this->_response_array[26]; |
|
595 | - $this->ship_to_address = $this->_response_array[27]; |
|
596 | - $this->ship_to_city = $this->_response_array[28]; |
|
597 | - $this->ship_to_state = $this->_response_array[29]; |
|
598 | - $this->ship_to_zip_code = $this->_response_array[30]; |
|
599 | - $this->ship_to_country = $this->_response_array[31]; |
|
600 | - $this->tax = $this->_response_array[32]; |
|
601 | - $this->duty = $this->_response_array[33]; |
|
602 | - $this->freight = $this->_response_array[34]; |
|
603 | - $this->tax_exempt = $this->_response_array[35]; |
|
604 | - $this->purchase_order_number = $this->_response_array[36]; |
|
605 | - $this->md5_hash = $this->_response_array[37]; |
|
606 | - $this->card_code_response = $this->_response_array[38]; |
|
607 | - $this->cavv_response = $this->_response_array[39]; |
|
608 | - $this->account_number = $this->_response_array[50]; |
|
609 | - $this->card_type = $this->_response_array[51]; |
|
610 | - $this->split_tender_id = $this->_response_array[52]; |
|
611 | - $this->requested_amount = $this->_response_array[53]; |
|
612 | - $this->balance_on_card = $this->_response_array[54]; |
|
613 | - |
|
614 | - $this->approved = ($this->response_code === self::APPROVED); |
|
615 | - $this->declined = ($this->response_code === self::DECLINED); |
|
616 | - $this->error = ($this->response_code === self::ERROR); |
|
617 | - $this->held = ($this->response_code === self::HELD); |
|
618 | - } else { |
|
619 | - $this->approved = false; |
|
620 | - $this->error = true; |
|
621 | - $this->error_message = esc_html__( |
|
622 | - 'Error connecting to Authorize.net', |
|
623 | - 'event_espresso' |
|
624 | - ); |
|
625 | - } |
|
626 | - } |
|
464 | + const APPROVED = '1'; |
|
465 | + const DECLINED = '2'; |
|
466 | + const ERROR = '3'; |
|
467 | + const HELD = '4'; |
|
468 | + |
|
469 | + protected $_x_post_fields = array( |
|
470 | + "version" => "3.1", |
|
471 | + "delim_char" => ",", |
|
472 | + "delim_data" => "TRUE", |
|
473 | + "relay_response" => "FALSE", |
|
474 | + "encap_char" => "|", |
|
475 | + ); |
|
476 | + public $approved; |
|
477 | + public $declined; |
|
478 | + public $error; |
|
479 | + public $held; |
|
480 | + public $response_code; |
|
481 | + public $response_subcode; |
|
482 | + public $response_reason_code; |
|
483 | + public $response_reason_text; |
|
484 | + public $authorization_code; |
|
485 | + public $avs_response; |
|
486 | + public $transaction_id; |
|
487 | + public $invoice_number; |
|
488 | + public $description; |
|
489 | + public $amount; |
|
490 | + public $method; |
|
491 | + public $transaction_type; |
|
492 | + public $customer_id; |
|
493 | + public $first_name; |
|
494 | + public $last_name; |
|
495 | + public $company; |
|
496 | + public $address; |
|
497 | + public $city; |
|
498 | + public $state; |
|
499 | + public $zip_code; |
|
500 | + public $country; |
|
501 | + public $phone; |
|
502 | + public $fax; |
|
503 | + public $email_address; |
|
504 | + public $ship_to_first_name; |
|
505 | + public $ship_to_last_name; |
|
506 | + public $ship_to_company; |
|
507 | + public $ship_to_address; |
|
508 | + public $ship_to_city; |
|
509 | + public $ship_to_state; |
|
510 | + public $ship_to_zip_code; |
|
511 | + public $ship_to_country; |
|
512 | + public $tax; |
|
513 | + public $duty; |
|
514 | + public $freight; |
|
515 | + public $tax_exempt; |
|
516 | + public $purchase_order_number; |
|
517 | + public $md5_hash; |
|
518 | + public $card_code_response; |
|
519 | + public $cavv_response; // cardholder_authentication_verification_response |
|
520 | + public $account_number; |
|
521 | + public $card_type; |
|
522 | + public $split_tender_id; |
|
523 | + public $requested_amount; |
|
524 | + public $balance_on_card; |
|
525 | + public $response; // The response string from AuthorizeNet. |
|
526 | + public $error_message; |
|
527 | + private $_response_array = array(); // An array with the split response. |
|
528 | + |
|
529 | + |
|
530 | + /** |
|
531 | + * Constructor. Parses the AuthorizeNet response string |
|
532 | + * |
|
533 | + * @param string $response The response from the AuthNet server. |
|
534 | + * @var string $delimiter The delimiter used (default is ",") |
|
535 | + * @var string $encap_char The encap_char used (default is "|") |
|
536 | + * @var array $custom_fields Any custom fields set in the request. |
|
537 | + */ |
|
538 | + |
|
539 | + public function __construct($response) |
|
540 | + { |
|
541 | + $encap_char = $this->_x_post_fields['encap_char']; |
|
542 | + $delimiter = $this->_x_post_fields['delim_char']; |
|
543 | + if ($response) { |
|
544 | + // Split Array |
|
545 | + $this->response = $response; |
|
546 | + if ($encap_char) { |
|
547 | + $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
548 | + } else { |
|
549 | + $this->_response_array = explode($delimiter, $response); |
|
550 | + } |
|
551 | + |
|
552 | + /** |
|
553 | + * If AuthorizeNet doesn't return a delimited response. |
|
554 | + */ |
|
555 | + if (count($this->_response_array) < 10) { |
|
556 | + $this->approved = false; |
|
557 | + $this->error = true; |
|
558 | + $this->error_message = sprintf( |
|
559 | + esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'), |
|
560 | + esc_html($response) |
|
561 | + ); |
|
562 | + return; |
|
563 | + } |
|
564 | + |
|
565 | + |
|
566 | + |
|
567 | + // Set all fields |
|
568 | + $this->response_code = $this->_response_array[0]; |
|
569 | + $this->response_subcode = $this->_response_array[1]; |
|
570 | + $this->response_reason_code = $this->_response_array[2]; |
|
571 | + $this->response_reason_text = $this->_response_array[3]; |
|
572 | + $this->authorization_code = $this->_response_array[4]; |
|
573 | + $this->avs_response = $this->_response_array[5]; |
|
574 | + $this->transaction_id = $this->_response_array[6]; |
|
575 | + $this->invoice_number = $this->_response_array[7]; |
|
576 | + $this->description = $this->_response_array[8]; |
|
577 | + $this->amount = $this->_response_array[9]; |
|
578 | + $this->method = $this->_response_array[10]; |
|
579 | + $this->transaction_type = $this->_response_array[11]; |
|
580 | + $this->customer_id = $this->_response_array[12]; |
|
581 | + $this->first_name = $this->_response_array[13]; |
|
582 | + $this->last_name = $this->_response_array[14]; |
|
583 | + $this->company = $this->_response_array[15]; |
|
584 | + $this->address = $this->_response_array[16]; |
|
585 | + $this->city = $this->_response_array[17]; |
|
586 | + $this->state = $this->_response_array[18]; |
|
587 | + $this->zip_code = $this->_response_array[19]; |
|
588 | + $this->country = $this->_response_array[20]; |
|
589 | + $this->phone = $this->_response_array[21]; |
|
590 | + $this->fax = $this->_response_array[22]; |
|
591 | + $this->email_address = $this->_response_array[23]; |
|
592 | + $this->ship_to_first_name = $this->_response_array[24]; |
|
593 | + $this->ship_to_last_name = $this->_response_array[25]; |
|
594 | + $this->ship_to_company = $this->_response_array[26]; |
|
595 | + $this->ship_to_address = $this->_response_array[27]; |
|
596 | + $this->ship_to_city = $this->_response_array[28]; |
|
597 | + $this->ship_to_state = $this->_response_array[29]; |
|
598 | + $this->ship_to_zip_code = $this->_response_array[30]; |
|
599 | + $this->ship_to_country = $this->_response_array[31]; |
|
600 | + $this->tax = $this->_response_array[32]; |
|
601 | + $this->duty = $this->_response_array[33]; |
|
602 | + $this->freight = $this->_response_array[34]; |
|
603 | + $this->tax_exempt = $this->_response_array[35]; |
|
604 | + $this->purchase_order_number = $this->_response_array[36]; |
|
605 | + $this->md5_hash = $this->_response_array[37]; |
|
606 | + $this->card_code_response = $this->_response_array[38]; |
|
607 | + $this->cavv_response = $this->_response_array[39]; |
|
608 | + $this->account_number = $this->_response_array[50]; |
|
609 | + $this->card_type = $this->_response_array[51]; |
|
610 | + $this->split_tender_id = $this->_response_array[52]; |
|
611 | + $this->requested_amount = $this->_response_array[53]; |
|
612 | + $this->balance_on_card = $this->_response_array[54]; |
|
613 | + |
|
614 | + $this->approved = ($this->response_code === self::APPROVED); |
|
615 | + $this->declined = ($this->response_code === self::DECLINED); |
|
616 | + $this->error = ($this->response_code === self::ERROR); |
|
617 | + $this->held = ($this->response_code === self::HELD); |
|
618 | + } else { |
|
619 | + $this->approved = false; |
|
620 | + $this->error = true; |
|
621 | + $this->error_message = esc_html__( |
|
622 | + 'Error connecting to Authorize.net', |
|
623 | + 'event_espresso' |
|
624 | + ); |
|
625 | + } |
|
626 | + } |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | if (! class_exists('AuthorizeNetException')) { |
630 | - /** |
|
631 | - * Class AuthorizeNetException |
|
632 | - * |
|
633 | - * @package AuthorizeNet |
|
634 | - */ |
|
635 | - class AuthorizeNetException extends Exception |
|
636 | - { |
|
637 | - |
|
638 | - /** |
|
639 | - * Construct the exception. Note: The message is NOT binary safe. |
|
640 | - * |
|
641 | - * @link http://php.net/manual/en/exception.construct.php |
|
642 | - * @param string $message [optional] The Exception message to throw. |
|
643 | - * @param int $code [optional] The Exception code. |
|
644 | - * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0 |
|
645 | - * @since 5.1.0 |
|
646 | - */ |
|
647 | - public function __construct($message = "", $code = 0, Exception $previous = null) |
|
648 | - { |
|
649 | - parent::__construct($message, $code, $previous); |
|
650 | - } |
|
651 | - } |
|
630 | + /** |
|
631 | + * Class AuthorizeNetException |
|
632 | + * |
|
633 | + * @package AuthorizeNet |
|
634 | + */ |
|
635 | + class AuthorizeNetException extends Exception |
|
636 | + { |
|
637 | + |
|
638 | + /** |
|
639 | + * Construct the exception. Note: The message is NOT binary safe. |
|
640 | + * |
|
641 | + * @link http://php.net/manual/en/exception.construct.php |
|
642 | + * @param string $message [optional] The Exception message to throw. |
|
643 | + * @param int $code [optional] The Exception code. |
|
644 | + * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0 |
|
645 | + * @since 5.1.0 |
|
646 | + */ |
|
647 | + public function __construct($message = "", $code = 0, Exception $previous = null) |
|
648 | + { |
|
649 | + parent::__construct($message, $code, $previous); |
|
650 | + } |
|
651 | + } |
|
652 | 652 | } |
@@ -1,12 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -use EventEspresso\core\domain\DomainFactory; |
|
4 | -use EventEspresso\core\domain\values\FilePath; |
|
5 | -use EventEspresso\core\domain\values\FullyQualifiedName; |
|
6 | -use EventEspresso\core\domain\values\Version; |
|
7 | 3 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
8 | 4 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
9 | -use EventEspresso\core\services\loaders\LoaderFactory; |
|
10 | 5 | use EventEspresso\core\services\request\RequestDecoratorInterface; |
11 | 6 | use EventEspresso\core\services\request\RequestInterface; |
12 | 7 | use EventEspresso\core\services\request\RequestStackCoreAppInterface; |
@@ -27,114 +27,114 @@ |
||
27 | 27 | class EE_Load_Espresso_Core implements RequestDecoratorInterface, RequestStackCoreAppInterface |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * @var RequestInterface $request |
|
32 | - */ |
|
33 | - protected $request; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var ResponseInterface $response |
|
37 | - */ |
|
38 | - protected $response; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var EE_Dependency_Map $dependency_map |
|
42 | - */ |
|
43 | - protected $dependency_map; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var EE_Registry $registry |
|
47 | - */ |
|
48 | - protected $registry; |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * EE_Load_Espresso_Core constructor |
|
53 | - * |
|
54 | - * @param EE_Registry $registry |
|
55 | - * @param EE_Dependency_Map $dependency_map |
|
56 | - * @throws EE_Error |
|
57 | - */ |
|
58 | - public function __construct(EE_Registry $registry, EE_Dependency_Map $dependency_map) |
|
59 | - { |
|
60 | - EE_Error::doing_it_wrong( |
|
61 | - __METHOD__, |
|
62 | - sprintf( |
|
63 | - esc_html__( |
|
64 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
65 | - 'event_espresso' |
|
66 | - ), |
|
67 | - 'EventEspresso\core\services\request\RequestStackCoreApp', |
|
68 | - '\core\services\request', |
|
69 | - 'EventEspresso\core\services\request' |
|
70 | - ), |
|
71 | - '4.9.53' |
|
72 | - ); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * handle |
|
78 | - * sets hooks for running rest of system |
|
79 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
80 | - * starting EE Addons from any other point may lead to problems |
|
81 | - * |
|
82 | - * @param RequestInterface $request |
|
83 | - * @param ResponseInterface $response |
|
84 | - * @return ResponseInterface |
|
85 | - * @throws EE_Error |
|
86 | - * @throws InvalidDataTypeException |
|
87 | - * @throws InvalidInterfaceException |
|
88 | - * @throws InvalidArgumentException |
|
89 | - * @throws DomainException |
|
90 | - */ |
|
91 | - public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
92 | - { |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @return RequestInterface |
|
98 | - */ |
|
99 | - public function request() |
|
100 | - { |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * @return ResponseInterface |
|
106 | - */ |
|
107 | - public function response() |
|
108 | - { |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * @return EE_Dependency_Map |
|
114 | - * @throws EE_Error |
|
115 | - */ |
|
116 | - public function dependency_map() |
|
117 | - { |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * @return EE_Registry |
|
123 | - * @throws EE_Error |
|
124 | - */ |
|
125 | - public function registry() |
|
126 | - { |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * called after the request stack has been fully processed |
|
132 | - * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
133 | - * |
|
134 | - * @param RequestInterface $request |
|
135 | - * @param ResponseInterface $response |
|
136 | - */ |
|
137 | - public function handleResponse(RequestInterface $request, ResponseInterface $response) |
|
138 | - { |
|
139 | - } |
|
30 | + /** |
|
31 | + * @var RequestInterface $request |
|
32 | + */ |
|
33 | + protected $request; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var ResponseInterface $response |
|
37 | + */ |
|
38 | + protected $response; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var EE_Dependency_Map $dependency_map |
|
42 | + */ |
|
43 | + protected $dependency_map; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var EE_Registry $registry |
|
47 | + */ |
|
48 | + protected $registry; |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * EE_Load_Espresso_Core constructor |
|
53 | + * |
|
54 | + * @param EE_Registry $registry |
|
55 | + * @param EE_Dependency_Map $dependency_map |
|
56 | + * @throws EE_Error |
|
57 | + */ |
|
58 | + public function __construct(EE_Registry $registry, EE_Dependency_Map $dependency_map) |
|
59 | + { |
|
60 | + EE_Error::doing_it_wrong( |
|
61 | + __METHOD__, |
|
62 | + sprintf( |
|
63 | + esc_html__( |
|
64 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
65 | + 'event_espresso' |
|
66 | + ), |
|
67 | + 'EventEspresso\core\services\request\RequestStackCoreApp', |
|
68 | + '\core\services\request', |
|
69 | + 'EventEspresso\core\services\request' |
|
70 | + ), |
|
71 | + '4.9.53' |
|
72 | + ); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * handle |
|
78 | + * sets hooks for running rest of system |
|
79 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
80 | + * starting EE Addons from any other point may lead to problems |
|
81 | + * |
|
82 | + * @param RequestInterface $request |
|
83 | + * @param ResponseInterface $response |
|
84 | + * @return ResponseInterface |
|
85 | + * @throws EE_Error |
|
86 | + * @throws InvalidDataTypeException |
|
87 | + * @throws InvalidInterfaceException |
|
88 | + * @throws InvalidArgumentException |
|
89 | + * @throws DomainException |
|
90 | + */ |
|
91 | + public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
92 | + { |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @return RequestInterface |
|
98 | + */ |
|
99 | + public function request() |
|
100 | + { |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * @return ResponseInterface |
|
106 | + */ |
|
107 | + public function response() |
|
108 | + { |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * @return EE_Dependency_Map |
|
114 | + * @throws EE_Error |
|
115 | + */ |
|
116 | + public function dependency_map() |
|
117 | + { |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * @return EE_Registry |
|
123 | + * @throws EE_Error |
|
124 | + */ |
|
125 | + public function registry() |
|
126 | + { |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * called after the request stack has been fully processed |
|
132 | + * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
133 | + * |
|
134 | + * @param RequestInterface $request |
|
135 | + * @param ResponseInterface $response |
|
136 | + */ |
|
137 | + public function handleResponse(RequestInterface $request, ResponseInterface $response) |
|
138 | + { |
|
139 | + } |
|
140 | 140 | } |