@@ -688,9 +688,9 @@ |
||
688 | 688 | $overdue_days_options[$i] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i ); |
689 | 689 | } |
690 | 690 | |
691 | - // Default, built-in gateways |
|
692 | - $emails = array( |
|
693 | - 'new_invoice' => array( |
|
691 | + // Default, built-in gateways |
|
692 | + $emails = array( |
|
693 | + 'new_invoice' => array( |
|
694 | 694 | 'email_new_invoice_header' => array( |
695 | 695 | 'id' => 'email_new_invoice_header', |
696 | 696 | 'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>', |
@@ -8,291 +8,291 @@ |
||
8 | 8 | * @since 1.0.0 |
9 | 9 | */ |
10 | 10 | class WPInv_Session { |
11 | - /** |
|
12 | - * Holds our session data. |
|
13 | - * |
|
14 | - * @var array |
|
15 | - * @access private |
|
16 | - * @since 1.0.0 |
|
17 | - */ |
|
18 | - private $session; |
|
19 | - |
|
20 | - /** |
|
21 | - * Whether to use PHP $_SESSION or WP_Session. |
|
22 | - * |
|
23 | - * @var bool |
|
24 | - * @access private |
|
25 | - * @since 1.0.0 |
|
26 | - */ |
|
27 | - private $use_php_sessions = false; |
|
28 | - |
|
29 | - /** |
|
30 | - * Session index prefix. |
|
31 | - * |
|
32 | - * @var string |
|
33 | - * @access private |
|
34 | - * @since 1.0.0 |
|
35 | - */ |
|
36 | - private $prefix = ''; |
|
37 | - |
|
38 | - /** |
|
39 | - * Get things started. |
|
40 | - * |
|
41 | - * Defines our WP_Session constants, includes the necessary libraries and |
|
42 | - * retrieves the WP Session instance. |
|
43 | - * |
|
44 | - * @since 1.0.0 |
|
45 | - */ |
|
46 | - public function __construct() { |
|
47 | - $this->use_php_sessions = $this->use_php_sessions(); |
|
48 | - |
|
49 | - if ( $this->use_php_sessions ) { |
|
50 | - if ( is_multisite() ) { |
|
51 | - $this->prefix = '_' . get_current_blog_id(); |
|
52 | - } |
|
53 | - |
|
54 | - // Use PHP SESSION (must be enabled via the WPINV_USE_PHP_SESSIONS constant) |
|
55 | - add_action( 'init', array( $this, 'maybe_start_session' ), -2 ); |
|
56 | - } else { |
|
57 | - // Use WP_Session (default) |
|
58 | - if ( !defined( 'WP_SESSION_COOKIE' ) ) { |
|
59 | - define( 'WP_SESSION_COOKIE', 'wpinv_wp_session' ); |
|
60 | - } |
|
61 | - |
|
62 | - if ( !class_exists( 'Recursive_ArrayAccess' ) ) { |
|
63 | - require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-recursive-arrayaccess.php'; |
|
64 | - } |
|
11 | + /** |
|
12 | + * Holds our session data. |
|
13 | + * |
|
14 | + * @var array |
|
15 | + * @access private |
|
16 | + * @since 1.0.0 |
|
17 | + */ |
|
18 | + private $session; |
|
19 | + |
|
20 | + /** |
|
21 | + * Whether to use PHP $_SESSION or WP_Session. |
|
22 | + * |
|
23 | + * @var bool |
|
24 | + * @access private |
|
25 | + * @since 1.0.0 |
|
26 | + */ |
|
27 | + private $use_php_sessions = false; |
|
28 | + |
|
29 | + /** |
|
30 | + * Session index prefix. |
|
31 | + * |
|
32 | + * @var string |
|
33 | + * @access private |
|
34 | + * @since 1.0.0 |
|
35 | + */ |
|
36 | + private $prefix = ''; |
|
37 | + |
|
38 | + /** |
|
39 | + * Get things started. |
|
40 | + * |
|
41 | + * Defines our WP_Session constants, includes the necessary libraries and |
|
42 | + * retrieves the WP Session instance. |
|
43 | + * |
|
44 | + * @since 1.0.0 |
|
45 | + */ |
|
46 | + public function __construct() { |
|
47 | + $this->use_php_sessions = $this->use_php_sessions(); |
|
48 | + |
|
49 | + if ( $this->use_php_sessions ) { |
|
50 | + if ( is_multisite() ) { |
|
51 | + $this->prefix = '_' . get_current_blog_id(); |
|
52 | + } |
|
53 | + |
|
54 | + // Use PHP SESSION (must be enabled via the WPINV_USE_PHP_SESSIONS constant) |
|
55 | + add_action( 'init', array( $this, 'maybe_start_session' ), -2 ); |
|
56 | + } else { |
|
57 | + // Use WP_Session (default) |
|
58 | + if ( !defined( 'WP_SESSION_COOKIE' ) ) { |
|
59 | + define( 'WP_SESSION_COOKIE', 'wpinv_wp_session' ); |
|
60 | + } |
|
61 | + |
|
62 | + if ( !class_exists( 'Recursive_ArrayAccess' ) ) { |
|
63 | + require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-recursive-arrayaccess.php'; |
|
64 | + } |
|
65 | 65 | |
66 | - if ( !class_exists( 'WP_Session_Utils' ) ) { |
|
67 | - require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session-utils.php'; |
|
68 | - } |
|
66 | + if ( !class_exists( 'WP_Session_Utils' ) ) { |
|
67 | + require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session-utils.php'; |
|
68 | + } |
|
69 | 69 | |
70 | - if ( defined( 'WP_CLI' ) && WP_CLI && !class_exists( 'WP_Session_Command' ) ) { |
|
71 | - require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-cli.php'; |
|
72 | - } |
|
73 | - |
|
74 | - if ( !class_exists( 'WP_Session' ) ) { |
|
75 | - require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session.php'; |
|
76 | - require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-session.php'; |
|
77 | - } |
|
78 | - |
|
79 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
80 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
81 | - } |
|
82 | - |
|
83 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
84 | - add_action( 'plugins_loaded', array( $this, 'init' ), -1 ); |
|
85 | - } else { |
|
86 | - add_action( 'init', array( $this, 'init' ), -1 ); |
|
87 | - } |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Setup the WP_Session instance. |
|
92 | - * |
|
93 | - * @access public |
|
94 | - * @since 1.0.0 |
|
95 | - * @return void |
|
96 | - */ |
|
97 | - public function init() { |
|
98 | - if ( $this->use_php_sessions ) { |
|
99 | - $this->session = isset( $_SESSION['wpi' . $this->prefix ] ) && is_array( $_SESSION['wpi' . $this->prefix ] ) ? $_SESSION['wpi' . $this->prefix ] : array(); |
|
100 | - } else { |
|
101 | - $this->session = WP_Session::get_instance(); |
|
102 | - } |
|
103 | - |
|
104 | - return $this->session; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Retrieve session ID. |
|
109 | - * |
|
110 | - * @access public |
|
111 | - * @since 1.0.0 |
|
112 | - * @return string Session ID |
|
113 | - */ |
|
114 | - public function get_id() { |
|
115 | - if ( $this->use_php_sessions ) { |
|
116 | - $session_id = !empty( $_SESSION ) && function_exists( 'session_id' ) ? session_id() : NULL; |
|
117 | - } else { |
|
118 | - $session_id = !empty( $this->session ) && isset( $this->session->session_id ) ? $this->session->session_id : NULL; |
|
119 | - } |
|
120 | - return $session_id; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Retrieve a session variable. |
|
125 | - * |
|
126 | - * @access public |
|
127 | - * @since 1.0.0 |
|
128 | - * @param string $key Session key |
|
129 | - * @return string Session variable |
|
130 | - */ |
|
131 | - public function get( $key ) { |
|
132 | - $key = sanitize_key( $key ); |
|
133 | - return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Set a session variable |
|
138 | - * |
|
139 | - * @since 1.0.0 |
|
140 | - * |
|
141 | - * @param string $key Session key |
|
142 | - * @param integer $value Session variable |
|
143 | - * @return string Session variable |
|
144 | - */ |
|
145 | - public function set( $key, $value ) { |
|
146 | - $key = sanitize_key( $key ); |
|
147 | - |
|
148 | - if ( is_array( $value ) ) { |
|
149 | - $this->session[ $key ] = maybe_serialize( $value ); |
|
150 | - } else { |
|
151 | - $this->session[ $key ] = $value; |
|
152 | - } |
|
153 | - |
|
154 | - if ( $this->use_php_sessions ) { |
|
155 | - $_SESSION['wpi' . $this->prefix ] = $this->session; |
|
156 | - } |
|
157 | - |
|
158 | - return $this->session[ $key ]; |
|
159 | - } |
|
70 | + if ( defined( 'WP_CLI' ) && WP_CLI && !class_exists( 'WP_Session_Command' ) ) { |
|
71 | + require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-cli.php'; |
|
72 | + } |
|
73 | + |
|
74 | + if ( !class_exists( 'WP_Session' ) ) { |
|
75 | + require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session.php'; |
|
76 | + require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-session.php'; |
|
77 | + } |
|
78 | + |
|
79 | + add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
80 | + add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
81 | + } |
|
82 | + |
|
83 | + if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
84 | + add_action( 'plugins_loaded', array( $this, 'init' ), -1 ); |
|
85 | + } else { |
|
86 | + add_action( 'init', array( $this, 'init' ), -1 ); |
|
87 | + } |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Setup the WP_Session instance. |
|
92 | + * |
|
93 | + * @access public |
|
94 | + * @since 1.0.0 |
|
95 | + * @return void |
|
96 | + */ |
|
97 | + public function init() { |
|
98 | + if ( $this->use_php_sessions ) { |
|
99 | + $this->session = isset( $_SESSION['wpi' . $this->prefix ] ) && is_array( $_SESSION['wpi' . $this->prefix ] ) ? $_SESSION['wpi' . $this->prefix ] : array(); |
|
100 | + } else { |
|
101 | + $this->session = WP_Session::get_instance(); |
|
102 | + } |
|
103 | + |
|
104 | + return $this->session; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Retrieve session ID. |
|
109 | + * |
|
110 | + * @access public |
|
111 | + * @since 1.0.0 |
|
112 | + * @return string Session ID |
|
113 | + */ |
|
114 | + public function get_id() { |
|
115 | + if ( $this->use_php_sessions ) { |
|
116 | + $session_id = !empty( $_SESSION ) && function_exists( 'session_id' ) ? session_id() : NULL; |
|
117 | + } else { |
|
118 | + $session_id = !empty( $this->session ) && isset( $this->session->session_id ) ? $this->session->session_id : NULL; |
|
119 | + } |
|
120 | + return $session_id; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Retrieve a session variable. |
|
125 | + * |
|
126 | + * @access public |
|
127 | + * @since 1.0.0 |
|
128 | + * @param string $key Session key |
|
129 | + * @return string Session variable |
|
130 | + */ |
|
131 | + public function get( $key ) { |
|
132 | + $key = sanitize_key( $key ); |
|
133 | + return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Set a session variable |
|
138 | + * |
|
139 | + * @since 1.0.0 |
|
140 | + * |
|
141 | + * @param string $key Session key |
|
142 | + * @param integer $value Session variable |
|
143 | + * @return string Session variable |
|
144 | + */ |
|
145 | + public function set( $key, $value ) { |
|
146 | + $key = sanitize_key( $key ); |
|
147 | + |
|
148 | + if ( is_array( $value ) ) { |
|
149 | + $this->session[ $key ] = maybe_serialize( $value ); |
|
150 | + } else { |
|
151 | + $this->session[ $key ] = $value; |
|
152 | + } |
|
153 | + |
|
154 | + if ( $this->use_php_sessions ) { |
|
155 | + $_SESSION['wpi' . $this->prefix ] = $this->session; |
|
156 | + } |
|
157 | + |
|
158 | + return $this->session[ $key ]; |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * Unset a session variable. |
|
163 | - * |
|
164 | - * @since 1.0.0 |
|
165 | - * |
|
166 | - * @param string|array $key Session key. |
|
167 | - * @param integer $value Session variable. |
|
168 | - * @return string Session variable. |
|
169 | - */ |
|
170 | - public function un_set( $key ) { |
|
171 | - if ( empty( $key ) ) { |
|
172 | - return false; |
|
173 | - } |
|
161 | + /** |
|
162 | + * Unset a session variable. |
|
163 | + * |
|
164 | + * @since 1.0.0 |
|
165 | + * |
|
166 | + * @param string|array $key Session key. |
|
167 | + * @param integer $value Session variable. |
|
168 | + * @return string Session variable. |
|
169 | + */ |
|
170 | + public function un_set( $key ) { |
|
171 | + if ( empty( $key ) ) { |
|
172 | + return false; |
|
173 | + } |
|
174 | 174 | |
175 | - if ( is_array( $key ) ) { |
|
176 | - foreach ($key as $index) { |
|
177 | - $index = sanitize_key( $index ); |
|
175 | + if ( is_array( $key ) ) { |
|
176 | + foreach ($key as $index) { |
|
177 | + $index = sanitize_key( $index ); |
|
178 | 178 | |
179 | - if ( $index && isset( $this->session[ $index ] ) ) { |
|
180 | - unset( $this->session[ $index ] ); |
|
181 | - } |
|
182 | - } |
|
183 | - } else { |
|
184 | - $key = sanitize_key( $key ); |
|
179 | + if ( $index && isset( $this->session[ $index ] ) ) { |
|
180 | + unset( $this->session[ $index ] ); |
|
181 | + } |
|
182 | + } |
|
183 | + } else { |
|
184 | + $key = sanitize_key( $key ); |
|
185 | 185 | |
186 | - if ( isset( $this->session[ $key ] ) ) { |
|
187 | - unset( $this->session[ $key ] ); |
|
188 | - } |
|
189 | - } |
|
186 | + if ( isset( $this->session[ $key ] ) ) { |
|
187 | + unset( $this->session[ $key ] ); |
|
188 | + } |
|
189 | + } |
|
190 | 190 | |
191 | - if ( $this->use_php_sessions ) { |
|
192 | - $_SESSION['wpi' . $this->prefix ] = $this->session; |
|
193 | - } |
|
191 | + if ( $this->use_php_sessions ) { |
|
192 | + $_SESSION['wpi' . $this->prefix ] = $this->session; |
|
193 | + } |
|
194 | 194 | |
195 | - return true; |
|
196 | - } |
|
195 | + return true; |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * Check a session variable is set or not. |
|
200 | - * |
|
201 | - * @since 1.0.0 |
|
202 | - * |
|
203 | - * @param string $key Session key. |
|
204 | - * @param integer $value Session variable. |
|
205 | - * @return string Session variable. |
|
206 | - */ |
|
207 | - public function is_set( $key ) { |
|
208 | - $key = sanitize_key( $key ); |
|
198 | + /** |
|
199 | + * Check a session variable is set or not. |
|
200 | + * |
|
201 | + * @since 1.0.0 |
|
202 | + * |
|
203 | + * @param string $key Session key. |
|
204 | + * @param integer $value Session variable. |
|
205 | + * @return string Session variable. |
|
206 | + */ |
|
207 | + public function is_set( $key ) { |
|
208 | + $key = sanitize_key( $key ); |
|
209 | 209 | |
210 | - if ( empty( $key ) ) { |
|
211 | - return false; |
|
212 | - } |
|
213 | - |
|
214 | - if ( isset( $this->session[ $key ] ) ) { |
|
215 | - return true; |
|
216 | - } |
|
217 | - |
|
218 | - return false; |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * Force the cookie expiration variant time to 23 hours |
|
223 | - * |
|
224 | - * @access public |
|
225 | - * @since 1.0.0 |
|
226 | - * @param int $exp Default expiration (1 hour) |
|
227 | - * @return int |
|
228 | - */ |
|
229 | - public function set_expiration_variant_time( $exp ) { |
|
230 | - return ( 30 * 60 * 23 ); |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * Force the cookie expiration time to 24 hours |
|
235 | - * |
|
236 | - * @access public |
|
237 | - * @since 1.0.0 |
|
238 | - * @param int $exp Default expiration (1 hour) |
|
239 | - * @return int |
|
240 | - */ |
|
241 | - public function set_expiration_time( $exp ) { |
|
242 | - return ( 30 * 60 * 24 ); |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * Starts a new session if one hasn't started yet. |
|
247 | - * |
|
248 | - * @return boolean |
|
249 | - * Checks to see if the server supports PHP sessions |
|
250 | - * or if the WPINV_USE_PHP_SESSIONS constant is defined |
|
251 | - * |
|
252 | - * @access public |
|
253 | - * @since 1.0.0 |
|
254 | - * @return boolean $ret True if we are using PHP sessions, false otherwise |
|
255 | - */ |
|
256 | - public function use_php_sessions() { |
|
257 | - $ret = false; |
|
258 | - |
|
259 | - // If the database variable is already set, no need to run autodetection |
|
260 | - $wpinv_use_php_sessions = (bool)get_option( 'wpinv_use_php_sessions' ); |
|
261 | - |
|
262 | - if (!$wpinv_use_php_sessions ) { |
|
263 | - // Attempt to detect if the server supports PHP sessions |
|
264 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
265 | - $this->set( 'wpinv_use_php_sessions', 1 ); |
|
210 | + if ( empty( $key ) ) { |
|
211 | + return false; |
|
212 | + } |
|
213 | + |
|
214 | + if ( isset( $this->session[ $key ] ) ) { |
|
215 | + return true; |
|
216 | + } |
|
217 | + |
|
218 | + return false; |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * Force the cookie expiration variant time to 23 hours |
|
223 | + * |
|
224 | + * @access public |
|
225 | + * @since 1.0.0 |
|
226 | + * @param int $exp Default expiration (1 hour) |
|
227 | + * @return int |
|
228 | + */ |
|
229 | + public function set_expiration_variant_time( $exp ) { |
|
230 | + return ( 30 * 60 * 23 ); |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * Force the cookie expiration time to 24 hours |
|
235 | + * |
|
236 | + * @access public |
|
237 | + * @since 1.0.0 |
|
238 | + * @param int $exp Default expiration (1 hour) |
|
239 | + * @return int |
|
240 | + */ |
|
241 | + public function set_expiration_time( $exp ) { |
|
242 | + return ( 30 * 60 * 24 ); |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * Starts a new session if one hasn't started yet. |
|
247 | + * |
|
248 | + * @return boolean |
|
249 | + * Checks to see if the server supports PHP sessions |
|
250 | + * or if the WPINV_USE_PHP_SESSIONS constant is defined |
|
251 | + * |
|
252 | + * @access public |
|
253 | + * @since 1.0.0 |
|
254 | + * @return boolean $ret True if we are using PHP sessions, false otherwise |
|
255 | + */ |
|
256 | + public function use_php_sessions() { |
|
257 | + $ret = false; |
|
258 | + |
|
259 | + // If the database variable is already set, no need to run autodetection |
|
260 | + $wpinv_use_php_sessions = (bool)get_option( 'wpinv_use_php_sessions' ); |
|
261 | + |
|
262 | + if (!$wpinv_use_php_sessions ) { |
|
263 | + // Attempt to detect if the server supports PHP sessions |
|
264 | + if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
265 | + $this->set( 'wpinv_use_php_sessions', 1 ); |
|
266 | 266 | |
267 | - if ( $this->get( 'wpinv_use_php_sessions' ) ) { |
|
268 | - $ret = true; |
|
269 | - |
|
270 | - // Set the database option |
|
271 | - update_option( 'wpinv_use_php_sessions', true ); |
|
272 | - } |
|
273 | - } |
|
274 | - } else { |
|
275 | - $ret = $wpinv_use_php_sessions; |
|
276 | - } |
|
277 | - |
|
278 | - // Enable or disable PHP Sessions based on the WPINV_USE_PHP_SESSIONS constant |
|
279 | - if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && WPINV_USE_PHP_SESSIONS ) { |
|
280 | - $ret = true; |
|
281 | - } else if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && ! WPINV_USE_PHP_SESSIONS ) { |
|
282 | - $ret = false; |
|
283 | - } |
|
284 | - |
|
285 | - return (bool) apply_filters( 'wpinv_use_php_sessions', $ret ); |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Starts a new session if one hasn't started yet. |
|
290 | - */ |
|
291 | - public function maybe_start_session() { |
|
292 | - if ( !session_id() && !headers_sent() ) { |
|
293 | - session_start(); |
|
294 | - } |
|
295 | - } |
|
267 | + if ( $this->get( 'wpinv_use_php_sessions' ) ) { |
|
268 | + $ret = true; |
|
269 | + |
|
270 | + // Set the database option |
|
271 | + update_option( 'wpinv_use_php_sessions', true ); |
|
272 | + } |
|
273 | + } |
|
274 | + } else { |
|
275 | + $ret = $wpinv_use_php_sessions; |
|
276 | + } |
|
277 | + |
|
278 | + // Enable or disable PHP Sessions based on the WPINV_USE_PHP_SESSIONS constant |
|
279 | + if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && WPINV_USE_PHP_SESSIONS ) { |
|
280 | + $ret = true; |
|
281 | + } else if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && ! WPINV_USE_PHP_SESSIONS ) { |
|
282 | + $ret = false; |
|
283 | + } |
|
284 | + |
|
285 | + return (bool) apply_filters( 'wpinv_use_php_sessions', $ret ); |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Starts a new session if one hasn't started yet. |
|
290 | + */ |
|
291 | + public function maybe_start_session() { |
|
292 | + if ( !session_id() && !headers_sent() ) { |
|
293 | + session_start(); |
|
294 | + } |
|
295 | + } |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | global $wpi_session; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | const EXCEPTION_CURL = 10; |
41 | 41 | |
42 | 42 | private $ch; |
43 | - private $login; |
|
43 | + private $login; |
|
44 | 44 | private $response; |
45 | 45 | private $response_xml; |
46 | 46 | private $results; |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | private $url; |
49 | 49 | private $xml; |
50 | 50 | |
51 | - public function __construct($login, $transkey, $test = self::USE_PRODUCTION_SERVER) |
|
52 | - { |
|
53 | - $login = trim($login); |
|
51 | + public function __construct($login, $transkey, $test = self::USE_PRODUCTION_SERVER) |
|
52 | + { |
|
53 | + $login = trim($login); |
|
54 | 54 | $transkey = trim($transkey); |
55 | 55 | if (empty($login) || empty($transkey)) |
56 | 56 | { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | $subdomain = ($test) ? 'apitest' : 'api'; |
65 | 65 | $this->url = 'https://' . $subdomain . '.authorize.net/xml/v1/request.api'; |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * remove XML response namespaces |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | return str_replace(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"','',$input); |
79 | 79 | } |
80 | 80 | |
81 | - public function __toString() |
|
82 | - { |
|
83 | - $output = ''; |
|
81 | + public function __toString() |
|
82 | + { |
|
83 | + $output = ''; |
|
84 | 84 | $output .= '<table summary="Authorize.Net Results" id="authnet">' . "\n"; |
85 | 85 | $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Class Parameters</b></th>' . "\n" . '</tr>' . "\n"; |
86 | 86 | $output .= '<tr>' . "\n\t\t" . '<td><b>API Login ID</b></td><td>' . $this->login . '</td>' . "\n" . '</tr>' . "\n"; |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | $output .= '</table>'; |
118 | 118 | |
119 | 119 | return $output; |
120 | - } |
|
120 | + } |
|
121 | 121 | |
122 | - public function __destruct() |
|
122 | + public function __destruct() |
|
123 | 123 | { |
124 | 124 | if (isset($this->ch)) |
125 | 125 | { |
@@ -128,31 +128,31 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | public function __get($var) |
131 | - { |
|
132 | - return $this->response_xml->$var; |
|
133 | - } |
|
134 | - |
|
135 | - public function __set($key, $value) |
|
136 | - { |
|
137 | - trigger_error('You cannot set parameters directly in ' . __CLASS__ . '.', E_USER_WARNING); |
|
138 | - return false; |
|
139 | - } |
|
140 | - |
|
141 | - public function __call($api_call, $args) |
|
142 | - { |
|
143 | - $this->xml = new SimpleXMLElement('<' . $api_call . '></' . $api_call . '>'); |
|
131 | + { |
|
132 | + return $this->response_xml->$var; |
|
133 | + } |
|
134 | + |
|
135 | + public function __set($key, $value) |
|
136 | + { |
|
137 | + trigger_error('You cannot set parameters directly in ' . __CLASS__ . '.', E_USER_WARNING); |
|
138 | + return false; |
|
139 | + } |
|
140 | + |
|
141 | + public function __call($api_call, $args) |
|
142 | + { |
|
143 | + $this->xml = new SimpleXMLElement('<' . $api_call . '></' . $api_call . '>'); |
|
144 | 144 | $this->xml->addAttribute('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'); |
145 | - $merch_auth = $this->xml->addChild('merchantAuthentication'); |
|
145 | + $merch_auth = $this->xml->addChild('merchantAuthentication'); |
|
146 | 146 | $merch_auth->addChild('name', $this->login); |
147 | - $merch_auth->addChild('transactionKey', $this->transkey); |
|
147 | + $merch_auth->addChild('transactionKey', $this->transkey); |
|
148 | 148 | |
149 | - $this->setParameters($this->xml, $args[0]); |
|
150 | - $this->process(); |
|
151 | - } |
|
149 | + $this->setParameters($this->xml, $args[0]); |
|
150 | + $this->process(); |
|
151 | + } |
|
152 | 152 | |
153 | - private function setParameters($xml, $array) |
|
154 | - { |
|
155 | - if (is_array($array)) |
|
153 | + private function setParameters($xml, $array) |
|
154 | + { |
|
155 | + if (is_array($array)) |
|
156 | 156 | { |
157 | 157 | $first = true; |
158 | 158 | foreach ($array as $key => $value) |
@@ -184,34 +184,34 @@ discard block |
||
184 | 184 | } |
185 | 185 | } |
186 | 186 | } |
187 | - } |
|
187 | + } |
|
188 | 188 | |
189 | - private function process() |
|
190 | - { |
|
191 | - $this->xml = $this->xml->asXML(); |
|
189 | + private function process() |
|
190 | + { |
|
191 | + $this->xml = $this->xml->asXML(); |
|
192 | 192 | |
193 | - $this->ch = curl_init(); |
|
193 | + $this->ch = curl_init(); |
|
194 | 194 | curl_setopt($this->ch, CURLOPT_URL, $this->url); |
195 | - curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); |
|
196 | - curl_setopt($this->ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); |
|
197 | - curl_setopt($this->ch, CURLOPT_HEADER, 0); |
|
198 | - curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->xml); |
|
199 | - curl_setopt($this->ch, CURLOPT_POST, 1); |
|
200 | - curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 2); |
|
201 | - curl_setopt($this->ch, CURLOPT_CAINFO, dirname(__FILE__) . '/ssl/cert.pem'); |
|
195 | + curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); |
|
196 | + curl_setopt($this->ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); |
|
197 | + curl_setopt($this->ch, CURLOPT_HEADER, 0); |
|
198 | + curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->xml); |
|
199 | + curl_setopt($this->ch, CURLOPT_POST, 1); |
|
200 | + curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 2); |
|
201 | + curl_setopt($this->ch, CURLOPT_CAINFO, dirname(__FILE__) . '/ssl/cert.pem'); |
|
202 | 202 | |
203 | 203 | if(($this->response = curl_exec($this->ch)) !== false) |
204 | 204 | { |
205 | 205 | $this->response_xml = @new SimpleXMLElement($this->response); |
206 | 206 | |
207 | - curl_close($this->ch); |
|
207 | + curl_close($this->ch); |
|
208 | 208 | unset($this->ch); |
209 | 209 | return; |
210 | - } |
|
210 | + } |
|
211 | 211 | throw new AuthnetXMLException('Connection error: ' . curl_error($this->ch) . ' (' . curl_errno($this->ch) . ')', self::EXCEPTION_CURL); |
212 | - } |
|
212 | + } |
|
213 | 213 | |
214 | - public function isSuccessful() |
|
214 | + public function isSuccessful() |
|
215 | 215 | { |
216 | 216 | return $this->response_xml->messages->resultCode == 'Ok'; |
217 | 217 | } |
@@ -91,13 +91,13 @@ |
||
91 | 91 | return $this->_sendRequest(); |
92 | 92 | } |
93 | 93 | |
94 | - /** |
|
95 | - * |
|
96 | - * |
|
97 | - * @param string $response |
|
98 | - * |
|
99 | - * @return AuthorizeNetARB_Response |
|
100 | - */ |
|
94 | + /** |
|
95 | + * |
|
96 | + * |
|
97 | + * @param string $response |
|
98 | + * |
|
99 | + * @return AuthorizeNetARB_Response |
|
100 | + */ |
|
101 | 101 | protected function _handleResponse($response) |
102 | 102 | { |
103 | 103 | return new AuthorizeNetARB_Response($response); |
@@ -316,9 +316,9 @@ |
||
316 | 316 | return $this->_sendRequest(); |
317 | 317 | } |
318 | 318 | |
319 | - /** |
|
320 | - * @return string |
|
321 | - */ |
|
319 | + /** |
|
320 | + * @return string |
|
321 | + */ |
|
322 | 322 | protected function _getPostUrl() |
323 | 323 | { |
324 | 324 | return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL); |
@@ -76,7 +76,7 @@ |
||
76 | 76 | } |
77 | 77 | else |
78 | 78 | { |
79 | - echo "Sorry, an error occurred: " . htmlentities($_GET['response_reason_text']); |
|
79 | + echo "Sorry, an error occurred: " . htmlentities($_GET['response_reason_text']); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'notify_url' => $listener_url, |
66 | 66 | 'cbt' => get_bloginfo( 'name' ), |
67 | 67 | 'bn' => 'WPInvoicing_SP', |
68 | - 'lc' => 'US' // this will force paypal site to english |
|
68 | + 'lc' => 'US' // this will force paypal site to english |
|
69 | 69 | ); |
70 | 70 | |
71 | 71 | $paypal_args['address1'] = $invoice->get_address(); |
@@ -217,261 +217,261 @@ discard block |
||
217 | 217 | add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 ); |
218 | 218 | |
219 | 219 | function wpinv_process_paypal_ipn() { |
220 | - // Check the request method is POST |
|
221 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
222 | - return; |
|
223 | - } |
|
224 | - |
|
225 | - // Set initial post data to empty string |
|
226 | - $post_data = ''; |
|
227 | - |
|
228 | - // Fallback just in case post_max_size is lower than needed |
|
229 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
230 | - $post_data = file_get_contents( 'php://input' ); |
|
231 | - } else { |
|
232 | - // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
|
233 | - ini_set( 'post_max_size', '12M' ); |
|
234 | - } |
|
235 | - // Start the encoded data collection with notification command |
|
236 | - $encoded_data = 'cmd=_notify-validate'; |
|
237 | - |
|
238 | - // Get current arg separator |
|
239 | - $arg_separator = wpinv_get_php_arg_separator_output(); |
|
240 | - |
|
241 | - // Verify there is a post_data |
|
242 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
243 | - // Append the data |
|
244 | - $encoded_data .= $arg_separator.$post_data; |
|
245 | - } else { |
|
246 | - // Check if POST is empty |
|
247 | - if ( empty( $_POST ) ) { |
|
248 | - // Nothing to do |
|
249 | - return; |
|
250 | - } else { |
|
251 | - // Loop through each POST |
|
252 | - foreach ( $_POST as $key => $value ) { |
|
253 | - // Encode the value and append the data |
|
254 | - $encoded_data .= $arg_separator."$key=" . urlencode( $value ); |
|
255 | - } |
|
256 | - } |
|
257 | - } |
|
258 | - |
|
259 | - // Convert collected post data to an array |
|
260 | - parse_str( $encoded_data, $encoded_data_array ); |
|
261 | - |
|
262 | - foreach ( $encoded_data_array as $key => $value ) { |
|
263 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
264 | - $new_key = str_replace( '&', '&', $key ); |
|
265 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
266 | - |
|
267 | - unset( $encoded_data_array[ $key ] ); |
|
268 | - $encoded_data_array[ $new_key ] = $value; |
|
269 | - } |
|
270 | - } |
|
271 | - |
|
272 | - // Get the PayPal redirect uri |
|
273 | - $paypal_redirect = wpinv_get_paypal_redirect( true ); |
|
274 | - |
|
275 | - if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
276 | - // Validate the IPN |
|
277 | - |
|
278 | - $remote_post_vars = array( |
|
279 | - 'method' => 'POST', |
|
280 | - 'timeout' => 45, |
|
281 | - 'redirection' => 5, |
|
282 | - 'httpversion' => '1.1', |
|
283 | - 'blocking' => true, |
|
284 | - 'headers' => array( |
|
285 | - 'host' => 'www.paypal.com', |
|
286 | - 'connection' => 'close', |
|
287 | - 'content-type' => 'application/x-www-form-urlencoded', |
|
288 | - 'post' => '/cgi-bin/webscr HTTP/1.1', |
|
289 | - |
|
290 | - ), |
|
291 | - 'sslverify' => false, |
|
292 | - 'body' => $encoded_data_array |
|
293 | - ); |
|
294 | - |
|
295 | - // Get response |
|
296 | - $api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars ); |
|
297 | - |
|
298 | - if ( is_wp_error( $api_response ) ) { |
|
299 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) ); |
|
300 | - return; // Something went wrong |
|
301 | - } |
|
302 | - |
|
303 | - if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
304 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) ); |
|
305 | - return; // Response not okay |
|
306 | - } |
|
307 | - } |
|
308 | - |
|
309 | - // Check if $post_data_array has been populated |
|
310 | - if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) ) |
|
311 | - return; |
|
312 | - |
|
313 | - $defaults = array( |
|
314 | - 'txn_type' => '', |
|
315 | - 'payment_status' => '' |
|
316 | - ); |
|
317 | - |
|
318 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
319 | - |
|
320 | - $invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
220 | + // Check the request method is POST |
|
221 | + if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
222 | + return; |
|
223 | + } |
|
224 | + |
|
225 | + // Set initial post data to empty string |
|
226 | + $post_data = ''; |
|
227 | + |
|
228 | + // Fallback just in case post_max_size is lower than needed |
|
229 | + if ( ini_get( 'allow_url_fopen' ) ) { |
|
230 | + $post_data = file_get_contents( 'php://input' ); |
|
231 | + } else { |
|
232 | + // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
|
233 | + ini_set( 'post_max_size', '12M' ); |
|
234 | + } |
|
235 | + // Start the encoded data collection with notification command |
|
236 | + $encoded_data = 'cmd=_notify-validate'; |
|
237 | + |
|
238 | + // Get current arg separator |
|
239 | + $arg_separator = wpinv_get_php_arg_separator_output(); |
|
240 | + |
|
241 | + // Verify there is a post_data |
|
242 | + if ( $post_data || strlen( $post_data ) > 0 ) { |
|
243 | + // Append the data |
|
244 | + $encoded_data .= $arg_separator.$post_data; |
|
245 | + } else { |
|
246 | + // Check if POST is empty |
|
247 | + if ( empty( $_POST ) ) { |
|
248 | + // Nothing to do |
|
249 | + return; |
|
250 | + } else { |
|
251 | + // Loop through each POST |
|
252 | + foreach ( $_POST as $key => $value ) { |
|
253 | + // Encode the value and append the data |
|
254 | + $encoded_data .= $arg_separator."$key=" . urlencode( $value ); |
|
255 | + } |
|
256 | + } |
|
257 | + } |
|
258 | + |
|
259 | + // Convert collected post data to an array |
|
260 | + parse_str( $encoded_data, $encoded_data_array ); |
|
261 | + |
|
262 | + foreach ( $encoded_data_array as $key => $value ) { |
|
263 | + if ( false !== strpos( $key, 'amp;' ) ) { |
|
264 | + $new_key = str_replace( '&', '&', $key ); |
|
265 | + $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
266 | + |
|
267 | + unset( $encoded_data_array[ $key ] ); |
|
268 | + $encoded_data_array[ $new_key ] = $value; |
|
269 | + } |
|
270 | + } |
|
271 | + |
|
272 | + // Get the PayPal redirect uri |
|
273 | + $paypal_redirect = wpinv_get_paypal_redirect( true ); |
|
274 | + |
|
275 | + if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
276 | + // Validate the IPN |
|
277 | + |
|
278 | + $remote_post_vars = array( |
|
279 | + 'method' => 'POST', |
|
280 | + 'timeout' => 45, |
|
281 | + 'redirection' => 5, |
|
282 | + 'httpversion' => '1.1', |
|
283 | + 'blocking' => true, |
|
284 | + 'headers' => array( |
|
285 | + 'host' => 'www.paypal.com', |
|
286 | + 'connection' => 'close', |
|
287 | + 'content-type' => 'application/x-www-form-urlencoded', |
|
288 | + 'post' => '/cgi-bin/webscr HTTP/1.1', |
|
289 | + |
|
290 | + ), |
|
291 | + 'sslverify' => false, |
|
292 | + 'body' => $encoded_data_array |
|
293 | + ); |
|
294 | + |
|
295 | + // Get response |
|
296 | + $api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars ); |
|
297 | + |
|
298 | + if ( is_wp_error( $api_response ) ) { |
|
299 | + wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) ); |
|
300 | + return; // Something went wrong |
|
301 | + } |
|
302 | + |
|
303 | + if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
304 | + wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) ); |
|
305 | + return; // Response not okay |
|
306 | + } |
|
307 | + } |
|
308 | + |
|
309 | + // Check if $post_data_array has been populated |
|
310 | + if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) ) |
|
311 | + return; |
|
312 | + |
|
313 | + $defaults = array( |
|
314 | + 'txn_type' => '', |
|
315 | + 'payment_status' => '' |
|
316 | + ); |
|
317 | + |
|
318 | + $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
319 | + |
|
320 | + $invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
321 | 321 | |
322 | - wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ ); |
|
323 | - |
|
324 | - if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
325 | - // Allow PayPal IPN types to be processed separately |
|
326 | - do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id ); |
|
327 | - } else { |
|
328 | - // Fallback to web accept just in case the txn_type isn't present |
|
329 | - do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id ); |
|
330 | - } |
|
331 | - exit; |
|
322 | + wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ ); |
|
323 | + |
|
324 | + if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
325 | + // Allow PayPal IPN types to be processed separately |
|
326 | + do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id ); |
|
327 | + } else { |
|
328 | + // Fallback to web accept just in case the txn_type isn't present |
|
329 | + do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id ); |
|
330 | + } |
|
331 | + exit; |
|
332 | 332 | } |
333 | 333 | add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' ); |
334 | 334 | |
335 | 335 | function wpinv_process_paypal_web_accept_and_cart( $data, $invoice_id ) { |
336 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
337 | - return; |
|
338 | - } |
|
339 | - |
|
340 | - if( empty( $invoice_id ) ) { |
|
341 | - return; |
|
342 | - } |
|
343 | - |
|
344 | - // Collect payment details |
|
345 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
346 | - $paypal_amount = $data['mc_gross']; |
|
347 | - $payment_status = strtolower( $data['payment_status'] ); |
|
348 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
349 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
350 | - $payment_meta = wpinv_get_invoice_meta( $invoice_id ); |
|
351 | - |
|
352 | - if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) { |
|
353 | - return; // this isn't a PayPal standard IPN |
|
354 | - } |
|
355 | - |
|
356 | - // Verify payment recipient |
|
357 | - if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) { |
|
358 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
359 | - wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
360 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ) ); |
|
361 | - return; |
|
362 | - } |
|
363 | - |
|
364 | - // Verify payment currency |
|
365 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
366 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
367 | - wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
368 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ) ); |
|
369 | - return; |
|
370 | - } |
|
371 | - |
|
372 | - if ( !wpinv_get_payment_user_email( $invoice_id ) ) { |
|
373 | - // This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal |
|
374 | - // No email associated with purchase, so store from PayPal |
|
375 | - wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] ); |
|
376 | - |
|
377 | - // Setup and store the customer's details |
|
378 | - $user_info = array( |
|
379 | - 'user_id' => '-1', |
|
380 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
381 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
382 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
383 | - 'discount' => '', |
|
384 | - ); |
|
385 | - $user_info['address'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
386 | - $user_info['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
387 | - $user_info['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
388 | - $user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
389 | - $user_info['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
390 | - |
|
391 | - $payment_meta['user_info'] = $user_info; |
|
392 | - wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta ); |
|
393 | - } |
|
394 | - |
|
395 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
396 | - // Process a refund |
|
397 | - wpinv_process_paypal_refund( $data, $invoice_id ); |
|
398 | - } else { |
|
399 | - if ( get_post_status( $invoice_id ) == 'publish' ) { |
|
400 | - return; // Only paid payments once |
|
401 | - } |
|
402 | - |
|
403 | - // Retrieve the total purchase amount (before PayPal) |
|
404 | - $payment_amount = wpinv_payment_total( $invoice_id ); |
|
405 | - |
|
406 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
407 | - // The prices don't match |
|
408 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
409 | - wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
410 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ) ); |
|
411 | - return; |
|
412 | - } |
|
413 | - if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) { |
|
414 | - // Purchase keys don't match |
|
415 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
416 | - wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
417 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ) ); |
|
418 | - return; |
|
419 | - } |
|
420 | - |
|
421 | - if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) { |
|
422 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ) ); |
|
423 | - wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] ); |
|
424 | - wpinv_update_payment_status( $invoice_id, 'publish' ); |
|
425 | - } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
426 | - // Look for possible pending reasons, such as an echeck |
|
427 | - $note = ''; |
|
428 | - |
|
429 | - switch( strtolower( $data['pending_reason'] ) ) { |
|
430 | - case 'echeck' : |
|
431 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' ); |
|
432 | - break; |
|
336 | + if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
337 | + return; |
|
338 | + } |
|
339 | + |
|
340 | + if( empty( $invoice_id ) ) { |
|
341 | + return; |
|
342 | + } |
|
343 | + |
|
344 | + // Collect payment details |
|
345 | + $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
346 | + $paypal_amount = $data['mc_gross']; |
|
347 | + $payment_status = strtolower( $data['payment_status'] ); |
|
348 | + $currency_code = strtolower( $data['mc_currency'] ); |
|
349 | + $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
350 | + $payment_meta = wpinv_get_invoice_meta( $invoice_id ); |
|
351 | + |
|
352 | + if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) { |
|
353 | + return; // this isn't a PayPal standard IPN |
|
354 | + } |
|
355 | + |
|
356 | + // Verify payment recipient |
|
357 | + if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) { |
|
358 | + wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
359 | + wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
360 | + wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ) ); |
|
361 | + return; |
|
362 | + } |
|
363 | + |
|
364 | + // Verify payment currency |
|
365 | + if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
366 | + wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
367 | + wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
368 | + wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ) ); |
|
369 | + return; |
|
370 | + } |
|
371 | + |
|
372 | + if ( !wpinv_get_payment_user_email( $invoice_id ) ) { |
|
373 | + // This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal |
|
374 | + // No email associated with purchase, so store from PayPal |
|
375 | + wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] ); |
|
376 | + |
|
377 | + // Setup and store the customer's details |
|
378 | + $user_info = array( |
|
379 | + 'user_id' => '-1', |
|
380 | + 'email' => sanitize_text_field( $data['payer_email'] ), |
|
381 | + 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
382 | + 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
383 | + 'discount' => '', |
|
384 | + ); |
|
385 | + $user_info['address'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
386 | + $user_info['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
387 | + $user_info['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
388 | + $user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
389 | + $user_info['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
390 | + |
|
391 | + $payment_meta['user_info'] = $user_info; |
|
392 | + wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta ); |
|
393 | + } |
|
394 | + |
|
395 | + if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
396 | + // Process a refund |
|
397 | + wpinv_process_paypal_refund( $data, $invoice_id ); |
|
398 | + } else { |
|
399 | + if ( get_post_status( $invoice_id ) == 'publish' ) { |
|
400 | + return; // Only paid payments once |
|
401 | + } |
|
402 | + |
|
403 | + // Retrieve the total purchase amount (before PayPal) |
|
404 | + $payment_amount = wpinv_payment_total( $invoice_id ); |
|
405 | + |
|
406 | + if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
407 | + // The prices don't match |
|
408 | + wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
409 | + wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
410 | + wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ) ); |
|
411 | + return; |
|
412 | + } |
|
413 | + if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) { |
|
414 | + // Purchase keys don't match |
|
415 | + wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
416 | + wpinv_update_payment_status( $invoice_id, 'failed' ); |
|
417 | + wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ) ); |
|
418 | + return; |
|
419 | + } |
|
420 | + |
|
421 | + if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) { |
|
422 | + wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ) ); |
|
423 | + wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] ); |
|
424 | + wpinv_update_payment_status( $invoice_id, 'publish' ); |
|
425 | + } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
426 | + // Look for possible pending reasons, such as an echeck |
|
427 | + $note = ''; |
|
428 | + |
|
429 | + switch( strtolower( $data['pending_reason'] ) ) { |
|
430 | + case 'echeck' : |
|
431 | + $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' ); |
|
432 | + break; |
|
433 | 433 | |
434 | 434 | case 'address' : |
435 | - $note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' ); |
|
436 | - break; |
|
435 | + $note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' ); |
|
436 | + break; |
|
437 | 437 | |
438 | 438 | case 'intl' : |
439 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' ); |
|
440 | - break; |
|
439 | + $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' ); |
|
440 | + break; |
|
441 | 441 | |
442 | 442 | case 'multi-currency' : |
443 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' ); |
|
444 | - break; |
|
443 | + $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' ); |
|
444 | + break; |
|
445 | 445 | |
446 | 446 | case 'paymentreview' : |
447 | 447 | case 'regulatory_review' : |
448 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' ); |
|
449 | - break; |
|
448 | + $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' ); |
|
449 | + break; |
|
450 | 450 | |
451 | 451 | case 'unilateral' : |
452 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' ); |
|
453 | - break; |
|
452 | + $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' ); |
|
453 | + break; |
|
454 | 454 | |
455 | 455 | case 'upgrade' : |
456 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' ); |
|
457 | - break; |
|
456 | + $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' ); |
|
457 | + break; |
|
458 | 458 | |
459 | 459 | case 'verify' : |
460 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' ); |
|
461 | - break; |
|
462 | - |
|
463 | - case 'other' : |
|
464 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' ); |
|
465 | - break; |
|
466 | - } |
|
467 | - |
|
468 | - if ( ! empty( $note ) ) { |
|
469 | - wpinv_insert_payment_note( $invoice_id, $note ); |
|
470 | - } |
|
471 | - } else { |
|
472 | - wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ) ); |
|
473 | - } |
|
474 | - } |
|
460 | + $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' ); |
|
461 | + break; |
|
462 | + |
|
463 | + case 'other' : |
|
464 | + $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' ); |
|
465 | + break; |
|
466 | + } |
|
467 | + |
|
468 | + if ( ! empty( $note ) ) { |
|
469 | + wpinv_insert_payment_note( $invoice_id, $note ); |
|
470 | + } |
|
471 | + } else { |
|
472 | + wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ) ); |
|
473 | + } |
|
474 | + } |
|
475 | 475 | } |
476 | 476 | add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 ); |
477 | 477 | |
@@ -686,27 +686,27 @@ discard block |
||
686 | 686 | } |
687 | 687 | |
688 | 688 | function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) { |
689 | - // Collect payment details |
|
689 | + // Collect payment details |
|
690 | 690 | |
691 | - if( empty( $invoice_id ) ) { |
|
692 | - return; |
|
693 | - } |
|
691 | + if( empty( $invoice_id ) ) { |
|
692 | + return; |
|
693 | + } |
|
694 | 694 | |
695 | - if ( get_post_status( $invoice_id ) == 'refunded' ) { |
|
696 | - return; // Only refund payments once |
|
697 | - } |
|
695 | + if ( get_post_status( $invoice_id ) == 'refunded' ) { |
|
696 | + return; // Only refund payments once |
|
697 | + } |
|
698 | 698 | |
699 | - $payment_amount = wpinv_payment_total( $invoice_id ); |
|
700 | - $refund_amount = $data['mc_gross'] * -1; |
|
699 | + $payment_amount = wpinv_payment_total( $invoice_id ); |
|
700 | + $refund_amount = $data['mc_gross'] * -1; |
|
701 | 701 | |
702 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
703 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Partial PayPal refund processed: %s', 'invoicing' ), $data['parent_txn_id'] ) ); |
|
704 | - return; // This is a partial refund |
|
705 | - } |
|
702 | + if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
703 | + wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Partial PayPal refund processed: %s', 'invoicing' ), $data['parent_txn_id'] ) ); |
|
704 | + return; // This is a partial refund |
|
705 | + } |
|
706 | 706 | |
707 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
708 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ) ); |
|
709 | - wpinv_update_payment_status( $invoice_id, 'refunded' ); |
|
707 | + wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
708 | + wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ) ); |
|
709 | + wpinv_update_payment_status( $invoice_id, 'refunded' ); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | function wpinv_get_paypal_redirect( $ssl_check = false ) { |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | function wpinv_get_default_country() { |
16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
16 | + $country = wpinv_get_option( 'default_country', 'UK' ); |
|
17 | 17 | |
18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
18 | + return apply_filters( 'wpinv_default_country', $country ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | function wpinv_is_base_country( $country ) { |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | function wpinv_get_default_state() { |
43 | - $state = wpinv_get_option( 'default_state', false ); |
|
43 | + $state = wpinv_get_option( 'default_state', false ); |
|
44 | 44 | |
45 | - return apply_filters( 'wpinv_default_state', $state ); |
|
45 | + return apply_filters( 'wpinv_default_state', $state ); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | function wpinv_state_name( $state_code = '', $country_code = '' ) { |
@@ -115,260 +115,260 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | function wpinv_get_country_list( $first_empty = false ) { |
118 | - $countries = array( |
|
119 | - 'US' => __('United States', 'invoicing'), |
|
120 | - 'CA' => __('Canada', 'invoicing'), |
|
121 | - 'GB' => __('United Kingdom', 'invoicing'), |
|
122 | - 'AF' => __('Afghanistan', 'invoicing'), |
|
123 | - 'AX' => __('Aland Islands', 'invoicing'), |
|
124 | - 'AL' => __('Albania', 'invoicing'), |
|
125 | - 'DZ' => __('Algeria', 'invoicing'), |
|
126 | - 'AS' => __('American Samoa', 'invoicing'), |
|
127 | - 'AD' => __('Andorra', 'invoicing'), |
|
128 | - 'AO' => __('Angola', 'invoicing'), |
|
129 | - 'AI' => __('Anguilla', 'invoicing'), |
|
130 | - 'AQ' => __('Antarctica', 'invoicing'), |
|
131 | - 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
132 | - 'AR' => __('Argentina', 'invoicing'), |
|
133 | - 'AM' => __('Armenia', 'invoicing'), |
|
134 | - 'AW' => __('Aruba', 'invoicing'), |
|
135 | - 'AU' => __('Australia', 'invoicing'), |
|
136 | - 'AT' => __('Austria', 'invoicing'), |
|
137 | - 'AZ' => __('Azerbaijan', 'invoicing'), |
|
138 | - 'BS' => __('Bahamas', 'invoicing'), |
|
139 | - 'BH' => __('Bahrain', 'invoicing'), |
|
140 | - 'BD' => __('Bangladesh', 'invoicing'), |
|
141 | - 'BB' => __('Barbados', 'invoicing'), |
|
142 | - 'BY' => __('Belarus', 'invoicing'), |
|
143 | - 'BE' => __('Belgium', 'invoicing'), |
|
144 | - 'BZ' => __('Belize', 'invoicing'), |
|
145 | - 'BJ' => __('Benin', 'invoicing'), |
|
146 | - 'BM' => __('Bermuda', 'invoicing'), |
|
147 | - 'BT' => __('Bhutan', 'invoicing'), |
|
148 | - 'BO' => __('Bolivia', 'invoicing'), |
|
149 | - 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
150 | - 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
151 | - 'BW' => __('Botswana', 'invoicing'), |
|
152 | - 'BV' => __('Bouvet Island', 'invoicing'), |
|
153 | - 'BR' => __('Brazil', 'invoicing'), |
|
154 | - 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
155 | - 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
156 | - 'BG' => __('Bulgaria', 'invoicing'), |
|
157 | - 'BF' => __('Burkina Faso', 'invoicing'), |
|
158 | - 'BI' => __('Burundi', 'invoicing'), |
|
159 | - 'KH' => __('Cambodia', 'invoicing'), |
|
160 | - 'CM' => __('Cameroon', 'invoicing'), |
|
161 | - 'CV' => __('Cape Verde', 'invoicing'), |
|
162 | - 'KY' => __('Cayman Islands', 'invoicing'), |
|
163 | - 'CF' => __('Central African Republic', 'invoicing'), |
|
164 | - 'TD' => __('Chad', 'invoicing'), |
|
165 | - 'CL' => __('Chile', 'invoicing'), |
|
166 | - 'CN' => __('China', 'invoicing'), |
|
167 | - 'CX' => __('Christmas Island', 'invoicing'), |
|
168 | - 'CC' => __('Cocos Islands', 'invoicing'), |
|
169 | - 'CO' => __('Colombia', 'invoicing'), |
|
170 | - 'KM' => __('Comoros', 'invoicing'), |
|
171 | - 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
172 | - 'CG' => __('Congo, Republic of', 'invoicing'), |
|
173 | - 'CK' => __('Cook Islands', 'invoicing'), |
|
174 | - 'CR' => __('Costa Rica', 'invoicing'), |
|
175 | - 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
176 | - 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
177 | - 'CU' => __('Cuba', 'invoicing'), |
|
178 | - 'CW' => __('CuraÇao', 'invoicing'), |
|
179 | - 'CY' => __('Cyprus', 'invoicing'), |
|
180 | - 'CZ' => __('Czech Republic', 'invoicing'), |
|
181 | - 'DK' => __('Denmark', 'invoicing'), |
|
182 | - 'DJ' => __('Djibouti', 'invoicing'), |
|
183 | - 'DM' => __('Dominica', 'invoicing'), |
|
184 | - 'DO' => __('Dominican Republic', 'invoicing'), |
|
185 | - 'TP' => __('East Timor', 'invoicing'), |
|
186 | - 'EC' => __('Ecuador', 'invoicing'), |
|
187 | - 'EG' => __('Egypt', 'invoicing'), |
|
188 | - 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
189 | - 'SV' => __('El Salvador', 'invoicing'), |
|
190 | - 'ER' => __('Eritrea', 'invoicing'), |
|
191 | - 'EE' => __('Estonia', 'invoicing'), |
|
192 | - 'ET' => __('Ethiopia', 'invoicing'), |
|
193 | - 'FK' => __('Falkland Islands', 'invoicing'), |
|
194 | - 'FO' => __('Faroe Islands', 'invoicing'), |
|
195 | - 'FJ' => __('Fiji', 'invoicing'), |
|
196 | - 'FI' => __('Finland', 'invoicing'), |
|
197 | - 'FR' => __('France', 'invoicing'), |
|
198 | - 'GF' => __('French Guiana', 'invoicing'), |
|
199 | - 'PF' => __('French Polynesia', 'invoicing'), |
|
200 | - 'TF' => __('French Southern Territories', 'invoicing'), |
|
201 | - 'GA' => __('Gabon', 'invoicing'), |
|
202 | - 'GM' => __('Gambia', 'invoicing'), |
|
203 | - 'GE' => __('Georgia', 'invoicing'), |
|
204 | - 'DE' => __('Germany', 'invoicing'), |
|
205 | - 'GR' => __('Greece', 'invoicing'), |
|
206 | - 'GH' => __('Ghana', 'invoicing'), |
|
207 | - 'GI' => __('Gibraltar', 'invoicing'), |
|
208 | - 'GL' => __('Greenland', 'invoicing'), |
|
209 | - 'GD' => __('Grenada', 'invoicing'), |
|
210 | - 'GP' => __('Guadeloupe', 'invoicing'), |
|
211 | - 'GU' => __('Guam', 'invoicing'), |
|
212 | - 'GT' => __('Guatemala', 'invoicing'), |
|
213 | - 'GG' => __('Guernsey', 'invoicing'), |
|
214 | - 'GN' => __('Guinea', 'invoicing'), |
|
215 | - 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
216 | - 'GY' => __('Guyana', 'invoicing'), |
|
217 | - 'HT' => __('Haiti', 'invoicing'), |
|
218 | - 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
219 | - 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
220 | - 'HN' => __('Honduras', 'invoicing'), |
|
221 | - 'HK' => __('Hong Kong', 'invoicing'), |
|
222 | - 'HU' => __('Hungary', 'invoicing'), |
|
223 | - 'IS' => __('Iceland', 'invoicing'), |
|
224 | - 'IN' => __('India', 'invoicing'), |
|
225 | - 'ID' => __('Indonesia', 'invoicing'), |
|
226 | - 'IR' => __('Iran', 'invoicing'), |
|
227 | - 'IQ' => __('Iraq', 'invoicing'), |
|
228 | - 'IE' => __('Ireland', 'invoicing'), |
|
229 | - 'IM' => __('Isle of Man', 'invoicing'), |
|
230 | - 'IL' => __('Israel', 'invoicing'), |
|
231 | - 'IT' => __('Italy', 'invoicing'), |
|
232 | - 'JM' => __('Jamaica', 'invoicing'), |
|
233 | - 'JP' => __('Japan', 'invoicing'), |
|
234 | - 'JE' => __('Jersey', 'invoicing'), |
|
235 | - 'JO' => __('Jordan', 'invoicing'), |
|
236 | - 'KZ' => __('Kazakhstan', 'invoicing'), |
|
237 | - 'KE' => __('Kenya', 'invoicing'), |
|
238 | - 'KI' => __('Kiribati', 'invoicing'), |
|
239 | - 'KW' => __('Kuwait', 'invoicing'), |
|
240 | - 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
241 | - 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
242 | - 'LV' => __('Latvia', 'invoicing'), |
|
243 | - 'LB' => __('Lebanon', 'invoicing'), |
|
244 | - 'LS' => __('Lesotho', 'invoicing'), |
|
245 | - 'LR' => __('Liberia', 'invoicing'), |
|
246 | - 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
247 | - 'LI' => __('Liechtenstein', 'invoicing'), |
|
248 | - 'LT' => __('Lithuania', 'invoicing'), |
|
249 | - 'LU' => __('Luxembourg', 'invoicing'), |
|
250 | - 'MO' => __('Macau', 'invoicing'), |
|
251 | - 'MK' => __('Macedonia', 'invoicing'), |
|
252 | - 'MG' => __('Madagascar', 'invoicing'), |
|
253 | - 'MW' => __('Malawi', 'invoicing'), |
|
254 | - 'MY' => __('Malaysia', 'invoicing'), |
|
255 | - 'MV' => __('Maldives', 'invoicing'), |
|
256 | - 'ML' => __('Mali', 'invoicing'), |
|
257 | - 'MT' => __('Malta', 'invoicing'), |
|
258 | - 'MH' => __('Marshall Islands', 'invoicing'), |
|
259 | - 'MQ' => __('Martinique', 'invoicing'), |
|
260 | - 'MR' => __('Mauritania', 'invoicing'), |
|
261 | - 'MU' => __('Mauritius', 'invoicing'), |
|
262 | - 'YT' => __('Mayotte', 'invoicing'), |
|
263 | - 'MX' => __('Mexico', 'invoicing'), |
|
264 | - 'FM' => __('Micronesia', 'invoicing'), |
|
265 | - 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
266 | - 'MC' => __('Monaco', 'invoicing'), |
|
267 | - 'MN' => __('Mongolia', 'invoicing'), |
|
268 | - 'ME' => __('Montenegro', 'invoicing'), |
|
269 | - 'MS' => __('Montserrat', 'invoicing'), |
|
270 | - 'MA' => __('Morocco', 'invoicing'), |
|
271 | - 'MZ' => __('Mozambique', 'invoicing'), |
|
272 | - 'MM' => __('Myanmar', 'invoicing'), |
|
273 | - 'NA' => __('Namibia', 'invoicing'), |
|
274 | - 'NR' => __('Nauru', 'invoicing'), |
|
275 | - 'NP' => __('Nepal', 'invoicing'), |
|
276 | - 'NL' => __('Netherlands', 'invoicing'), |
|
277 | - 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
278 | - 'NC' => __('New Caledonia', 'invoicing'), |
|
279 | - 'NZ' => __('New Zealand', 'invoicing'), |
|
280 | - 'NI' => __('Nicaragua', 'invoicing'), |
|
281 | - 'NE' => __('Niger', 'invoicing'), |
|
282 | - 'NG' => __('Nigeria', 'invoicing'), |
|
283 | - 'NU' => __('Niue', 'invoicing'), |
|
284 | - 'NF' => __('Norfolk Island', 'invoicing'), |
|
285 | - 'KP' => __('North Korea', 'invoicing'), |
|
286 | - 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
287 | - 'NO' => __('Norway', 'invoicing'), |
|
288 | - 'OM' => __('Oman', 'invoicing'), |
|
289 | - 'PK' => __('Pakistan', 'invoicing'), |
|
290 | - 'PW' => __('Palau', 'invoicing'), |
|
291 | - 'PS' => __('Palestinian Territories', 'invoicing'), |
|
292 | - 'PA' => __('Panama', 'invoicing'), |
|
293 | - 'PG' => __('Papua New Guinea', 'invoicing'), |
|
294 | - 'PY' => __('Paraguay', 'invoicing'), |
|
295 | - 'PE' => __('Peru', 'invoicing'), |
|
296 | - 'PH' => __('Phillipines', 'invoicing'), |
|
297 | - 'PN' => __('Pitcairn Island', 'invoicing'), |
|
298 | - 'PL' => __('Poland', 'invoicing'), |
|
299 | - 'PT' => __('Portugal', 'invoicing'), |
|
300 | - 'PR' => __('Puerto Rico', 'invoicing'), |
|
301 | - 'QA' => __('Qatar', 'invoicing'), |
|
302 | - 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
303 | - 'RE' => __('Reunion Island', 'invoicing'), |
|
304 | - 'RO' => __('Romania', 'invoicing'), |
|
305 | - 'RU' => __('Russian Federation', 'invoicing'), |
|
306 | - 'RW' => __('Rwanda', 'invoicing'), |
|
307 | - 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
308 | - 'SH' => __('Saint Helena', 'invoicing'), |
|
309 | - 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
310 | - 'LC' => __('Saint Lucia', 'invoicing'), |
|
311 | - 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
312 | - 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
313 | - 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
314 | - 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
315 | - 'SM' => __('San Marino', 'invoicing'), |
|
316 | - 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
317 | - 'SA' => __('Saudi Arabia', 'invoicing'), |
|
318 | - 'SN' => __('Senegal', 'invoicing'), |
|
319 | - 'RS' => __('Serbia', 'invoicing'), |
|
320 | - 'SC' => __('Seychelles', 'invoicing'), |
|
321 | - 'SL' => __('Sierra Leone', 'invoicing'), |
|
322 | - 'SG' => __('Singapore', 'invoicing'), |
|
323 | - 'SK' => __('Slovak Republic', 'invoicing'), |
|
324 | - 'SI' => __('Slovenia', 'invoicing'), |
|
325 | - 'SB' => __('Solomon Islands', 'invoicing'), |
|
326 | - 'SO' => __('Somalia', 'invoicing'), |
|
327 | - 'ZA' => __('South Africa', 'invoicing'), |
|
328 | - 'GS' => __('South Georgia', 'invoicing'), |
|
329 | - 'KR' => __('South Korea', 'invoicing'), |
|
330 | - 'SS' => __('South Sudan', 'invoicing'), |
|
331 | - 'ES' => __('Spain', 'invoicing'), |
|
332 | - 'LK' => __('Sri Lanka', 'invoicing'), |
|
333 | - 'SD' => __('Sudan', 'invoicing'), |
|
334 | - 'SR' => __('Suriname', 'invoicing'), |
|
335 | - 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
336 | - 'SZ' => __('Swaziland', 'invoicing'), |
|
337 | - 'SE' => __('Sweden', 'invoicing'), |
|
338 | - 'CH' => __('Switzerland', 'invoicing'), |
|
339 | - 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
340 | - 'TW' => __('Taiwan', 'invoicing'), |
|
341 | - 'TJ' => __('Tajikistan', 'invoicing'), |
|
342 | - 'TZ' => __('Tanzania', 'invoicing'), |
|
343 | - 'TH' => __('Thailand', 'invoicing'), |
|
344 | - 'TL' => __('Timor-Leste', 'invoicing'), |
|
345 | - 'TG' => __('Togo', 'invoicing'), |
|
346 | - 'TK' => __('Tokelau', 'invoicing'), |
|
347 | - 'TO' => __('Tonga', 'invoicing'), |
|
348 | - 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
349 | - 'TN' => __('Tunisia', 'invoicing'), |
|
350 | - 'TR' => __('Turkey', 'invoicing'), |
|
351 | - 'TM' => __('Turkmenistan', 'invoicing'), |
|
352 | - 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
353 | - 'TV' => __('Tuvalu', 'invoicing'), |
|
354 | - 'UG' => __('Uganda', 'invoicing'), |
|
355 | - 'UA' => __('Ukraine', 'invoicing'), |
|
356 | - 'AE' => __('United Arab Emirates', 'invoicing'), |
|
357 | - 'UY' => __('Uruguay', 'invoicing'), |
|
358 | - 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
359 | - 'UZ' => __('Uzbekistan', 'invoicing'), |
|
360 | - 'VU' => __('Vanuatu', 'invoicing'), |
|
361 | - 'VE' => __('Venezuela', 'invoicing'), |
|
362 | - 'VN' => __('Vietnam', 'invoicing'), |
|
363 | - 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
364 | - 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
365 | - 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
366 | - 'EH' => __('Western Sahara', 'invoicing'), |
|
367 | - 'WS' => __('Western Samoa', 'invoicing'), |
|
368 | - 'YE' => __('Yemen', 'invoicing'), |
|
369 | - 'ZM' => __('Zambia', 'invoicing'), |
|
370 | - 'ZW' => __('Zimbabwe', 'invoicing'), |
|
371 | - ); |
|
118 | + $countries = array( |
|
119 | + 'US' => __('United States', 'invoicing'), |
|
120 | + 'CA' => __('Canada', 'invoicing'), |
|
121 | + 'GB' => __('United Kingdom', 'invoicing'), |
|
122 | + 'AF' => __('Afghanistan', 'invoicing'), |
|
123 | + 'AX' => __('Aland Islands', 'invoicing'), |
|
124 | + 'AL' => __('Albania', 'invoicing'), |
|
125 | + 'DZ' => __('Algeria', 'invoicing'), |
|
126 | + 'AS' => __('American Samoa', 'invoicing'), |
|
127 | + 'AD' => __('Andorra', 'invoicing'), |
|
128 | + 'AO' => __('Angola', 'invoicing'), |
|
129 | + 'AI' => __('Anguilla', 'invoicing'), |
|
130 | + 'AQ' => __('Antarctica', 'invoicing'), |
|
131 | + 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
132 | + 'AR' => __('Argentina', 'invoicing'), |
|
133 | + 'AM' => __('Armenia', 'invoicing'), |
|
134 | + 'AW' => __('Aruba', 'invoicing'), |
|
135 | + 'AU' => __('Australia', 'invoicing'), |
|
136 | + 'AT' => __('Austria', 'invoicing'), |
|
137 | + 'AZ' => __('Azerbaijan', 'invoicing'), |
|
138 | + 'BS' => __('Bahamas', 'invoicing'), |
|
139 | + 'BH' => __('Bahrain', 'invoicing'), |
|
140 | + 'BD' => __('Bangladesh', 'invoicing'), |
|
141 | + 'BB' => __('Barbados', 'invoicing'), |
|
142 | + 'BY' => __('Belarus', 'invoicing'), |
|
143 | + 'BE' => __('Belgium', 'invoicing'), |
|
144 | + 'BZ' => __('Belize', 'invoicing'), |
|
145 | + 'BJ' => __('Benin', 'invoicing'), |
|
146 | + 'BM' => __('Bermuda', 'invoicing'), |
|
147 | + 'BT' => __('Bhutan', 'invoicing'), |
|
148 | + 'BO' => __('Bolivia', 'invoicing'), |
|
149 | + 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
150 | + 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
151 | + 'BW' => __('Botswana', 'invoicing'), |
|
152 | + 'BV' => __('Bouvet Island', 'invoicing'), |
|
153 | + 'BR' => __('Brazil', 'invoicing'), |
|
154 | + 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
155 | + 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
156 | + 'BG' => __('Bulgaria', 'invoicing'), |
|
157 | + 'BF' => __('Burkina Faso', 'invoicing'), |
|
158 | + 'BI' => __('Burundi', 'invoicing'), |
|
159 | + 'KH' => __('Cambodia', 'invoicing'), |
|
160 | + 'CM' => __('Cameroon', 'invoicing'), |
|
161 | + 'CV' => __('Cape Verde', 'invoicing'), |
|
162 | + 'KY' => __('Cayman Islands', 'invoicing'), |
|
163 | + 'CF' => __('Central African Republic', 'invoicing'), |
|
164 | + 'TD' => __('Chad', 'invoicing'), |
|
165 | + 'CL' => __('Chile', 'invoicing'), |
|
166 | + 'CN' => __('China', 'invoicing'), |
|
167 | + 'CX' => __('Christmas Island', 'invoicing'), |
|
168 | + 'CC' => __('Cocos Islands', 'invoicing'), |
|
169 | + 'CO' => __('Colombia', 'invoicing'), |
|
170 | + 'KM' => __('Comoros', 'invoicing'), |
|
171 | + 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
172 | + 'CG' => __('Congo, Republic of', 'invoicing'), |
|
173 | + 'CK' => __('Cook Islands', 'invoicing'), |
|
174 | + 'CR' => __('Costa Rica', 'invoicing'), |
|
175 | + 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
176 | + 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
177 | + 'CU' => __('Cuba', 'invoicing'), |
|
178 | + 'CW' => __('CuraÇao', 'invoicing'), |
|
179 | + 'CY' => __('Cyprus', 'invoicing'), |
|
180 | + 'CZ' => __('Czech Republic', 'invoicing'), |
|
181 | + 'DK' => __('Denmark', 'invoicing'), |
|
182 | + 'DJ' => __('Djibouti', 'invoicing'), |
|
183 | + 'DM' => __('Dominica', 'invoicing'), |
|
184 | + 'DO' => __('Dominican Republic', 'invoicing'), |
|
185 | + 'TP' => __('East Timor', 'invoicing'), |
|
186 | + 'EC' => __('Ecuador', 'invoicing'), |
|
187 | + 'EG' => __('Egypt', 'invoicing'), |
|
188 | + 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
189 | + 'SV' => __('El Salvador', 'invoicing'), |
|
190 | + 'ER' => __('Eritrea', 'invoicing'), |
|
191 | + 'EE' => __('Estonia', 'invoicing'), |
|
192 | + 'ET' => __('Ethiopia', 'invoicing'), |
|
193 | + 'FK' => __('Falkland Islands', 'invoicing'), |
|
194 | + 'FO' => __('Faroe Islands', 'invoicing'), |
|
195 | + 'FJ' => __('Fiji', 'invoicing'), |
|
196 | + 'FI' => __('Finland', 'invoicing'), |
|
197 | + 'FR' => __('France', 'invoicing'), |
|
198 | + 'GF' => __('French Guiana', 'invoicing'), |
|
199 | + 'PF' => __('French Polynesia', 'invoicing'), |
|
200 | + 'TF' => __('French Southern Territories', 'invoicing'), |
|
201 | + 'GA' => __('Gabon', 'invoicing'), |
|
202 | + 'GM' => __('Gambia', 'invoicing'), |
|
203 | + 'GE' => __('Georgia', 'invoicing'), |
|
204 | + 'DE' => __('Germany', 'invoicing'), |
|
205 | + 'GR' => __('Greece', 'invoicing'), |
|
206 | + 'GH' => __('Ghana', 'invoicing'), |
|
207 | + 'GI' => __('Gibraltar', 'invoicing'), |
|
208 | + 'GL' => __('Greenland', 'invoicing'), |
|
209 | + 'GD' => __('Grenada', 'invoicing'), |
|
210 | + 'GP' => __('Guadeloupe', 'invoicing'), |
|
211 | + 'GU' => __('Guam', 'invoicing'), |
|
212 | + 'GT' => __('Guatemala', 'invoicing'), |
|
213 | + 'GG' => __('Guernsey', 'invoicing'), |
|
214 | + 'GN' => __('Guinea', 'invoicing'), |
|
215 | + 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
216 | + 'GY' => __('Guyana', 'invoicing'), |
|
217 | + 'HT' => __('Haiti', 'invoicing'), |
|
218 | + 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
219 | + 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
220 | + 'HN' => __('Honduras', 'invoicing'), |
|
221 | + 'HK' => __('Hong Kong', 'invoicing'), |
|
222 | + 'HU' => __('Hungary', 'invoicing'), |
|
223 | + 'IS' => __('Iceland', 'invoicing'), |
|
224 | + 'IN' => __('India', 'invoicing'), |
|
225 | + 'ID' => __('Indonesia', 'invoicing'), |
|
226 | + 'IR' => __('Iran', 'invoicing'), |
|
227 | + 'IQ' => __('Iraq', 'invoicing'), |
|
228 | + 'IE' => __('Ireland', 'invoicing'), |
|
229 | + 'IM' => __('Isle of Man', 'invoicing'), |
|
230 | + 'IL' => __('Israel', 'invoicing'), |
|
231 | + 'IT' => __('Italy', 'invoicing'), |
|
232 | + 'JM' => __('Jamaica', 'invoicing'), |
|
233 | + 'JP' => __('Japan', 'invoicing'), |
|
234 | + 'JE' => __('Jersey', 'invoicing'), |
|
235 | + 'JO' => __('Jordan', 'invoicing'), |
|
236 | + 'KZ' => __('Kazakhstan', 'invoicing'), |
|
237 | + 'KE' => __('Kenya', 'invoicing'), |
|
238 | + 'KI' => __('Kiribati', 'invoicing'), |
|
239 | + 'KW' => __('Kuwait', 'invoicing'), |
|
240 | + 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
241 | + 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
242 | + 'LV' => __('Latvia', 'invoicing'), |
|
243 | + 'LB' => __('Lebanon', 'invoicing'), |
|
244 | + 'LS' => __('Lesotho', 'invoicing'), |
|
245 | + 'LR' => __('Liberia', 'invoicing'), |
|
246 | + 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
247 | + 'LI' => __('Liechtenstein', 'invoicing'), |
|
248 | + 'LT' => __('Lithuania', 'invoicing'), |
|
249 | + 'LU' => __('Luxembourg', 'invoicing'), |
|
250 | + 'MO' => __('Macau', 'invoicing'), |
|
251 | + 'MK' => __('Macedonia', 'invoicing'), |
|
252 | + 'MG' => __('Madagascar', 'invoicing'), |
|
253 | + 'MW' => __('Malawi', 'invoicing'), |
|
254 | + 'MY' => __('Malaysia', 'invoicing'), |
|
255 | + 'MV' => __('Maldives', 'invoicing'), |
|
256 | + 'ML' => __('Mali', 'invoicing'), |
|
257 | + 'MT' => __('Malta', 'invoicing'), |
|
258 | + 'MH' => __('Marshall Islands', 'invoicing'), |
|
259 | + 'MQ' => __('Martinique', 'invoicing'), |
|
260 | + 'MR' => __('Mauritania', 'invoicing'), |
|
261 | + 'MU' => __('Mauritius', 'invoicing'), |
|
262 | + 'YT' => __('Mayotte', 'invoicing'), |
|
263 | + 'MX' => __('Mexico', 'invoicing'), |
|
264 | + 'FM' => __('Micronesia', 'invoicing'), |
|
265 | + 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
266 | + 'MC' => __('Monaco', 'invoicing'), |
|
267 | + 'MN' => __('Mongolia', 'invoicing'), |
|
268 | + 'ME' => __('Montenegro', 'invoicing'), |
|
269 | + 'MS' => __('Montserrat', 'invoicing'), |
|
270 | + 'MA' => __('Morocco', 'invoicing'), |
|
271 | + 'MZ' => __('Mozambique', 'invoicing'), |
|
272 | + 'MM' => __('Myanmar', 'invoicing'), |
|
273 | + 'NA' => __('Namibia', 'invoicing'), |
|
274 | + 'NR' => __('Nauru', 'invoicing'), |
|
275 | + 'NP' => __('Nepal', 'invoicing'), |
|
276 | + 'NL' => __('Netherlands', 'invoicing'), |
|
277 | + 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
278 | + 'NC' => __('New Caledonia', 'invoicing'), |
|
279 | + 'NZ' => __('New Zealand', 'invoicing'), |
|
280 | + 'NI' => __('Nicaragua', 'invoicing'), |
|
281 | + 'NE' => __('Niger', 'invoicing'), |
|
282 | + 'NG' => __('Nigeria', 'invoicing'), |
|
283 | + 'NU' => __('Niue', 'invoicing'), |
|
284 | + 'NF' => __('Norfolk Island', 'invoicing'), |
|
285 | + 'KP' => __('North Korea', 'invoicing'), |
|
286 | + 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
287 | + 'NO' => __('Norway', 'invoicing'), |
|
288 | + 'OM' => __('Oman', 'invoicing'), |
|
289 | + 'PK' => __('Pakistan', 'invoicing'), |
|
290 | + 'PW' => __('Palau', 'invoicing'), |
|
291 | + 'PS' => __('Palestinian Territories', 'invoicing'), |
|
292 | + 'PA' => __('Panama', 'invoicing'), |
|
293 | + 'PG' => __('Papua New Guinea', 'invoicing'), |
|
294 | + 'PY' => __('Paraguay', 'invoicing'), |
|
295 | + 'PE' => __('Peru', 'invoicing'), |
|
296 | + 'PH' => __('Phillipines', 'invoicing'), |
|
297 | + 'PN' => __('Pitcairn Island', 'invoicing'), |
|
298 | + 'PL' => __('Poland', 'invoicing'), |
|
299 | + 'PT' => __('Portugal', 'invoicing'), |
|
300 | + 'PR' => __('Puerto Rico', 'invoicing'), |
|
301 | + 'QA' => __('Qatar', 'invoicing'), |
|
302 | + 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
303 | + 'RE' => __('Reunion Island', 'invoicing'), |
|
304 | + 'RO' => __('Romania', 'invoicing'), |
|
305 | + 'RU' => __('Russian Federation', 'invoicing'), |
|
306 | + 'RW' => __('Rwanda', 'invoicing'), |
|
307 | + 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
308 | + 'SH' => __('Saint Helena', 'invoicing'), |
|
309 | + 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
310 | + 'LC' => __('Saint Lucia', 'invoicing'), |
|
311 | + 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
312 | + 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
313 | + 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
314 | + 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
315 | + 'SM' => __('San Marino', 'invoicing'), |
|
316 | + 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
317 | + 'SA' => __('Saudi Arabia', 'invoicing'), |
|
318 | + 'SN' => __('Senegal', 'invoicing'), |
|
319 | + 'RS' => __('Serbia', 'invoicing'), |
|
320 | + 'SC' => __('Seychelles', 'invoicing'), |
|
321 | + 'SL' => __('Sierra Leone', 'invoicing'), |
|
322 | + 'SG' => __('Singapore', 'invoicing'), |
|
323 | + 'SK' => __('Slovak Republic', 'invoicing'), |
|
324 | + 'SI' => __('Slovenia', 'invoicing'), |
|
325 | + 'SB' => __('Solomon Islands', 'invoicing'), |
|
326 | + 'SO' => __('Somalia', 'invoicing'), |
|
327 | + 'ZA' => __('South Africa', 'invoicing'), |
|
328 | + 'GS' => __('South Georgia', 'invoicing'), |
|
329 | + 'KR' => __('South Korea', 'invoicing'), |
|
330 | + 'SS' => __('South Sudan', 'invoicing'), |
|
331 | + 'ES' => __('Spain', 'invoicing'), |
|
332 | + 'LK' => __('Sri Lanka', 'invoicing'), |
|
333 | + 'SD' => __('Sudan', 'invoicing'), |
|
334 | + 'SR' => __('Suriname', 'invoicing'), |
|
335 | + 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
336 | + 'SZ' => __('Swaziland', 'invoicing'), |
|
337 | + 'SE' => __('Sweden', 'invoicing'), |
|
338 | + 'CH' => __('Switzerland', 'invoicing'), |
|
339 | + 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
340 | + 'TW' => __('Taiwan', 'invoicing'), |
|
341 | + 'TJ' => __('Tajikistan', 'invoicing'), |
|
342 | + 'TZ' => __('Tanzania', 'invoicing'), |
|
343 | + 'TH' => __('Thailand', 'invoicing'), |
|
344 | + 'TL' => __('Timor-Leste', 'invoicing'), |
|
345 | + 'TG' => __('Togo', 'invoicing'), |
|
346 | + 'TK' => __('Tokelau', 'invoicing'), |
|
347 | + 'TO' => __('Tonga', 'invoicing'), |
|
348 | + 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
349 | + 'TN' => __('Tunisia', 'invoicing'), |
|
350 | + 'TR' => __('Turkey', 'invoicing'), |
|
351 | + 'TM' => __('Turkmenistan', 'invoicing'), |
|
352 | + 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
353 | + 'TV' => __('Tuvalu', 'invoicing'), |
|
354 | + 'UG' => __('Uganda', 'invoicing'), |
|
355 | + 'UA' => __('Ukraine', 'invoicing'), |
|
356 | + 'AE' => __('United Arab Emirates', 'invoicing'), |
|
357 | + 'UY' => __('Uruguay', 'invoicing'), |
|
358 | + 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
359 | + 'UZ' => __('Uzbekistan', 'invoicing'), |
|
360 | + 'VU' => __('Vanuatu', 'invoicing'), |
|
361 | + 'VE' => __('Venezuela', 'invoicing'), |
|
362 | + 'VN' => __('Vietnam', 'invoicing'), |
|
363 | + 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
364 | + 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
365 | + 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
366 | + 'EH' => __('Western Sahara', 'invoicing'), |
|
367 | + 'WS' => __('Western Samoa', 'invoicing'), |
|
368 | + 'YE' => __('Yemen', 'invoicing'), |
|
369 | + 'ZM' => __('Zambia', 'invoicing'), |
|
370 | + 'ZW' => __('Zimbabwe', 'invoicing'), |
|
371 | + ); |
|
372 | 372 | |
373 | 373 | if ( $first_empty ) { |
374 | 374 | $countries = array_merge( array( '' => '' ), $countries ); |
@@ -1537,30 +1537,30 @@ discard block |
||
1537 | 1537 | } |
1538 | 1538 | |
1539 | 1539 | function wpinv_get_states_field() { |
1540 | - if( empty( $_POST['country'] ) ) { |
|
1541 | - $_POST['country'] = wpinv_get_default_country(); |
|
1542 | - } |
|
1543 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
1540 | + if( empty( $_POST['country'] ) ) { |
|
1541 | + $_POST['country'] = wpinv_get_default_country(); |
|
1542 | + } |
|
1543 | + $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
1544 | 1544 | |
1545 | - if( !empty( $states ) ) { |
|
1546 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
1545 | + if( !empty( $states ) ) { |
|
1546 | + $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
1547 | 1547 | |
1548 | 1548 | $args = array( |
1549 | - 'name' => $sanitized_field_name, |
|
1550 | - 'id' => $sanitized_field_name, |
|
1551 | - 'class' => $sanitized_field_name . ' wpinv-select', |
|
1552 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1553 | - 'show_option_all' => false, |
|
1554 | - 'show_option_none' => false |
|
1555 | - ); |
|
1556 | - |
|
1557 | - $response = wpinv_html_select( $args ); |
|
1558 | - |
|
1559 | - } else { |
|
1560 | - $response = 'nostates'; |
|
1561 | - } |
|
1549 | + 'name' => $sanitized_field_name, |
|
1550 | + 'id' => $sanitized_field_name, |
|
1551 | + 'class' => $sanitized_field_name . ' wpinv-select', |
|
1552 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
1553 | + 'show_option_all' => false, |
|
1554 | + 'show_option_none' => false |
|
1555 | + ); |
|
1556 | + |
|
1557 | + $response = wpinv_html_select( $args ); |
|
1558 | + |
|
1559 | + } else { |
|
1560 | + $response = 'nostates'; |
|
1561 | + } |
|
1562 | 1562 | |
1563 | - return $response; |
|
1563 | + return $response; |
|
1564 | 1564 | } |
1565 | 1565 | |
1566 | 1566 | function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | function wpinv_get_payment_key( $invoice_id = 0 ) { |
218 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
218 | + $invoice = new WPInv_Invoice( $invoice_id ); |
|
219 | 219 | return $invoice->get_key(); |
220 | 220 | } |
221 | 221 | |
@@ -731,20 +731,20 @@ discard block |
||
731 | 731 | } |
732 | 732 | |
733 | 733 | function wpinv_checkout_get_cc_info() { |
734 | - $cc_info = array(); |
|
735 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
736 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
737 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
738 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
739 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
740 | - $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
741 | - $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
742 | - $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
743 | - $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
744 | - $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
745 | - |
|
746 | - // Return cc info |
|
747 | - return $cc_info; |
|
734 | + $cc_info = array(); |
|
735 | + $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
736 | + $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
737 | + $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
738 | + $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
739 | + $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
740 | + $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
741 | + $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
742 | + $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
743 | + $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
744 | + $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
745 | + |
|
746 | + // Return cc info |
|
747 | + return $cc_info; |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | $required_fields = wpinv_checkout_required_fields(); |
943 | 943 | |
944 | 944 | // Loop through required fields and show error messages |
945 | - if ( !empty( $required_fields ) ) { |
|
945 | + if ( !empty( $required_fields ) ) { |
|
946 | 946 | foreach ( $required_fields as $field_name => $value ) { |
947 | 947 | if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) { |
948 | 948 | wpinv_set_error( $value['error_id'], $value['error_message'] ); |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | function wpinv_get_checkout_session() { |
1028 | - global $wpi_session; |
|
1028 | + global $wpi_session; |
|
1029 | 1029 | |
1030 | 1030 | return $wpi_session->get( 'wpinv_checkout' ); |
1031 | 1031 | } |
@@ -1376,47 +1376,47 @@ discard block |
||
1376 | 1376 | } |
1377 | 1377 | |
1378 | 1378 | function wpinv_get_invoice_id_by_key( $key ) { |
1379 | - global $wpdb; |
|
1379 | + global $wpdb; |
|
1380 | 1380 | |
1381 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1381 | + $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1382 | 1382 | |
1383 | - if ( $invoice_id != NULL ) |
|
1384 | - return $invoice_id; |
|
1383 | + if ( $invoice_id != NULL ) |
|
1384 | + return $invoice_id; |
|
1385 | 1385 | |
1386 | - return 0; |
|
1386 | + return 0; |
|
1387 | 1387 | } |
1388 | 1388 | |
1389 | 1389 | function wpinv_can_view_receipt( $invoice_key = '' ) { |
1390 | - $return = false; |
|
1390 | + $return = false; |
|
1391 | 1391 | |
1392 | - if ( empty( $invoice_key ) ) { |
|
1393 | - return $return; |
|
1394 | - } |
|
1392 | + if ( empty( $invoice_key ) ) { |
|
1393 | + return $return; |
|
1394 | + } |
|
1395 | 1395 | |
1396 | - global $wpinv_receipt_args; |
|
1396 | + global $wpinv_receipt_args; |
|
1397 | 1397 | |
1398 | - $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
1399 | - if ( isset( $_GET['invoice-id'] ) ) { |
|
1400 | - $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
1401 | - } |
|
1398 | + $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
1399 | + if ( isset( $_GET['invoice-id'] ) ) { |
|
1400 | + $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
1401 | + } |
|
1402 | 1402 | |
1403 | - $user_id = (int) wpinv_get_user_id( $wpinv_receipt_args['id'] ); |
|
1403 | + $user_id = (int) wpinv_get_user_id( $wpinv_receipt_args['id'] ); |
|
1404 | 1404 | $invoice_meta = wpinv_get_invoice_meta( $wpinv_receipt_args['id'] ); |
1405 | 1405 | |
1406 | - if ( is_user_logged_in() ) { |
|
1407 | - if ( $user_id === (int) get_current_user_id() ) { |
|
1408 | - $return = true; |
|
1409 | - } |
|
1410 | - } |
|
1406 | + if ( is_user_logged_in() ) { |
|
1407 | + if ( $user_id === (int) get_current_user_id() ) { |
|
1408 | + $return = true; |
|
1409 | + } |
|
1410 | + } |
|
1411 | 1411 | |
1412 | - $session = wpinv_get_checkout_session(); |
|
1413 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
1414 | - if ( $session['invoice_key'] === $invoice_meta['key'] ) { |
|
1415 | - $return = true; |
|
1416 | - } |
|
1417 | - } |
|
1412 | + $session = wpinv_get_checkout_session(); |
|
1413 | + if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
1414 | + if ( $session['invoice_key'] === $invoice_meta['key'] ) { |
|
1415 | + $return = true; |
|
1416 | + } |
|
1417 | + } |
|
1418 | 1418 | |
1419 | - return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
1419 | + return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
1420 | 1420 | } |
1421 | 1421 | |
1422 | 1422 | function wpinv_pay_for_invoice() { |