@@ -20,33 +20,33 @@ |
||
20 | 20 | class Windows1252 extends FormatterBase |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Converts the string to windows-1252 encoding. |
|
25 | - * |
|
26 | - * @param string|int|float $input anything easily cast into a string |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function format($input) |
|
30 | - { |
|
31 | - //in case an int or float etc was passed in |
|
32 | - $input = (string)$input; |
|
33 | - if (function_exists('iconv')) { |
|
34 | - $input = iconv('utf-8', 'cp1252//TRANSLIT', $input); |
|
35 | - } elseif ( WP_DEBUG) { |
|
36 | - trigger_error( |
|
37 | - sprintf( |
|
38 | - // @codingStandardsIgnoreStart |
|
39 | - esc_html__('%1$s could not format the string "%2$s" because the function "%3$s" does not exist. Please verify PHP is installed with this function, see %4$s', 'event_espresso'), |
|
40 | - // @codingStandardsIgnoreEnd |
|
41 | - get_class($this), |
|
42 | - $input, |
|
43 | - 'iconv', |
|
44 | - '<a href="http://php.net/manual/en/iconv.installation.php">http://php.net/manual/en/iconv.installation.php</a>' |
|
45 | - ) |
|
46 | - ); |
|
47 | - } |
|
48 | - return $input; |
|
49 | - } |
|
23 | + /** |
|
24 | + * Converts the string to windows-1252 encoding. |
|
25 | + * |
|
26 | + * @param string|int|float $input anything easily cast into a string |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function format($input) |
|
30 | + { |
|
31 | + //in case an int or float etc was passed in |
|
32 | + $input = (string)$input; |
|
33 | + if (function_exists('iconv')) { |
|
34 | + $input = iconv('utf-8', 'cp1252//TRANSLIT', $input); |
|
35 | + } elseif ( WP_DEBUG) { |
|
36 | + trigger_error( |
|
37 | + sprintf( |
|
38 | + // @codingStandardsIgnoreStart |
|
39 | + esc_html__('%1$s could not format the string "%2$s" because the function "%3$s" does not exist. Please verify PHP is installed with this function, see %4$s', 'event_espresso'), |
|
40 | + // @codingStandardsIgnoreEnd |
|
41 | + get_class($this), |
|
42 | + $input, |
|
43 | + 'iconv', |
|
44 | + '<a href="http://php.net/manual/en/iconv.installation.php">http://php.net/manual/en/iconv.installation.php</a>' |
|
45 | + ) |
|
46 | + ); |
|
47 | + } |
|
48 | + return $input; |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | // End of file EmojiRemoval.php |
52 | 52 | // Location: core\services\formatters/EmojiRemoval.php |
@@ -29,10 +29,10 @@ |
||
29 | 29 | public function format($input) |
30 | 30 | { |
31 | 31 | //in case an int or float etc was passed in |
32 | - $input = (string)$input; |
|
32 | + $input = (string) $input; |
|
33 | 33 | if (function_exists('iconv')) { |
34 | 34 | $input = iconv('utf-8', 'cp1252//TRANSLIT', $input); |
35 | - } elseif ( WP_DEBUG) { |
|
35 | + } elseif (WP_DEBUG) { |
|
36 | 36 | trigger_error( |
37 | 37 | sprintf( |
38 | 38 | // @codingStandardsIgnoreStart |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEG_Aim extends EE_Onsite_Gateway{ |
|
28 | +class EEG_Aim extends EE_Onsite_Gateway { |
|
29 | 29 | |
30 | 30 | const LIVE_URL = 'https://secure2.authorize.net/gateway/transact.dll'; //Authnet URL |
31 | 31 | |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | * @param EEG_Aim $gateway_object |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public function possibly_use_deprecated_aim_server( $url, EEG_Aim $gateway_object ) { |
|
161 | - if( $gateway_object->_server === 'authorize.net' |
|
162 | - && ! $gateway_object->_debug_mode ) { |
|
160 | + public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object) { |
|
161 | + if ($gateway_object->_server === 'authorize.net' |
|
162 | + && ! $gateway_object->_debug_mode) { |
|
163 | 163 | return 'https://secure.authorize.net/gateway/transact.dll'; |
164 | 164 | } else { |
165 | 165 | return $url; |
@@ -182,33 +182,33 @@ discard block |
||
182 | 182 | */ |
183 | 183 | |
184 | 184 | public function do_direct_payment($payment, $billing_info = null) { |
185 | - add_filter( 'FHEE__EEG_Aim___get_server_url', array( $this, 'possibly_use_deprecated_aim_server' ), 10, 2 ); |
|
185 | + add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2); |
|
186 | 186 | // Enable test mode if needed |
187 | 187 | //4007000000027 <-- test successful visa |
188 | 188 | //4222222222222 <-- test failure card number |
189 | 189 | |
190 | 190 | $item_num = 1; |
191 | 191 | $transaction = $payment->transaction(); |
192 | - $order_description = $this->_format_order_description( $payment ); |
|
192 | + $order_description = $this->_format_order_description($payment); |
|
193 | 193 | $primary_registrant = $transaction->primary_registration(); |
194 | 194 | //if we're are charging for the full amount, show the normal line items |
195 | 195 | //and the itemized total adds up properly |
196 | - if( $this->_can_easily_itemize_transaction_for( $payment ) ){ |
|
196 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
197 | 197 | $total_line_item = $transaction->total_line_item(); |
198 | 198 | foreach ($total_line_item->get_items() as $line_item) { |
199 | - if( $line_item->quantity() == 0 ){ |
|
199 | + if ($line_item->quantity() == 0) { |
|
200 | 200 | continue; |
201 | 201 | } |
202 | 202 | $this->addLineItem( |
203 | 203 | $item_num++, |
204 | - $this->_format_line_item_name( $line_item, $payment ), |
|
205 | - $this->_format_line_item_desc( $line_item, $payment ), |
|
204 | + $this->_format_line_item_name($line_item, $payment), |
|
205 | + $this->_format_line_item_desc($line_item, $payment), |
|
206 | 206 | $line_item->quantity(), |
207 | 207 | $line_item->unit_price(), |
208 | 208 | 'N'); |
209 | 209 | $order_description .= $line_item->desc().', '; |
210 | 210 | } |
211 | - foreach($total_line_item->tax_descendants() as $tax_line_item){ |
|
211 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
212 | 212 | $this->addLineItem($item_num++, $tax_line_item->name(), $tax_line_item->desc(), 1, $tax_line_item->total(), 'N'); |
213 | 213 | } |
214 | 214 | } |
@@ -219,18 +219,18 @@ discard block |
||
219 | 219 | //start transaction |
220 | 220 | //if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id |
221 | 221 | $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363'; |
222 | - $this->setField( 'solution_id', $partner_id ); |
|
222 | + $this->setField('solution_id', $partner_id); |
|
223 | 223 | $this->setField('amount', $this->format_currency($payment->amount())); |
224 | - $this->setField('description',substr(rtrim($order_description, ', '), 0, 255)); |
|
225 | - $this->_set_sensitive_billing_data( $billing_info ); |
|
224 | + $this->setField('description', substr(rtrim($order_description, ', '), 0, 255)); |
|
225 | + $this->_set_sensitive_billing_data($billing_info); |
|
226 | 226 | $this->setField('first_name', $billing_info['first_name']); |
227 | 227 | $this->setField('last_name', $billing_info['last_name']); |
228 | 228 | $this->setField('email', $billing_info['email']); |
229 | 229 | $this->setField('company', $billing_info['company']); |
230 | 230 | $this->setField('address', $billing_info['address'].' '.$billing_info['address2']); |
231 | 231 | $this->setField('city', $billing_info['city']); |
232 | - $this->setField('state', $billing_info['state'] ); |
|
233 | - $this->setField('country', $billing_info['country'] ); |
|
232 | + $this->setField('state', $billing_info['state']); |
|
233 | + $this->setField('country', $billing_info['country']); |
|
234 | 234 | $this->setField('zip', $billing_info['zip']); |
235 | 235 | $this->setField('fax', $billing_info['fax']); |
236 | 236 | $this->setField('cust_id', $primary_registrant->ID()); |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | //invoice_num would be nice to have it be unique per SPCO page-load, that way if users |
239 | 239 | //press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page |
240 | 240 | //in which case, we need to generate teh invoice num per request right here... |
241 | - $this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
241 | + $this->setField('invoice_num', wp_generate_password(12, false)); //$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
242 | 242 | //tell AIM that any duplicates sent in the next 5 minutes are to be ignored |
243 | - $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS ); |
|
243 | + $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS); |
|
244 | 244 | |
245 | 245 | |
246 | 246 | if ($this->_test_transactions) { |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | //Capture response |
251 | 251 | $this->type = "AUTH_CAPTURE"; |
252 | 252 | $response = $this->_sendRequest($payment); |
253 | - if (!empty($response)){ |
|
253 | + if ( ! empty($response)) { |
|
254 | 254 | if ($response->error_message) { |
255 | 255 | $payment->set_status($this->_pay_model->failed_status()); |
256 | 256 | $payment->set_gateway_response($response->error_message); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | $payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status(); |
259 | 259 | $payment->set_status($payment_status); |
260 | 260 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
261 | - $payment->set_amount( (float) $response->amount ); |
|
261 | + $payment->set_amount((float) $response->amount); |
|
262 | 262 | $payment->set_gateway_response( |
263 | 263 | sprintf( |
264 | 264 | esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'), |
@@ -271,14 +271,14 @@ discard block |
||
271 | 271 | } else { |
272 | 272 | $txn_id = $response->transaction_id; |
273 | 273 | } |
274 | - $payment->set_txn_id_chq_nmbr( $txn_id ); |
|
274 | + $payment->set_txn_id_chq_nmbr($txn_id); |
|
275 | 275 | } |
276 | 276 | $payment->set_extra_accntng($primary_registrant->reg_code()); |
277 | - $payment->set_details(print_r($response,true)); |
|
277 | + $payment->set_details(print_r($response, true)); |
|
278 | 278 | } else { |
279 | 279 | $payment->set_status($this->_pay_model->failed_status()); |
280 | 280 | $payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso')); |
281 | - $payment->set_details(print_r($response,true)); |
|
281 | + $payment->set_details(print_r($response, true)); |
|
282 | 282 | } |
283 | 283 | return $payment; |
284 | 284 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * what billing data gets sent |
290 | 290 | * @param array $billing_info |
291 | 291 | */ |
292 | - protected function _set_sensitive_billing_data( $billing_info ) { |
|
292 | + protected function _set_sensitive_billing_data($billing_info) { |
|
293 | 293 | $this->setField('card_num', $billing_info['credit_card']); |
294 | 294 | $this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']); |
295 | 295 | $this->setField('card_code', $billing_info['cvv']); |
@@ -347,23 +347,23 @@ discard block |
||
347 | 347 | $this->_x_post_fields['tran_key'] = $this->_transaction_key; |
348 | 348 | $x_keys = array(); |
349 | 349 | foreach ($this->_x_post_fields as $key => $value) { |
350 | - $x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value)); |
|
350 | + $x_keys[] = "x_$key=".urlencode($this->_get_unsupported_character_remover()->format($value)); |
|
351 | 351 | } |
352 | 352 | // Add line items |
353 | 353 | foreach ($this->_additional_line_items as $key => $value) { |
354 | - $x_keys[] = "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value)); |
|
354 | + $x_keys[] = "x_line_item=".urlencode($this->_get_unsupported_character_remover()->format($value)); |
|
355 | 355 | } |
356 | 356 | $this->_log_clean_request($x_keys, $payment); |
357 | 357 | $post_url = $this->_get_server_url(); |
358 | 358 | $curl_request = curl_init($post_url); |
359 | - $post_body = implode("&",$x_keys); |
|
359 | + $post_body = implode("&", $x_keys); |
|
360 | 360 | curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body); |
361 | 361 | curl_setopt($curl_request, CURLOPT_HEADER, 0); |
362 | 362 | curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); |
363 | 363 | curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); |
364 | 364 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); |
365 | 365 | if ($this->VERIFY_PEER) { |
366 | - curl_setopt($curl_request, CURLOPT_CAINFO, dirname( __DIR__ ) . '/ssl/cert.pem'); |
|
366 | + curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__).'/ssl/cert.pem'); |
|
367 | 367 | } else { |
368 | 368 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); |
369 | 369 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $response = curl_exec($curl_request); |
376 | 376 | |
377 | 377 | curl_close($curl_request); |
378 | - $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
378 | + $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
379 | 379 | |
380 | 380 | return $this->_log_and_clean_response($response_obj, $payment); |
381 | 381 | } |
@@ -384,18 +384,18 @@ discard block |
||
384 | 384 | * @param array $request_array |
385 | 385 | * @param EEI_Payment $payment |
386 | 386 | */ |
387 | - protected function _log_clean_request($request_array,$payment){ |
|
388 | - $keys_to_filter_out = array( 'x_card_num', 'x_card_code', 'x_exp_date' ); |
|
389 | - foreach($request_array as $index => $keyvaltogether ) { |
|
390 | - foreach( $keys_to_filter_out as $key ) { |
|
391 | - if( strpos( $keyvaltogether, $key ) === 0 ){ |
|
387 | + protected function _log_clean_request($request_array, $payment) { |
|
388 | + $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date'); |
|
389 | + foreach ($request_array as $index => $keyvaltogether) { |
|
390 | + foreach ($keys_to_filter_out as $key) { |
|
391 | + if (strpos($keyvaltogether, $key) === 0) { |
|
392 | 392 | //found it at the first character |
393 | 393 | //so its one of them |
394 | - unset( $request_array[ $index ] ); |
|
394 | + unset($request_array[$index]); |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | } |
398 | - $this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url() ),$payment); |
|
398 | + $this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url()), $payment); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | |
@@ -407,9 +407,9 @@ discard block |
||
407 | 407 | * @param EE_Payment $payment |
408 | 408 | * @return \EE_AuthorizeNetAIM_Response |
409 | 409 | */ |
410 | - private function _log_and_clean_response($response_obj,$payment){ |
|
410 | + private function _log_and_clean_response($response_obj, $payment) { |
|
411 | 411 | $response_obj->account_number = ''; |
412 | - $this->log(array('AIM Response received:'=>(array)$response_obj),$payment); |
|
412 | + $this->log(array('AIM Response received:'=>(array) $response_obj), $payment); |
|
413 | 413 | return $response_obj; |
414 | 414 | } |
415 | 415 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | // Split Array |
509 | 509 | $this->response = $response; |
510 | 510 | if ($encap_char) { |
511 | - $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
511 | + $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); |
|
512 | 512 | } else { |
513 | 513 | $this->_response_array = explode($delimiter, $response); |
514 | 514 | } |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | |
592 | 592 | } |
593 | 593 | |
594 | -if ( ! class_exists( 'AuthorizeNetException' ) ) { |
|
594 | +if ( ! class_exists('AuthorizeNetException')) { |
|
595 | 595 | /** |
596 | 596 | * Class AuthorizeNetException |
597 | 597 | * |
@@ -607,8 +607,8 @@ discard block |
||
607 | 607 | * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0 |
608 | 608 | * @since 5.1.0 |
609 | 609 | */ |
610 | - public function __construct( $message = "", $code = 0, Exception $previous = null ) { |
|
611 | - parent::__construct( $message, $code, $previous ); |
|
610 | + public function __construct($message = "", $code = 0, Exception $previous = null) { |
|
611 | + parent::__construct($message, $code, $previous); |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | //in which case, we need to generate teh invoice num per request right here... |
241 | 241 | $this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
242 | 242 | //tell AIM that any duplicates sent in the next 5 minutes are to be ignored |
243 | - $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS ); |
|
243 | + $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS ); |
|
244 | 244 | |
245 | 245 | |
246 | 246 | if ($this->_test_transactions) { |
@@ -252,27 +252,27 @@ discard block |
||
252 | 252 | $response = $this->_sendRequest($payment); |
253 | 253 | if (!empty($response)){ |
254 | 254 | if ($response->error_message) { |
255 | - $payment->set_status($this->_pay_model->failed_status()); |
|
256 | - $payment->set_gateway_response($response->error_message); |
|
257 | - } else { |
|
258 | - $payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status(); |
|
259 | - $payment->set_status($payment_status); |
|
260 | - //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
|
261 | - $payment->set_amount( (float) $response->amount ); |
|
262 | - $payment->set_gateway_response( |
|
263 | - sprintf( |
|
264 | - esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'), |
|
265 | - $response->response_reason_text, |
|
266 | - $response->response_reason_code |
|
267 | - ) |
|
268 | - ); |
|
269 | - if ($this->_debug_mode) { |
|
270 | - $txn_id = $response->invoice_number; |
|
271 | - } else { |
|
272 | - $txn_id = $response->transaction_id; |
|
273 | - } |
|
274 | - $payment->set_txn_id_chq_nmbr( $txn_id ); |
|
275 | - } |
|
255 | + $payment->set_status($this->_pay_model->failed_status()); |
|
256 | + $payment->set_gateway_response($response->error_message); |
|
257 | + } else { |
|
258 | + $payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status(); |
|
259 | + $payment->set_status($payment_status); |
|
260 | + //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
|
261 | + $payment->set_amount( (float) $response->amount ); |
|
262 | + $payment->set_gateway_response( |
|
263 | + sprintf( |
|
264 | + esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'), |
|
265 | + $response->response_reason_text, |
|
266 | + $response->response_reason_code |
|
267 | + ) |
|
268 | + ); |
|
269 | + if ($this->_debug_mode) { |
|
270 | + $txn_id = $response->invoice_number; |
|
271 | + } else { |
|
272 | + $txn_id = $response->transaction_id; |
|
273 | + } |
|
274 | + $payment->set_txn_id_chq_nmbr( $txn_id ); |
|
275 | + } |
|
276 | 276 | $payment->set_extra_accntng($primary_registrant->reg_code()); |
277 | 277 | $payment->set_details(print_r($response,true)); |
278 | 278 | } else { |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $this->_log_clean_request($x_keys, $payment); |
357 | 357 | $post_url = $this->_get_server_url(); |
358 | 358 | $curl_request = curl_init($post_url); |
359 | - $post_body = implode("&",$x_keys); |
|
359 | + $post_body = implode("&",$x_keys); |
|
360 | 360 | curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body); |
361 | 361 | curl_setopt($curl_request, CURLOPT_HEADER, 0); |
362 | 362 | curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | public $requested_amount; |
490 | 490 | public $balance_on_card; |
491 | 491 | public $response; // The response string from AuthorizeNet. |
492 | - public $error_message; |
|
492 | + public $error_message; |
|
493 | 493 | private $_response_array = array(); // An array with the split response. |
494 | 494 | |
495 | 495 | /** |
@@ -521,9 +521,9 @@ discard block |
||
521 | 521 | $this->approved = false; |
522 | 522 | $this->error = true; |
523 | 523 | $this->error_message = sprintf( |
524 | - esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'), |
|
525 | - esc_html($response) |
|
526 | - ); |
|
524 | + esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'), |
|
525 | + esc_html($response) |
|
526 | + ); |
|
527 | 527 | return; |
528 | 528 | } |
529 | 529 | |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | $this->approved = false; |
585 | 585 | $this->error = true; |
586 | 586 | $this->error_message = esc_html__( |
587 | - 'Error connecting to Authorize.net', |
|
588 | - 'event_espresso' |
|
589 | - ); |
|
587 | + 'Error connecting to Authorize.net', |
|
588 | + 'event_espresso' |
|
589 | + ); |
|
590 | 590 | } |
591 | 591 | } |
592 | 592 |
@@ -8,71 +8,71 @@ discard block |
||
8 | 8 | */ |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
10 | 10 | /** |
11 | - * |
|
12 | - * Money helper class. |
|
13 | - * This class has helper methods that help with money related conversions and calculations. |
|
14 | - * |
|
15 | - * @since %VER% |
|
16 | - * |
|
17 | - * @package Event Espresso |
|
18 | - * @subpackage helpers |
|
19 | - * @author Darren Ethier |
|
20 | - * |
|
21 | - * ------------------------------------------------------------------------ |
|
22 | - */ |
|
11 | + * |
|
12 | + * Money helper class. |
|
13 | + * This class has helper methods that help with money related conversions and calculations. |
|
14 | + * |
|
15 | + * @since %VER% |
|
16 | + * |
|
17 | + * @package Event Espresso |
|
18 | + * @subpackage helpers |
|
19 | + * @author Darren Ethier |
|
20 | + * |
|
21 | + * ------------------------------------------------------------------------ |
|
22 | + */ |
|
23 | 23 | class EEH_Money extends EEH_Base { |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * This removes all localized money formatting from the incoming value |
|
28 | - * |
|
29 | - * Note: uses this site's currency settings for deciding what is considered a |
|
30 | - * "thousands separator" (usually the character "," ) |
|
31 | - * and what is a "decimal mark" (usually the character ".") |
|
32 | - * |
|
33 | - * @param int|float|string $money_value |
|
34 | - * @param string $CNT_ISO |
|
35 | - * @return float |
|
36 | - * @throws EE_Error |
|
37 | - */ |
|
26 | + /** |
|
27 | + * This removes all localized money formatting from the incoming value |
|
28 | + * |
|
29 | + * Note: uses this site's currency settings for deciding what is considered a |
|
30 | + * "thousands separator" (usually the character "," ) |
|
31 | + * and what is a "decimal mark" (usually the character ".") |
|
32 | + * |
|
33 | + * @param int|float|string $money_value |
|
34 | + * @param string $CNT_ISO |
|
35 | + * @return float |
|
36 | + * @throws EE_Error |
|
37 | + */ |
|
38 | 38 | public static function strip_localized_money_formatting($money_value, $CNT_ISO = '') { |
39 | - $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
40 | - $money_value = str_replace( |
|
41 | - array( |
|
42 | - $currency_config->thsnds, |
|
43 | - $currency_config->dec_mrk, |
|
44 | - ), |
|
45 | - array( |
|
46 | - '', // remove thousands separator |
|
47 | - '.', // convert decimal mark to what PHP expects |
|
48 | - ), |
|
49 | - $money_value |
|
50 | - ); |
|
51 | - $money_value = filter_var( |
|
52 | - $money_value, |
|
53 | - FILTER_SANITIZE_NUMBER_FLOAT, |
|
54 | - FILTER_FLAG_ALLOW_FRACTION |
|
55 | - ); |
|
56 | - return $money_value; |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * This converts an incoming localized money value into a standard float item (to three decimal places) |
|
63 | - * |
|
64 | - * Only use this if you know the $money_value follows your currency configuration's |
|
65 | - * settings. Note: this uses this site's currency settings for deciding what is considered a |
|
66 | - * "thousands separator" (usually the character "," ) |
|
67 | - * and what is a "decimal mark" (usually the character ".") |
|
68 | - * |
|
69 | - * @param int|string $money_value |
|
70 | - * @return float |
|
71 | - * @throws EE_Error |
|
72 | - */ |
|
39 | + $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
40 | + $money_value = str_replace( |
|
41 | + array( |
|
42 | + $currency_config->thsnds, |
|
43 | + $currency_config->dec_mrk, |
|
44 | + ), |
|
45 | + array( |
|
46 | + '', // remove thousands separator |
|
47 | + '.', // convert decimal mark to what PHP expects |
|
48 | + ), |
|
49 | + $money_value |
|
50 | + ); |
|
51 | + $money_value = filter_var( |
|
52 | + $money_value, |
|
53 | + FILTER_SANITIZE_NUMBER_FLOAT, |
|
54 | + FILTER_FLAG_ALLOW_FRACTION |
|
55 | + ); |
|
56 | + return $money_value; |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * This converts an incoming localized money value into a standard float item (to three decimal places) |
|
63 | + * |
|
64 | + * Only use this if you know the $money_value follows your currency configuration's |
|
65 | + * settings. Note: this uses this site's currency settings for deciding what is considered a |
|
66 | + * "thousands separator" (usually the character "," ) |
|
67 | + * and what is a "decimal mark" (usually the character ".") |
|
68 | + * |
|
69 | + * @param int|string $money_value |
|
70 | + * @return float |
|
71 | + * @throws EE_Error |
|
72 | + */ |
|
73 | 73 | public static function convert_to_float_from_localized_money($money_value ) { |
74 | 74 | //float it! and round to three decimal places |
75 | - return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 ); |
|
75 | + return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -160,19 +160,19 @@ discard block |
||
160 | 160 | |
161 | 161 | |
162 | 162 | |
163 | - /** |
|
164 | - * This returns a localized format string suitable for jQplot. |
|
165 | - * |
|
166 | - * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
167 | - * Otherwise will use currency settings for current active country on site. |
|
168 | - * @return string |
|
169 | - * @throws EE_Error |
|
170 | - */ |
|
163 | + /** |
|
164 | + * This returns a localized format string suitable for jQplot. |
|
165 | + * |
|
166 | + * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
167 | + * Otherwise will use currency settings for current active country on site. |
|
168 | + * @return string |
|
169 | + * @throws EE_Error |
|
170 | + */ |
|
171 | 171 | public static function get_format_for_jqplot( $CNT_ISO = '') { |
172 | 172 | //default format |
173 | 173 | $format = 'f'; |
174 | 174 | $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
175 | - //first get the decimal place and number of places |
|
175 | + //first get the decimal place and number of places |
|
176 | 176 | $format = "%'." . $currency_config->dec_plc . $format; |
177 | 177 | //currency symbol on right side. |
178 | 178 | $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
@@ -181,16 +181,16 @@ discard block |
||
181 | 181 | |
182 | 182 | |
183 | 183 | |
184 | - /** |
|
185 | - * This returns a localized format string suitable for usage with the Google Charts API format param. |
|
186 | - * |
|
187 | - * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
188 | - * Otherwise will use currency settings for current active country on site. |
|
189 | - * Note: GoogleCharts uses ICU pattern set |
|
190 | - * (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details) |
|
191 | - * @return string |
|
192 | - * @throws EE_Error |
|
193 | - */ |
|
184 | + /** |
|
185 | + * This returns a localized format string suitable for usage with the Google Charts API format param. |
|
186 | + * |
|
187 | + * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
188 | + * Otherwise will use currency settings for current active country on site. |
|
189 | + * Note: GoogleCharts uses ICU pattern set |
|
190 | + * (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details) |
|
191 | + * @return string |
|
192 | + * @throws EE_Error |
|
193 | + */ |
|
194 | 194 | public static function get_format_for_google_charts( $CNT_ISO = '' ) { |
195 | 195 | $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
196 | 196 | $decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' ); |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | |
218 | 218 | |
219 | 219 | |
220 | - /** |
|
221 | - * @param string $CNT_ISO |
|
222 | - * @return EE_Currency_Config|null |
|
223 | - * @throws EE_Error |
|
224 | - */ |
|
225 | - public static function get_currency_config($CNT_ISO = '') |
|
226 | - { |
|
227 | - //if CNT_ISO passed lets try to get currency settings for it. |
|
228 | - $currency_config = $CNT_ISO !== '' |
|
229 | - ? new EE_Currency_Config($CNT_ISO) |
|
230 | - : null; |
|
231 | - //default currency settings for site if not set |
|
232 | - if (! $currency_config instanceof EE_Currency_Config) { |
|
233 | - $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
234 | - ? EE_Registry::instance()->CFG->currency |
|
235 | - : new EE_Currency_Config(); |
|
236 | - } |
|
237 | - return $currency_config; |
|
238 | - } |
|
220 | + /** |
|
221 | + * @param string $CNT_ISO |
|
222 | + * @return EE_Currency_Config|null |
|
223 | + * @throws EE_Error |
|
224 | + */ |
|
225 | + public static function get_currency_config($CNT_ISO = '') |
|
226 | + { |
|
227 | + //if CNT_ISO passed lets try to get currency settings for it. |
|
228 | + $currency_config = $CNT_ISO !== '' |
|
229 | + ? new EE_Currency_Config($CNT_ISO) |
|
230 | + : null; |
|
231 | + //default currency settings for site if not set |
|
232 | + if (! $currency_config instanceof EE_Currency_Config) { |
|
233 | + $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
234 | + ? EE_Registry::instance()->CFG->currency |
|
235 | + : new EE_Currency_Config(); |
|
236 | + } |
|
237 | + return $currency_config; |
|
238 | + } |
|
239 | 239 | |
240 | 240 | } //end class EEH_Money |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
4 | - exit('NO direct script access allowed'); |
|
4 | + exit('NO direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -36,82 +36,82 @@ discard block |
||
36 | 36 | { |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * _init_props |
|
41 | - * |
|
42 | - * @access protected |
|
43 | - * @return void |
|
44 | - */ |
|
45 | - protected function _init_props() |
|
46 | - { |
|
47 | - $this->label = __('Attendee Shortcodes', 'event_espresso'); |
|
48 | - $this->description = __('All shortcodes specific to attendee related data', 'event_espresso'); |
|
49 | - $this->_shortcodes = array( |
|
50 | - '[QUESTION]' => __('Will parse to a question.', 'event_espresso'), |
|
51 | - '[ANSWER]' => __('Will parse to the answer for a question', 'event_espresso') |
|
52 | - ); |
|
53 | - } |
|
39 | + /** |
|
40 | + * _init_props |
|
41 | + * |
|
42 | + * @access protected |
|
43 | + * @return void |
|
44 | + */ |
|
45 | + protected function _init_props() |
|
46 | + { |
|
47 | + $this->label = __('Attendee Shortcodes', 'event_espresso'); |
|
48 | + $this->description = __('All shortcodes specific to attendee related data', 'event_espresso'); |
|
49 | + $this->_shortcodes = array( |
|
50 | + '[QUESTION]' => __('Will parse to a question.', 'event_espresso'), |
|
51 | + '[ANSWER]' => __('Will parse to the answer for a question', 'event_espresso') |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * This method will give parsing instructions for each shortcode defined in the _shortcodes array. Child methods |
|
58 | - * will have to take care of handling. |
|
59 | - * |
|
60 | - * @access protected |
|
61 | - * |
|
62 | - * @param string $shortcode the shortcode to be parsed. |
|
63 | - * |
|
64 | - * @return string parsed shortcode |
|
65 | - */ |
|
66 | - protected function _parser($shortcode) |
|
67 | - { |
|
56 | + /** |
|
57 | + * This method will give parsing instructions for each shortcode defined in the _shortcodes array. Child methods |
|
58 | + * will have to take care of handling. |
|
59 | + * |
|
60 | + * @access protected |
|
61 | + * |
|
62 | + * @param string $shortcode the shortcode to be parsed. |
|
63 | + * |
|
64 | + * @return string parsed shortcode |
|
65 | + */ |
|
66 | + protected function _parser($shortcode) |
|
67 | + { |
|
68 | 68 | |
69 | - if ( ! $this->_data instanceof EE_Answer || ! isset($this->_extra_data['data']) || ! $this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
70 | - return ''; |
|
71 | - } |
|
69 | + if ( ! $this->_data instanceof EE_Answer || ! isset($this->_extra_data['data']) || ! $this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
70 | + return ''; |
|
71 | + } |
|
72 | 72 | |
73 | - switch ($shortcode) { |
|
73 | + switch ($shortcode) { |
|
74 | 74 | |
75 | - case '[QUESTION]' : |
|
76 | - $question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question(); |
|
77 | - if ( ! $question instanceof EE_Question) { |
|
78 | - return ''; //get out because we can't figure out what the question is. |
|
79 | - } |
|
75 | + case '[QUESTION]' : |
|
76 | + $question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question(); |
|
77 | + if ( ! $question instanceof EE_Question) { |
|
78 | + return ''; //get out because we can't figure out what the question is. |
|
79 | + } |
|
80 | 80 | |
81 | - return $question->get('QST_display_text'); |
|
82 | - break; |
|
81 | + return $question->get('QST_display_text'); |
|
82 | + break; |
|
83 | 83 | |
84 | - case '[ANSWER]' : |
|
85 | - //need to get the question to determine the type of question (some questions require translation of the answer). |
|
86 | - $question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question(); |
|
87 | - if ( ! $question instanceof EE_Question) { |
|
88 | - return ''; //get out cause we can't figure out what the question type is! |
|
89 | - } |
|
84 | + case '[ANSWER]' : |
|
85 | + //need to get the question to determine the type of question (some questions require translation of the answer). |
|
86 | + $question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question(); |
|
87 | + if ( ! $question instanceof EE_Question) { |
|
88 | + return ''; //get out cause we can't figure out what the question type is! |
|
89 | + } |
|
90 | 90 | |
91 | - //what we show for the answer depends on the question type! |
|
92 | - switch ($question->get('QST_type')) { |
|
91 | + //what we show for the answer depends on the question type! |
|
92 | + switch ($question->get('QST_type')) { |
|
93 | 93 | |
94 | - case 'STATE' : |
|
95 | - $state = EEM_State::instance()->get_one_by_ID($this->_data->get('ANS_value')); |
|
96 | - $answer = $state instanceof EE_State ? $state->name() : ''; |
|
97 | - break; |
|
94 | + case 'STATE' : |
|
95 | + $state = EEM_State::instance()->get_one_by_ID($this->_data->get('ANS_value')); |
|
96 | + $answer = $state instanceof EE_State ? $state->name() : ''; |
|
97 | + break; |
|
98 | 98 | |
99 | - case 'COUNTRY' : |
|
100 | - $country = EEM_Country::instance()->get_one_by_ID($this->_data->get('ANS_value')); |
|
101 | - $answer = $country instanceof EE_Country ? $country->name() : ''; |
|
102 | - break; |
|
99 | + case 'COUNTRY' : |
|
100 | + $country = EEM_Country::instance()->get_one_by_ID($this->_data->get('ANS_value')); |
|
101 | + $answer = $country instanceof EE_Country ? $country->name() : ''; |
|
102 | + break; |
|
103 | 103 | |
104 | - default : |
|
105 | - $answer = $this->_data->get_pretty('ANS_value', 'no_wpautop'); |
|
106 | - break; |
|
107 | - } |
|
104 | + default : |
|
105 | + $answer = $this->_data->get_pretty('ANS_value', 'no_wpautop'); |
|
106 | + break; |
|
107 | + } |
|
108 | 108 | |
109 | - return $answer; |
|
110 | - break; |
|
109 | + return $answer; |
|
110 | + break; |
|
111 | 111 | |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | - return ''; |
|
115 | - } |
|
114 | + return ''; |
|
115 | + } |
|
116 | 116 | |
117 | 117 | } //end EE_Question_Shortcodes class |
@@ -43,7 +43,7 @@ |
||
43 | 43 | <div class="padding"> |
44 | 44 | <h4 class="espresso-header"><span class="dashicons dashicons-post-trash ee-icon-size-22"></span><?php esc_html_e('Permanently Delete ALL Event Espresso Data', 'event_espresso');?></h4> |
45 | 45 | <p><?php esc_html_e(' This will delete data for Event Espresso 4, and all currently active add-ons. Event Espresso will then be deactivated. You may need to manually deactivate each add-on individually.', |
46 | - 'event_espresso');?></p> |
|
46 | + 'event_espresso');?></p> |
|
47 | 47 | <p><?php esc_html_e('If you know for certain that you will no longer be using Event Espresso and you wish to remove ALL traces of the plugin from your system, then perform the following steps.', 'event_espresso');?></p> |
48 | 48 | <p class="important-notice"><?php printf( esc_html__('Please note: %sThis is permanent and can NOT be undone.%s', 'event_espresso'), '<em>', '</em>' ); ?><br/></p> |
49 | 49 | <ol> |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | /** @var string $delete_db_url */ |
8 | 8 | ?> |
9 | 9 | <h2> |
10 | - <?php esc_html_e( 'Reset/Delete Data for Event Espresso', 'event_espresso' );?> |
|
10 | + <?php esc_html_e('Reset/Delete Data for Event Espresso', 'event_espresso'); ?> |
|
11 | 11 | </h2> |
12 | 12 | <br /> |
13 | 13 | |
14 | 14 | <div class="padding"> |
15 | - <h4 class="espresso-header"><span class="dashicons dashicons-update ee-icon-size-22"></span><?php esc_html_e('Reset Ticket and Datetime Reserved Counts', 'event_espresso');?></h4> |
|
16 | - <p><?php esc_html_e('Use this to reset the counts for ticket and datetime reservations.', 'event_espresso');?></p> |
|
15 | + <h4 class="espresso-header"><span class="dashicons dashicons-update ee-icon-size-22"></span><?php esc_html_e('Reset Ticket and Datetime Reserved Counts', 'event_espresso'); ?></h4> |
|
16 | + <p><?php esc_html_e('Use this to reset the counts for ticket and datetime reservations.', 'event_espresso'); ?></p> |
|
17 | 17 | <div class="float-right"><?php echo $reset_reservations_button; ?></div> |
18 | 18 | <div class="clear"></div> |
19 | 19 | </div> |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | |
23 | 23 | <!-- reset DB url is here. Just need to make it look pretty and unhide it--> |
24 | 24 | <div class="padding"> |
25 | - <h4 class="espresso-header"><span class="dashicons dashicons-update ee-icon-size-22"></span><?php esc_html_e('Reset Event Espresso Capabilities', 'event_espresso');?></h4> |
|
26 | - <p><?php esc_html_e('Use this to reset the capabilities on WP roles to the defaults as defined via EE_Capabilities. Note this reset does not REMOVE any existing capabilities, it just ensures that all the defaults are ADDED to the roles.', 'event_espresso');?></p> |
|
25 | + <h4 class="espresso-header"><span class="dashicons dashicons-update ee-icon-size-22"></span><?php esc_html_e('Reset Event Espresso Capabilities', 'event_espresso'); ?></h4> |
|
26 | + <p><?php esc_html_e('Use this to reset the capabilities on WP roles to the defaults as defined via EE_Capabilities. Note this reset does not REMOVE any existing capabilities, it just ensures that all the defaults are ADDED to the roles.', 'event_espresso'); ?></p> |
|
27 | 27 | <div class="float-right"><?php echo $reset_capabilities_button; ?></div> |
28 | 28 | <div class="clear"></div> |
29 | 29 | </div> |
@@ -31,27 +31,27 @@ discard block |
||
31 | 31 | <br /> |
32 | 32 | |
33 | 33 | <div class="padding"> |
34 | - <h4 class="espresso-header"><span class="dashicons dashicons-update ee-icon-size-22"></span><?php esc_html_e('Reset Event Espresso Data', 'event_espresso');?></h4> |
|
35 | - <p><?php esc_html_e(' This will reset data for Event Espresso 4, and for all active add-ons. Inactive add-ons will not be affected.', 'event_espresso');?></p> |
|
36 | - <p><?php esc_html_e('Your Event Espresso data will return to its default settings. The rest of your website will be unaffected.', 'event_espresso');?></p> |
|
37 | - <div class="float-right"><a class="button button-primary" href="<?php echo $reset_db_url;?>"><?php esc_html_e('Reset Event Espresso Tables', 'event_espresso');?></a></div> |
|
34 | + <h4 class="espresso-header"><span class="dashicons dashicons-update ee-icon-size-22"></span><?php esc_html_e('Reset Event Espresso Data', 'event_espresso'); ?></h4> |
|
35 | + <p><?php esc_html_e(' This will reset data for Event Espresso 4, and for all active add-ons. Inactive add-ons will not be affected.', 'event_espresso'); ?></p> |
|
36 | + <p><?php esc_html_e('Your Event Espresso data will return to its default settings. The rest of your website will be unaffected.', 'event_espresso'); ?></p> |
|
37 | + <div class="float-right"><a class="button button-primary" href="<?php echo $reset_db_url; ?>"><?php esc_html_e('Reset Event Espresso Tables', 'event_espresso'); ?></a></div> |
|
38 | 38 | <div class="clear"></div> |
39 | 39 | </div> |
40 | 40 | <br /> |
41 | 41 | <br /> |
42 | 42 | |
43 | 43 | <div class="padding"> |
44 | - <h4 class="espresso-header"><span class="dashicons dashicons-post-trash ee-icon-size-22"></span><?php esc_html_e('Permanently Delete ALL Event Espresso Data', 'event_espresso');?></h4> |
|
44 | + <h4 class="espresso-header"><span class="dashicons dashicons-post-trash ee-icon-size-22"></span><?php esc_html_e('Permanently Delete ALL Event Espresso Data', 'event_espresso'); ?></h4> |
|
45 | 45 | <p><?php esc_html_e(' This will delete data for Event Espresso 4, and all currently active add-ons. Event Espresso will then be deactivated. You may need to manually deactivate each add-on individually.', |
46 | - 'event_espresso');?></p> |
|
47 | - <p><?php esc_html_e('If you know for certain that you will no longer be using Event Espresso and you wish to remove ALL traces of the plugin from your system, then perform the following steps.', 'event_espresso');?></p> |
|
48 | - <p class="important-notice"><?php printf( esc_html__('Please note: %sThis is permanent and can NOT be undone.%s', 'event_espresso'), '<em>', '</em>' ); ?><br/></p> |
|
46 | + 'event_espresso'); ?></p> |
|
47 | + <p><?php esc_html_e('If you know for certain that you will no longer be using Event Espresso and you wish to remove ALL traces of the plugin from your system, then perform the following steps.', 'event_espresso'); ?></p> |
|
48 | + <p class="important-notice"><?php printf(esc_html__('Please note: %sThis is permanent and can NOT be undone.%s', 'event_espresso'), '<em>', '</em>'); ?><br/></p> |
|
49 | 49 | <ol> |
50 | - <li><?php printf( esc_html__('First, click the button below to permanently delete all Event Espresso tables, records, and options from your WordPress database . If you receive a "500 Internal Server Error" or a blank white screen, it means the server has timed out due to the large number of records being updated. This is not a cause for concern. Simply %1$srefresh the page%2$s and the Database Update will continue where it left off.', 'event_espresso'), '<strong>', '</strong>' );?></li> |
|
51 | - <li><?php printf( esc_html__('Then, locate Event Espresso on the WordPress Plugins page, and click on %sDelete%s', 'event_espresso'), '<strong>', '</strong>' ); ?></li> |
|
52 | - <li><?php printf( esc_html__('Once you are on the Delete Plugin page, click on %sYes, Delete these files and data%s', 'event_espresso'), '<strong>', '</strong>' ); ?></li> |
|
50 | + <li><?php printf(esc_html__('First, click the button below to permanently delete all Event Espresso tables, records, and options from your WordPress database . If you receive a "500 Internal Server Error" or a blank white screen, it means the server has timed out due to the large number of records being updated. This is not a cause for concern. Simply %1$srefresh the page%2$s and the Database Update will continue where it left off.', 'event_espresso'), '<strong>', '</strong>'); ?></li> |
|
51 | + <li><?php printf(esc_html__('Then, locate Event Espresso on the WordPress Plugins page, and click on %sDelete%s', 'event_espresso'), '<strong>', '</strong>'); ?></li> |
|
52 | + <li><?php printf(esc_html__('Once you are on the Delete Plugin page, click on %sYes, Delete these files and data%s', 'event_espresso'), '<strong>', '</strong>'); ?></li> |
|
53 | 53 | </ol> |
54 | - <div class="float-right"><a href="<?php echo $delete_db_url; ?>" id="delete-all-data-btn" class="button-primary"><?php esc_html_e('Permanently Delete All Event Espresso Data', 'event_espresso');?></a></div> |
|
54 | + <div class="float-right"><a href="<?php echo $delete_db_url; ?>" id="delete-all-data-btn" class="button-primary"><?php esc_html_e('Permanently Delete All Event Espresso Data', 'event_espresso'); ?></a></div> |
|
55 | 55 | <div class="clear"></div> |
56 | 56 | </div> |
57 | 57 | <br/> |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $default_espresso_events_shortcode_atts |
102 | 102 | ); |
103 | 103 | // grab attributes and merge with defaults, then extract |
104 | - $attributes = array_merge((array)$default_espresso_events_shortcode_atts, (array)$attributes); |
|
104 | + $attributes = array_merge((array) $default_espresso_events_shortcode_atts, (array) $attributes); |
|
105 | 105 | $attributes = \EES_Shortcode::sanitize_attributes( |
106 | 106 | $attributes, |
107 | 107 | // the following get sanitized/whitelisted in EEH_Event_Query |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | { |
186 | 186 | // incoming args could be a mix of WP query args + EE shortcode args |
187 | 187 | foreach ($args as $key => $value) { |
188 | - $property = '_' . $key; |
|
188 | + $property = '_'.$key; |
|
189 | 189 | // if the arg is a property of this class, then it's an EE shortcode arg |
190 | 190 | if (property_exists($this, $property)) { |
191 | 191 | // set the property value |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function event_list_title($event_list_title = '') |
247 | 247 | { |
248 | - if (! empty($this->_title)) { |
|
248 | + if ( ! empty($this->_title)) { |
|
249 | 249 | return $this->_title; |
250 | 250 | } |
251 | 251 | return $event_list_title; |
@@ -15,131 +15,131 @@ discard block |
||
15 | 15 | class EES_Espresso_Events extends EES_Shortcode |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * set_hooks - for hooking into EE Core, modules, etc |
|
20 | - * |
|
21 | - * @access public |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - public static function set_hooks() |
|
25 | - { |
|
26 | - } |
|
27 | - |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
32 | - * |
|
33 | - * @access public |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public static function set_hooks_admin() |
|
37 | - { |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * run - initial module setup |
|
44 | - * |
|
45 | - * @access public |
|
46 | - * @param WP $WP |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - public function run(WP $WP) |
|
50 | - { |
|
51 | - if (did_action('pre_get_posts') && did_action('send_headers')) { |
|
52 | - EED_Events_Archive::instance()->event_list(); |
|
53 | - } else { |
|
54 | - // this will trigger the EED_Events_Archive module's event_list() method |
|
55 | - // during the pre_get_posts hook point, this allows us to initialize things, enqueue assets, etc, |
|
56 | - // as well, this saves an instantiation of the module in an array |
|
57 | - // using 'espresso_events' as the key, so that we can retrieve it |
|
58 | - add_action('pre_get_posts', array(EED_Events_Archive::instance(), 'event_list')); |
|
59 | - } |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * process_shortcode - ESPRESSO_EVENTS - Returns a list of events |
|
66 | - * [ESPRESSO_EVENTS] |
|
67 | - * [ESPRESSO_EVENTS title="My Super Event"] |
|
68 | - * [ESPRESSO_EVENTS limit=5] |
|
69 | - * [ESPRESSO_EVENTS css_class="my-custom-class"] |
|
70 | - * [ESPRESSO_EVENTS month="April 2014"] |
|
71 | - * [ESPRESSO_EVENTS show_expired=true] |
|
72 | - * [ESPRESSO_EVENTS category_slug="free-events"] |
|
73 | - * [ESPRESSO_EVENTS order_by="start_date,id"] |
|
74 | - * [ESPRESSO_EVENTS sort="ASC"] |
|
75 | - * [ESPRESSO_EVENTS show_title=true] |
|
76 | - * |
|
77 | - * @access public |
|
78 | - * @param array $attributes |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function process_shortcode($attributes = array()) |
|
82 | - { |
|
83 | - // make sure EED_Events_Archive is setup properly |
|
84 | - if (apply_filters('FHEE__fallback_shortcode_processor__EES_Espresso_Events', false)) { |
|
85 | - EED_Events_Archive::instance()->event_list(); |
|
86 | - } |
|
87 | - //set default attributes |
|
88 | - $default_espresso_events_shortcode_atts = array( |
|
89 | - 'title' => null, |
|
90 | - 'limit' => 10, |
|
91 | - 'css_class' => null, |
|
92 | - 'show_expired' => false, |
|
93 | - 'month' => null, |
|
94 | - 'category_slug' => null, |
|
95 | - 'order_by' => 'start_date', |
|
96 | - 'sort' => 'ASC', |
|
97 | - 'show_title' => true, |
|
98 | - 'fallback_shortcode_processor' => false, |
|
99 | - ); |
|
100 | - // allow the defaults to be filtered |
|
101 | - $default_espresso_events_shortcode_atts = apply_filters( |
|
102 | - 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
|
103 | - $default_espresso_events_shortcode_atts |
|
104 | - ); |
|
105 | - // grab attributes and merge with defaults, then extract |
|
106 | - $attributes = array_merge((array)$default_espresso_events_shortcode_atts, (array)$attributes); |
|
107 | - $attributes = \EES_Shortcode::sanitize_attributes( |
|
108 | - $attributes, |
|
109 | - // the following get sanitized/whitelisted in EEH_Event_Query |
|
110 | - array( |
|
111 | - 'category_slug' => 'skip_sanitization', |
|
112 | - 'show_expired' => 'skip_sanitization', |
|
113 | - 'order_by' => 'skip_sanitization', |
|
114 | - 'month' => 'skip_sanitization', |
|
115 | - 'sort' => 'skip_sanitization', |
|
116 | - ) |
|
117 | - ); |
|
118 | - // make sure we use the_excerpt() |
|
119 | - add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
120 | - // apply query filters |
|
121 | - add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
122 | - // run the query |
|
123 | - global $wp_query; |
|
124 | - $wp_query = new EE_Event_List_Query($attributes); |
|
125 | - // check what template is loaded and load filters accordingly |
|
126 | - EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
127 | - // load our template |
|
128 | - $event_list = EEH_Template::locate_template( |
|
129 | - 'loop-espresso_events.php', |
|
130 | - array(), |
|
131 | - true, |
|
132 | - true |
|
133 | - ); |
|
134 | - // now reset the query and postdata |
|
135 | - wp_reset_query(); |
|
136 | - wp_reset_postdata(); |
|
137 | - EED_Events_Archive::remove_all_events_archive_filters(); |
|
138 | - // remove query filters |
|
139 | - remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
140 | - // pull our content from the output buffer and return it |
|
141 | - return $event_list; |
|
142 | - } |
|
18 | + /** |
|
19 | + * set_hooks - for hooking into EE Core, modules, etc |
|
20 | + * |
|
21 | + * @access public |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + public static function set_hooks() |
|
25 | + { |
|
26 | + } |
|
27 | + |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
32 | + * |
|
33 | + * @access public |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public static function set_hooks_admin() |
|
37 | + { |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * run - initial module setup |
|
44 | + * |
|
45 | + * @access public |
|
46 | + * @param WP $WP |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + public function run(WP $WP) |
|
50 | + { |
|
51 | + if (did_action('pre_get_posts') && did_action('send_headers')) { |
|
52 | + EED_Events_Archive::instance()->event_list(); |
|
53 | + } else { |
|
54 | + // this will trigger the EED_Events_Archive module's event_list() method |
|
55 | + // during the pre_get_posts hook point, this allows us to initialize things, enqueue assets, etc, |
|
56 | + // as well, this saves an instantiation of the module in an array |
|
57 | + // using 'espresso_events' as the key, so that we can retrieve it |
|
58 | + add_action('pre_get_posts', array(EED_Events_Archive::instance(), 'event_list')); |
|
59 | + } |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * process_shortcode - ESPRESSO_EVENTS - Returns a list of events |
|
66 | + * [ESPRESSO_EVENTS] |
|
67 | + * [ESPRESSO_EVENTS title="My Super Event"] |
|
68 | + * [ESPRESSO_EVENTS limit=5] |
|
69 | + * [ESPRESSO_EVENTS css_class="my-custom-class"] |
|
70 | + * [ESPRESSO_EVENTS month="April 2014"] |
|
71 | + * [ESPRESSO_EVENTS show_expired=true] |
|
72 | + * [ESPRESSO_EVENTS category_slug="free-events"] |
|
73 | + * [ESPRESSO_EVENTS order_by="start_date,id"] |
|
74 | + * [ESPRESSO_EVENTS sort="ASC"] |
|
75 | + * [ESPRESSO_EVENTS show_title=true] |
|
76 | + * |
|
77 | + * @access public |
|
78 | + * @param array $attributes |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function process_shortcode($attributes = array()) |
|
82 | + { |
|
83 | + // make sure EED_Events_Archive is setup properly |
|
84 | + if (apply_filters('FHEE__fallback_shortcode_processor__EES_Espresso_Events', false)) { |
|
85 | + EED_Events_Archive::instance()->event_list(); |
|
86 | + } |
|
87 | + //set default attributes |
|
88 | + $default_espresso_events_shortcode_atts = array( |
|
89 | + 'title' => null, |
|
90 | + 'limit' => 10, |
|
91 | + 'css_class' => null, |
|
92 | + 'show_expired' => false, |
|
93 | + 'month' => null, |
|
94 | + 'category_slug' => null, |
|
95 | + 'order_by' => 'start_date', |
|
96 | + 'sort' => 'ASC', |
|
97 | + 'show_title' => true, |
|
98 | + 'fallback_shortcode_processor' => false, |
|
99 | + ); |
|
100 | + // allow the defaults to be filtered |
|
101 | + $default_espresso_events_shortcode_atts = apply_filters( |
|
102 | + 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
|
103 | + $default_espresso_events_shortcode_atts |
|
104 | + ); |
|
105 | + // grab attributes and merge with defaults, then extract |
|
106 | + $attributes = array_merge((array)$default_espresso_events_shortcode_atts, (array)$attributes); |
|
107 | + $attributes = \EES_Shortcode::sanitize_attributes( |
|
108 | + $attributes, |
|
109 | + // the following get sanitized/whitelisted in EEH_Event_Query |
|
110 | + array( |
|
111 | + 'category_slug' => 'skip_sanitization', |
|
112 | + 'show_expired' => 'skip_sanitization', |
|
113 | + 'order_by' => 'skip_sanitization', |
|
114 | + 'month' => 'skip_sanitization', |
|
115 | + 'sort' => 'skip_sanitization', |
|
116 | + ) |
|
117 | + ); |
|
118 | + // make sure we use the_excerpt() |
|
119 | + add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
120 | + // apply query filters |
|
121 | + add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
122 | + // run the query |
|
123 | + global $wp_query; |
|
124 | + $wp_query = new EE_Event_List_Query($attributes); |
|
125 | + // check what template is loaded and load filters accordingly |
|
126 | + EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
127 | + // load our template |
|
128 | + $event_list = EEH_Template::locate_template( |
|
129 | + 'loop-espresso_events.php', |
|
130 | + array(), |
|
131 | + true, |
|
132 | + true |
|
133 | + ); |
|
134 | + // now reset the query and postdata |
|
135 | + wp_reset_query(); |
|
136 | + wp_reset_postdata(); |
|
137 | + EED_Events_Archive::remove_all_events_archive_filters(); |
|
138 | + // remove query filters |
|
139 | + remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
140 | + // pull our content from the output buffer and return it |
|
141 | + return $event_list; |
|
142 | + } |
|
143 | 143 | |
144 | 144 | |
145 | 145 | |
@@ -159,141 +159,141 @@ discard block |
||
159 | 159 | class EE_Event_List_Query extends WP_Query |
160 | 160 | { |
161 | 161 | |
162 | - private $_title = null; |
|
163 | - |
|
164 | - private $_limit = 10; |
|
165 | - |
|
166 | - private $_css_class = null; |
|
167 | - |
|
168 | - private $_show_expired = false; |
|
169 | - |
|
170 | - private $_month = null; |
|
171 | - |
|
172 | - private $_category_slug = null; |
|
173 | - |
|
174 | - private $_order_by = null; |
|
175 | - |
|
176 | - private $_sort = null; |
|
177 | - |
|
178 | - private $_show_title = true; |
|
179 | - |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * EE_Event_List_Query Constructor * |
|
184 | - * sets up a WordPress query |
|
185 | - * |
|
186 | - * @param array $args |
|
187 | - */ |
|
188 | - public function __construct($args = array()) |
|
189 | - { |
|
190 | - // incoming args could be a mix of WP query args + EE shortcode args |
|
191 | - foreach ($args as $key => $value) { |
|
192 | - $property = '_' . $key; |
|
193 | - // if the arg is a property of this class, then it's an EE shortcode arg |
|
194 | - if (property_exists($this, $property)) { |
|
195 | - // set the property value |
|
196 | - $this->{$property} = $value; |
|
197 | - // then remove it from the array of args that will later be passed to WP_Query() |
|
198 | - unset($args[$key]); |
|
199 | - } |
|
200 | - } |
|
201 | - //add query filters |
|
202 | - EEH_Event_Query::add_query_filters(); |
|
203 | - // set params that will get used by the filters |
|
204 | - EEH_Event_Query::set_query_params( |
|
205 | - $this->_month, |
|
206 | - $this->_category_slug, |
|
207 | - $this->_show_expired, |
|
208 | - $this->_order_by, |
|
209 | - $this->_sort |
|
210 | - ); |
|
211 | - // first off, let's remove any filters from previous queries |
|
212 | - remove_filter( |
|
213 | - 'FHEE__archive_espresso_events_template__show_header', |
|
214 | - array($this, 'show_event_list_title') |
|
215 | - ); |
|
216 | - remove_filter( |
|
217 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
218 | - array($this, 'event_list_title') |
|
219 | - ); |
|
220 | - remove_all_filters('FHEE__content_espresso_events__event_class'); |
|
221 | - // Event List Title ? |
|
222 | - add_filter( |
|
223 | - 'FHEE__archive_espresso_events_template__show_header', |
|
224 | - array($this, 'show_event_list_title') |
|
225 | - ); |
|
226 | - add_filter( |
|
227 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
228 | - array($this, 'event_list_title') |
|
229 | - ); |
|
230 | - // add the css class |
|
231 | - add_filter( |
|
232 | - 'FHEE__content_espresso_events__event_class', |
|
233 | - array($this, 'event_list_css') |
|
234 | - ); |
|
235 | - // the current "page" we are viewing |
|
236 | - $paged = max(1, get_query_var('paged')); |
|
237 | - // Force these args |
|
238 | - $args = array_merge($args, array( |
|
239 | - 'post_type' => 'espresso_events', |
|
240 | - 'posts_per_page' => $this->_limit, |
|
241 | - 'update_post_term_cache' => false, |
|
242 | - 'update_post_meta_cache' => false, |
|
243 | - 'paged' => $paged, |
|
244 | - 'offset' => ($paged - 1) * $this->_limit, |
|
245 | - )); |
|
246 | - // run the query |
|
247 | - parent::__construct($args); |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * event_list_title |
|
254 | - * |
|
255 | - * @param string $event_list_title |
|
256 | - * @return string |
|
257 | - */ |
|
258 | - public function event_list_title($event_list_title = '') |
|
259 | - { |
|
260 | - if (! empty($this->_title)) { |
|
261 | - return $this->_title; |
|
262 | - } |
|
263 | - return $event_list_title; |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - |
|
268 | - /** |
|
269 | - * show_event_list_title |
|
270 | - * |
|
271 | - * @param bool $show_title |
|
272 | - * @return boolean |
|
273 | - */ |
|
274 | - public function show_event_list_title($show_title = true) |
|
275 | - { |
|
276 | - return filter_var( |
|
277 | - $this->_show_title, |
|
278 | - FILTER_VALIDATE_BOOLEAN |
|
279 | - ); |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - |
|
284 | - /** |
|
285 | - * event_list_css |
|
286 | - * |
|
287 | - * @param string $event_list_css |
|
288 | - * @return string |
|
289 | - */ |
|
290 | - public function event_list_css($event_list_css = '') |
|
291 | - { |
|
292 | - $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
293 | - $event_list_css .= ! empty($this->_css_class) ? $this->_css_class : ''; |
|
294 | - $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
295 | - $event_list_css .= ! empty($this->_category_slug) ? $this->_category_slug : ''; |
|
296 | - return $event_list_css; |
|
297 | - } |
|
162 | + private $_title = null; |
|
163 | + |
|
164 | + private $_limit = 10; |
|
165 | + |
|
166 | + private $_css_class = null; |
|
167 | + |
|
168 | + private $_show_expired = false; |
|
169 | + |
|
170 | + private $_month = null; |
|
171 | + |
|
172 | + private $_category_slug = null; |
|
173 | + |
|
174 | + private $_order_by = null; |
|
175 | + |
|
176 | + private $_sort = null; |
|
177 | + |
|
178 | + private $_show_title = true; |
|
179 | + |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * EE_Event_List_Query Constructor * |
|
184 | + * sets up a WordPress query |
|
185 | + * |
|
186 | + * @param array $args |
|
187 | + */ |
|
188 | + public function __construct($args = array()) |
|
189 | + { |
|
190 | + // incoming args could be a mix of WP query args + EE shortcode args |
|
191 | + foreach ($args as $key => $value) { |
|
192 | + $property = '_' . $key; |
|
193 | + // if the arg is a property of this class, then it's an EE shortcode arg |
|
194 | + if (property_exists($this, $property)) { |
|
195 | + // set the property value |
|
196 | + $this->{$property} = $value; |
|
197 | + // then remove it from the array of args that will later be passed to WP_Query() |
|
198 | + unset($args[$key]); |
|
199 | + } |
|
200 | + } |
|
201 | + //add query filters |
|
202 | + EEH_Event_Query::add_query_filters(); |
|
203 | + // set params that will get used by the filters |
|
204 | + EEH_Event_Query::set_query_params( |
|
205 | + $this->_month, |
|
206 | + $this->_category_slug, |
|
207 | + $this->_show_expired, |
|
208 | + $this->_order_by, |
|
209 | + $this->_sort |
|
210 | + ); |
|
211 | + // first off, let's remove any filters from previous queries |
|
212 | + remove_filter( |
|
213 | + 'FHEE__archive_espresso_events_template__show_header', |
|
214 | + array($this, 'show_event_list_title') |
|
215 | + ); |
|
216 | + remove_filter( |
|
217 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
218 | + array($this, 'event_list_title') |
|
219 | + ); |
|
220 | + remove_all_filters('FHEE__content_espresso_events__event_class'); |
|
221 | + // Event List Title ? |
|
222 | + add_filter( |
|
223 | + 'FHEE__archive_espresso_events_template__show_header', |
|
224 | + array($this, 'show_event_list_title') |
|
225 | + ); |
|
226 | + add_filter( |
|
227 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
228 | + array($this, 'event_list_title') |
|
229 | + ); |
|
230 | + // add the css class |
|
231 | + add_filter( |
|
232 | + 'FHEE__content_espresso_events__event_class', |
|
233 | + array($this, 'event_list_css') |
|
234 | + ); |
|
235 | + // the current "page" we are viewing |
|
236 | + $paged = max(1, get_query_var('paged')); |
|
237 | + // Force these args |
|
238 | + $args = array_merge($args, array( |
|
239 | + 'post_type' => 'espresso_events', |
|
240 | + 'posts_per_page' => $this->_limit, |
|
241 | + 'update_post_term_cache' => false, |
|
242 | + 'update_post_meta_cache' => false, |
|
243 | + 'paged' => $paged, |
|
244 | + 'offset' => ($paged - 1) * $this->_limit, |
|
245 | + )); |
|
246 | + // run the query |
|
247 | + parent::__construct($args); |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * event_list_title |
|
254 | + * |
|
255 | + * @param string $event_list_title |
|
256 | + * @return string |
|
257 | + */ |
|
258 | + public function event_list_title($event_list_title = '') |
|
259 | + { |
|
260 | + if (! empty($this->_title)) { |
|
261 | + return $this->_title; |
|
262 | + } |
|
263 | + return $event_list_title; |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + |
|
268 | + /** |
|
269 | + * show_event_list_title |
|
270 | + * |
|
271 | + * @param bool $show_title |
|
272 | + * @return boolean |
|
273 | + */ |
|
274 | + public function show_event_list_title($show_title = true) |
|
275 | + { |
|
276 | + return filter_var( |
|
277 | + $this->_show_title, |
|
278 | + FILTER_VALIDATE_BOOLEAN |
|
279 | + ); |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + |
|
284 | + /** |
|
285 | + * event_list_css |
|
286 | + * |
|
287 | + * @param string $event_list_css |
|
288 | + * @return string |
|
289 | + */ |
|
290 | + public function event_list_css($event_list_css = '') |
|
291 | + { |
|
292 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
293 | + $event_list_css .= ! empty($this->_css_class) ? $this->_css_class : ''; |
|
294 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
295 | + $event_list_css .= ! empty($this->_category_slug) ? $this->_category_slug : ''; |
|
296 | + return $event_list_css; |
|
297 | + } |
|
298 | 298 | |
299 | 299 | } |
@@ -11,48 +11,48 @@ |
||
11 | 11 | * @version 4+ |
12 | 12 | */ |
13 | 13 | if (have_posts()) : |
14 | - if (apply_filters('FHEE__archive_espresso_events_template__show_header', true)) : ?> |
|
14 | + if (apply_filters('FHEE__archive_espresso_events_template__show_header', true)) : ?> |
|
15 | 15 | <header class="page-header"> |
16 | 16 | <h1 class="page-title"> |
17 | 17 | <?php |
18 | - if (is_day()) : |
|
19 | - printf(__('Today\'s Events: %s', 'event_espresso'), get_the_date()); |
|
20 | - elseif (is_month()) : |
|
21 | - printf( |
|
22 | - __('Events This Month: %s', 'event_espresso'), |
|
23 | - get_the_date(_x('F Y', 'monthly archives date format', 'event_espresso')) |
|
24 | - ); |
|
25 | - elseif (is_year()) : |
|
26 | - printf( |
|
27 | - __('Events This Year: %s', 'event_espresso'), |
|
28 | - get_the_date(_x('Y', 'yearly archives date format', 'event_espresso')) |
|
29 | - ); |
|
30 | - else : |
|
31 | - echo apply_filters( |
|
32 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
33 | - __('Upcoming Events', 'event_espresso') |
|
34 | - ); |
|
35 | - endif; |
|
36 | - ?> |
|
18 | + if (is_day()) : |
|
19 | + printf(__('Today\'s Events: %s', 'event_espresso'), get_the_date()); |
|
20 | + elseif (is_month()) : |
|
21 | + printf( |
|
22 | + __('Events This Month: %s', 'event_espresso'), |
|
23 | + get_the_date(_x('F Y', 'monthly archives date format', 'event_espresso')) |
|
24 | + ); |
|
25 | + elseif (is_year()) : |
|
26 | + printf( |
|
27 | + __('Events This Year: %s', 'event_espresso'), |
|
28 | + get_the_date(_x('Y', 'yearly archives date format', 'event_espresso')) |
|
29 | + ); |
|
30 | + else : |
|
31 | + echo apply_filters( |
|
32 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
33 | + __('Upcoming Events', 'event_espresso') |
|
34 | + ); |
|
35 | + endif; |
|
36 | + ?> |
|
37 | 37 | </h1> |
38 | 38 | |
39 | 39 | </header><!-- .page-header --> |
40 | 40 | |
41 | 41 | <?php |
42 | - endif; |
|
43 | - // allow other stuff |
|
44 | - do_action('AHEE__archive_espresso_events_template__before_loop'); |
|
45 | - // Start the Loop. |
|
46 | - while (have_posts()) : the_post(); |
|
47 | - // Include the post TYPE-specific template for the content. |
|
48 | - espresso_get_template_part('content', 'espresso_events-shortcode'); |
|
49 | - endwhile; |
|
50 | - // Previous/next page navigation. |
|
51 | - espresso_pagination(); |
|
52 | - // allow moar other stuff |
|
53 | - do_action('AHEE__archive_espresso_events_template__after_loop'); |
|
42 | + endif; |
|
43 | + // allow other stuff |
|
44 | + do_action('AHEE__archive_espresso_events_template__before_loop'); |
|
45 | + // Start the Loop. |
|
46 | + while (have_posts()) : the_post(); |
|
47 | + // Include the post TYPE-specific template for the content. |
|
48 | + espresso_get_template_part('content', 'espresso_events-shortcode'); |
|
49 | + endwhile; |
|
50 | + // Previous/next page navigation. |
|
51 | + espresso_pagination(); |
|
52 | + // allow moar other stuff |
|
53 | + do_action('AHEE__archive_espresso_events_template__after_loop'); |
|
54 | 54 | else : |
55 | - // If no content, include the "No posts found" template. |
|
56 | - espresso_get_template_part('content', 'none'); |
|
55 | + // If no content, include the "No posts found" template. |
|
56 | + espresso_get_template_part('content', 'none'); |
|
57 | 57 | endif; |
58 | 58 |
@@ -27,11 +27,13 @@ discard block |
||
27 | 27 | __('Events This Year: %s', 'event_espresso'), |
28 | 28 | get_the_date(_x('Y', 'yearly archives date format', 'event_espresso')) |
29 | 29 | ); |
30 | - else : |
|
30 | + else { |
|
31 | + : |
|
31 | 32 | echo apply_filters( |
32 | 33 | 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
33 | 34 | __('Upcoming Events', 'event_espresso') |
34 | 35 | ); |
36 | + } |
|
35 | 37 | endif; |
36 | 38 | ?> |
37 | 39 | </h1> |
@@ -51,8 +53,10 @@ discard block |
||
51 | 53 | espresso_pagination(); |
52 | 54 | // allow moar other stuff |
53 | 55 | do_action('AHEE__archive_espresso_events_template__after_loop'); |
54 | -else : |
|
56 | +else { |
|
57 | + : |
|
55 | 58 | // If no content, include the "No posts found" template. |
56 | 59 | espresso_get_template_part('content', 'none'); |
60 | +} |
|
57 | 61 | endif; |
58 | 62 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <div class="padding"> |
2 | 2 | <p> |
3 | - <?php esc_html_e('Displays a list of events based on a set of criteria on a WordPress page or post. Unless otherwise specified, events are sorted by start date.', 'event_espresso'); ?> <?php echo sprintf( esc_html__('For a full list of available shortcodes, please view the %sshortcode documentation%s on our website.', 'event_espresso'), '<a href="https://eventespresso.com/wiki/ee4-shortcodes-template-variables/">', '</a>' ); ?> |
|
3 | + <?php esc_html_e('Displays a list of events based on a set of criteria on a WordPress page or post. Unless otherwise specified, events are sorted by start date.', 'event_espresso'); ?> <?php echo sprintf(esc_html__('For a full list of available shortcodes, please view the %sshortcode documentation%s on our website.', 'event_espresso'), '<a href="https://eventespresso.com/wiki/ee4-shortcodes-template-variables/">', '</a>'); ?> |
|
4 | 4 | </p> |
5 | 5 | <ul> |
6 | 6 | <li><strong><?php esc_html_e('Show a list of all of your events', 'event_espresso'); ?></strong><br /> [ESPRESSO_EVENTS]</li> |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | <li><strong><?php esc_html_e('Don\'t display a title/heading before the event list', 'event_espresso'); ?></strong><br /> [ESPRESSO_EVENTS show_title=false]</li> |
9 | 9 | <li><strong><?php esc_html_e('Limit (paginate) the number of events that are shown in the event list on a page or post', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS limit=5]</li> |
10 | 10 | <li><strong><?php esc_html_e('Add a custom CSS class to each event post/article', 'event_espresso'); ?></strong><br /> [ESPRESSO_EVENTS css_class=my-custom-class]</li> |
11 | - <li><strong><?php esc_html_e('Filter the event list by month and year', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS month="<?php echo date( 'F Y' ); ?>"]</li> |
|
11 | + <li><strong><?php esc_html_e('Filter the event list by month and year', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS month="<?php echo date('F Y'); ?>"]</li> |
|
12 | 12 | <li><strong><?php esc_html_e('Show expired events in the event list', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS show_expired=true]</li> |
13 | 13 | <li><strong><?php esc_html_e('Sorts the event list in ascending order', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS sort=ASC]</li> |
14 | 14 | <li><strong><?php esc_html_e('Sorts the event list in descending order', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS sort=DESC]</li> |
@@ -450,7 +450,7 @@ |
||
450 | 450 | |
451 | 451 | |
452 | 452 | /** |
453 | - * @param $Request |
|
453 | + * @param string $Request |
|
454 | 454 | * @return mixed |
455 | 455 | */ |
456 | 456 | private function _CURLRequest($Request) |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('No direct script access allowed'); |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -25,549 +25,549 @@ discard block |
||
25 | 25 | class EEG_Paypal_Pro extends EE_Onsite_Gateway |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var $_paypal_api_username string |
|
30 | - */ |
|
31 | - protected $_username = null; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var $_password string |
|
35 | - */ |
|
36 | - protected $_password = null; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var $_signature string |
|
40 | - */ |
|
41 | - protected $_signature = null; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var $_credit_card_types array with the keys for credit card types accepted on this account |
|
45 | - */ |
|
46 | - protected $_credit_card_types = null; |
|
47 | - |
|
48 | - protected $_currencies_supported = array( |
|
49 | - 'USD', |
|
50 | - 'GBP', |
|
51 | - 'CAD', |
|
52 | - 'AUD', |
|
53 | - 'BRL', |
|
54 | - 'CHF', |
|
55 | - 'CZK', |
|
56 | - 'DKK', |
|
57 | - 'EUR', |
|
58 | - 'HKD', |
|
59 | - 'HUF', |
|
60 | - 'ILS', |
|
61 | - 'JPY', |
|
62 | - 'MXN', |
|
63 | - 'MYR', |
|
64 | - 'NOK', |
|
65 | - 'NZD', |
|
66 | - 'PHP', |
|
67 | - 'PLN', |
|
68 | - 'SEK', |
|
69 | - 'SGD', |
|
70 | - 'THB', |
|
71 | - 'TRY', |
|
72 | - 'TWD', |
|
73 | - 'RUB', |
|
74 | - ); |
|
75 | - |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @param EEI_Payment $payment |
|
80 | - * @param array $billing_info { |
|
81 | - * @type $credit_card string |
|
82 | - * @type $credit_card_type string |
|
83 | - * @type $exp_month string always 2 characters |
|
84 | - * @type $exp_year string always 4 characters |
|
85 | - * @type $cvv string |
|
86 | - * } @see parent::do_direct_payment for more info |
|
87 | - * @return \EE_Payment|\EEI_Payment |
|
88 | - */ |
|
89 | - public function do_direct_payment($payment, $billing_info = null) |
|
90 | - { |
|
91 | - $transaction = $payment->transaction(); |
|
92 | - if (! $transaction instanceof EEI_Transaction) { |
|
93 | - throw new EE_Error(esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')); |
|
94 | - } |
|
95 | - $primary_registrant = $transaction->primary_registration(); |
|
96 | - if (! $primary_registrant instanceof EEI_Registration) { |
|
97 | - throw new EE_Error(esc_html__('No primary registration on transaction while paying with PayPal Pro.', |
|
98 | - 'event_espresso')); |
|
99 | - } |
|
100 | - $attendee = $primary_registrant->attendee(); |
|
101 | - if (! $attendee instanceof EEI_Attendee) { |
|
102 | - throw new EE_Error(esc_html__('No attendee on primary registration while paying with PayPal Pro.', |
|
103 | - 'event_espresso')); |
|
104 | - } |
|
105 | - $order_description = $this->_format_order_description($payment); |
|
106 | - //charge for the full amount. Show itemized list |
|
107 | - if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
108 | - $item_num = 1; |
|
109 | - $total_line_item = $transaction->total_line_item(); |
|
110 | - $order_items = array(); |
|
111 | - foreach ($total_line_item->get_items() as $line_item) { |
|
112 | - //ignore line items with a quantity of 0 |
|
113 | - if ($line_item->quantity() == 0) { |
|
114 | - continue; |
|
115 | - } |
|
116 | - $item = array( |
|
117 | - // Item Name. 127 char max. |
|
118 | - 'l_name' => substr( |
|
119 | - $this->_format_line_item_name($line_item, $payment), |
|
120 | - 0, |
|
121 | - 127 |
|
122 | - ), |
|
123 | - // Item description. 127 char max. |
|
124 | - 'l_desc' => substr( |
|
125 | - $this->_format_line_item_desc($line_item, $payment), |
|
126 | - 0, |
|
127 | - 127 |
|
128 | - ), |
|
129 | - // Cost of individual item. |
|
130 | - 'l_amt' => $line_item->unit_price(), |
|
131 | - // Item Number. 127 char max. |
|
132 | - 'l_number' => $item_num++, |
|
133 | - // Item quantity. Must be any positive integer. |
|
134 | - 'l_qty' => $line_item->quantity(), |
|
135 | - // Item's sales tax amount. |
|
136 | - 'l_taxamt' => '', |
|
137 | - // eBay auction number of item. |
|
138 | - 'l_ebayitemnumber' => '', |
|
139 | - // eBay transaction ID of purchased item. |
|
140 | - 'l_ebayitemauctiontxnid' => '', |
|
141 | - // eBay order ID for the item. |
|
142 | - 'l_ebayitemorderid' => '', |
|
143 | - ); |
|
144 | - // add to array of all items |
|
145 | - array_push($order_items, $item); |
|
146 | - } |
|
147 | - $item_amount = $total_line_item->get_items_total(); |
|
148 | - $tax_amount = $total_line_item->get_total_tax(); |
|
149 | - } else { |
|
150 | - $order_items = array(); |
|
151 | - $item_amount = $payment->amount(); |
|
152 | - $tax_amount = 0; |
|
153 | - array_push($order_items, array( |
|
154 | - // Item Name. 127 char max. |
|
155 | - 'l_name' => substr( |
|
156 | - $this->_format_partial_payment_line_item_name($payment), |
|
157 | - 0, |
|
158 | - 127 |
|
159 | - ), |
|
160 | - // Item description. 127 char max. |
|
161 | - 'l_desc' => substr( |
|
162 | - $this->_format_partial_payment_line_item_desc($payment), |
|
163 | - 0, |
|
164 | - 127 |
|
165 | - ), |
|
166 | - // Cost of individual item. |
|
167 | - 'l_amt' => $payment->amount(), |
|
168 | - // Item Number. 127 char max. |
|
169 | - 'l_number' => 1, |
|
170 | - // Item quantity. Must be any positive integer. |
|
171 | - 'l_qty' => 1, |
|
172 | - )); |
|
173 | - } |
|
174 | - // Populate data arrays with order data. |
|
175 | - $DPFields = array( |
|
176 | - // How you want to obtain payment ? |
|
177 | - // Authorization indidicates the payment is a basic auth subject to settlement with Auth & Capture. |
|
178 | - // Sale indicates that this is a final sale for which you are requesting payment. Default is Sale. |
|
179 | - 'paymentaction' => 'Sale', |
|
180 | - // Required. IP address of the payer's browser. |
|
181 | - 'ipaddress' => $_SERVER['REMOTE_ADDR'], |
|
182 | - // Flag to determine whether you want the results returned by FMF. 1 or 0. Default is 0. |
|
183 | - 'returnfmfdetails' => '1', |
|
184 | - ); |
|
185 | - $CCDetails = array( |
|
186 | - // Required. Type of credit card. Visa, MasterCard, Discover, Amex, Maestro, Solo. |
|
187 | - // If Maestro or Solo, the currency code must be GBP. In addition, either start date or issue number must be specified. |
|
188 | - 'creditcardtype' => $billing_info['credit_card_type'], |
|
189 | - // Required. Credit card number. No spaces or punctuation. |
|
190 | - 'acct' => $billing_info['credit_card'], |
|
191 | - // Required. Credit card expiration date. Format is MMYYYY |
|
192 | - 'expdate' => $billing_info['exp_month'] . $billing_info['exp_year'], |
|
193 | - // Requirements determined by your PayPal account settings. Security digits for credit card. |
|
194 | - 'cvv2' => $billing_info['cvv'], |
|
195 | - ); |
|
196 | - $PayerInfo = array( |
|
197 | - // Email address of payer. |
|
198 | - 'email' => $billing_info['email'], |
|
199 | - // Unique PayPal customer ID for payer. |
|
200 | - 'payerid' => '', |
|
201 | - // Status of payer. Values are verified or unverified |
|
202 | - 'payerstatus' => '', |
|
203 | - // Payer's business name. |
|
204 | - 'business' => '', |
|
205 | - ); |
|
206 | - $PayerName = array( |
|
207 | - // Payer's salutation. 20 char max. |
|
208 | - 'salutation' => '', |
|
209 | - // Payer's first name. 25 char max. |
|
210 | - 'firstname' => substr($billing_info['first_name'], 0, 25), |
|
211 | - // Payer's middle name. 25 char max. |
|
212 | - 'middlename' => '', |
|
213 | - // Payer's last name. 25 char max. |
|
214 | - 'lastname' => substr($billing_info['last_name'], 0, 25), |
|
215 | - // Payer's suffix. 12 char max. |
|
216 | - 'suffix' => '', |
|
217 | - ); |
|
218 | - $BillingAddress = array( |
|
219 | - // Required. First street address. |
|
220 | - 'street' => $billing_info['address'], |
|
221 | - // Second street address. |
|
222 | - 'street2' => $billing_info['address2'], |
|
223 | - // Required. Name of City. |
|
224 | - 'city' => $billing_info['city'], |
|
225 | - // Required. Name of State or Province. |
|
226 | - 'state' => substr($billing_info['state'], 0, 40), |
|
227 | - // Required. Country code. |
|
228 | - 'countrycode' => $billing_info['country'], |
|
229 | - // Required. Postal code of payer. |
|
230 | - 'zip' => $billing_info['zip'], |
|
231 | - ); |
|
232 | - //check if the registration info contains the needed fields for paypal pro (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/) |
|
233 | - if ($attendee->address() && $attendee->city() && $attendee->country_ID()) { |
|
234 | - $use_registration_address_info = true; |
|
235 | - } else { |
|
236 | - $use_registration_address_info = false; |
|
237 | - } |
|
238 | - //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it. If not, use the billing info again |
|
239 | - $ShippingAddress = array( |
|
240 | - 'shiptoname' => substr($use_registration_address_info ? $attendee->full_name() : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32), |
|
241 | - 'shiptostreet' => substr($use_registration_address_info ? $attendee->address() : $billing_info['address'], 0, 100), |
|
242 | - 'shiptostreet2' => substr($use_registration_address_info ? $attendee->address2() : $billing_info['address2'], 0, 100), |
|
243 | - 'shiptocity' => substr($use_registration_address_info ? $attendee->city() : $billing_info['city'], 0, 40), |
|
244 | - 'state' => substr($use_registration_address_info ? $attendee->state_name() : $billing_info['state'], 0, 40), |
|
245 | - 'shiptocountry' => $use_registration_address_info ? $attendee->country_ID() : $billing_info['country'], |
|
246 | - 'shiptozip' => substr($use_registration_address_info ? $attendee->zip() : $billing_info['zip'], 0, 20), |
|
247 | - 'shiptophonenum' => substr($use_registration_address_info ? $attendee->phone() : $billing_info['phone'], 0, 20), |
|
248 | - ); |
|
249 | - $PaymentDetails = array( |
|
250 | - // Required. Total amount of order, including shipping, handling, and tax. |
|
251 | - 'amt' => $this->format_currency($payment->amount()), |
|
252 | - // Required. Three-letter currency code. Default is USD. |
|
253 | - 'currencycode' => $payment->currency_code(), |
|
254 | - // Required if you include itemized cart details. (L_AMTn, etc.) Subtotal of items not including S&H, or tax. |
|
255 | - 'itemamt' => $this->format_currency($item_amount),// |
|
256 | - // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
|
257 | - 'shippingamt' => '', |
|
258 | - // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
|
259 | - 'handlingamt' => '', |
|
260 | - // Required if you specify itemized cart tax details. Sum of tax for all items on the order. Total sales tax. |
|
261 | - 'taxamt' => $this->format_currency($tax_amount), |
|
262 | - // Description of the order the customer is purchasing. 127 char max. |
|
263 | - 'desc' => $order_description, |
|
264 | - // Free-form field for your own use. 256 char max. |
|
265 | - 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
|
266 | - // Your own invoice or tracking number |
|
267 | - 'invnum' => wp_generate_password(12, false),//$transaction->ID(), |
|
268 | - // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
|
269 | - 'notifyurl' => '', |
|
270 | - 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
271 | - ); |
|
272 | - // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
|
273 | - $PayPalRequestData = array( |
|
274 | - 'DPFields' => $DPFields, |
|
275 | - 'CCDetails' => $CCDetails, |
|
276 | - 'PayerInfo' => $PayerInfo, |
|
277 | - 'PayerName' => $PayerName, |
|
278 | - 'BillingAddress' => $BillingAddress, |
|
279 | - 'ShippingAddress' => $ShippingAddress, |
|
280 | - 'PaymentDetails' => $PaymentDetails, |
|
281 | - 'OrderItems' => $order_items, |
|
282 | - ); |
|
283 | - $this->_log_clean_request($PayPalRequestData, $payment); |
|
284 | - try { |
|
285 | - $PayPalResult = $this->prep_and_curl_request($PayPalRequestData); |
|
286 | - //remove PCI-sensitive data so it doesn't get stored |
|
287 | - $PayPalResult = $this->_log_clean_response($PayPalResult, $payment); |
|
288 | - $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK']; |
|
289 | - if (empty($PayPalResult['RAWRESPONSE'])) { |
|
290 | - $payment->set_status($this->_pay_model->failed_status()); |
|
291 | - $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso')); |
|
292 | - $payment->set_details($PayPalResult); |
|
293 | - } else { |
|
294 | - if ($this->_APICallSuccessful($PayPalResult)) { |
|
295 | - $payment->set_status($this->_pay_model->approved_status()); |
|
296 | - } else { |
|
297 | - $payment->set_status($this->_pay_model->declined_status()); |
|
298 | - } |
|
299 | - //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
|
300 | - $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0); |
|
301 | - $payment->set_gateway_response($message); |
|
302 | - $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null); |
|
303 | - $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
|
304 | - $payment->set_extra_accntng($primary_registration_code); |
|
305 | - $payment->set_details($PayPalResult); |
|
306 | - } |
|
307 | - } catch (Exception $e) { |
|
308 | - $payment->set_status($this->_pay_model->failed_status()); |
|
309 | - $payment->set_gateway_response($e->getMessage()); |
|
310 | - } |
|
311 | - //$payment->set_status( $this->_pay_model->declined_status() ); |
|
312 | - //$payment->set_gateway_response( '' ); |
|
313 | - return $payment; |
|
314 | - } |
|
315 | - |
|
316 | - |
|
317 | - |
|
318 | - /** |
|
319 | - * CLeans out sensitive CC data and then logs it, and returns the cleaned request |
|
320 | - * |
|
321 | - * @param array $request |
|
322 | - * @param EEI_Payment $payment |
|
323 | - * @return array |
|
324 | - */ |
|
325 | - private function _log_clean_request($request, $payment) |
|
326 | - { |
|
327 | - $cleaned_request_data = $request; |
|
328 | - unset($cleaned_request_data['CCDetails']['acct']); |
|
329 | - unset($cleaned_request_data['CCDetails']['cvv2']); |
|
330 | - unset($cleaned_request_data['CCDetails']['expdate']); |
|
331 | - $this->log(array('Paypal Request' => $cleaned_request_data), $payment); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * Cleans the response, logs it, and returns it |
|
338 | - * |
|
339 | - * @param array $response |
|
340 | - * @param EEI_Payment $payment |
|
341 | - * @return array cleaned |
|
342 | - */ |
|
343 | - private function _log_clean_response($response, $payment) |
|
344 | - { |
|
345 | - unset($response['REQUESTDATA']['CREDITCARDTYPE']); |
|
346 | - unset($response['REQUESTDATA']['ACCT']); |
|
347 | - unset($response['REQUESTDATA']['EXPDATE']); |
|
348 | - unset($response['REQUESTDATA']['CVV2']); |
|
349 | - unset($response['RAWREQUEST']); |
|
350 | - $this->log(array('Paypal Response' => $response), $payment); |
|
351 | - return $response; |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * @param $DataArray |
|
358 | - * @return array |
|
359 | - */ |
|
360 | - private function prep_and_curl_request($DataArray) |
|
361 | - { |
|
362 | - // Create empty holders for each portion of the NVP string |
|
363 | - $DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP'; |
|
364 | - $CCDetailsNVP = ''; |
|
365 | - $PayerInfoNVP = ''; |
|
366 | - $PayerNameNVP = ''; |
|
367 | - $BillingAddressNVP = ''; |
|
368 | - $ShippingAddressNVP = ''; |
|
369 | - $PaymentDetailsNVP = ''; |
|
370 | - $OrderItemsNVP = ''; |
|
371 | - $Secure3DNVP = ''; |
|
372 | - // DP Fields |
|
373 | - $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
|
374 | - foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) { |
|
375 | - $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
376 | - } |
|
377 | - // CC Details Fields |
|
378 | - $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
|
379 | - foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) { |
|
380 | - $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
381 | - } |
|
382 | - // PayerInfo Type Fields |
|
383 | - $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
|
384 | - foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) { |
|
385 | - $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
386 | - } |
|
387 | - // Payer Name Fields |
|
388 | - $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
|
389 | - foreach ($PayerName as $PayerNameVar => $PayerNameVal) { |
|
390 | - $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
391 | - } |
|
392 | - // Address Fields (Billing) |
|
393 | - $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
|
394 | - foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) { |
|
395 | - $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
396 | - } |
|
397 | - // Payment Details Type Fields |
|
398 | - $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
|
399 | - foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) { |
|
400 | - $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
401 | - } |
|
402 | - // Payment Details Item Type Fields |
|
403 | - $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
|
404 | - $n = 0; |
|
405 | - foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
|
406 | - $CurrentItem = $OrderItems[$OrderItemsVar]; |
|
407 | - foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) { |
|
408 | - $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
409 | - } |
|
410 | - $n++; |
|
411 | - } |
|
412 | - // Ship To Address Fields |
|
413 | - $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
|
414 | - foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) { |
|
415 | - $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
416 | - } |
|
417 | - // 3D Secure Fields |
|
418 | - $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
|
419 | - foreach ($Secure3D as $Secure3DVar => $Secure3DVal) { |
|
420 | - $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
421 | - } |
|
422 | - // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
|
423 | - $NVPRequest = 'USER=' |
|
424 | - . $this->_username |
|
425 | - . '&PWD=' |
|
426 | - . $this->_password |
|
427 | - . '&VERSION=64.0' |
|
428 | - . '&SIGNATURE=' |
|
429 | - . $this->_signature |
|
430 | - . $DPFieldsNVP |
|
431 | - . $CCDetailsNVP |
|
432 | - . $PayerInfoNVP |
|
433 | - . $PayerNameNVP |
|
434 | - . $BillingAddressNVP |
|
435 | - . $PaymentDetailsNVP |
|
436 | - . $OrderItemsNVP |
|
437 | - . $ShippingAddressNVP |
|
438 | - . $Secure3DNVP; |
|
439 | - $NVPResponse = $this->_CURLRequest($NVPRequest); |
|
440 | - $NVPRequestArray = $this->_NVPToArray($NVPRequest); |
|
441 | - $NVPResponseArray = $this->_NVPToArray($NVPResponse); |
|
442 | - $Errors = $this->_GetErrors($NVPResponseArray); |
|
443 | - $NVPResponseArray['ERRORS'] = $Errors; |
|
444 | - $NVPResponseArray['REQUESTDATA'] = $NVPRequestArray; |
|
445 | - $NVPResponseArray['RAWREQUEST'] = $NVPRequest; |
|
446 | - $NVPResponseArray['RAWRESPONSE'] = $NVPResponse; |
|
447 | - return $NVPResponseArray; |
|
448 | - } |
|
449 | - |
|
450 | - |
|
451 | - |
|
452 | - /** |
|
453 | - * @param $Request |
|
454 | - * @return mixed |
|
455 | - */ |
|
456 | - private function _CURLRequest($Request) |
|
457 | - { |
|
458 | - $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; |
|
459 | - $curl = curl_init(); |
|
460 | - curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true)); |
|
461 | - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
|
462 | - curl_setopt($curl, CURLOPT_TIMEOUT, 60); |
|
463 | - curl_setopt($curl, CURLOPT_URL, $EndPointURL); |
|
464 | - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); |
|
465 | - curl_setopt($curl, CURLOPT_POSTFIELDS, $Request); |
|
466 | - curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
|
467 | - //execute the curl POST |
|
468 | - $Response = curl_exec($curl); |
|
469 | - curl_close($curl); |
|
470 | - return $Response; |
|
471 | - } |
|
472 | - |
|
473 | - |
|
474 | - |
|
475 | - /** |
|
476 | - * @param $NVPString |
|
477 | - * @return array |
|
478 | - */ |
|
479 | - private function _NVPToArray($NVPString) |
|
480 | - { |
|
481 | - // prepare responses into array |
|
482 | - $proArray = array(); |
|
483 | - while (strlen($NVPString)) { |
|
484 | - // name |
|
485 | - $keypos = strpos($NVPString, '='); |
|
486 | - $keyval = substr($NVPString, 0, $keypos); |
|
487 | - // value |
|
488 | - $valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString); |
|
489 | - $valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1); |
|
490 | - // decoding the respose |
|
491 | - $proArray[$keyval] = urldecode($valval); |
|
492 | - $NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString)); |
|
493 | - } |
|
494 | - return $proArray; |
|
495 | - } |
|
496 | - |
|
497 | - |
|
498 | - |
|
499 | - /** |
|
500 | - * @param array $PayPalResult |
|
501 | - * @return bool |
|
502 | - */ |
|
503 | - private function _APICallSuccessful($PayPalResult) |
|
504 | - { |
|
505 | - $approved = false; |
|
506 | - // check main response message from PayPal |
|
507 | - if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) { |
|
508 | - $ack = strtoupper($PayPalResult['ACK']); |
|
509 | - $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false; |
|
510 | - } |
|
511 | - return $approved; |
|
512 | - } |
|
513 | - |
|
514 | - |
|
515 | - |
|
516 | - /** |
|
517 | - * @param $DataArray |
|
518 | - * @return array |
|
519 | - */ |
|
520 | - private function _GetErrors($DataArray) |
|
521 | - { |
|
522 | - $Errors = array(); |
|
523 | - $n = 0; |
|
524 | - while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
525 | - $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
526 | - $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : ''; |
|
527 | - $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : ''; |
|
528 | - $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : ''; |
|
529 | - $CurrentItem = array( |
|
530 | - 'L_ERRORCODE' => $LErrorCode, |
|
531 | - 'L_SHORTMESSAGE' => $LShortMessage, |
|
532 | - 'L_LONGMESSAGE' => $LLongMessage, |
|
533 | - 'L_SEVERITYCODE' => $LSeverityCode, |
|
534 | - ); |
|
535 | - array_push($Errors, $CurrentItem); |
|
536 | - $n++; |
|
537 | - } |
|
538 | - return $Errors; |
|
539 | - } |
|
540 | - |
|
541 | - |
|
542 | - |
|
543 | - /** |
|
544 | - * nothing to see here... move along.... |
|
545 | - * |
|
546 | - * @access protected |
|
547 | - * @param $Errors |
|
548 | - * @return string |
|
549 | - */ |
|
550 | - private function _DisplayErrors($Errors) |
|
551 | - { |
|
552 | - $error = ''; |
|
553 | - foreach ($Errors as $ErrorVar => $ErrorVal) { |
|
554 | - $CurrentError = $Errors[$ErrorVar]; |
|
555 | - foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) { |
|
556 | - $CurrentVarName = ''; |
|
557 | - if ($CurrentErrorVar == 'L_ERRORCODE') { |
|
558 | - $CurrentVarName = 'Error Code'; |
|
559 | - } elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') { |
|
560 | - $CurrentVarName = 'Short Message'; |
|
561 | - } elseif ($CurrentErrorVar == 'L_LONGMESSAGE') { |
|
562 | - $CurrentVarName = 'Long Message'; |
|
563 | - } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') { |
|
564 | - $CurrentVarName = 'Severity Code'; |
|
565 | - } |
|
566 | - $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
567 | - } |
|
568 | - } |
|
569 | - return $error; |
|
570 | - } |
|
28 | + /** |
|
29 | + * @var $_paypal_api_username string |
|
30 | + */ |
|
31 | + protected $_username = null; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var $_password string |
|
35 | + */ |
|
36 | + protected $_password = null; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var $_signature string |
|
40 | + */ |
|
41 | + protected $_signature = null; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var $_credit_card_types array with the keys for credit card types accepted on this account |
|
45 | + */ |
|
46 | + protected $_credit_card_types = null; |
|
47 | + |
|
48 | + protected $_currencies_supported = array( |
|
49 | + 'USD', |
|
50 | + 'GBP', |
|
51 | + 'CAD', |
|
52 | + 'AUD', |
|
53 | + 'BRL', |
|
54 | + 'CHF', |
|
55 | + 'CZK', |
|
56 | + 'DKK', |
|
57 | + 'EUR', |
|
58 | + 'HKD', |
|
59 | + 'HUF', |
|
60 | + 'ILS', |
|
61 | + 'JPY', |
|
62 | + 'MXN', |
|
63 | + 'MYR', |
|
64 | + 'NOK', |
|
65 | + 'NZD', |
|
66 | + 'PHP', |
|
67 | + 'PLN', |
|
68 | + 'SEK', |
|
69 | + 'SGD', |
|
70 | + 'THB', |
|
71 | + 'TRY', |
|
72 | + 'TWD', |
|
73 | + 'RUB', |
|
74 | + ); |
|
75 | + |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @param EEI_Payment $payment |
|
80 | + * @param array $billing_info { |
|
81 | + * @type $credit_card string |
|
82 | + * @type $credit_card_type string |
|
83 | + * @type $exp_month string always 2 characters |
|
84 | + * @type $exp_year string always 4 characters |
|
85 | + * @type $cvv string |
|
86 | + * } @see parent::do_direct_payment for more info |
|
87 | + * @return \EE_Payment|\EEI_Payment |
|
88 | + */ |
|
89 | + public function do_direct_payment($payment, $billing_info = null) |
|
90 | + { |
|
91 | + $transaction = $payment->transaction(); |
|
92 | + if (! $transaction instanceof EEI_Transaction) { |
|
93 | + throw new EE_Error(esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')); |
|
94 | + } |
|
95 | + $primary_registrant = $transaction->primary_registration(); |
|
96 | + if (! $primary_registrant instanceof EEI_Registration) { |
|
97 | + throw new EE_Error(esc_html__('No primary registration on transaction while paying with PayPal Pro.', |
|
98 | + 'event_espresso')); |
|
99 | + } |
|
100 | + $attendee = $primary_registrant->attendee(); |
|
101 | + if (! $attendee instanceof EEI_Attendee) { |
|
102 | + throw new EE_Error(esc_html__('No attendee on primary registration while paying with PayPal Pro.', |
|
103 | + 'event_espresso')); |
|
104 | + } |
|
105 | + $order_description = $this->_format_order_description($payment); |
|
106 | + //charge for the full amount. Show itemized list |
|
107 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
108 | + $item_num = 1; |
|
109 | + $total_line_item = $transaction->total_line_item(); |
|
110 | + $order_items = array(); |
|
111 | + foreach ($total_line_item->get_items() as $line_item) { |
|
112 | + //ignore line items with a quantity of 0 |
|
113 | + if ($line_item->quantity() == 0) { |
|
114 | + continue; |
|
115 | + } |
|
116 | + $item = array( |
|
117 | + // Item Name. 127 char max. |
|
118 | + 'l_name' => substr( |
|
119 | + $this->_format_line_item_name($line_item, $payment), |
|
120 | + 0, |
|
121 | + 127 |
|
122 | + ), |
|
123 | + // Item description. 127 char max. |
|
124 | + 'l_desc' => substr( |
|
125 | + $this->_format_line_item_desc($line_item, $payment), |
|
126 | + 0, |
|
127 | + 127 |
|
128 | + ), |
|
129 | + // Cost of individual item. |
|
130 | + 'l_amt' => $line_item->unit_price(), |
|
131 | + // Item Number. 127 char max. |
|
132 | + 'l_number' => $item_num++, |
|
133 | + // Item quantity. Must be any positive integer. |
|
134 | + 'l_qty' => $line_item->quantity(), |
|
135 | + // Item's sales tax amount. |
|
136 | + 'l_taxamt' => '', |
|
137 | + // eBay auction number of item. |
|
138 | + 'l_ebayitemnumber' => '', |
|
139 | + // eBay transaction ID of purchased item. |
|
140 | + 'l_ebayitemauctiontxnid' => '', |
|
141 | + // eBay order ID for the item. |
|
142 | + 'l_ebayitemorderid' => '', |
|
143 | + ); |
|
144 | + // add to array of all items |
|
145 | + array_push($order_items, $item); |
|
146 | + } |
|
147 | + $item_amount = $total_line_item->get_items_total(); |
|
148 | + $tax_amount = $total_line_item->get_total_tax(); |
|
149 | + } else { |
|
150 | + $order_items = array(); |
|
151 | + $item_amount = $payment->amount(); |
|
152 | + $tax_amount = 0; |
|
153 | + array_push($order_items, array( |
|
154 | + // Item Name. 127 char max. |
|
155 | + 'l_name' => substr( |
|
156 | + $this->_format_partial_payment_line_item_name($payment), |
|
157 | + 0, |
|
158 | + 127 |
|
159 | + ), |
|
160 | + // Item description. 127 char max. |
|
161 | + 'l_desc' => substr( |
|
162 | + $this->_format_partial_payment_line_item_desc($payment), |
|
163 | + 0, |
|
164 | + 127 |
|
165 | + ), |
|
166 | + // Cost of individual item. |
|
167 | + 'l_amt' => $payment->amount(), |
|
168 | + // Item Number. 127 char max. |
|
169 | + 'l_number' => 1, |
|
170 | + // Item quantity. Must be any positive integer. |
|
171 | + 'l_qty' => 1, |
|
172 | + )); |
|
173 | + } |
|
174 | + // Populate data arrays with order data. |
|
175 | + $DPFields = array( |
|
176 | + // How you want to obtain payment ? |
|
177 | + // Authorization indidicates the payment is a basic auth subject to settlement with Auth & Capture. |
|
178 | + // Sale indicates that this is a final sale for which you are requesting payment. Default is Sale. |
|
179 | + 'paymentaction' => 'Sale', |
|
180 | + // Required. IP address of the payer's browser. |
|
181 | + 'ipaddress' => $_SERVER['REMOTE_ADDR'], |
|
182 | + // Flag to determine whether you want the results returned by FMF. 1 or 0. Default is 0. |
|
183 | + 'returnfmfdetails' => '1', |
|
184 | + ); |
|
185 | + $CCDetails = array( |
|
186 | + // Required. Type of credit card. Visa, MasterCard, Discover, Amex, Maestro, Solo. |
|
187 | + // If Maestro or Solo, the currency code must be GBP. In addition, either start date or issue number must be specified. |
|
188 | + 'creditcardtype' => $billing_info['credit_card_type'], |
|
189 | + // Required. Credit card number. No spaces or punctuation. |
|
190 | + 'acct' => $billing_info['credit_card'], |
|
191 | + // Required. Credit card expiration date. Format is MMYYYY |
|
192 | + 'expdate' => $billing_info['exp_month'] . $billing_info['exp_year'], |
|
193 | + // Requirements determined by your PayPal account settings. Security digits for credit card. |
|
194 | + 'cvv2' => $billing_info['cvv'], |
|
195 | + ); |
|
196 | + $PayerInfo = array( |
|
197 | + // Email address of payer. |
|
198 | + 'email' => $billing_info['email'], |
|
199 | + // Unique PayPal customer ID for payer. |
|
200 | + 'payerid' => '', |
|
201 | + // Status of payer. Values are verified or unverified |
|
202 | + 'payerstatus' => '', |
|
203 | + // Payer's business name. |
|
204 | + 'business' => '', |
|
205 | + ); |
|
206 | + $PayerName = array( |
|
207 | + // Payer's salutation. 20 char max. |
|
208 | + 'salutation' => '', |
|
209 | + // Payer's first name. 25 char max. |
|
210 | + 'firstname' => substr($billing_info['first_name'], 0, 25), |
|
211 | + // Payer's middle name. 25 char max. |
|
212 | + 'middlename' => '', |
|
213 | + // Payer's last name. 25 char max. |
|
214 | + 'lastname' => substr($billing_info['last_name'], 0, 25), |
|
215 | + // Payer's suffix. 12 char max. |
|
216 | + 'suffix' => '', |
|
217 | + ); |
|
218 | + $BillingAddress = array( |
|
219 | + // Required. First street address. |
|
220 | + 'street' => $billing_info['address'], |
|
221 | + // Second street address. |
|
222 | + 'street2' => $billing_info['address2'], |
|
223 | + // Required. Name of City. |
|
224 | + 'city' => $billing_info['city'], |
|
225 | + // Required. Name of State or Province. |
|
226 | + 'state' => substr($billing_info['state'], 0, 40), |
|
227 | + // Required. Country code. |
|
228 | + 'countrycode' => $billing_info['country'], |
|
229 | + // Required. Postal code of payer. |
|
230 | + 'zip' => $billing_info['zip'], |
|
231 | + ); |
|
232 | + //check if the registration info contains the needed fields for paypal pro (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/) |
|
233 | + if ($attendee->address() && $attendee->city() && $attendee->country_ID()) { |
|
234 | + $use_registration_address_info = true; |
|
235 | + } else { |
|
236 | + $use_registration_address_info = false; |
|
237 | + } |
|
238 | + //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it. If not, use the billing info again |
|
239 | + $ShippingAddress = array( |
|
240 | + 'shiptoname' => substr($use_registration_address_info ? $attendee->full_name() : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32), |
|
241 | + 'shiptostreet' => substr($use_registration_address_info ? $attendee->address() : $billing_info['address'], 0, 100), |
|
242 | + 'shiptostreet2' => substr($use_registration_address_info ? $attendee->address2() : $billing_info['address2'], 0, 100), |
|
243 | + 'shiptocity' => substr($use_registration_address_info ? $attendee->city() : $billing_info['city'], 0, 40), |
|
244 | + 'state' => substr($use_registration_address_info ? $attendee->state_name() : $billing_info['state'], 0, 40), |
|
245 | + 'shiptocountry' => $use_registration_address_info ? $attendee->country_ID() : $billing_info['country'], |
|
246 | + 'shiptozip' => substr($use_registration_address_info ? $attendee->zip() : $billing_info['zip'], 0, 20), |
|
247 | + 'shiptophonenum' => substr($use_registration_address_info ? $attendee->phone() : $billing_info['phone'], 0, 20), |
|
248 | + ); |
|
249 | + $PaymentDetails = array( |
|
250 | + // Required. Total amount of order, including shipping, handling, and tax. |
|
251 | + 'amt' => $this->format_currency($payment->amount()), |
|
252 | + // Required. Three-letter currency code. Default is USD. |
|
253 | + 'currencycode' => $payment->currency_code(), |
|
254 | + // Required if you include itemized cart details. (L_AMTn, etc.) Subtotal of items not including S&H, or tax. |
|
255 | + 'itemamt' => $this->format_currency($item_amount),// |
|
256 | + // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
|
257 | + 'shippingamt' => '', |
|
258 | + // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
|
259 | + 'handlingamt' => '', |
|
260 | + // Required if you specify itemized cart tax details. Sum of tax for all items on the order. Total sales tax. |
|
261 | + 'taxamt' => $this->format_currency($tax_amount), |
|
262 | + // Description of the order the customer is purchasing. 127 char max. |
|
263 | + 'desc' => $order_description, |
|
264 | + // Free-form field for your own use. 256 char max. |
|
265 | + 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
|
266 | + // Your own invoice or tracking number |
|
267 | + 'invnum' => wp_generate_password(12, false),//$transaction->ID(), |
|
268 | + // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
|
269 | + 'notifyurl' => '', |
|
270 | + 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
271 | + ); |
|
272 | + // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
|
273 | + $PayPalRequestData = array( |
|
274 | + 'DPFields' => $DPFields, |
|
275 | + 'CCDetails' => $CCDetails, |
|
276 | + 'PayerInfo' => $PayerInfo, |
|
277 | + 'PayerName' => $PayerName, |
|
278 | + 'BillingAddress' => $BillingAddress, |
|
279 | + 'ShippingAddress' => $ShippingAddress, |
|
280 | + 'PaymentDetails' => $PaymentDetails, |
|
281 | + 'OrderItems' => $order_items, |
|
282 | + ); |
|
283 | + $this->_log_clean_request($PayPalRequestData, $payment); |
|
284 | + try { |
|
285 | + $PayPalResult = $this->prep_and_curl_request($PayPalRequestData); |
|
286 | + //remove PCI-sensitive data so it doesn't get stored |
|
287 | + $PayPalResult = $this->_log_clean_response($PayPalResult, $payment); |
|
288 | + $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK']; |
|
289 | + if (empty($PayPalResult['RAWRESPONSE'])) { |
|
290 | + $payment->set_status($this->_pay_model->failed_status()); |
|
291 | + $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso')); |
|
292 | + $payment->set_details($PayPalResult); |
|
293 | + } else { |
|
294 | + if ($this->_APICallSuccessful($PayPalResult)) { |
|
295 | + $payment->set_status($this->_pay_model->approved_status()); |
|
296 | + } else { |
|
297 | + $payment->set_status($this->_pay_model->declined_status()); |
|
298 | + } |
|
299 | + //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
|
300 | + $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0); |
|
301 | + $payment->set_gateway_response($message); |
|
302 | + $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null); |
|
303 | + $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
|
304 | + $payment->set_extra_accntng($primary_registration_code); |
|
305 | + $payment->set_details($PayPalResult); |
|
306 | + } |
|
307 | + } catch (Exception $e) { |
|
308 | + $payment->set_status($this->_pay_model->failed_status()); |
|
309 | + $payment->set_gateway_response($e->getMessage()); |
|
310 | + } |
|
311 | + //$payment->set_status( $this->_pay_model->declined_status() ); |
|
312 | + //$payment->set_gateway_response( '' ); |
|
313 | + return $payment; |
|
314 | + } |
|
315 | + |
|
316 | + |
|
317 | + |
|
318 | + /** |
|
319 | + * CLeans out sensitive CC data and then logs it, and returns the cleaned request |
|
320 | + * |
|
321 | + * @param array $request |
|
322 | + * @param EEI_Payment $payment |
|
323 | + * @return array |
|
324 | + */ |
|
325 | + private function _log_clean_request($request, $payment) |
|
326 | + { |
|
327 | + $cleaned_request_data = $request; |
|
328 | + unset($cleaned_request_data['CCDetails']['acct']); |
|
329 | + unset($cleaned_request_data['CCDetails']['cvv2']); |
|
330 | + unset($cleaned_request_data['CCDetails']['expdate']); |
|
331 | + $this->log(array('Paypal Request' => $cleaned_request_data), $payment); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * Cleans the response, logs it, and returns it |
|
338 | + * |
|
339 | + * @param array $response |
|
340 | + * @param EEI_Payment $payment |
|
341 | + * @return array cleaned |
|
342 | + */ |
|
343 | + private function _log_clean_response($response, $payment) |
|
344 | + { |
|
345 | + unset($response['REQUESTDATA']['CREDITCARDTYPE']); |
|
346 | + unset($response['REQUESTDATA']['ACCT']); |
|
347 | + unset($response['REQUESTDATA']['EXPDATE']); |
|
348 | + unset($response['REQUESTDATA']['CVV2']); |
|
349 | + unset($response['RAWREQUEST']); |
|
350 | + $this->log(array('Paypal Response' => $response), $payment); |
|
351 | + return $response; |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * @param $DataArray |
|
358 | + * @return array |
|
359 | + */ |
|
360 | + private function prep_and_curl_request($DataArray) |
|
361 | + { |
|
362 | + // Create empty holders for each portion of the NVP string |
|
363 | + $DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP'; |
|
364 | + $CCDetailsNVP = ''; |
|
365 | + $PayerInfoNVP = ''; |
|
366 | + $PayerNameNVP = ''; |
|
367 | + $BillingAddressNVP = ''; |
|
368 | + $ShippingAddressNVP = ''; |
|
369 | + $PaymentDetailsNVP = ''; |
|
370 | + $OrderItemsNVP = ''; |
|
371 | + $Secure3DNVP = ''; |
|
372 | + // DP Fields |
|
373 | + $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
|
374 | + foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) { |
|
375 | + $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
376 | + } |
|
377 | + // CC Details Fields |
|
378 | + $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
|
379 | + foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) { |
|
380 | + $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
381 | + } |
|
382 | + // PayerInfo Type Fields |
|
383 | + $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
|
384 | + foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) { |
|
385 | + $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
386 | + } |
|
387 | + // Payer Name Fields |
|
388 | + $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
|
389 | + foreach ($PayerName as $PayerNameVar => $PayerNameVal) { |
|
390 | + $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
391 | + } |
|
392 | + // Address Fields (Billing) |
|
393 | + $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
|
394 | + foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) { |
|
395 | + $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
396 | + } |
|
397 | + // Payment Details Type Fields |
|
398 | + $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
|
399 | + foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) { |
|
400 | + $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
401 | + } |
|
402 | + // Payment Details Item Type Fields |
|
403 | + $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
|
404 | + $n = 0; |
|
405 | + foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
|
406 | + $CurrentItem = $OrderItems[$OrderItemsVar]; |
|
407 | + foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) { |
|
408 | + $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
409 | + } |
|
410 | + $n++; |
|
411 | + } |
|
412 | + // Ship To Address Fields |
|
413 | + $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
|
414 | + foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) { |
|
415 | + $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
416 | + } |
|
417 | + // 3D Secure Fields |
|
418 | + $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
|
419 | + foreach ($Secure3D as $Secure3DVar => $Secure3DVal) { |
|
420 | + $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
421 | + } |
|
422 | + // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
|
423 | + $NVPRequest = 'USER=' |
|
424 | + . $this->_username |
|
425 | + . '&PWD=' |
|
426 | + . $this->_password |
|
427 | + . '&VERSION=64.0' |
|
428 | + . '&SIGNATURE=' |
|
429 | + . $this->_signature |
|
430 | + . $DPFieldsNVP |
|
431 | + . $CCDetailsNVP |
|
432 | + . $PayerInfoNVP |
|
433 | + . $PayerNameNVP |
|
434 | + . $BillingAddressNVP |
|
435 | + . $PaymentDetailsNVP |
|
436 | + . $OrderItemsNVP |
|
437 | + . $ShippingAddressNVP |
|
438 | + . $Secure3DNVP; |
|
439 | + $NVPResponse = $this->_CURLRequest($NVPRequest); |
|
440 | + $NVPRequestArray = $this->_NVPToArray($NVPRequest); |
|
441 | + $NVPResponseArray = $this->_NVPToArray($NVPResponse); |
|
442 | + $Errors = $this->_GetErrors($NVPResponseArray); |
|
443 | + $NVPResponseArray['ERRORS'] = $Errors; |
|
444 | + $NVPResponseArray['REQUESTDATA'] = $NVPRequestArray; |
|
445 | + $NVPResponseArray['RAWREQUEST'] = $NVPRequest; |
|
446 | + $NVPResponseArray['RAWRESPONSE'] = $NVPResponse; |
|
447 | + return $NVPResponseArray; |
|
448 | + } |
|
449 | + |
|
450 | + |
|
451 | + |
|
452 | + /** |
|
453 | + * @param $Request |
|
454 | + * @return mixed |
|
455 | + */ |
|
456 | + private function _CURLRequest($Request) |
|
457 | + { |
|
458 | + $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; |
|
459 | + $curl = curl_init(); |
|
460 | + curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true)); |
|
461 | + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
|
462 | + curl_setopt($curl, CURLOPT_TIMEOUT, 60); |
|
463 | + curl_setopt($curl, CURLOPT_URL, $EndPointURL); |
|
464 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); |
|
465 | + curl_setopt($curl, CURLOPT_POSTFIELDS, $Request); |
|
466 | + curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
|
467 | + //execute the curl POST |
|
468 | + $Response = curl_exec($curl); |
|
469 | + curl_close($curl); |
|
470 | + return $Response; |
|
471 | + } |
|
472 | + |
|
473 | + |
|
474 | + |
|
475 | + /** |
|
476 | + * @param $NVPString |
|
477 | + * @return array |
|
478 | + */ |
|
479 | + private function _NVPToArray($NVPString) |
|
480 | + { |
|
481 | + // prepare responses into array |
|
482 | + $proArray = array(); |
|
483 | + while (strlen($NVPString)) { |
|
484 | + // name |
|
485 | + $keypos = strpos($NVPString, '='); |
|
486 | + $keyval = substr($NVPString, 0, $keypos); |
|
487 | + // value |
|
488 | + $valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString); |
|
489 | + $valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1); |
|
490 | + // decoding the respose |
|
491 | + $proArray[$keyval] = urldecode($valval); |
|
492 | + $NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString)); |
|
493 | + } |
|
494 | + return $proArray; |
|
495 | + } |
|
496 | + |
|
497 | + |
|
498 | + |
|
499 | + /** |
|
500 | + * @param array $PayPalResult |
|
501 | + * @return bool |
|
502 | + */ |
|
503 | + private function _APICallSuccessful($PayPalResult) |
|
504 | + { |
|
505 | + $approved = false; |
|
506 | + // check main response message from PayPal |
|
507 | + if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) { |
|
508 | + $ack = strtoupper($PayPalResult['ACK']); |
|
509 | + $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false; |
|
510 | + } |
|
511 | + return $approved; |
|
512 | + } |
|
513 | + |
|
514 | + |
|
515 | + |
|
516 | + /** |
|
517 | + * @param $DataArray |
|
518 | + * @return array |
|
519 | + */ |
|
520 | + private function _GetErrors($DataArray) |
|
521 | + { |
|
522 | + $Errors = array(); |
|
523 | + $n = 0; |
|
524 | + while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
525 | + $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
526 | + $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : ''; |
|
527 | + $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : ''; |
|
528 | + $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : ''; |
|
529 | + $CurrentItem = array( |
|
530 | + 'L_ERRORCODE' => $LErrorCode, |
|
531 | + 'L_SHORTMESSAGE' => $LShortMessage, |
|
532 | + 'L_LONGMESSAGE' => $LLongMessage, |
|
533 | + 'L_SEVERITYCODE' => $LSeverityCode, |
|
534 | + ); |
|
535 | + array_push($Errors, $CurrentItem); |
|
536 | + $n++; |
|
537 | + } |
|
538 | + return $Errors; |
|
539 | + } |
|
540 | + |
|
541 | + |
|
542 | + |
|
543 | + /** |
|
544 | + * nothing to see here... move along.... |
|
545 | + * |
|
546 | + * @access protected |
|
547 | + * @param $Errors |
|
548 | + * @return string |
|
549 | + */ |
|
550 | + private function _DisplayErrors($Errors) |
|
551 | + { |
|
552 | + $error = ''; |
|
553 | + foreach ($Errors as $ErrorVar => $ErrorVal) { |
|
554 | + $CurrentError = $Errors[$ErrorVar]; |
|
555 | + foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) { |
|
556 | + $CurrentVarName = ''; |
|
557 | + if ($CurrentErrorVar == 'L_ERRORCODE') { |
|
558 | + $CurrentVarName = 'Error Code'; |
|
559 | + } elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') { |
|
560 | + $CurrentVarName = 'Short Message'; |
|
561 | + } elseif ($CurrentErrorVar == 'L_LONGMESSAGE') { |
|
562 | + $CurrentVarName = 'Long Message'; |
|
563 | + } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') { |
|
564 | + $CurrentVarName = 'Severity Code'; |
|
565 | + } |
|
566 | + $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
567 | + } |
|
568 | + } |
|
569 | + return $error; |
|
570 | + } |
|
571 | 571 | |
572 | 572 | |
573 | 573 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | } |
5 | 5 | |
@@ -89,16 +89,16 @@ discard block |
||
89 | 89 | public function do_direct_payment($payment, $billing_info = null) |
90 | 90 | { |
91 | 91 | $transaction = $payment->transaction(); |
92 | - if (! $transaction instanceof EEI_Transaction) { |
|
92 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
93 | 93 | throw new EE_Error(esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')); |
94 | 94 | } |
95 | 95 | $primary_registrant = $transaction->primary_registration(); |
96 | - if (! $primary_registrant instanceof EEI_Registration) { |
|
96 | + if ( ! $primary_registrant instanceof EEI_Registration) { |
|
97 | 97 | throw new EE_Error(esc_html__('No primary registration on transaction while paying with PayPal Pro.', |
98 | 98 | 'event_espresso')); |
99 | 99 | } |
100 | 100 | $attendee = $primary_registrant->attendee(); |
101 | - if (! $attendee instanceof EEI_Attendee) { |
|
101 | + if ( ! $attendee instanceof EEI_Attendee) { |
|
102 | 102 | throw new EE_Error(esc_html__('No attendee on primary registration while paying with PayPal Pro.', |
103 | 103 | 'event_espresso')); |
104 | 104 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | // Required. Credit card number. No spaces or punctuation. |
190 | 190 | 'acct' => $billing_info['credit_card'], |
191 | 191 | // Required. Credit card expiration date. Format is MMYYYY |
192 | - 'expdate' => $billing_info['exp_month'] . $billing_info['exp_year'], |
|
192 | + 'expdate' => $billing_info['exp_month'].$billing_info['exp_year'], |
|
193 | 193 | // Requirements determined by your PayPal account settings. Security digits for credit card. |
194 | 194 | 'cvv2' => $billing_info['cvv'], |
195 | 195 | ); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | } |
238 | 238 | //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it. If not, use the billing info again |
239 | 239 | $ShippingAddress = array( |
240 | - 'shiptoname' => substr($use_registration_address_info ? $attendee->full_name() : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32), |
|
240 | + 'shiptoname' => substr($use_registration_address_info ? $attendee->full_name() : $billing_info['first_name'].' '.$billing_info['last_name'], 0, 32), |
|
241 | 241 | 'shiptostreet' => substr($use_registration_address_info ? $attendee->address() : $billing_info['address'], 0, 100), |
242 | 242 | 'shiptostreet2' => substr($use_registration_address_info ? $attendee->address2() : $billing_info['address2'], 0, 100), |
243 | 243 | 'shiptocity' => substr($use_registration_address_info ? $attendee->city() : $billing_info['city'], 0, 40), |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | // Required. Three-letter currency code. Default is USD. |
253 | 253 | 'currencycode' => $payment->currency_code(), |
254 | 254 | // Required if you include itemized cart details. (L_AMTn, etc.) Subtotal of items not including S&H, or tax. |
255 | - 'itemamt' => $this->format_currency($item_amount),// |
|
255 | + 'itemamt' => $this->format_currency($item_amount), // |
|
256 | 256 | // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
257 | 257 | 'shippingamt' => '', |
258 | 258 | // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | // Free-form field for your own use. 256 char max. |
265 | 265 | 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
266 | 266 | // Your own invoice or tracking number |
267 | - 'invnum' => wp_generate_password(12, false),//$transaction->ID(), |
|
267 | + 'invnum' => wp_generate_password(12, false), //$transaction->ID(), |
|
268 | 268 | // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
269 | 269 | 'notifyurl' => '', |
270 | - 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
270 | + 'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this |
|
271 | 271 | ); |
272 | 272 | // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
273 | 273 | $PayPalRequestData = array( |
@@ -372,32 +372,32 @@ discard block |
||
372 | 372 | // DP Fields |
373 | 373 | $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
374 | 374 | foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) { |
375 | - $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
375 | + $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal); |
|
376 | 376 | } |
377 | 377 | // CC Details Fields |
378 | 378 | $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
379 | 379 | foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) { |
380 | - $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
380 | + $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal); |
|
381 | 381 | } |
382 | 382 | // PayerInfo Type Fields |
383 | 383 | $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
384 | 384 | foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) { |
385 | - $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
385 | + $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal); |
|
386 | 386 | } |
387 | 387 | // Payer Name Fields |
388 | 388 | $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
389 | 389 | foreach ($PayerName as $PayerNameVar => $PayerNameVal) { |
390 | - $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
390 | + $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal); |
|
391 | 391 | } |
392 | 392 | // Address Fields (Billing) |
393 | 393 | $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
394 | 394 | foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) { |
395 | - $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
395 | + $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal); |
|
396 | 396 | } |
397 | 397 | // Payment Details Type Fields |
398 | 398 | $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
399 | 399 | foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) { |
400 | - $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
400 | + $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal); |
|
401 | 401 | } |
402 | 402 | // Payment Details Item Type Fields |
403 | 403 | $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
@@ -405,19 +405,19 @@ discard block |
||
405 | 405 | foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
406 | 406 | $CurrentItem = $OrderItems[$OrderItemsVar]; |
407 | 407 | foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) { |
408 | - $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
408 | + $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal); |
|
409 | 409 | } |
410 | 410 | $n++; |
411 | 411 | } |
412 | 412 | // Ship To Address Fields |
413 | 413 | $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
414 | 414 | foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) { |
415 | - $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
415 | + $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal); |
|
416 | 416 | } |
417 | 417 | // 3D Secure Fields |
418 | 418 | $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
419 | 419 | foreach ($Secure3D as $Secure3DVar => $Secure3DVal) { |
420 | - $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
420 | + $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal); |
|
421 | 421 | } |
422 | 422 | // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
423 | 423 | $NVPRequest = 'USER=' |
@@ -521,11 +521,11 @@ discard block |
||
521 | 521 | { |
522 | 522 | $Errors = array(); |
523 | 523 | $n = 0; |
524 | - while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
525 | - $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
526 | - $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : ''; |
|
527 | - $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : ''; |
|
528 | - $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : ''; |
|
524 | + while (isset($DataArray['L_ERRORCODE'.$n.''])) { |
|
525 | + $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : ''; |
|
526 | + $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) ? $DataArray['L_SHORTMESSAGE'.$n.''] : ''; |
|
527 | + $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) ? $DataArray['L_LONGMESSAGE'.$n.''] : ''; |
|
528 | + $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) ? $DataArray['L_SEVERITYCODE'.$n.''] : ''; |
|
529 | 529 | $CurrentItem = array( |
530 | 530 | 'L_ERRORCODE' => $LErrorCode, |
531 | 531 | 'L_SHORTMESSAGE' => $LShortMessage, |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') { |
564 | 564 | $CurrentVarName = 'Severity Code'; |
565 | 565 | } |
566 | - $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
566 | + $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal; |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 | return $error; |