@@ -12,125 +12,125 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class WPInv_Session_Handler extends WPInv_Session { |
14 | 14 | |
15 | - /** |
|
16 | - * Cookie name used for the session. |
|
17 | - * |
|
18 | - * @var string cookie name |
|
19 | - */ |
|
20 | - protected $_cookie; |
|
21 | - |
|
22 | - /** |
|
23 | - * Stores session expiry. |
|
24 | - * |
|
25 | - * @var string session due to expire timestamp |
|
26 | - */ |
|
27 | - protected $_session_expiring; |
|
28 | - |
|
29 | - /** |
|
30 | - * Stores session due to expire timestamp. |
|
31 | - * |
|
32 | - * @var string session expiration timestamp |
|
33 | - */ |
|
34 | - protected $_session_expiration; |
|
35 | - |
|
36 | - /** |
|
37 | - * True when the cookie exists. |
|
38 | - * |
|
39 | - * @var bool Based on whether a cookie exists. |
|
40 | - */ |
|
41 | - protected $_has_cookie = false; |
|
42 | - |
|
43 | - /** |
|
44 | - * Table name for session data. |
|
45 | - * |
|
46 | - * @var string Custom session table name |
|
47 | - */ |
|
48 | - protected $_table; |
|
49 | - |
|
50 | - /** |
|
51 | - * Constructor for the session class. |
|
52 | - */ |
|
53 | - public function __construct() { |
|
54 | - |
|
55 | - $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH ); |
|
15 | + /** |
|
16 | + * Cookie name used for the session. |
|
17 | + * |
|
18 | + * @var string cookie name |
|
19 | + */ |
|
20 | + protected $_cookie; |
|
21 | + |
|
22 | + /** |
|
23 | + * Stores session expiry. |
|
24 | + * |
|
25 | + * @var string session due to expire timestamp |
|
26 | + */ |
|
27 | + protected $_session_expiring; |
|
28 | + |
|
29 | + /** |
|
30 | + * Stores session due to expire timestamp. |
|
31 | + * |
|
32 | + * @var string session expiration timestamp |
|
33 | + */ |
|
34 | + protected $_session_expiration; |
|
35 | + |
|
36 | + /** |
|
37 | + * True when the cookie exists. |
|
38 | + * |
|
39 | + * @var bool Based on whether a cookie exists. |
|
40 | + */ |
|
41 | + protected $_has_cookie = false; |
|
42 | + |
|
43 | + /** |
|
44 | + * Table name for session data. |
|
45 | + * |
|
46 | + * @var string Custom session table name |
|
47 | + */ |
|
48 | + protected $_table; |
|
49 | + |
|
50 | + /** |
|
51 | + * Constructor for the session class. |
|
52 | + */ |
|
53 | + public function __construct() { |
|
54 | + |
|
55 | + $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH ); |
|
56 | 56 | add_action( 'init', array( $this, 'init' ), -1 ); |
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * Init hooks and session data. |
|
61 | - * |
|
62 | - * @since 3.3.0 |
|
63 | - */ |
|
64 | - public function init() { |
|
65 | - $this->init_session_cookie(); |
|
66 | - |
|
67 | - add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 ); |
|
68 | - add_action( 'shutdown', array( $this, 'save_data' ), 20 ); |
|
69 | - add_action( 'wp_logout', array( $this, 'destroy_session' ) ); |
|
70 | - |
|
71 | - if ( ! is_user_logged_in() ) { |
|
72 | - add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) ); |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Setup cookie and customer ID. |
|
78 | - * |
|
79 | - * @since 3.6.0 |
|
80 | - */ |
|
81 | - public function init_session_cookie() { |
|
82 | - $cookie = $this->get_session_cookie(); |
|
83 | - |
|
84 | - if ( $cookie ) { |
|
85 | - $this->_customer_id = $cookie[0]; |
|
86 | - $this->_session_expiration = $cookie[1]; |
|
87 | - $this->_session_expiring = $cookie[2]; |
|
88 | - $this->_has_cookie = true; |
|
89 | - $this->_data = $this->get_session_data(); |
|
90 | - |
|
91 | - // If the user logs in, update session. |
|
92 | - if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) { |
|
93 | - $this->_customer_id = get_current_user_id(); |
|
94 | - $this->_dirty = true; |
|
95 | - $this->save_data(); |
|
96 | - $this->set_customer_session_cookie( true ); |
|
97 | - } |
|
98 | - |
|
99 | - // Update session if its close to expiring. |
|
100 | - if ( time() > $this->_session_expiring ) { |
|
101 | - $this->set_session_expiration(); |
|
102 | - $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration ); |
|
103 | - } |
|
104 | - } else { |
|
105 | - $this->set_session_expiration(); |
|
106 | - $this->_customer_id = $this->generate_customer_id(); |
|
107 | - $this->_data = $this->get_session_data(); |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Sets the session cookie on-demand (usually after adding an item to the cart). |
|
113 | - * |
|
114 | - * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set. |
|
115 | - * |
|
116 | - * Warning: Cookies will only be set if this is called before the headers are sent. |
|
117 | - * |
|
118 | - * @param bool $set Should the session cookie be set. |
|
119 | - */ |
|
120 | - public function set_customer_session_cookie( $set ) { |
|
121 | - if ( $set ) { |
|
122 | - $to_hash = $this->_customer_id . '|' . $this->_session_expiration; |
|
123 | - $cookie_hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
124 | - $cookie_value = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash; |
|
125 | - $this->_has_cookie = true; |
|
126 | - |
|
127 | - if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) { |
|
128 | - $this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true ); |
|
129 | - } |
|
130 | - } |
|
131 | - } |
|
132 | - |
|
133 | - public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){ |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * Init hooks and session data. |
|
61 | + * |
|
62 | + * @since 3.3.0 |
|
63 | + */ |
|
64 | + public function init() { |
|
65 | + $this->init_session_cookie(); |
|
66 | + |
|
67 | + add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 ); |
|
68 | + add_action( 'shutdown', array( $this, 'save_data' ), 20 ); |
|
69 | + add_action( 'wp_logout', array( $this, 'destroy_session' ) ); |
|
70 | + |
|
71 | + if ( ! is_user_logged_in() ) { |
|
72 | + add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) ); |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Setup cookie and customer ID. |
|
78 | + * |
|
79 | + * @since 3.6.0 |
|
80 | + */ |
|
81 | + public function init_session_cookie() { |
|
82 | + $cookie = $this->get_session_cookie(); |
|
83 | + |
|
84 | + if ( $cookie ) { |
|
85 | + $this->_customer_id = $cookie[0]; |
|
86 | + $this->_session_expiration = $cookie[1]; |
|
87 | + $this->_session_expiring = $cookie[2]; |
|
88 | + $this->_has_cookie = true; |
|
89 | + $this->_data = $this->get_session_data(); |
|
90 | + |
|
91 | + // If the user logs in, update session. |
|
92 | + if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) { |
|
93 | + $this->_customer_id = get_current_user_id(); |
|
94 | + $this->_dirty = true; |
|
95 | + $this->save_data(); |
|
96 | + $this->set_customer_session_cookie( true ); |
|
97 | + } |
|
98 | + |
|
99 | + // Update session if its close to expiring. |
|
100 | + if ( time() > $this->_session_expiring ) { |
|
101 | + $this->set_session_expiration(); |
|
102 | + $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration ); |
|
103 | + } |
|
104 | + } else { |
|
105 | + $this->set_session_expiration(); |
|
106 | + $this->_customer_id = $this->generate_customer_id(); |
|
107 | + $this->_data = $this->get_session_data(); |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Sets the session cookie on-demand (usually after adding an item to the cart). |
|
113 | + * |
|
114 | + * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set. |
|
115 | + * |
|
116 | + * Warning: Cookies will only be set if this is called before the headers are sent. |
|
117 | + * |
|
118 | + * @param bool $set Should the session cookie be set. |
|
119 | + */ |
|
120 | + public function set_customer_session_cookie( $set ) { |
|
121 | + if ( $set ) { |
|
122 | + $to_hash = $this->_customer_id . '|' . $this->_session_expiration; |
|
123 | + $cookie_hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
124 | + $cookie_value = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash; |
|
125 | + $this->_has_cookie = true; |
|
126 | + |
|
127 | + if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) { |
|
128 | + $this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true ); |
|
129 | + } |
|
130 | + } |
|
131 | + } |
|
132 | + |
|
133 | + public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){ |
|
134 | 134 | if ( ! headers_sent() ) { |
135 | 135 | setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) ); |
136 | 136 | } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
@@ -139,96 +139,96 @@ discard block |
||
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | - /** |
|
143 | - * Should the session cookie be secure? |
|
144 | - * |
|
145 | - * @since 3.6.0 |
|
146 | - * @return bool |
|
147 | - */ |
|
148 | - protected function use_secure_cookie() { |
|
142 | + /** |
|
143 | + * Should the session cookie be secure? |
|
144 | + * |
|
145 | + * @since 3.6.0 |
|
146 | + * @return bool |
|
147 | + */ |
|
148 | + protected function use_secure_cookie() { |
|
149 | 149 | $is_https = false !== strstr( get_option( 'home' ), 'https:' ); |
150 | - return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() ); |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * Return true if the current user has an active session, i.e. a cookie to retrieve values. |
|
155 | - * |
|
156 | - * @return bool |
|
157 | - */ |
|
158 | - public function has_session() { |
|
159 | - return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine. |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * Set session expiration. |
|
164 | - */ |
|
165 | - public function set_session_expiration() { |
|
166 | - $this->_session_expiring = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours. |
|
167 | - $this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours. |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Generate a unique customer ID for guests, or return user ID if logged in. |
|
172 | - * |
|
173 | - * Uses Portable PHP password hashing framework to generate a unique cryptographically strong ID. |
|
174 | - * |
|
175 | - * @return string |
|
176 | - */ |
|
177 | - public function generate_customer_id() { |
|
178 | - $customer_id = ''; |
|
179 | - |
|
180 | - if ( is_user_logged_in() ) { |
|
181 | - $customer_id = get_current_user_id(); |
|
182 | - } |
|
183 | - |
|
184 | - if ( empty( $customer_id ) ) { |
|
150 | + return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() ); |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * Return true if the current user has an active session, i.e. a cookie to retrieve values. |
|
155 | + * |
|
156 | + * @return bool |
|
157 | + */ |
|
158 | + public function has_session() { |
|
159 | + return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine. |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * Set session expiration. |
|
164 | + */ |
|
165 | + public function set_session_expiration() { |
|
166 | + $this->_session_expiring = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours. |
|
167 | + $this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours. |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Generate a unique customer ID for guests, or return user ID if logged in. |
|
172 | + * |
|
173 | + * Uses Portable PHP password hashing framework to generate a unique cryptographically strong ID. |
|
174 | + * |
|
175 | + * @return string |
|
176 | + */ |
|
177 | + public function generate_customer_id() { |
|
178 | + $customer_id = ''; |
|
179 | + |
|
180 | + if ( is_user_logged_in() ) { |
|
181 | + $customer_id = get_current_user_id(); |
|
182 | + } |
|
183 | + |
|
184 | + if ( empty( $customer_id ) ) { |
|
185 | 185 | $customer_id = wp_create_nonce('wpinv-session-customer-id'); |
186 | - } |
|
187 | - |
|
188 | - return $customer_id; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Get the session cookie, if set. Otherwise return false. |
|
193 | - * |
|
194 | - * Session cookies without a customer ID are invalid. |
|
195 | - * |
|
196 | - * @return bool|array |
|
197 | - */ |
|
198 | - public function get_session_cookie() { |
|
199 | - $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine. |
|
200 | - |
|
201 | - if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) { |
|
202 | - return false; |
|
203 | - } |
|
204 | - |
|
205 | - list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value ); |
|
206 | - |
|
207 | - if ( empty( $customer_id ) ) { |
|
208 | - return false; |
|
209 | - } |
|
210 | - |
|
211 | - // Validate hash. |
|
212 | - $to_hash = $customer_id . '|' . $session_expiration; |
|
213 | - $hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
214 | - |
|
215 | - if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) { |
|
216 | - return false; |
|
217 | - } |
|
218 | - |
|
219 | - return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash ); |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * Get session data. |
|
224 | - * |
|
225 | - * @return array |
|
226 | - */ |
|
227 | - public function get_session_data() { |
|
228 | - return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array(); |
|
229 | - } |
|
230 | - |
|
231 | - public function generate_key($customer_id){ |
|
186 | + } |
|
187 | + |
|
188 | + return $customer_id; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Get the session cookie, if set. Otherwise return false. |
|
193 | + * |
|
194 | + * Session cookies without a customer ID are invalid. |
|
195 | + * |
|
196 | + * @return bool|array |
|
197 | + */ |
|
198 | + public function get_session_cookie() { |
|
199 | + $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine. |
|
200 | + |
|
201 | + if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) { |
|
202 | + return false; |
|
203 | + } |
|
204 | + |
|
205 | + list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value ); |
|
206 | + |
|
207 | + if ( empty( $customer_id ) ) { |
|
208 | + return false; |
|
209 | + } |
|
210 | + |
|
211 | + // Validate hash. |
|
212 | + $to_hash = $customer_id . '|' . $session_expiration; |
|
213 | + $hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
214 | + |
|
215 | + if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) { |
|
216 | + return false; |
|
217 | + } |
|
218 | + |
|
219 | + return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash ); |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * Get session data. |
|
224 | + * |
|
225 | + * @return array |
|
226 | + */ |
|
227 | + public function get_session_data() { |
|
228 | + return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array(); |
|
229 | + } |
|
230 | + |
|
231 | + public function generate_key($customer_id){ |
|
232 | 232 | if(!$customer_id){ |
233 | 233 | return; |
234 | 234 | } |
@@ -236,62 +236,62 @@ discard block |
||
236 | 236 | return 'wpi_trans_'.$customer_id; |
237 | 237 | } |
238 | 238 | |
239 | - /** |
|
240 | - * Save data. |
|
241 | - */ |
|
242 | - public function save_data() { |
|
243 | - // Dirty if something changed - prevents saving nothing new. |
|
244 | - if ( $this->_dirty && $this->has_session() ) { |
|
239 | + /** |
|
240 | + * Save data. |
|
241 | + */ |
|
242 | + public function save_data() { |
|
243 | + // Dirty if something changed - prevents saving nothing new. |
|
244 | + if ( $this->_dirty && $this->has_session() ) { |
|
245 | 245 | |
246 | 246 | set_transient( $this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration); |
247 | 247 | |
248 | - $this->_dirty = false; |
|
249 | - } |
|
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * Destroy all session data. |
|
254 | - */ |
|
255 | - public function destroy_session() { |
|
256 | - $this->delete_session( $this->_customer_id ); |
|
257 | - $this->forget_session(); |
|
258 | - } |
|
259 | - |
|
260 | - /** |
|
261 | - * Forget all session data without destroying it. |
|
262 | - */ |
|
263 | - public function forget_session() { |
|
264 | - $this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true ); |
|
265 | - |
|
266 | - wpinv_empty_cart(); |
|
267 | - |
|
268 | - $this->_data = array(); |
|
269 | - $this->_dirty = false; |
|
270 | - $this->_customer_id = $this->generate_customer_id(); |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * When a user is logged out, ensure they have a unique nonce by using the customer/session ID. |
|
275 | - * |
|
276 | - * @param int $uid User ID. |
|
277 | - * @return string |
|
278 | - */ |
|
279 | - public function nonce_user_logged_out( $uid ) { |
|
280 | - return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid; |
|
281 | - } |
|
282 | - |
|
283 | - /** |
|
284 | - * Returns the session. |
|
285 | - * |
|
286 | - * @param string $customer_id Customer ID. |
|
287 | - * @param mixed $default Default session value. |
|
288 | - * @return string|array |
|
289 | - */ |
|
290 | - public function get_session( $customer_id, $default = false ) { |
|
291 | - |
|
292 | - if ( defined( 'WP_SETUP_CONFIG' ) ) { |
|
293 | - return false; |
|
294 | - } |
|
248 | + $this->_dirty = false; |
|
249 | + } |
|
250 | + } |
|
251 | + |
|
252 | + /** |
|
253 | + * Destroy all session data. |
|
254 | + */ |
|
255 | + public function destroy_session() { |
|
256 | + $this->delete_session( $this->_customer_id ); |
|
257 | + $this->forget_session(); |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * Forget all session data without destroying it. |
|
262 | + */ |
|
263 | + public function forget_session() { |
|
264 | + $this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true ); |
|
265 | + |
|
266 | + wpinv_empty_cart(); |
|
267 | + |
|
268 | + $this->_data = array(); |
|
269 | + $this->_dirty = false; |
|
270 | + $this->_customer_id = $this->generate_customer_id(); |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * When a user is logged out, ensure they have a unique nonce by using the customer/session ID. |
|
275 | + * |
|
276 | + * @param int $uid User ID. |
|
277 | + * @return string |
|
278 | + */ |
|
279 | + public function nonce_user_logged_out( $uid ) { |
|
280 | + return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid; |
|
281 | + } |
|
282 | + |
|
283 | + /** |
|
284 | + * Returns the session. |
|
285 | + * |
|
286 | + * @param string $customer_id Customer ID. |
|
287 | + * @param mixed $default Default session value. |
|
288 | + * @return string|array |
|
289 | + */ |
|
290 | + public function get_session( $customer_id, $default = false ) { |
|
291 | + |
|
292 | + if ( defined( 'WP_SETUP_CONFIG' ) ) { |
|
293 | + return false; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | if ( !is_user_logged_in() ) { |
297 | 297 | if(!wp_verify_nonce( $customer_id, 'wpinv-session-customer-id' )){ |
@@ -306,32 +306,32 @@ discard block |
||
306 | 306 | $value = $default; |
307 | 307 | } |
308 | 308 | |
309 | - return maybe_unserialize( $value ); |
|
310 | - } |
|
309 | + return maybe_unserialize( $value ); |
|
310 | + } |
|
311 | 311 | |
312 | - /** |
|
313 | - * Delete the session from the cache and database. |
|
314 | - * |
|
315 | - * @param int $customer_id Customer ID. |
|
316 | - */ |
|
317 | - public function delete_session( $customer_id ) { |
|
312 | + /** |
|
313 | + * Delete the session from the cache and database. |
|
314 | + * |
|
315 | + * @param int $customer_id Customer ID. |
|
316 | + */ |
|
317 | + public function delete_session( $customer_id ) { |
|
318 | 318 | |
319 | 319 | $key = $this->generate_key($customer_id); |
320 | 320 | |
321 | - delete_transient($key); |
|
322 | - } |
|
321 | + delete_transient($key); |
|
322 | + } |
|
323 | 323 | |
324 | - /** |
|
325 | - * Update the session expiry timestamp. |
|
326 | - * |
|
327 | - * @param string $customer_id Customer ID. |
|
328 | - * @param int $timestamp Timestamp to expire the cookie. |
|
329 | - */ |
|
330 | - public function update_session_timestamp( $customer_id, $timestamp ) { |
|
324 | + /** |
|
325 | + * Update the session expiry timestamp. |
|
326 | + * |
|
327 | + * @param string $customer_id Customer ID. |
|
328 | + * @param int $timestamp Timestamp to expire the cookie. |
|
329 | + */ |
|
330 | + public function update_session_timestamp( $customer_id, $timestamp ) { |
|
331 | 331 | |
332 | 332 | set_transient( $this->generate_key($customer_id), maybe_serialize( $this->_data ), $timestamp); |
333 | 333 | |
334 | - } |
|
334 | + } |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | global $wpi_session; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | */ |
5 | 5 | |
6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
7 | - exit; |
|
7 | + exit; |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |
@@ -12,112 +12,112 @@ discard block |
||
12 | 12 | */ |
13 | 13 | abstract class WPInv_Session { |
14 | 14 | |
15 | - /** |
|
16 | - * Customer ID. |
|
17 | - * |
|
18 | - * @var int $_customer_id Customer ID. |
|
19 | - */ |
|
20 | - protected $_customer_id; |
|
15 | + /** |
|
16 | + * Customer ID. |
|
17 | + * |
|
18 | + * @var int $_customer_id Customer ID. |
|
19 | + */ |
|
20 | + protected $_customer_id; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Session Data. |
|
24 | - * |
|
25 | - * @var array $_data Data array. |
|
26 | - */ |
|
27 | - protected $_data = array(); |
|
22 | + /** |
|
23 | + * Session Data. |
|
24 | + * |
|
25 | + * @var array $_data Data array. |
|
26 | + */ |
|
27 | + protected $_data = array(); |
|
28 | 28 | |
29 | - /** |
|
30 | - * Dirty when the session needs saving. |
|
31 | - * |
|
32 | - * @var bool $_dirty When something changes |
|
33 | - */ |
|
34 | - protected $_dirty = false; |
|
29 | + /** |
|
30 | + * Dirty when the session needs saving. |
|
31 | + * |
|
32 | + * @var bool $_dirty When something changes |
|
33 | + */ |
|
34 | + protected $_dirty = false; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Init hooks and session data. Extended by child classes. |
|
38 | - * |
|
39 | - * @since 3.3.0 |
|
40 | - */ |
|
41 | - public function init() {} |
|
36 | + /** |
|
37 | + * Init hooks and session data. Extended by child classes. |
|
38 | + * |
|
39 | + * @since 3.3.0 |
|
40 | + */ |
|
41 | + public function init() {} |
|
42 | 42 | |
43 | - /** |
|
44 | - * Cleanup session data. Extended by child classes. |
|
45 | - */ |
|
46 | - public function cleanup_sessions() {} |
|
43 | + /** |
|
44 | + * Cleanup session data. Extended by child classes. |
|
45 | + */ |
|
46 | + public function cleanup_sessions() {} |
|
47 | 47 | |
48 | - /** |
|
49 | - * Magic get method. |
|
50 | - * |
|
51 | - * @param mixed $key Key to get. |
|
52 | - * @return mixed |
|
53 | - */ |
|
54 | - public function __get( $key ) { |
|
55 | - return $this->get( $key ); |
|
56 | - } |
|
48 | + /** |
|
49 | + * Magic get method. |
|
50 | + * |
|
51 | + * @param mixed $key Key to get. |
|
52 | + * @return mixed |
|
53 | + */ |
|
54 | + public function __get( $key ) { |
|
55 | + return $this->get( $key ); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Magic set method. |
|
60 | - * |
|
61 | - * @param mixed $key Key to set. |
|
62 | - * @param mixed $value Value to set. |
|
63 | - */ |
|
64 | - public function __set( $key, $value ) { |
|
65 | - $this->set( $key, $value ); |
|
66 | - } |
|
58 | + /** |
|
59 | + * Magic set method. |
|
60 | + * |
|
61 | + * @param mixed $key Key to set. |
|
62 | + * @param mixed $value Value to set. |
|
63 | + */ |
|
64 | + public function __set( $key, $value ) { |
|
65 | + $this->set( $key, $value ); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Magic isset method. |
|
70 | - * |
|
71 | - * @param mixed $key Key to check. |
|
72 | - * @return bool |
|
73 | - */ |
|
74 | - public function __isset( $key ) { |
|
75 | - return isset( $this->_data[ sanitize_title( $key ) ] ); |
|
76 | - } |
|
68 | + /** |
|
69 | + * Magic isset method. |
|
70 | + * |
|
71 | + * @param mixed $key Key to check. |
|
72 | + * @return bool |
|
73 | + */ |
|
74 | + public function __isset( $key ) { |
|
75 | + return isset( $this->_data[ sanitize_title( $key ) ] ); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Magic unset method. |
|
80 | - * |
|
81 | - * @param mixed $key Key to unset. |
|
82 | - */ |
|
83 | - public function __unset( $key ) { |
|
84 | - if ( isset( $this->_data[ $key ] ) ) { |
|
85 | - unset( $this->_data[ $key ] ); |
|
86 | - $this->_dirty = true; |
|
87 | - } |
|
88 | - } |
|
78 | + /** |
|
79 | + * Magic unset method. |
|
80 | + * |
|
81 | + * @param mixed $key Key to unset. |
|
82 | + */ |
|
83 | + public function __unset( $key ) { |
|
84 | + if ( isset( $this->_data[ $key ] ) ) { |
|
85 | + unset( $this->_data[ $key ] ); |
|
86 | + $this->_dirty = true; |
|
87 | + } |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Get a session variable. |
|
92 | - * |
|
93 | - * @param string $key Key to get. |
|
94 | - * @param mixed $default used if the session variable isn't set. |
|
95 | - * @return array|string value of session variable |
|
96 | - */ |
|
97 | - public function get( $key, $default = null ) { |
|
98 | - $key = sanitize_key( $key ); |
|
99 | - return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default; |
|
100 | - } |
|
90 | + /** |
|
91 | + * Get a session variable. |
|
92 | + * |
|
93 | + * @param string $key Key to get. |
|
94 | + * @param mixed $default used if the session variable isn't set. |
|
95 | + * @return array|string value of session variable |
|
96 | + */ |
|
97 | + public function get( $key, $default = null ) { |
|
98 | + $key = sanitize_key( $key ); |
|
99 | + return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default; |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Set a session variable. |
|
104 | - * |
|
105 | - * @param string $key Key to set. |
|
106 | - * @param mixed $value Value to set. |
|
107 | - */ |
|
108 | - public function set( $key, $value ) { |
|
109 | - if ( $value !== $this->get( $key ) ) { |
|
110 | - $this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value ); |
|
111 | - $this->_dirty = true; |
|
112 | - } |
|
113 | - } |
|
102 | + /** |
|
103 | + * Set a session variable. |
|
104 | + * |
|
105 | + * @param string $key Key to set. |
|
106 | + * @param mixed $value Value to set. |
|
107 | + */ |
|
108 | + public function set( $key, $value ) { |
|
109 | + if ( $value !== $this->get( $key ) ) { |
|
110 | + $this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value ); |
|
111 | + $this->_dirty = true; |
|
112 | + } |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Get customer ID. |
|
117 | - * |
|
118 | - * @return int |
|
119 | - */ |
|
120 | - public function get_customer_id() { |
|
121 | - return $this->_customer_id; |
|
122 | - } |
|
115 | + /** |
|
116 | + * Get customer ID. |
|
117 | + * |
|
118 | + * @return int |
|
119 | + */ |
|
120 | + public function get_customer_id() { |
|
121 | + return $this->_customer_id; |
|
122 | + } |
|
123 | 123 | } |
@@ -11,231 +11,231 @@ discard block |
||
11 | 11 | $this->method_title = '3-D Secure Payment Gateway by CardinalCommerce'; |
12 | 12 | |
13 | 13 | $this->currencies = array( |
14 | - 'ADP' => '020', |
|
15 | - 'AED' => '784', |
|
16 | - 'AFA' => '004', |
|
17 | - 'AFN' => '971', |
|
18 | - 'ALL' => '008', |
|
19 | - 'AMD' => '051', |
|
20 | - 'ANG' => '532', |
|
21 | - 'AOA' => '973', |
|
22 | - 'AON' => '024', |
|
23 | - 'ARS' => '032', |
|
24 | - 'ATS' => '040', |
|
25 | - 'AUD' => '036', |
|
26 | - 'AWG' => '533', |
|
27 | - 'AZM' => '031', |
|
28 | - 'AZN' => '944', |
|
29 | - 'BAM' => '977', |
|
30 | - 'BBD' => '052', |
|
31 | - 'BDT' => '050', |
|
32 | - 'BEF' => '056', |
|
33 | - 'BGL' => '100', |
|
34 | - 'BGN' => '975', |
|
35 | - 'BHD' => '048', |
|
36 | - 'BIF' => '108', |
|
37 | - 'BMD' => '060', |
|
38 | - 'BND' => '096', |
|
39 | - 'BOB' => '068', |
|
40 | - 'BOV' => '984', |
|
41 | - 'BRL' => '986', |
|
42 | - 'BSD' => '044', |
|
43 | - 'BTN' => '064', |
|
44 | - 'BWP' => '072', |
|
45 | - 'BYR' => '974', |
|
46 | - 'BZD' => '084', |
|
47 | - 'CAD' => '124', |
|
48 | - 'CDF' => '976', |
|
49 | - 'CHE' => '947', |
|
50 | - 'CHF' => '756', |
|
51 | - 'CHW' => '948', |
|
52 | - 'CLF' => '990', |
|
53 | - 'CLP' => '152', |
|
54 | - 'CNY' => '156', |
|
55 | - 'COP' => '170', |
|
56 | - 'COU' => '970', |
|
57 | - 'CRC' => '188', |
|
58 | - 'CSD' => '891', |
|
59 | - 'CUC' => '931', |
|
60 | - 'CUP' => '192', |
|
61 | - 'CVE' => '132', |
|
62 | - 'CYP' => '196', |
|
63 | - 'CZK' => '203', |
|
64 | - 'DEM' => '276', |
|
65 | - 'DJF' => '262', |
|
66 | - 'DKK' => '208', |
|
67 | - 'DOP' => '214', |
|
68 | - 'DZD' => '012', |
|
69 | - 'EEK' => '233', |
|
70 | - 'EGP' => '818', |
|
71 | - 'ERN' => '232', |
|
72 | - 'ESP' => '724', |
|
73 | - 'ETB' => '230', |
|
74 | - 'EUR' => '978', |
|
75 | - 'FIM' => '246', |
|
76 | - 'FJD' => '242', |
|
77 | - 'FKP' => '238', |
|
78 | - 'FRF' => '250', |
|
79 | - 'GBP' => '826', |
|
80 | - 'GEL' => '981', |
|
81 | - 'GHC' => '288', |
|
82 | - 'GHS' => '936', |
|
83 | - 'GIP' => '292', |
|
84 | - 'GMD' => '270', |
|
85 | - 'GNF' => '324', |
|
86 | - 'GTQ' => '320', |
|
87 | - 'GWP' => '624', |
|
88 | - 'GYD' => '328', |
|
89 | - 'HKD' => '344', |
|
90 | - 'HNL' => '340', |
|
91 | - 'HRK' => '191', |
|
92 | - 'HTG' => '332', |
|
93 | - 'HUF' => '348', |
|
94 | - 'IDR' => '360', |
|
95 | - 'IEP' => '372', |
|
96 | - 'ILS' => '376', |
|
97 | - 'INR' => '356', |
|
98 | - 'IQD' => '368', |
|
99 | - 'IRR' => '364', |
|
100 | - 'ISK' => '352', |
|
101 | - 'ITL' => '380', |
|
102 | - 'JMD' => '388', |
|
103 | - 'JOD' => '400', |
|
104 | - 'JPY' => '392', |
|
105 | - 'KES' => '404', |
|
106 | - 'KGS' => '417', |
|
107 | - 'KHR' => '116', |
|
108 | - 'KMF' => '174', |
|
109 | - 'KPW' => '408', |
|
110 | - 'KRW' => '410', |
|
111 | - 'KWD' => '414', |
|
112 | - 'KYD' => '136', |
|
113 | - 'KZT' => '398', |
|
114 | - 'LAK' => '418', |
|
115 | - 'LBP' => '422', |
|
116 | - 'LKR' => '144', |
|
117 | - 'LRD' => '430', |
|
118 | - 'LSL' => '426', |
|
119 | - 'LTL' => '440', |
|
120 | - 'LUF' => '442', |
|
121 | - 'LVL' => '428', |
|
122 | - 'LYD' => '434', |
|
123 | - 'MAD' => '504', |
|
124 | - 'MDL' => '498', |
|
125 | - 'MGA' => '969', |
|
126 | - 'MGF' => '450', |
|
127 | - 'MKD' => '807', |
|
128 | - 'MMK' => '104', |
|
129 | - 'MNT' => '496', |
|
130 | - 'MOP' => '446', |
|
131 | - 'MRO' => '478', |
|
132 | - 'MTL' => '470', |
|
133 | - 'MUR' => '480', |
|
134 | - 'MVR' => '462', |
|
135 | - 'MWK' => '454', |
|
136 | - 'MXN' => '484', |
|
137 | - 'MXV' => '979', |
|
138 | - 'MYR' => '458', |
|
139 | - 'MZM' => '508', |
|
140 | - 'MZN' => '943', |
|
141 | - 'NAD' => '516', |
|
142 | - 'NGN' => '566', |
|
143 | - 'NIO' => '558', |
|
144 | - 'NLG' => '528', |
|
145 | - 'NOK' => '578', |
|
146 | - 'NPR' => '524', |
|
147 | - 'NZD' => '554', |
|
148 | - 'OMR' => '512', |
|
149 | - 'PAB' => '590', |
|
150 | - 'PEN' => '604', |
|
151 | - 'PGK' => '598', |
|
152 | - 'PHP' => '608', |
|
153 | - 'PKR' => '586', |
|
154 | - 'PLN' => '985', |
|
155 | - 'PTE' => '620', |
|
156 | - 'PYG' => '600', |
|
157 | - 'QAR' => '634', |
|
158 | - 'ROL' => '642', |
|
159 | - 'RON' => '946', |
|
160 | - 'RSD' => '941', |
|
161 | - 'RUB' => '643', |
|
162 | - 'RUR' => '810', |
|
163 | - 'RWF' => '646', |
|
164 | - 'SAR' => '682', |
|
165 | - 'SBD' => '090', |
|
166 | - 'SCR' => '690', |
|
167 | - 'SDD' => '736', |
|
168 | - 'SDG' => '938', |
|
169 | - 'SEK' => '752', |
|
170 | - 'SGD' => '702', |
|
171 | - 'SHP' => '654', |
|
172 | - 'SIT' => '705', |
|
173 | - 'SKK' => '703', |
|
174 | - 'SLL' => '694', |
|
175 | - 'SOS' => '706', |
|
176 | - 'SRD' => '968', |
|
177 | - 'SRG' => '740', |
|
178 | - 'SSP' => '728', |
|
179 | - 'STD' => '678', |
|
180 | - 'SVC' => '222', |
|
181 | - 'SYP' => '760', |
|
182 | - 'SZL' => '748', |
|
183 | - 'THB' => '764', |
|
184 | - 'TJS' => '972', |
|
185 | - 'TMM' => '795', |
|
186 | - 'TMT' => '934', |
|
187 | - 'TND' => '788', |
|
188 | - 'TOP' => '776', |
|
189 | - 'TPE' => '626', |
|
190 | - 'TRL' => '792', |
|
191 | - 'TRY' => '949', |
|
192 | - 'TTD' => '780', |
|
193 | - 'TWD' => '901', |
|
194 | - 'TZS' => '834', |
|
195 | - 'UAH' => '980', |
|
196 | - 'UGX' => '800', |
|
197 | - 'USD' => '840', |
|
198 | - 'USN' => '997', |
|
199 | - 'UYI' => '940', |
|
200 | - 'UYU' => '858', |
|
201 | - 'UZS' => '860', |
|
202 | - 'VEB' => '862', |
|
203 | - 'VEF' => '937', |
|
204 | - 'VND' => '704', |
|
205 | - 'VUV' => '548', |
|
206 | - 'WST' => '882', |
|
207 | - 'XAF' => '950', |
|
208 | - 'XCD' => '951', |
|
209 | - 'XOF' => '952', |
|
210 | - 'XPF' => '953', |
|
211 | - 'XXX' => '999', |
|
212 | - 'YER' => '886', |
|
213 | - 'YUM' => '891', |
|
214 | - 'ZAR' => '710', |
|
215 | - 'ZMK' => '894', |
|
216 | - 'ZMW' => '967', |
|
217 | - 'ZWD' => '716', |
|
218 | - 'ZWL' => '932', |
|
14 | + 'ADP' => '020', |
|
15 | + 'AED' => '784', |
|
16 | + 'AFA' => '004', |
|
17 | + 'AFN' => '971', |
|
18 | + 'ALL' => '008', |
|
19 | + 'AMD' => '051', |
|
20 | + 'ANG' => '532', |
|
21 | + 'AOA' => '973', |
|
22 | + 'AON' => '024', |
|
23 | + 'ARS' => '032', |
|
24 | + 'ATS' => '040', |
|
25 | + 'AUD' => '036', |
|
26 | + 'AWG' => '533', |
|
27 | + 'AZM' => '031', |
|
28 | + 'AZN' => '944', |
|
29 | + 'BAM' => '977', |
|
30 | + 'BBD' => '052', |
|
31 | + 'BDT' => '050', |
|
32 | + 'BEF' => '056', |
|
33 | + 'BGL' => '100', |
|
34 | + 'BGN' => '975', |
|
35 | + 'BHD' => '048', |
|
36 | + 'BIF' => '108', |
|
37 | + 'BMD' => '060', |
|
38 | + 'BND' => '096', |
|
39 | + 'BOB' => '068', |
|
40 | + 'BOV' => '984', |
|
41 | + 'BRL' => '986', |
|
42 | + 'BSD' => '044', |
|
43 | + 'BTN' => '064', |
|
44 | + 'BWP' => '072', |
|
45 | + 'BYR' => '974', |
|
46 | + 'BZD' => '084', |
|
47 | + 'CAD' => '124', |
|
48 | + 'CDF' => '976', |
|
49 | + 'CHE' => '947', |
|
50 | + 'CHF' => '756', |
|
51 | + 'CHW' => '948', |
|
52 | + 'CLF' => '990', |
|
53 | + 'CLP' => '152', |
|
54 | + 'CNY' => '156', |
|
55 | + 'COP' => '170', |
|
56 | + 'COU' => '970', |
|
57 | + 'CRC' => '188', |
|
58 | + 'CSD' => '891', |
|
59 | + 'CUC' => '931', |
|
60 | + 'CUP' => '192', |
|
61 | + 'CVE' => '132', |
|
62 | + 'CYP' => '196', |
|
63 | + 'CZK' => '203', |
|
64 | + 'DEM' => '276', |
|
65 | + 'DJF' => '262', |
|
66 | + 'DKK' => '208', |
|
67 | + 'DOP' => '214', |
|
68 | + 'DZD' => '012', |
|
69 | + 'EEK' => '233', |
|
70 | + 'EGP' => '818', |
|
71 | + 'ERN' => '232', |
|
72 | + 'ESP' => '724', |
|
73 | + 'ETB' => '230', |
|
74 | + 'EUR' => '978', |
|
75 | + 'FIM' => '246', |
|
76 | + 'FJD' => '242', |
|
77 | + 'FKP' => '238', |
|
78 | + 'FRF' => '250', |
|
79 | + 'GBP' => '826', |
|
80 | + 'GEL' => '981', |
|
81 | + 'GHC' => '288', |
|
82 | + 'GHS' => '936', |
|
83 | + 'GIP' => '292', |
|
84 | + 'GMD' => '270', |
|
85 | + 'GNF' => '324', |
|
86 | + 'GTQ' => '320', |
|
87 | + 'GWP' => '624', |
|
88 | + 'GYD' => '328', |
|
89 | + 'HKD' => '344', |
|
90 | + 'HNL' => '340', |
|
91 | + 'HRK' => '191', |
|
92 | + 'HTG' => '332', |
|
93 | + 'HUF' => '348', |
|
94 | + 'IDR' => '360', |
|
95 | + 'IEP' => '372', |
|
96 | + 'ILS' => '376', |
|
97 | + 'INR' => '356', |
|
98 | + 'IQD' => '368', |
|
99 | + 'IRR' => '364', |
|
100 | + 'ISK' => '352', |
|
101 | + 'ITL' => '380', |
|
102 | + 'JMD' => '388', |
|
103 | + 'JOD' => '400', |
|
104 | + 'JPY' => '392', |
|
105 | + 'KES' => '404', |
|
106 | + 'KGS' => '417', |
|
107 | + 'KHR' => '116', |
|
108 | + 'KMF' => '174', |
|
109 | + 'KPW' => '408', |
|
110 | + 'KRW' => '410', |
|
111 | + 'KWD' => '414', |
|
112 | + 'KYD' => '136', |
|
113 | + 'KZT' => '398', |
|
114 | + 'LAK' => '418', |
|
115 | + 'LBP' => '422', |
|
116 | + 'LKR' => '144', |
|
117 | + 'LRD' => '430', |
|
118 | + 'LSL' => '426', |
|
119 | + 'LTL' => '440', |
|
120 | + 'LUF' => '442', |
|
121 | + 'LVL' => '428', |
|
122 | + 'LYD' => '434', |
|
123 | + 'MAD' => '504', |
|
124 | + 'MDL' => '498', |
|
125 | + 'MGA' => '969', |
|
126 | + 'MGF' => '450', |
|
127 | + 'MKD' => '807', |
|
128 | + 'MMK' => '104', |
|
129 | + 'MNT' => '496', |
|
130 | + 'MOP' => '446', |
|
131 | + 'MRO' => '478', |
|
132 | + 'MTL' => '470', |
|
133 | + 'MUR' => '480', |
|
134 | + 'MVR' => '462', |
|
135 | + 'MWK' => '454', |
|
136 | + 'MXN' => '484', |
|
137 | + 'MXV' => '979', |
|
138 | + 'MYR' => '458', |
|
139 | + 'MZM' => '508', |
|
140 | + 'MZN' => '943', |
|
141 | + 'NAD' => '516', |
|
142 | + 'NGN' => '566', |
|
143 | + 'NIO' => '558', |
|
144 | + 'NLG' => '528', |
|
145 | + 'NOK' => '578', |
|
146 | + 'NPR' => '524', |
|
147 | + 'NZD' => '554', |
|
148 | + 'OMR' => '512', |
|
149 | + 'PAB' => '590', |
|
150 | + 'PEN' => '604', |
|
151 | + 'PGK' => '598', |
|
152 | + 'PHP' => '608', |
|
153 | + 'PKR' => '586', |
|
154 | + 'PLN' => '985', |
|
155 | + 'PTE' => '620', |
|
156 | + 'PYG' => '600', |
|
157 | + 'QAR' => '634', |
|
158 | + 'ROL' => '642', |
|
159 | + 'RON' => '946', |
|
160 | + 'RSD' => '941', |
|
161 | + 'RUB' => '643', |
|
162 | + 'RUR' => '810', |
|
163 | + 'RWF' => '646', |
|
164 | + 'SAR' => '682', |
|
165 | + 'SBD' => '090', |
|
166 | + 'SCR' => '690', |
|
167 | + 'SDD' => '736', |
|
168 | + 'SDG' => '938', |
|
169 | + 'SEK' => '752', |
|
170 | + 'SGD' => '702', |
|
171 | + 'SHP' => '654', |
|
172 | + 'SIT' => '705', |
|
173 | + 'SKK' => '703', |
|
174 | + 'SLL' => '694', |
|
175 | + 'SOS' => '706', |
|
176 | + 'SRD' => '968', |
|
177 | + 'SRG' => '740', |
|
178 | + 'SSP' => '728', |
|
179 | + 'STD' => '678', |
|
180 | + 'SVC' => '222', |
|
181 | + 'SYP' => '760', |
|
182 | + 'SZL' => '748', |
|
183 | + 'THB' => '764', |
|
184 | + 'TJS' => '972', |
|
185 | + 'TMM' => '795', |
|
186 | + 'TMT' => '934', |
|
187 | + 'TND' => '788', |
|
188 | + 'TOP' => '776', |
|
189 | + 'TPE' => '626', |
|
190 | + 'TRL' => '792', |
|
191 | + 'TRY' => '949', |
|
192 | + 'TTD' => '780', |
|
193 | + 'TWD' => '901', |
|
194 | + 'TZS' => '834', |
|
195 | + 'UAH' => '980', |
|
196 | + 'UGX' => '800', |
|
197 | + 'USD' => '840', |
|
198 | + 'USN' => '997', |
|
199 | + 'UYI' => '940', |
|
200 | + 'UYU' => '858', |
|
201 | + 'UZS' => '860', |
|
202 | + 'VEB' => '862', |
|
203 | + 'VEF' => '937', |
|
204 | + 'VND' => '704', |
|
205 | + 'VUV' => '548', |
|
206 | + 'WST' => '882', |
|
207 | + 'XAF' => '950', |
|
208 | + 'XCD' => '951', |
|
209 | + 'XOF' => '952', |
|
210 | + 'XPF' => '953', |
|
211 | + 'XXX' => '999', |
|
212 | + 'YER' => '886', |
|
213 | + 'YUM' => '891', |
|
214 | + 'ZAR' => '710', |
|
215 | + 'ZMK' => '894', |
|
216 | + 'ZMW' => '967', |
|
217 | + 'ZWD' => '716', |
|
218 | + 'ZWL' => '932', |
|
219 | 219 | ); |
220 | 220 | |
221 | 221 | $this->instances = array( |
222 | - 'STAG' => 'centineltest.cardinalcommerce.com', |
|
223 | - 'CYBERSOURCE' => 'cybersource.cardinalcommerce.com', |
|
224 | - 'FIRSTDATA' => 'production.altpayfirstdata.com', |
|
225 | - 'FIRSTDATA_TEST' => 'test.altpayfirstdata.com', |
|
226 | - 'PAYMENTECH' => 'paymentech.cardinalcommerce.com', |
|
227 | - 'PAYPAL' => 'paypal.cardinalcommerce.com', |
|
228 | - '200' => 'centinel.cardinalcommerce.com', |
|
229 | - '300' => 'centinel300.cardinalcommerce.com', |
|
230 | - '400' => 'centinel400.cardinalcommerce.com', |
|
231 | - 'PROD' => 'centinel600.cardinalcommerce.com', |
|
232 | - '800' => 'centinel800.cardinalcommerce.com', |
|
233 | - '1000' => 'centinel1000.cardinalcommerce.com', |
|
234 | - '1200' => 'centinel1200.cardinalcommerce.com', |
|
222 | + 'STAG' => 'centineltest.cardinalcommerce.com', |
|
223 | + 'CYBERSOURCE' => 'cybersource.cardinalcommerce.com', |
|
224 | + 'FIRSTDATA' => 'production.altpayfirstdata.com', |
|
225 | + 'FIRSTDATA_TEST' => 'test.altpayfirstdata.com', |
|
226 | + 'PAYMENTECH' => 'paymentech.cardinalcommerce.com', |
|
227 | + 'PAYPAL' => 'paypal.cardinalcommerce.com', |
|
228 | + '200' => 'centinel.cardinalcommerce.com', |
|
229 | + '300' => 'centinel300.cardinalcommerce.com', |
|
230 | + '400' => 'centinel400.cardinalcommerce.com', |
|
231 | + 'PROD' => 'centinel600.cardinalcommerce.com', |
|
232 | + '800' => 'centinel800.cardinalcommerce.com', |
|
233 | + '1000' => 'centinel1000.cardinalcommerce.com', |
|
234 | + '1200' => 'centinel1200.cardinalcommerce.com', |
|
235 | 235 | ); |
236 | 236 | |
237 | - add_filter( 'wp_enqueue_scripts', array($this, 'register_scripts') ); |
|
238 | - add_filter( 'wpinv_purchase_form_before_submit', array($this, 'purchase_form_before_submit') ); |
|
237 | + add_filter( 'wp_enqueue_scripts', array($this, 'register_scripts') ); |
|
238 | + add_filter( 'wpinv_purchase_form_before_submit', array($this, 'purchase_form_before_submit') ); |
|
239 | 239 | |
240 | 240 | } |
241 | 241 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | wp_register_script( |
251 | 251 | 'cardinalcommerce-oneconnect', WPINV_PLUGIN_URL.'assets/js/cardinalcommerce-oneconnect.js', |
252 | 252 | array('jquery', 'cardinalcommerce-oneconnect-songbird'), |
253 | - WPINV_VERSION, true); |
|
253 | + WPINV_VERSION, true); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | private static function base64_encode_urlsafe($source) { |
@@ -323,10 +323,10 @@ discard block |
||
323 | 323 | |
324 | 324 | public function purchase_form_before_submit() { |
325 | 325 | wp_enqueue_script('cardinalcommerce-oneconnect'); |
326 | - $invoice = wpinv_get_invoice_cart(); |
|
327 | - $jwt = $this->generate_cruise_jwt($invoice); |
|
328 | - $this->hidden_input('CardinalOneConnectJWT', $jwt); |
|
329 | - $this->hidden_input('CardinalOneConnectLoggingLevel','verbose'); |
|
326 | + $invoice = wpinv_get_invoice_cart(); |
|
327 | + $jwt = $this->generate_cruise_jwt($invoice); |
|
328 | + $this->hidden_input('CardinalOneConnectJWT', $jwt); |
|
329 | + $this->hidden_input('CardinalOneConnectLoggingLevel','verbose'); |
|
330 | 330 | |
331 | 331 | $id = 'CardinalOneConnectResult'; |
332 | 332 | $merchant_content = 'Consumer Messaging'; |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | |
425 | 425 | public function reject_with_error($message, $permanent = false) { |
426 | 426 | wpinv_set_error('wpinv_error', "{$this->method_title}: {$message}"); |
427 | - wpinv_send_back_to_checkout( '?payment-mode=paypalpro' ); |
|
427 | + wpinv_send_back_to_checkout( '?payment-mode=paypalpro' ); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | public function order_add($invoice, $key, $value) { |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | } |
438 | 438 | |
439 | 439 | public function status_message($invoice, $message, $amount = null, |
440 | - $error = null) { |
|
440 | + $error = null) { |
|
441 | 441 | if (!$amount) { |
442 | 442 | $amount = $invoice->get_total(); |
443 | 443 | } |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | } |
451 | 451 | |
452 | 452 | public function process_payment( $invoice_id ) { |
453 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
453 | + $invoice = wpinv_get_invoice( $invoice_id ); |
|
454 | 454 | |
455 | 455 | $cruise_result_json = $_POST['CardinalOneConnectResult']; |
456 | 456 | if ( ! $cruise_result_json ) { |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | $this->reject_with_error('data and Payload ActionCode do not match'); |
501 | 501 | } |
502 | 502 | |
503 | - $invoiceid = $payload->AuthorizationProcessor->ProcessorOrderId; |
|
503 | + $invoiceid = $payload->AuthorizationProcessor->ProcessorOrderId; |
|
504 | 504 | $cca = $payload->Payment->ExtendedData; |
505 | 505 | $eci = isset($cca->ECIFlag) ? $cca->ECIFlag : ''; |
506 | 506 | $cavv = isset($cca->CAVV) ? $cca->CAVV : ''; |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | |
621 | 621 | public function create_request_order_object($invoice) { |
622 | 622 | $currency = $invoice->get_currency(); |
623 | - $currency_alpha = $this->currencies[$currency]; |
|
623 | + $currency_alpha = $this->currencies[$currency]; |
|
624 | 624 | $raw_amount = self::raw_amount($invoice->get_total(), $currency_alpha); |
625 | 625 | |
626 | 626 | $request_order_object = array( |