Completed
Branch new-admin-design (7f58b2)
by
unknown
02:54
created
payment_reminder/EE_Messages_Email_Payment_Reminder_Validator.class.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -15,37 +15,37 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    public function __construct($fields, $context)
19
-    {
20
-        $this->_m_name = 'email';
21
-        $this->_mt_name = 'payment_reminder';
22
-
23
-        parent::__construct($fields, $context);
24
-    }
25
-
26
-    /**
27
-     * at this point no custom validation needed for this messenger/message_type combo.
28
-     */
29
-    protected function _modify_validator()
30
-    {
31
-        $new_config = $this->_messenger->get_validator_config();
32
-
33
-        // modify just event_list
34
-        $new_config['event_list'] = array(
35
-            'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization','recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list')
36
-            );
37
-        $new_config['ticket_list'] = array(
38
-            'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'recipient_details', 'transaction')
39
-            );
40
-        $new_config['content'] = array(
41
-            'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger')
42
-            );
43
-        $this->_messenger->set_validator_config($new_config);
44
-
45
-        if ($this->_context != 'admin') {
46
-            $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list');
47
-        }
48
-
49
-        $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]');
50
-    }
18
+	public function __construct($fields, $context)
19
+	{
20
+		$this->_m_name = 'email';
21
+		$this->_mt_name = 'payment_reminder';
22
+
23
+		parent::__construct($fields, $context);
24
+	}
25
+
26
+	/**
27
+	 * at this point no custom validation needed for this messenger/message_type combo.
28
+	 */
29
+	protected function _modify_validator()
30
+	{
31
+		$new_config = $this->_messenger->get_validator_config();
32
+
33
+		// modify just event_list
34
+		$new_config['event_list'] = array(
35
+			'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization','recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list')
36
+			);
37
+		$new_config['ticket_list'] = array(
38
+			'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'recipient_details', 'transaction')
39
+			);
40
+		$new_config['content'] = array(
41
+			'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger')
42
+			);
43
+		$this->_messenger->set_validator_config($new_config);
44
+
45
+		if ($this->_context != 'admin') {
46
+			$this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list');
47
+		}
48
+
49
+		$this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]');
50
+	}
51 51
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,18 +32,18 @@
 block discarded – undo
32 32
 
33 33
         // modify just event_list
34 34
         $new_config['event_list'] = array(
35
-            'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization','recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list')
35
+            'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list')
36 36
             );
37 37
         $new_config['ticket_list'] = array(
38 38
             'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'recipient_details', 'transaction')
39 39
             );
40 40
         $new_config['content'] = array(
41
-            'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger')
41
+            'shortcodes' => array('event_list', 'attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger')
42 42
             );
43 43
         $this->_messenger->set_validator_config($new_config);
44 44
 
45 45
         if ($this->_context != 'admin') {
46
-            $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list');
46
+            $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list');
47 47
         }
48 48
 
49 49
         $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]');
Please login to merge, or discard this patch.
caffeinated/core/libraries/shortcodes/EE_Question_Shortcodes.lib.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
     protected function _parser($shortcode)
50 50
     {
51 51
 
52
-        if (! $this->_data instanceof EE_Answer || ! isset($this->_extra_data['data']) || ! $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
52
+        if ( ! $this->_data instanceof EE_Answer || ! isset($this->_extra_data['data']) || ! $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
53 53
             return '';
54 54
         }
55 55
 
56 56
         switch ($shortcode) {
57 57
             case '[QUESTION]':
58
-                $question = isset($this->_extra_data['data']->questions[ $this->_data->ID() ])
59
-                    ? $this->_extra_data['data']->questions[ $this->_data->ID() ] : $this->_data->question();
60
-                if (! $question instanceof EE_Question) {
58
+                $question = isset($this->_extra_data['data']->questions[$this->_data->ID()])
59
+                    ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question();
60
+                if ( ! $question instanceof EE_Question) {
61 61
                     return ''; // get out because we can't figure out what the question is.
62 62
                 }
63 63
 
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 
67 67
             case '[ANSWER]':
68 68
                 // need to get the question to determine the type of question (some questions require translation of the answer).
69
-                $question = isset($this->_extra_data['data']->questions[ $this->_data->ID() ])
70
-                    ? $this->_extra_data['data']->questions[ $this->_data->ID() ] : $this->_data->question();
71
-                if (! $question instanceof EE_Question) {
69
+                $question = isset($this->_extra_data['data']->questions[$this->_data->ID()])
70
+                    ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question();
71
+                if ( ! $question instanceof EE_Question) {
72 72
                     return ''; // get out cause we can't figure out what the question type is!
73 73
                 }
74 74
 
Please login to merge, or discard this patch.
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -19,85 +19,85 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * _init_props
24
-     *
25
-     * @access protected
26
-     * @return void
27
-     */
28
-    protected function _init_props()
29
-    {
30
-        $this->label = esc_html__('Attendee Shortcodes', 'event_espresso');
31
-        $this->description = esc_html__('All shortcodes specific to attendee related data', 'event_espresso');
32
-        $this->_shortcodes = array(
33
-            '[QUESTION]' => esc_html__('Will parse to a question.', 'event_espresso'),
34
-            '[ANSWER]'   => esc_html__('Will parse to the answer for a question', 'event_espresso'),
35
-        );
36
-    }
22
+	/**
23
+	 * _init_props
24
+	 *
25
+	 * @access protected
26
+	 * @return void
27
+	 */
28
+	protected function _init_props()
29
+	{
30
+		$this->label = esc_html__('Attendee Shortcodes', 'event_espresso');
31
+		$this->description = esc_html__('All shortcodes specific to attendee related data', 'event_espresso');
32
+		$this->_shortcodes = array(
33
+			'[QUESTION]' => esc_html__('Will parse to a question.', 'event_espresso'),
34
+			'[ANSWER]'   => esc_html__('Will parse to the answer for a question', 'event_espresso'),
35
+		);
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * This method will give parsing instructions for each shortcode defined in the _shortcodes array.  Child methods
41
-     * will have to take care of handling.
42
-     *
43
-     * @access protected
44
-     *
45
-     * @param string $shortcode the shortcode to be parsed.
46
-     *
47
-     * @return string parsed shortcode
48
-     */
49
-    protected function _parser($shortcode)
50
-    {
39
+	/**
40
+	 * This method will give parsing instructions for each shortcode defined in the _shortcodes array.  Child methods
41
+	 * will have to take care of handling.
42
+	 *
43
+	 * @access protected
44
+	 *
45
+	 * @param string $shortcode the shortcode to be parsed.
46
+	 *
47
+	 * @return string parsed shortcode
48
+	 */
49
+	protected function _parser($shortcode)
50
+	{
51 51
 
52
-        if (! $this->_data instanceof EE_Answer || ! isset($this->_extra_data['data']) || ! $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
53
-            return '';
54
-        }
52
+		if (! $this->_data instanceof EE_Answer || ! isset($this->_extra_data['data']) || ! $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
53
+			return '';
54
+		}
55 55
 
56
-        switch ($shortcode) {
57
-            case '[QUESTION]':
58
-                $question = isset($this->_extra_data['data']->questions[ $this->_data->ID() ])
59
-                    ? $this->_extra_data['data']->questions[ $this->_data->ID() ] : $this->_data->question();
60
-                if (! $question instanceof EE_Question) {
61
-                    return ''; // get out because we can't figure out what the question is.
62
-                }
56
+		switch ($shortcode) {
57
+			case '[QUESTION]':
58
+				$question = isset($this->_extra_data['data']->questions[ $this->_data->ID() ])
59
+					? $this->_extra_data['data']->questions[ $this->_data->ID() ] : $this->_data->question();
60
+				if (! $question instanceof EE_Question) {
61
+					return ''; // get out because we can't figure out what the question is.
62
+				}
63 63
 
64
-                return $question->get('QST_display_text');
65
-                break;
64
+				return $question->get('QST_display_text');
65
+				break;
66 66
 
67
-            case '[ANSWER]':
68
-                // need to get the question to determine the type of question (some questions require translation of the answer).
69
-                $question = isset($this->_extra_data['data']->questions[ $this->_data->ID() ])
70
-                    ? $this->_extra_data['data']->questions[ $this->_data->ID() ] : $this->_data->question();
71
-                if (! $question instanceof EE_Question) {
72
-                    return ''; // get out cause we can't figure out what the question type is!
73
-                }
67
+			case '[ANSWER]':
68
+				// need to get the question to determine the type of question (some questions require translation of the answer).
69
+				$question = isset($this->_extra_data['data']->questions[ $this->_data->ID() ])
70
+					? $this->_extra_data['data']->questions[ $this->_data->ID() ] : $this->_data->question();
71
+				if (! $question instanceof EE_Question) {
72
+					return ''; // get out cause we can't figure out what the question type is!
73
+				}
74 74
 
75
-                // what we show for the answer depends on the question type!
76
-                switch ($question->get('QST_type')) {
77
-                    case 'STATE':
78
-                        $state = EEM_State::instance()->get_one_by_ID($this->_data->get('ANS_value'));
79
-                        $answer = $state instanceof EE_State ? $state->name() : '';
80
-                        break;
75
+				// what we show for the answer depends on the question type!
76
+				switch ($question->get('QST_type')) {
77
+					case 'STATE':
78
+						$state = EEM_State::instance()->get_one_by_ID($this->_data->get('ANS_value'));
79
+						$answer = $state instanceof EE_State ? $state->name() : '';
80
+						break;
81 81
 
82
-                    case 'COUNTRY':
83
-                        $country = EEM_Country::instance()->get_one_by_ID($this->_data->get('ANS_value'));
84
-                        $answer = $country instanceof EE_Country ? $country->name() : '';
85
-                        break;
82
+					case 'COUNTRY':
83
+						$country = EEM_Country::instance()->get_one_by_ID($this->_data->get('ANS_value'));
84
+						$answer = $country instanceof EE_Country ? $country->name() : '';
85
+						break;
86 86
 
87
-                    default:
88
-                        $answer = $this->_data->get_pretty('ANS_value', 'no_wpautop');
89
-                        break;
90
-                }
87
+					default:
88
+						$answer = $this->_data->get_pretty('ANS_value', 'no_wpautop');
89
+						break;
90
+				}
91 91
 
92
-                return apply_filters(
93
-                    'FHEE__EE_Question_Shortcodes___parser__answer',
94
-                    $answer,
95
-                    $question,
96
-                    $this->_data
97
-                );
98
-                break;
99
-        }
92
+				return apply_filters(
93
+					'FHEE__EE_Question_Shortcodes___parser__answer',
94
+					$answer,
95
+					$question,
96
+					$this->_data
97
+				);
98
+				break;
99
+		}
100 100
 
101
-        return '';
102
-    }
101
+		return '';
102
+	}
103 103
 }
Please login to merge, or discard this patch.
caffeinated/modules/recaptcha/templates/recaptcha.template.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
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
 /** @type string $recaptcha_language */
6 6
 /** @type string $recaptcha_publickey */
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
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
 /** @type string $recaptcha_language */
Please login to merge, or discard this patch.
caffeinated/payment_methods/Paypal_Pro/EEG_Paypal_Pro.gateway.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
     public function do_direct_payment($payment, $billing_info = null)
78 78
     {
79 79
         $transaction = $payment->transaction();
80
-        if (! $transaction instanceof EEI_Transaction) {
80
+        if ( ! $transaction instanceof EEI_Transaction) {
81 81
             throw new EE_Error(
82 82
                 esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
83 83
             );
84 84
         }
85 85
         $primary_registrant = $transaction->primary_registration();
86
-        if (! $primary_registrant instanceof EEI_Registration) {
86
+        if ( ! $primary_registrant instanceof EEI_Registration) {
87 87
             throw new EE_Error(
88 88
                 esc_html__(
89 89
                     'No primary registration on transaction while paying with PayPal Pro.',
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
             );
93 93
         }
94 94
         $attendee = $primary_registrant->attendee();
95
-        if (! $attendee instanceof EEI_Attendee) {
95
+        if ( ! $attendee instanceof EEI_Attendee) {
96 96
             throw new EE_Error(
97 97
                 esc_html__(
98 98
                     'No attendee on primary registration while paying with PayPal Pro.',
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
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
         );
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         $ShippingAddress = array(
242 242
             'shiptoname'     => substr($use_registration_address_info
243 243
                 ? $attendee->full_name()
244
-                : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
244
+                : $billing_info['first_name'].' '.$billing_info['last_name'], 0, 32),
245 245
             'shiptostreet'   => substr($use_registration_address_info
246 246
                 ? $attendee->address()
247 247
                 : $billing_info['address'], 0, 100),
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
             'currencycode' => $payment->currency_code(),
271 271
             // Required if you include itemized cart details. (L_AMTn, etc.)
272 272
             // Subtotal of items not including S&H, or tax.
273
-            'itemamt'      => $gateway_formatter->formatCurrency($item_amount),//
273
+            'itemamt'      => $gateway_formatter->formatCurrency($item_amount), //
274 274
             // Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
275 275
             'shippingamt'  => '',
276 276
             // Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
             // Free-form field for your own use.  256 char max.
284 284
             'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
285 285
             // Your own invoice or tracking number
286
-            'invnum'       => wp_generate_password(12, false),// $transaction->ID(),
286
+            'invnum'       => wp_generate_password(12, false), // $transaction->ID(),
287 287
             // URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
288 288
             'notifyurl'    => '',
289
-            'buttonsource' => 'EventEspresso_SP',// EE will blow up if you change this
289
+            'buttonsource' => 'EventEspresso_SP', // EE will blow up if you change this
290 290
         );
291 291
         // Wrap all data arrays into a single, "master" array which will be passed into the class function.
292 292
         $PayPalRequestData = array(
@@ -396,52 +396,52 @@  discard block
 block discarded – undo
396 396
         // DP Fields
397 397
         $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
398 398
         foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
399
-            $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
399
+            $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal);
400 400
         }
401 401
         // CC Details Fields
402 402
         $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
403 403
         foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
404
-            $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
404
+            $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal);
405 405
         }
406 406
         // PayerInfo Type Fields
407 407
         $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
408 408
         foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
409
-            $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
409
+            $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal);
410 410
         }
411 411
         // Payer Name Fields
412 412
         $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
413 413
         foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
414
-            $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
414
+            $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal);
415 415
         }
416 416
         // Address Fields (Billing)
417 417
         $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
418 418
         foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
419
-            $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
419
+            $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal);
420 420
         }
421 421
         // Payment Details Type Fields
422 422
         $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
423 423
         foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
424
-            $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
424
+            $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal);
425 425
         }
426 426
         // Payment Details Item Type Fields
427 427
         $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
428 428
         $n = 0;
429 429
         foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
430
-            $CurrentItem = $OrderItems[ $OrderItemsVar ];
430
+            $CurrentItem = $OrderItems[$OrderItemsVar];
431 431
             foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
432
-                $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
432
+                $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal);
433 433
             }
434 434
             $n++;
435 435
         }
436 436
         // Ship To Address Fields
437 437
         $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
438 438
         foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
439
-            $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
439
+            $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal);
440 440
         }
441 441
         // 3D Secure Fields
442 442
         $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
443 443
         foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
444
-            $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
444
+            $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal);
445 445
         }
446 446
         // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
447 447
         $NVPRequest = 'USER='
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
             $valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
513 513
             $valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
514 514
             // decoding the response
515
-            $proArray[ $keyval ] = urldecode($valval);
515
+            $proArray[$keyval] = urldecode($valval);
516 516
             $NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
517 517
         }
518 518
         return $proArray;
@@ -545,16 +545,16 @@  discard block
 block discarded – undo
545 545
     {
546 546
         $Errors = array();
547 547
         $n = 0;
548
-        while (isset($DataArray[ 'L_ERRORCODE' . $n . '' ])) {
549
-            $LErrorCode = isset($DataArray[ 'L_ERRORCODE' . $n . '' ]) ? $DataArray[ 'L_ERRORCODE' . $n . '' ] : '';
550
-            $LShortMessage = isset($DataArray[ 'L_SHORTMESSAGE' . $n . '' ])
551
-                ? $DataArray[ 'L_SHORTMESSAGE' . $n . '' ]
548
+        while (isset($DataArray['L_ERRORCODE'.$n.''])) {
549
+            $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : '';
550
+            $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.''])
551
+                ? $DataArray['L_SHORTMESSAGE'.$n.'']
552 552
                 : '';
553
-            $LLongMessage = isset($DataArray[ 'L_LONGMESSAGE' . $n . '' ])
554
-                ? $DataArray[ 'L_LONGMESSAGE' . $n . '' ]
553
+            $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.''])
554
+                ? $DataArray['L_LONGMESSAGE'.$n.'']
555 555
                 : '';
556
-            $LSeverityCode = isset($DataArray[ 'L_SEVERITYCODE' . $n . '' ])
557
-                ? $DataArray[ 'L_SEVERITYCODE' . $n . '' ]
556
+            $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.''])
557
+                ? $DataArray['L_SEVERITYCODE'.$n.'']
558 558
                 : '';
559 559
             $CurrentItem = array(
560 560
                 'L_ERRORCODE'    => $LErrorCode,
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
     {
582 582
         $error = '';
583 583
         foreach ($Errors as $ErrorVar => $ErrorVal) {
584
-            $CurrentError = $Errors[ $ErrorVar ];
584
+            $CurrentError = $Errors[$ErrorVar];
585 585
             foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
586 586
                 $CurrentVarName = '';
587 587
                 if ($CurrentErrorVar == 'L_ERRORCODE') {
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
                 } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
594 594
                     $CurrentVarName = 'Severity Code';
595 595
                 }
596
-                $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
596
+                $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal;
597 597
             }
598 598
         }
599 599
         return $error;
Please login to merge, or discard this patch.
Indentation   +606 added lines, -606 removed lines patch added patch discarded remove patch
@@ -14,610 +14,610 @@
 block discarded – undo
14 14
 class EEG_Paypal_Pro extends EE_Onsite_Gateway
15 15
 {
16 16
 
17
-    /**
18
-     * @var $_paypal_api_username string
19
-     */
20
-    protected $_api_username = null;
21
-
22
-    /**
23
-     * @var $_api_password string
24
-     */
25
-    protected $_api_password = null;
26
-
27
-    /**
28
-     * @var $_api_signature string
29
-     */
30
-    protected $_api_signature = null;
31
-
32
-    /**
33
-     * @var $_credit_card_types array with the keys for credit card types accepted on this account
34
-     */
35
-    protected $_credit_card_types    = null;
36
-
37
-    protected $_currencies_supported = array(
38
-        'USD',
39
-        'GBP',
40
-        'CAD',
41
-        'AUD',
42
-        'BRL',
43
-        'CHF',
44
-        'CZK',
45
-        'DKK',
46
-        'EUR',
47
-        'HKD',
48
-        'HUF',
49
-        'ILS',
50
-        'JPY',
51
-        'MXN',
52
-        'MYR',
53
-        'NOK',
54
-        'NZD',
55
-        'PHP',
56
-        'PLN',
57
-        'SEK',
58
-        'SGD',
59
-        'THB',
60
-        'TRY',
61
-        'TWD',
62
-        'RUB',
63
-        'INR',
64
-    );
65
-
66
-
67
-
68
-    /**
69
-     * @param EEI_Payment $payment
70
-     * @param array       $billing_info {
71
-     * @type string $credit_card
72
-     * @type string $credit_card_type
73
-     * @type string $exp_month always 2 characters
74
-     * @type string $exp_year always 4 characters
75
-     * @type string $cvv
76
-     * }
77
-     * @see      parent::do_direct_payment for more info
78
-     * @return EE_Payment|EEI_Payment
79
-     * @throws EE_Error
80
-     */
81
-    public function do_direct_payment($payment, $billing_info = null)
82
-    {
83
-        $transaction = $payment->transaction();
84
-        if (! $transaction instanceof EEI_Transaction) {
85
-            throw new EE_Error(
86
-                esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
87
-            );
88
-        }
89
-        $primary_registrant = $transaction->primary_registration();
90
-        if (! $primary_registrant instanceof EEI_Registration) {
91
-            throw new EE_Error(
92
-                esc_html__(
93
-                    'No primary registration on transaction while paying with PayPal Pro.',
94
-                    'event_espresso'
95
-                )
96
-            );
97
-        }
98
-        $attendee = $primary_registrant->attendee();
99
-        if (! $attendee instanceof EEI_Attendee) {
100
-            throw new EE_Error(
101
-                esc_html__(
102
-                    'No attendee on primary registration while paying with PayPal Pro.',
103
-                    'event_espresso'
104
-                )
105
-            );
106
-        }
107
-        $gateway_formatter = $this->_get_gateway_formatter();
108
-        $order_description = substr($gateway_formatter->formatOrderDescription($payment), 0, 127);
109
-        // charge for the full amount. Show itemized list
110
-        if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) {
111
-            $item_num = 1;
112
-            $total_line_item = $transaction->total_line_item();
113
-            $order_items = array();
114
-            foreach ($total_line_item->get_items() as $line_item) {
115
-                // ignore line items with a quantity of 0
116
-                if ($line_item->quantity() == 0) {
117
-                    continue;
118
-                }
119
-                // For percent items, whose unit_price is 0, use the total instead.
120
-                if ($line_item->is_percent()) {
121
-                    $unit_price = $line_item->total();
122
-                    $line_item_quantity = 1;
123
-                } else {
124
-                    $unit_price = $line_item->unit_price();
125
-                    $line_item_quantity = $line_item->quantity();
126
-                }
127
-                $item = array(
128
-                    // Item Name.  127 char max.
129
-                    'l_name'                 => substr(
130
-                        $gateway_formatter->formatLineItemName($line_item, $payment),
131
-                        0,
132
-                        127
133
-                    ),
134
-                    // Item description.  127 char max.
135
-                    'l_desc'                 => substr(
136
-                        $gateway_formatter->formatLineItemDesc($line_item, $payment),
137
-                        0,
138
-                        127
139
-                    ),
140
-                    // Cost of individual item.
141
-                    'l_amt'                  => $unit_price,
142
-                    // Item Number.  127 char max.
143
-                    'l_number'               => $item_num++,
144
-                    // Item quantity.  Must be any positive integer.
145
-                    'l_qty'                  => $line_item_quantity,
146
-                    // Item's sales tax amount.
147
-                    'l_taxamt'               => '',
148
-                    // eBay auction number of item.
149
-                    'l_ebayitemnumber'       => '',
150
-                    // eBay transaction ID of purchased item.
151
-                    'l_ebayitemauctiontxnid' => '',
152
-                    // eBay order ID for the item.
153
-                    'l_ebayitemorderid'      => '',
154
-                );
155
-                // add to array of all items
156
-                array_push($order_items, $item);
157
-            }
158
-            $item_amount = $total_line_item->get_items_total();
159
-            $tax_amount = $total_line_item->get_total_tax();
160
-        } else {
161
-            $order_items = array();
162
-            $item_amount = $payment->amount();
163
-            $tax_amount = 0;
164
-            array_push($order_items, array(
165
-                // Item Name.  127 char max.
166
-                'l_name'   => substr(
167
-                    $gateway_formatter->formatPartialPaymentLineItemName($payment),
168
-                    0,
169
-                    127
170
-                ),
171
-                // Item description.  127 char max.
172
-                'l_desc'   => substr(
173
-                    $gateway_formatter->formatPartialPaymentLineItemDesc($payment),
174
-                    0,
175
-                    127
176
-                ),
177
-                // Cost of individual item.
178
-                'l_amt'    => $payment->amount(),
179
-                // Item Number.  127 char max.
180
-                'l_number' => 1,
181
-                // Item quantity.  Must be any positive integer.
182
-                'l_qty'    => 1,
183
-            ));
184
-        }
185
-
186
-
187
-        /** @var RequestInterface $request */
188
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
189
-        // Populate data arrays with order data.
190
-        $DPFields = array(
191
-            // How you want to obtain payment ?
192
-            // Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture.
193
-            // Sale indicates that this is a final sale for which you are requesting payment.  Default is Sale.
194
-            'paymentaction'    => 'Sale',
195
-            // Required.  IP address of the payer's browser.
196
-            'ipaddress'        => $request->ipAddress(),
197
-            // Flag to determine whether you want the results returned by FMF.  1 or 0.  Default is 0.
198
-            'returnfmfdetails' => '1',
199
-        );
200
-        $CCDetails = array(
201
-            // Required. Type of credit card.  Visa, MasterCard, Discover, Amex, Maestro, Solo.
202
-            // If Maestro or Solo, the currency code must be GBP.
203
-            //  In addition, either start date or issue number must be specified.
204
-            'creditcardtype' => $billing_info['credit_card_type'],
205
-            // Required.  Credit card number.  No spaces or punctuation.
206
-            'acct'           => $billing_info['credit_card'],
207
-            // Required.  Credit card expiration date.  Format is MMYYYY
208
-            'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
209
-            // Requirements determined by your PayPal account settings.  Security digits for credit card.
210
-            'cvv2'           => $billing_info['cvv'],
211
-        );
212
-        $PayerInfo = array(
213
-            // Email address of payer.
214
-            'email'       => $billing_info['email'],
215
-            // Unique PayPal customer ID for payer.
216
-            'payerid'     => '',
217
-            // Status of payer.  Values are verified or unverified
218
-            'payerstatus' => '',
219
-            // Payer's business name.
220
-            'business'    => '',
221
-        );
222
-        $PayerName = array(
223
-            // Payer's salutation.  20 char max.
224
-            'salutation' => '',
225
-            // Payer's first name.  25 char max.
226
-            'firstname'  => substr($billing_info['first_name'], 0, 25),
227
-            // Payer's middle name.  25 char max.
228
-            'middlename' => '',
229
-            // Payer's last name.  25 char max.
230
-            'lastname'   => substr($billing_info['last_name'], 0, 25),
231
-            // Payer's suffix.  12 char max.
232
-            'suffix'     => '',
233
-        );
234
-        $BillingAddress = array(
235
-            // Required.  First street address.
236
-            'street'      => $billing_info['address'],
237
-            // Second street address.
238
-            'street2'     => $billing_info['address2'],
239
-            // Required.  Name of City.
240
-            'city'        => $billing_info['city'],
241
-            // Required. Name of State or Province.
242
-            'state'       => substr($billing_info['state'], 0, 40),
243
-            // Required.  Country code.
244
-            'countrycode' => $billing_info['country'],
245
-            // Required.  Postal code of payer.
246
-            'zip'         => $billing_info['zip'],
247
-        );
248
-        // check if the registration info contains the needed fields for paypal pro
249
-        // (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
250
-        if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
251
-            $use_registration_address_info = true;
252
-        } else {
253
-            $use_registration_address_info = false;
254
-        }
255
-        // so if the attendee has enough data to fill out PayPal Pro's shipping info, use it.
256
-        // If not, use the billing info again
257
-        $ShippingAddress = array(
258
-            'shiptoname'     => substr($use_registration_address_info
259
-                ? $attendee->full_name()
260
-                : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
261
-            'shiptostreet'   => substr($use_registration_address_info
262
-                ? $attendee->address()
263
-                : $billing_info['address'], 0, 100),
264
-            'shiptostreet2'  => substr($use_registration_address_info
265
-                ? $attendee->address2() : $billing_info['address2'], 0, 100),
266
-            'shiptocity'     => substr($use_registration_address_info
267
-                ? $attendee->city()
268
-                : $billing_info['city'], 0, 40),
269
-            'shiptostate'          => substr($use_registration_address_info
270
-                ? $attendee->state_name()
271
-                : $billing_info['state'], 0, 40),
272
-            'shiptocountry'  => $use_registration_address_info
273
-                ? $attendee->country_ID()
274
-                : $billing_info['country'],
275
-            'shiptozip'      => substr($use_registration_address_info
276
-                ? $attendee->zip()
277
-                : $billing_info['zip'], 0, 20),
278
-            'shiptophonenum' => substr($use_registration_address_info
279
-                ? $attendee->phone()
280
-                : $billing_info['phone'], 0, 20),
281
-        );
282
-        $PaymentDetails = array(
283
-            // Required.  Total amount of order, including shipping, handling, and tax.
284
-            'amt'          => $gateway_formatter->formatCurrency($payment->amount()),
285
-            // Required.  Three-letter currency code.  Default is USD.
286
-            'currencycode' => $payment->currency_code(),
287
-            // Required if you include itemized cart details. (L_AMTn, etc.)
288
-            // Subtotal of items not including S&H, or tax.
289
-            'itemamt'      => $gateway_formatter->formatCurrency($item_amount),//
290
-            // Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
291
-            'shippingamt'  => '',
292
-            // Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
293
-            'handlingamt'  => '',
294
-            // Required if you specify itemized cart tax details.
295
-            // Sum of tax for all items on the order.  Total sales tax.
296
-            'taxamt'       => $gateway_formatter->formatCurrency($tax_amount),
297
-            // Description of the order the customer is purchasing.  127 char max.
298
-            'desc'         => $order_description,
299
-            // Free-form field for your own use.  256 char max.
300
-            'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
301
-            // Your own invoice or tracking number
302
-            'invnum'       => wp_generate_password(12, false),// $transaction->ID(),
303
-            // URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
304
-            'notifyurl'    => '',
305
-            'buttonsource' => 'EventEspresso_SP',// EE will blow up if you change this
306
-        );
307
-        // Wrap all data arrays into a single, "master" array which will be passed into the class function.
308
-        $PayPalRequestData = array(
309
-            'DPFields'        => $DPFields,
310
-            'CCDetails'       => $CCDetails,
311
-            'PayerInfo'       => $PayerInfo,
312
-            'PayerName'       => $PayerName,
313
-            'BillingAddress'  => $BillingAddress,
314
-            'ShippingAddress' => $ShippingAddress,
315
-            'PaymentDetails'  => $PaymentDetails,
316
-            'OrderItems'      => $order_items,
317
-        );
318
-        $this->_log_clean_request($PayPalRequestData, $payment);
319
-        try {
320
-            $PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
321
-            // remove PCI-sensitive data so it doesn't get stored
322
-            $PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
323
-            if (isset($PayPalResult['L_ERRORCODE0']) && $PayPalResult['L_ERRORCODE0'] === '10002') {
324
-                $message = esc_html__('PayPal did not accept your API username, password, or signature. Please double-check these credentials and if debug mode is on.', 'event_espresso');
325
-            } elseif (isset($PayPalResult['L_LONGMESSAGE0'])) {
326
-                $message = $PayPalResult['L_LONGMESSAGE0'];
327
-            } else {
328
-                $message = $PayPalResult['ACK'];
329
-            }
330
-            if (empty($PayPalResult['RAWRESPONSE'])) {
331
-                $payment->set_status($this->_pay_model->failed_status());
332
-                $payment->set_gateway_response(esc_html__('No response received from Paypal Pro', 'event_espresso'));
333
-                $payment->set_details($PayPalResult);
334
-            } else {
335
-                if ($this->_APICallSuccessful($PayPalResult)) {
336
-                    $payment->set_status($this->_pay_model->approved_status());
337
-                } else {
338
-                    $payment->set_status($this->_pay_model->declined_status());
339
-                }
340
-                // make sure we interpret the AMT as a float, not an international string
341
-                // (where periods are thousand separators)
342
-                $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
343
-                $payment->set_gateway_response($message);
344
-                $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID'])
345
-                    ? $PayPalResult['TRANSACTIONID']
346
-                    : null);
347
-                $primary_registration_code = $primary_registrant instanceof EE_Registration
348
-                    ? $primary_registrant->reg_code()
349
-                    : '';
350
-                $payment->set_extra_accntng($primary_registration_code);
351
-                $payment->set_details($PayPalResult);
352
-            }
353
-        } catch (Exception $e) {
354
-            $payment->set_status($this->_pay_model->failed_status());
355
-            $payment->set_gateway_response($e->getMessage());
356
-        }
357
-        // $payment->set_status( $this->_pay_model->declined_status() );
358
-        // $payment->set_gateway_response( '' );
359
-        return $payment;
360
-    }
361
-
362
-
363
-
364
-    /**
365
-     * CLeans out sensitive CC data and then logs it, and returns the cleaned request
366
-     *
367
-     * @param array       $request
368
-     * @param EEI_Payment $payment
369
-     * @return void
370
-     */
371
-    private function _log_clean_request($request, $payment)
372
-    {
373
-        $cleaned_request_data = $request;
374
-        unset($cleaned_request_data['CCDetails']['acct']);
375
-        unset($cleaned_request_data['CCDetails']['cvv2']);
376
-        unset($cleaned_request_data['CCDetails']['expdate']);
377
-        $this->log(array('Paypal Request' => $cleaned_request_data), $payment);
378
-    }
379
-
380
-
381
-
382
-    /**
383
-     * Cleans the response, logs it, and returns it
384
-     *
385
-     * @param array       $response
386
-     * @param EEI_Payment $payment
387
-     * @return array cleaned
388
-     */
389
-    private function _log_clean_response($response, $payment)
390
-    {
391
-        unset($response['REQUESTDATA']['CREDITCARDTYPE']);
392
-        unset($response['REQUESTDATA']['ACCT']);
393
-        unset($response['REQUESTDATA']['EXPDATE']);
394
-        unset($response['REQUESTDATA']['CVV2']);
395
-        unset($response['RAWREQUEST']);
396
-        $this->log(array('Paypal Response' => $response), $payment);
397
-        return $response;
398
-    }
399
-
400
-
401
-
402
-    /**
403
-     * @param $DataArray
404
-     * @return array
405
-     */
406
-    private function prep_and_curl_request($DataArray)
407
-    {
408
-        // Create empty holders for each portion of the NVP string
409
-        $DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP';
410
-        $CCDetailsNVP = '';
411
-        $PayerInfoNVP = '';
412
-        $PayerNameNVP = '';
413
-        $BillingAddressNVP = '';
414
-        $ShippingAddressNVP = '';
415
-        $PaymentDetailsNVP = '';
416
-        $OrderItemsNVP = '';
417
-        $Secure3DNVP = '';
418
-        // DP Fields
419
-        $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
420
-        foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
421
-            $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
422
-        }
423
-        // CC Details Fields
424
-        $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
425
-        foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
426
-            $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
427
-        }
428
-        // PayerInfo Type Fields
429
-        $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
430
-        foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
431
-            $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
432
-        }
433
-        // Payer Name Fields
434
-        $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
435
-        foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
436
-            $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
437
-        }
438
-        // Address Fields (Billing)
439
-        $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
440
-        foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
441
-            $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
442
-        }
443
-        // Payment Details Type Fields
444
-        $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
445
-        foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
446
-            $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
447
-        }
448
-        // Payment Details Item Type Fields
449
-        $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
450
-        $n = 0;
451
-        foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
452
-            $CurrentItem = $OrderItems[ $OrderItemsVar ];
453
-            foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
454
-                $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
455
-            }
456
-            $n++;
457
-        }
458
-        // Ship To Address Fields
459
-        $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
460
-        foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
461
-            $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
462
-        }
463
-        // 3D Secure Fields
464
-        $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
465
-        foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
466
-            $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
467
-        }
468
-        // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
469
-        $NVPRequest = 'USER='
470
-                      . $this->_api_username
471
-                      . '&PWD='
472
-                      . $this->_api_password
473
-                      . '&VERSION=64.0'
474
-                      . '&SIGNATURE='
475
-                      . $this->_api_signature
476
-                      . $DPFieldsNVP
477
-                      . $CCDetailsNVP
478
-                      . $PayerInfoNVP
479
-                      . $PayerNameNVP
480
-                      . $BillingAddressNVP
481
-                      . $PaymentDetailsNVP
482
-                      . $OrderItemsNVP
483
-                      . $ShippingAddressNVP
484
-                      . $Secure3DNVP;
485
-        $NVPResponse = $this->_CURLRequest($NVPRequest);
486
-        $NVPRequestArray = $this->_NVPToArray($NVPRequest);
487
-        $NVPResponseArray = $this->_NVPToArray($NVPResponse);
488
-        $Errors = $this->_GetErrors($NVPResponseArray);
489
-        $NVPResponseArray['ERRORS'] = $Errors;
490
-        $NVPResponseArray['REQUESTDATA'] = $NVPRequestArray;
491
-        $NVPResponseArray['RAWREQUEST'] = $NVPRequest;
492
-        $NVPResponseArray['RAWRESPONSE'] = $NVPResponse;
493
-        return $NVPResponseArray;
494
-    }
495
-
496
-
497
-
498
-    /**
499
-     * @param $Request
500
-     * @return mixed
501
-     */
502
-    private function _CURLRequest($Request)
503
-    {
504
-        $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
505
-        $curl = curl_init();
506
-        curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true));
507
-        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
508
-        curl_setopt($curl, CURLOPT_TIMEOUT, 60);
509
-        curl_setopt($curl, CURLOPT_URL, $EndPointURL);
510
-        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
511
-        curl_setopt($curl, CURLOPT_POSTFIELDS, $Request);
512
-        curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
513
-        // execute the curl POST
514
-        $Response = curl_exec($curl);
515
-        curl_close($curl);
516
-        return $Response;
517
-    }
518
-
519
-
520
-
521
-    /**
522
-     * @param $NVPString
523
-     * @return array
524
-     */
525
-    private function _NVPToArray($NVPString)
526
-    {
527
-        // prepare responses into array
528
-        $proArray = array();
529
-        while (strlen($NVPString)) {
530
-            // name
531
-            $keypos = strpos($NVPString, '=');
532
-            $keyval = substr($NVPString, 0, $keypos);
533
-            // value
534
-            $valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
535
-            $valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
536
-            // decoding the response
537
-            $proArray[ $keyval ] = urldecode($valval);
538
-            $NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
539
-        }
540
-        return $proArray;
541
-    }
542
-
543
-
544
-
545
-    /**
546
-     * @param array $PayPalResult
547
-     * @return bool
548
-     */
549
-    private function _APICallSuccessful($PayPalResult)
550
-    {
551
-        $approved = false;
552
-        // check main response message from PayPal
553
-        if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
554
-            $ack = strtoupper($PayPalResult['ACK']);
555
-            $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
556
-        }
557
-        return $approved;
558
-    }
559
-
560
-
561
-
562
-    /**
563
-     * @param $DataArray
564
-     * @return array
565
-     */
566
-    private function _GetErrors($DataArray)
567
-    {
568
-        $Errors = array();
569
-        $n = 0;
570
-        while (isset($DataArray[ 'L_ERRORCODE' . $n . '' ])) {
571
-            $LErrorCode = isset($DataArray[ 'L_ERRORCODE' . $n . '' ]) ? $DataArray[ 'L_ERRORCODE' . $n . '' ] : '';
572
-            $LShortMessage = isset($DataArray[ 'L_SHORTMESSAGE' . $n . '' ])
573
-                ? $DataArray[ 'L_SHORTMESSAGE' . $n . '' ]
574
-                : '';
575
-            $LLongMessage = isset($DataArray[ 'L_LONGMESSAGE' . $n . '' ])
576
-                ? $DataArray[ 'L_LONGMESSAGE' . $n . '' ]
577
-                : '';
578
-            $LSeverityCode = isset($DataArray[ 'L_SEVERITYCODE' . $n . '' ])
579
-                ? $DataArray[ 'L_SEVERITYCODE' . $n . '' ]
580
-                : '';
581
-            $CurrentItem = array(
582
-                'L_ERRORCODE'    => $LErrorCode,
583
-                'L_SHORTMESSAGE' => $LShortMessage,
584
-                'L_LONGMESSAGE'  => $LLongMessage,
585
-                'L_SEVERITYCODE' => $LSeverityCode,
586
-            );
587
-            array_push($Errors, $CurrentItem);
588
-            $n++;
589
-        }
590
-        return $Errors;
591
-    }
592
-
593
-
594
-
595
-    /**
596
-     *        nothing to see here...  move along....
597
-     *
598
-     * @access protected
599
-     * @param $Errors
600
-     * @return string
601
-     */
602
-    private function _DisplayErrors($Errors)
603
-    {
604
-        $error = '';
605
-        foreach ($Errors as $ErrorVar => $ErrorVal) {
606
-            $CurrentError = $Errors[ $ErrorVar ];
607
-            foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
608
-                $CurrentVarName = '';
609
-                if ($CurrentErrorVar == 'L_ERRORCODE') {
610
-                    $CurrentVarName = 'Error Code';
611
-                } elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') {
612
-                    $CurrentVarName = 'Short Message';
613
-                } elseif ($CurrentErrorVar == 'L_LONGMESSAGE') {
614
-                    $CurrentVarName = 'Long Message';
615
-                } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
616
-                    $CurrentVarName = 'Severity Code';
617
-                }
618
-                $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
619
-            }
620
-        }
621
-        return $error;
622
-    }
17
+	/**
18
+	 * @var $_paypal_api_username string
19
+	 */
20
+	protected $_api_username = null;
21
+
22
+	/**
23
+	 * @var $_api_password string
24
+	 */
25
+	protected $_api_password = null;
26
+
27
+	/**
28
+	 * @var $_api_signature string
29
+	 */
30
+	protected $_api_signature = null;
31
+
32
+	/**
33
+	 * @var $_credit_card_types array with the keys for credit card types accepted on this account
34
+	 */
35
+	protected $_credit_card_types    = null;
36
+
37
+	protected $_currencies_supported = array(
38
+		'USD',
39
+		'GBP',
40
+		'CAD',
41
+		'AUD',
42
+		'BRL',
43
+		'CHF',
44
+		'CZK',
45
+		'DKK',
46
+		'EUR',
47
+		'HKD',
48
+		'HUF',
49
+		'ILS',
50
+		'JPY',
51
+		'MXN',
52
+		'MYR',
53
+		'NOK',
54
+		'NZD',
55
+		'PHP',
56
+		'PLN',
57
+		'SEK',
58
+		'SGD',
59
+		'THB',
60
+		'TRY',
61
+		'TWD',
62
+		'RUB',
63
+		'INR',
64
+	);
65
+
66
+
67
+
68
+	/**
69
+	 * @param EEI_Payment $payment
70
+	 * @param array       $billing_info {
71
+	 * @type string $credit_card
72
+	 * @type string $credit_card_type
73
+	 * @type string $exp_month always 2 characters
74
+	 * @type string $exp_year always 4 characters
75
+	 * @type string $cvv
76
+	 * }
77
+	 * @see      parent::do_direct_payment for more info
78
+	 * @return EE_Payment|EEI_Payment
79
+	 * @throws EE_Error
80
+	 */
81
+	public function do_direct_payment($payment, $billing_info = null)
82
+	{
83
+		$transaction = $payment->transaction();
84
+		if (! $transaction instanceof EEI_Transaction) {
85
+			throw new EE_Error(
86
+				esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
87
+			);
88
+		}
89
+		$primary_registrant = $transaction->primary_registration();
90
+		if (! $primary_registrant instanceof EEI_Registration) {
91
+			throw new EE_Error(
92
+				esc_html__(
93
+					'No primary registration on transaction while paying with PayPal Pro.',
94
+					'event_espresso'
95
+				)
96
+			);
97
+		}
98
+		$attendee = $primary_registrant->attendee();
99
+		if (! $attendee instanceof EEI_Attendee) {
100
+			throw new EE_Error(
101
+				esc_html__(
102
+					'No attendee on primary registration while paying with PayPal Pro.',
103
+					'event_espresso'
104
+				)
105
+			);
106
+		}
107
+		$gateway_formatter = $this->_get_gateway_formatter();
108
+		$order_description = substr($gateway_formatter->formatOrderDescription($payment), 0, 127);
109
+		// charge for the full amount. Show itemized list
110
+		if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) {
111
+			$item_num = 1;
112
+			$total_line_item = $transaction->total_line_item();
113
+			$order_items = array();
114
+			foreach ($total_line_item->get_items() as $line_item) {
115
+				// ignore line items with a quantity of 0
116
+				if ($line_item->quantity() == 0) {
117
+					continue;
118
+				}
119
+				// For percent items, whose unit_price is 0, use the total instead.
120
+				if ($line_item->is_percent()) {
121
+					$unit_price = $line_item->total();
122
+					$line_item_quantity = 1;
123
+				} else {
124
+					$unit_price = $line_item->unit_price();
125
+					$line_item_quantity = $line_item->quantity();
126
+				}
127
+				$item = array(
128
+					// Item Name.  127 char max.
129
+					'l_name'                 => substr(
130
+						$gateway_formatter->formatLineItemName($line_item, $payment),
131
+						0,
132
+						127
133
+					),
134
+					// Item description.  127 char max.
135
+					'l_desc'                 => substr(
136
+						$gateway_formatter->formatLineItemDesc($line_item, $payment),
137
+						0,
138
+						127
139
+					),
140
+					// Cost of individual item.
141
+					'l_amt'                  => $unit_price,
142
+					// Item Number.  127 char max.
143
+					'l_number'               => $item_num++,
144
+					// Item quantity.  Must be any positive integer.
145
+					'l_qty'                  => $line_item_quantity,
146
+					// Item's sales tax amount.
147
+					'l_taxamt'               => '',
148
+					// eBay auction number of item.
149
+					'l_ebayitemnumber'       => '',
150
+					// eBay transaction ID of purchased item.
151
+					'l_ebayitemauctiontxnid' => '',
152
+					// eBay order ID for the item.
153
+					'l_ebayitemorderid'      => '',
154
+				);
155
+				// add to array of all items
156
+				array_push($order_items, $item);
157
+			}
158
+			$item_amount = $total_line_item->get_items_total();
159
+			$tax_amount = $total_line_item->get_total_tax();
160
+		} else {
161
+			$order_items = array();
162
+			$item_amount = $payment->amount();
163
+			$tax_amount = 0;
164
+			array_push($order_items, array(
165
+				// Item Name.  127 char max.
166
+				'l_name'   => substr(
167
+					$gateway_formatter->formatPartialPaymentLineItemName($payment),
168
+					0,
169
+					127
170
+				),
171
+				// Item description.  127 char max.
172
+				'l_desc'   => substr(
173
+					$gateway_formatter->formatPartialPaymentLineItemDesc($payment),
174
+					0,
175
+					127
176
+				),
177
+				// Cost of individual item.
178
+				'l_amt'    => $payment->amount(),
179
+				// Item Number.  127 char max.
180
+				'l_number' => 1,
181
+				// Item quantity.  Must be any positive integer.
182
+				'l_qty'    => 1,
183
+			));
184
+		}
185
+
186
+
187
+		/** @var RequestInterface $request */
188
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
189
+		// Populate data arrays with order data.
190
+		$DPFields = array(
191
+			// How you want to obtain payment ?
192
+			// Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture.
193
+			// Sale indicates that this is a final sale for which you are requesting payment.  Default is Sale.
194
+			'paymentaction'    => 'Sale',
195
+			// Required.  IP address of the payer's browser.
196
+			'ipaddress'        => $request->ipAddress(),
197
+			// Flag to determine whether you want the results returned by FMF.  1 or 0.  Default is 0.
198
+			'returnfmfdetails' => '1',
199
+		);
200
+		$CCDetails = array(
201
+			// Required. Type of credit card.  Visa, MasterCard, Discover, Amex, Maestro, Solo.
202
+			// If Maestro or Solo, the currency code must be GBP.
203
+			//  In addition, either start date or issue number must be specified.
204
+			'creditcardtype' => $billing_info['credit_card_type'],
205
+			// Required.  Credit card number.  No spaces or punctuation.
206
+			'acct'           => $billing_info['credit_card'],
207
+			// Required.  Credit card expiration date.  Format is MMYYYY
208
+			'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
209
+			// Requirements determined by your PayPal account settings.  Security digits for credit card.
210
+			'cvv2'           => $billing_info['cvv'],
211
+		);
212
+		$PayerInfo = array(
213
+			// Email address of payer.
214
+			'email'       => $billing_info['email'],
215
+			// Unique PayPal customer ID for payer.
216
+			'payerid'     => '',
217
+			// Status of payer.  Values are verified or unverified
218
+			'payerstatus' => '',
219
+			// Payer's business name.
220
+			'business'    => '',
221
+		);
222
+		$PayerName = array(
223
+			// Payer's salutation.  20 char max.
224
+			'salutation' => '',
225
+			// Payer's first name.  25 char max.
226
+			'firstname'  => substr($billing_info['first_name'], 0, 25),
227
+			// Payer's middle name.  25 char max.
228
+			'middlename' => '',
229
+			// Payer's last name.  25 char max.
230
+			'lastname'   => substr($billing_info['last_name'], 0, 25),
231
+			// Payer's suffix.  12 char max.
232
+			'suffix'     => '',
233
+		);
234
+		$BillingAddress = array(
235
+			// Required.  First street address.
236
+			'street'      => $billing_info['address'],
237
+			// Second street address.
238
+			'street2'     => $billing_info['address2'],
239
+			// Required.  Name of City.
240
+			'city'        => $billing_info['city'],
241
+			// Required. Name of State or Province.
242
+			'state'       => substr($billing_info['state'], 0, 40),
243
+			// Required.  Country code.
244
+			'countrycode' => $billing_info['country'],
245
+			// Required.  Postal code of payer.
246
+			'zip'         => $billing_info['zip'],
247
+		);
248
+		// check if the registration info contains the needed fields for paypal pro
249
+		// (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
250
+		if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
251
+			$use_registration_address_info = true;
252
+		} else {
253
+			$use_registration_address_info = false;
254
+		}
255
+		// so if the attendee has enough data to fill out PayPal Pro's shipping info, use it.
256
+		// If not, use the billing info again
257
+		$ShippingAddress = array(
258
+			'shiptoname'     => substr($use_registration_address_info
259
+				? $attendee->full_name()
260
+				: $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
261
+			'shiptostreet'   => substr($use_registration_address_info
262
+				? $attendee->address()
263
+				: $billing_info['address'], 0, 100),
264
+			'shiptostreet2'  => substr($use_registration_address_info
265
+				? $attendee->address2() : $billing_info['address2'], 0, 100),
266
+			'shiptocity'     => substr($use_registration_address_info
267
+				? $attendee->city()
268
+				: $billing_info['city'], 0, 40),
269
+			'shiptostate'          => substr($use_registration_address_info
270
+				? $attendee->state_name()
271
+				: $billing_info['state'], 0, 40),
272
+			'shiptocountry'  => $use_registration_address_info
273
+				? $attendee->country_ID()
274
+				: $billing_info['country'],
275
+			'shiptozip'      => substr($use_registration_address_info
276
+				? $attendee->zip()
277
+				: $billing_info['zip'], 0, 20),
278
+			'shiptophonenum' => substr($use_registration_address_info
279
+				? $attendee->phone()
280
+				: $billing_info['phone'], 0, 20),
281
+		);
282
+		$PaymentDetails = array(
283
+			// Required.  Total amount of order, including shipping, handling, and tax.
284
+			'amt'          => $gateway_formatter->formatCurrency($payment->amount()),
285
+			// Required.  Three-letter currency code.  Default is USD.
286
+			'currencycode' => $payment->currency_code(),
287
+			// Required if you include itemized cart details. (L_AMTn, etc.)
288
+			// Subtotal of items not including S&H, or tax.
289
+			'itemamt'      => $gateway_formatter->formatCurrency($item_amount),//
290
+			// Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
291
+			'shippingamt'  => '',
292
+			// Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
293
+			'handlingamt'  => '',
294
+			// Required if you specify itemized cart tax details.
295
+			// Sum of tax for all items on the order.  Total sales tax.
296
+			'taxamt'       => $gateway_formatter->formatCurrency($tax_amount),
297
+			// Description of the order the customer is purchasing.  127 char max.
298
+			'desc'         => $order_description,
299
+			// Free-form field for your own use.  256 char max.
300
+			'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
301
+			// Your own invoice or tracking number
302
+			'invnum'       => wp_generate_password(12, false),// $transaction->ID(),
303
+			// URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
304
+			'notifyurl'    => '',
305
+			'buttonsource' => 'EventEspresso_SP',// EE will blow up if you change this
306
+		);
307
+		// Wrap all data arrays into a single, "master" array which will be passed into the class function.
308
+		$PayPalRequestData = array(
309
+			'DPFields'        => $DPFields,
310
+			'CCDetails'       => $CCDetails,
311
+			'PayerInfo'       => $PayerInfo,
312
+			'PayerName'       => $PayerName,
313
+			'BillingAddress'  => $BillingAddress,
314
+			'ShippingAddress' => $ShippingAddress,
315
+			'PaymentDetails'  => $PaymentDetails,
316
+			'OrderItems'      => $order_items,
317
+		);
318
+		$this->_log_clean_request($PayPalRequestData, $payment);
319
+		try {
320
+			$PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
321
+			// remove PCI-sensitive data so it doesn't get stored
322
+			$PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
323
+			if (isset($PayPalResult['L_ERRORCODE0']) && $PayPalResult['L_ERRORCODE0'] === '10002') {
324
+				$message = esc_html__('PayPal did not accept your API username, password, or signature. Please double-check these credentials and if debug mode is on.', 'event_espresso');
325
+			} elseif (isset($PayPalResult['L_LONGMESSAGE0'])) {
326
+				$message = $PayPalResult['L_LONGMESSAGE0'];
327
+			} else {
328
+				$message = $PayPalResult['ACK'];
329
+			}
330
+			if (empty($PayPalResult['RAWRESPONSE'])) {
331
+				$payment->set_status($this->_pay_model->failed_status());
332
+				$payment->set_gateway_response(esc_html__('No response received from Paypal Pro', 'event_espresso'));
333
+				$payment->set_details($PayPalResult);
334
+			} else {
335
+				if ($this->_APICallSuccessful($PayPalResult)) {
336
+					$payment->set_status($this->_pay_model->approved_status());
337
+				} else {
338
+					$payment->set_status($this->_pay_model->declined_status());
339
+				}
340
+				// make sure we interpret the AMT as a float, not an international string
341
+				// (where periods are thousand separators)
342
+				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
343
+				$payment->set_gateway_response($message);
344
+				$payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID'])
345
+					? $PayPalResult['TRANSACTIONID']
346
+					: null);
347
+				$primary_registration_code = $primary_registrant instanceof EE_Registration
348
+					? $primary_registrant->reg_code()
349
+					: '';
350
+				$payment->set_extra_accntng($primary_registration_code);
351
+				$payment->set_details($PayPalResult);
352
+			}
353
+		} catch (Exception $e) {
354
+			$payment->set_status($this->_pay_model->failed_status());
355
+			$payment->set_gateway_response($e->getMessage());
356
+		}
357
+		// $payment->set_status( $this->_pay_model->declined_status() );
358
+		// $payment->set_gateway_response( '' );
359
+		return $payment;
360
+	}
361
+
362
+
363
+
364
+	/**
365
+	 * CLeans out sensitive CC data and then logs it, and returns the cleaned request
366
+	 *
367
+	 * @param array       $request
368
+	 * @param EEI_Payment $payment
369
+	 * @return void
370
+	 */
371
+	private function _log_clean_request($request, $payment)
372
+	{
373
+		$cleaned_request_data = $request;
374
+		unset($cleaned_request_data['CCDetails']['acct']);
375
+		unset($cleaned_request_data['CCDetails']['cvv2']);
376
+		unset($cleaned_request_data['CCDetails']['expdate']);
377
+		$this->log(array('Paypal Request' => $cleaned_request_data), $payment);
378
+	}
379
+
380
+
381
+
382
+	/**
383
+	 * Cleans the response, logs it, and returns it
384
+	 *
385
+	 * @param array       $response
386
+	 * @param EEI_Payment $payment
387
+	 * @return array cleaned
388
+	 */
389
+	private function _log_clean_response($response, $payment)
390
+	{
391
+		unset($response['REQUESTDATA']['CREDITCARDTYPE']);
392
+		unset($response['REQUESTDATA']['ACCT']);
393
+		unset($response['REQUESTDATA']['EXPDATE']);
394
+		unset($response['REQUESTDATA']['CVV2']);
395
+		unset($response['RAWREQUEST']);
396
+		$this->log(array('Paypal Response' => $response), $payment);
397
+		return $response;
398
+	}
399
+
400
+
401
+
402
+	/**
403
+	 * @param $DataArray
404
+	 * @return array
405
+	 */
406
+	private function prep_and_curl_request($DataArray)
407
+	{
408
+		// Create empty holders for each portion of the NVP string
409
+		$DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP';
410
+		$CCDetailsNVP = '';
411
+		$PayerInfoNVP = '';
412
+		$PayerNameNVP = '';
413
+		$BillingAddressNVP = '';
414
+		$ShippingAddressNVP = '';
415
+		$PaymentDetailsNVP = '';
416
+		$OrderItemsNVP = '';
417
+		$Secure3DNVP = '';
418
+		// DP Fields
419
+		$DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
420
+		foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
421
+			$DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
422
+		}
423
+		// CC Details Fields
424
+		$CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
425
+		foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
426
+			$CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
427
+		}
428
+		// PayerInfo Type Fields
429
+		$PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
430
+		foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
431
+			$PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
432
+		}
433
+		// Payer Name Fields
434
+		$PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
435
+		foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
436
+			$PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
437
+		}
438
+		// Address Fields (Billing)
439
+		$BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
440
+		foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
441
+			$BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
442
+		}
443
+		// Payment Details Type Fields
444
+		$PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
445
+		foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
446
+			$PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
447
+		}
448
+		// Payment Details Item Type Fields
449
+		$OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
450
+		$n = 0;
451
+		foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
452
+			$CurrentItem = $OrderItems[ $OrderItemsVar ];
453
+			foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
454
+				$OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
455
+			}
456
+			$n++;
457
+		}
458
+		// Ship To Address Fields
459
+		$ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
460
+		foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
461
+			$ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
462
+		}
463
+		// 3D Secure Fields
464
+		$Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
465
+		foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
466
+			$Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
467
+		}
468
+		// Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
469
+		$NVPRequest = 'USER='
470
+					  . $this->_api_username
471
+					  . '&PWD='
472
+					  . $this->_api_password
473
+					  . '&VERSION=64.0'
474
+					  . '&SIGNATURE='
475
+					  . $this->_api_signature
476
+					  . $DPFieldsNVP
477
+					  . $CCDetailsNVP
478
+					  . $PayerInfoNVP
479
+					  . $PayerNameNVP
480
+					  . $BillingAddressNVP
481
+					  . $PaymentDetailsNVP
482
+					  . $OrderItemsNVP
483
+					  . $ShippingAddressNVP
484
+					  . $Secure3DNVP;
485
+		$NVPResponse = $this->_CURLRequest($NVPRequest);
486
+		$NVPRequestArray = $this->_NVPToArray($NVPRequest);
487
+		$NVPResponseArray = $this->_NVPToArray($NVPResponse);
488
+		$Errors = $this->_GetErrors($NVPResponseArray);
489
+		$NVPResponseArray['ERRORS'] = $Errors;
490
+		$NVPResponseArray['REQUESTDATA'] = $NVPRequestArray;
491
+		$NVPResponseArray['RAWREQUEST'] = $NVPRequest;
492
+		$NVPResponseArray['RAWRESPONSE'] = $NVPResponse;
493
+		return $NVPResponseArray;
494
+	}
495
+
496
+
497
+
498
+	/**
499
+	 * @param $Request
500
+	 * @return mixed
501
+	 */
502
+	private function _CURLRequest($Request)
503
+	{
504
+		$EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
505
+		$curl = curl_init();
506
+		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true));
507
+		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
508
+		curl_setopt($curl, CURLOPT_TIMEOUT, 60);
509
+		curl_setopt($curl, CURLOPT_URL, $EndPointURL);
510
+		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
511
+		curl_setopt($curl, CURLOPT_POSTFIELDS, $Request);
512
+		curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
513
+		// execute the curl POST
514
+		$Response = curl_exec($curl);
515
+		curl_close($curl);
516
+		return $Response;
517
+	}
518
+
519
+
520
+
521
+	/**
522
+	 * @param $NVPString
523
+	 * @return array
524
+	 */
525
+	private function _NVPToArray($NVPString)
526
+	{
527
+		// prepare responses into array
528
+		$proArray = array();
529
+		while (strlen($NVPString)) {
530
+			// name
531
+			$keypos = strpos($NVPString, '=');
532
+			$keyval = substr($NVPString, 0, $keypos);
533
+			// value
534
+			$valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
535
+			$valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
536
+			// decoding the response
537
+			$proArray[ $keyval ] = urldecode($valval);
538
+			$NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
539
+		}
540
+		return $proArray;
541
+	}
542
+
543
+
544
+
545
+	/**
546
+	 * @param array $PayPalResult
547
+	 * @return bool
548
+	 */
549
+	private function _APICallSuccessful($PayPalResult)
550
+	{
551
+		$approved = false;
552
+		// check main response message from PayPal
553
+		if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
554
+			$ack = strtoupper($PayPalResult['ACK']);
555
+			$approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
556
+		}
557
+		return $approved;
558
+	}
559
+
560
+
561
+
562
+	/**
563
+	 * @param $DataArray
564
+	 * @return array
565
+	 */
566
+	private function _GetErrors($DataArray)
567
+	{
568
+		$Errors = array();
569
+		$n = 0;
570
+		while (isset($DataArray[ 'L_ERRORCODE' . $n . '' ])) {
571
+			$LErrorCode = isset($DataArray[ 'L_ERRORCODE' . $n . '' ]) ? $DataArray[ 'L_ERRORCODE' . $n . '' ] : '';
572
+			$LShortMessage = isset($DataArray[ 'L_SHORTMESSAGE' . $n . '' ])
573
+				? $DataArray[ 'L_SHORTMESSAGE' . $n . '' ]
574
+				: '';
575
+			$LLongMessage = isset($DataArray[ 'L_LONGMESSAGE' . $n . '' ])
576
+				? $DataArray[ 'L_LONGMESSAGE' . $n . '' ]
577
+				: '';
578
+			$LSeverityCode = isset($DataArray[ 'L_SEVERITYCODE' . $n . '' ])
579
+				? $DataArray[ 'L_SEVERITYCODE' . $n . '' ]
580
+				: '';
581
+			$CurrentItem = array(
582
+				'L_ERRORCODE'    => $LErrorCode,
583
+				'L_SHORTMESSAGE' => $LShortMessage,
584
+				'L_LONGMESSAGE'  => $LLongMessage,
585
+				'L_SEVERITYCODE' => $LSeverityCode,
586
+			);
587
+			array_push($Errors, $CurrentItem);
588
+			$n++;
589
+		}
590
+		return $Errors;
591
+	}
592
+
593
+
594
+
595
+	/**
596
+	 *        nothing to see here...  move along....
597
+	 *
598
+	 * @access protected
599
+	 * @param $Errors
600
+	 * @return string
601
+	 */
602
+	private function _DisplayErrors($Errors)
603
+	{
604
+		$error = '';
605
+		foreach ($Errors as $ErrorVar => $ErrorVal) {
606
+			$CurrentError = $Errors[ $ErrorVar ];
607
+			foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
608
+				$CurrentVarName = '';
609
+				if ($CurrentErrorVar == 'L_ERRORCODE') {
610
+					$CurrentVarName = 'Error Code';
611
+				} elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') {
612
+					$CurrentVarName = 'Short Message';
613
+				} elseif ($CurrentErrorVar == 'L_LONGMESSAGE') {
614
+					$CurrentVarName = 'Long Message';
615
+				} elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
616
+					$CurrentVarName = 'Severity Code';
617
+				}
618
+				$error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
619
+			}
620
+		}
621
+		return $error;
622
+	}
623 623
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Enum_Text_Field.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -89,8 +89,8 @@
 block discarded – undo
89 89
     public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
90 90
     {
91 91
         $options = $this->_allowed_enum_values();
92
-        if (isset($options[ $value_on_field_to_be_outputted ])) {
93
-            return $options[ $value_on_field_to_be_outputted ];
92
+        if (isset($options[$value_on_field_to_be_outputted])) {
93
+            return $options[$value_on_field_to_be_outputted];
94 94
         } else {
95 95
             return $value_on_field_to_be_outputted;
96 96
         }
Please login to merge, or discard this patch.
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -11,131 +11,131 @@
 block discarded – undo
11 11
 class EE_Enum_Text_Field extends EE_Text_Field_Base
12 12
 {
13 13
 
14
-    /**
15
-     * @var array $_allowed_enum_values
16
-     */
17
-    public $_allowed_enum_values;
18
-
19
-    /**
20
-     * @param string  $table_column
21
-     * @param string  $nice_name
22
-     * @param boolean $nullable
23
-     * @param mixed   $default_value
24
-     * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
25
-     */
26
-    public function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values)
27
-    {
28
-        $this->_allowed_enum_values = $allowed_enum_values;
29
-        parent::__construct($table_column, $nice_name, $nullable, $default_value);
30
-        $this->setSchemaType('object');
31
-    }
32
-
33
-
34
-
35
-    /**
36
-     * Returns the list of allowed enum options, but filterable.
37
-     * This is used internally
38
-     *
39
-     * @return array
40
-     */
41
-    protected function _allowed_enum_values()
42
-    {
43
-        return apply_filters(
44
-            'FHEE__EE_Enum_Text_Field___allowed_enum_options',
45
-            $this->_allowed_enum_values,
46
-            $this
47
-        );
48
-    }
49
-
50
-
51
-
52
-    /**
53
-     * When setting, just verify that the value being used matches what we've defined as allowable enum values.
54
-     * If not, throw an error (but if WP_DEBUG is false, just set the value to default).
55
-     *
56
-     * @param string $value_inputted_for_field_on_model_object
57
-     * @return string
58
-     * @throws EE_Error
59
-     */
60
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
61
-    {
62
-        if (
63
-            $value_inputted_for_field_on_model_object !== null
64
-            && ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values())
65
-        ) {
66
-            if (defined('WP_DEBUG') && WP_DEBUG) {
67
-                $msg = sprintf(
68
-                    esc_html__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
69
-                    $value_inputted_for_field_on_model_object,
70
-                    $this->_name
71
-                );
72
-                $msg2 = sprintf(
73
-                    esc_html__('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'),
74
-                    $this->_name,
75
-                    implode(', ', array_keys($this->_allowed_enum_values())),
76
-                    $value_inputted_for_field_on_model_object
77
-                );
78
-                EE_Error::add_error("{$msg}||{$msg2}", __FILE__, __FUNCTION__, __LINE__);
79
-            }
80
-            return $this->get_default_value();
81
-        }
82
-        return $value_inputted_for_field_on_model_object;
83
-    }
84
-
85
-
86
-    /**
87
-     * Gets the pretty version of the enum's value.
88
-     *
89
-     * @param     int |string $value_on_field_to_be_outputted
90
-     * @param    null         $schema
91
-     * @return    string
92
-     */
93
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
94
-    {
95
-        $options = $this->_allowed_enum_values();
96
-        if (isset($options[ $value_on_field_to_be_outputted ])) {
97
-            return $options[ $value_on_field_to_be_outputted ];
98
-        } else {
99
-            return $value_on_field_to_be_outputted;
100
-        }
101
-    }
102
-
103
-
104
-
105
-    /**
106
-     * When retrieving something from the DB, don't enforce the enum's options. If it's in the DB, we just have to live
107
-     * with that. Note also: when we're saving to the DB again, we also don't enforce the enum options. It's ONLY
108
-     * when we're receiving USER input from prepare_for_set() that we enforce the enum options.
109
-     *
110
-     * @param mixed $value_in_db
111
-     * @return mixed
112
-     */
113
-    public function prepare_for_set_from_db($value_in_db)
114
-    {
115
-        return $value_in_db;
116
-    }
117
-
118
-
119
-    public function getSchemaProperties()
120
-    {
121
-        return array(
122
-            'raw' => array(
123
-                'description' =>  sprintf(
124
-                    esc_html__('%s - the value in the database.', 'event_espresso'),
125
-                    $this->get_nicename()
126
-                ),
127
-                'type' => 'string',
128
-                'enum' => array_keys($this->_allowed_enum_values)
129
-            ),
130
-            'pretty' => array(
131
-                'description' =>  sprintf(
132
-                    esc_html__('%s - the value for display.', 'event_espresso'),
133
-                    $this->get_nicename()
134
-                ),
135
-                'type' => 'string',
136
-                'enum' => array_values($this->_allowed_enum_values),
137
-                'read_only' => true
138
-            )
139
-        );
140
-    }
14
+	/**
15
+	 * @var array $_allowed_enum_values
16
+	 */
17
+	public $_allowed_enum_values;
18
+
19
+	/**
20
+	 * @param string  $table_column
21
+	 * @param string  $nice_name
22
+	 * @param boolean $nullable
23
+	 * @param mixed   $default_value
24
+	 * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
25
+	 */
26
+	public function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values)
27
+	{
28
+		$this->_allowed_enum_values = $allowed_enum_values;
29
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
30
+		$this->setSchemaType('object');
31
+	}
32
+
33
+
34
+
35
+	/**
36
+	 * Returns the list of allowed enum options, but filterable.
37
+	 * This is used internally
38
+	 *
39
+	 * @return array
40
+	 */
41
+	protected function _allowed_enum_values()
42
+	{
43
+		return apply_filters(
44
+			'FHEE__EE_Enum_Text_Field___allowed_enum_options',
45
+			$this->_allowed_enum_values,
46
+			$this
47
+		);
48
+	}
49
+
50
+
51
+
52
+	/**
53
+	 * When setting, just verify that the value being used matches what we've defined as allowable enum values.
54
+	 * If not, throw an error (but if WP_DEBUG is false, just set the value to default).
55
+	 *
56
+	 * @param string $value_inputted_for_field_on_model_object
57
+	 * @return string
58
+	 * @throws EE_Error
59
+	 */
60
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
61
+	{
62
+		if (
63
+			$value_inputted_for_field_on_model_object !== null
64
+			&& ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values())
65
+		) {
66
+			if (defined('WP_DEBUG') && WP_DEBUG) {
67
+				$msg = sprintf(
68
+					esc_html__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
69
+					$value_inputted_for_field_on_model_object,
70
+					$this->_name
71
+				);
72
+				$msg2 = sprintf(
73
+					esc_html__('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'),
74
+					$this->_name,
75
+					implode(', ', array_keys($this->_allowed_enum_values())),
76
+					$value_inputted_for_field_on_model_object
77
+				);
78
+				EE_Error::add_error("{$msg}||{$msg2}", __FILE__, __FUNCTION__, __LINE__);
79
+			}
80
+			return $this->get_default_value();
81
+		}
82
+		return $value_inputted_for_field_on_model_object;
83
+	}
84
+
85
+
86
+	/**
87
+	 * Gets the pretty version of the enum's value.
88
+	 *
89
+	 * @param     int |string $value_on_field_to_be_outputted
90
+	 * @param    null         $schema
91
+	 * @return    string
92
+	 */
93
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
94
+	{
95
+		$options = $this->_allowed_enum_values();
96
+		if (isset($options[ $value_on_field_to_be_outputted ])) {
97
+			return $options[ $value_on_field_to_be_outputted ];
98
+		} else {
99
+			return $value_on_field_to_be_outputted;
100
+		}
101
+	}
102
+
103
+
104
+
105
+	/**
106
+	 * When retrieving something from the DB, don't enforce the enum's options. If it's in the DB, we just have to live
107
+	 * with that. Note also: when we're saving to the DB again, we also don't enforce the enum options. It's ONLY
108
+	 * when we're receiving USER input from prepare_for_set() that we enforce the enum options.
109
+	 *
110
+	 * @param mixed $value_in_db
111
+	 * @return mixed
112
+	 */
113
+	public function prepare_for_set_from_db($value_in_db)
114
+	{
115
+		return $value_in_db;
116
+	}
117
+
118
+
119
+	public function getSchemaProperties()
120
+	{
121
+		return array(
122
+			'raw' => array(
123
+				'description' =>  sprintf(
124
+					esc_html__('%s - the value in the database.', 'event_espresso'),
125
+					$this->get_nicename()
126
+				),
127
+				'type' => 'string',
128
+				'enum' => array_keys($this->_allowed_enum_values)
129
+			),
130
+			'pretty' => array(
131
+				'description' =>  sprintf(
132
+					esc_html__('%s - the value for display.', 'event_espresso'),
133
+					$this->get_nicename()
134
+				),
135
+				'type' => 'string',
136
+				'enum' => array_values($this->_allowed_enum_values),
137
+				'read_only' => true
138
+			)
139
+		);
140
+	}
141 141
 }
Please login to merge, or discard this patch.
modules/thank_you_page/templates/thank-you-page-overview.template.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 <div id="espresso-thank-you-page-overview-dv" class="width-100">
11 11
 
12
-    <?php if (! $revisit) : ?>
12
+    <?php if ( ! $revisit) : ?>
13 13
         <div class="ee-attention">
14 14
             <div class="extra-padding-sides">
15 15
                 <?php echo apply_filters(
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
                         '<br />'
22 22
                     )
23 23
                 );
24
-                if (! empty($TXN_receipt_url)) : ?>
24
+                if ( ! empty($TXN_receipt_url)) : ?>
25 25
                     <br/>
26 26
                     <div class="jst-rght">
27 27
                         <a class="ee-button ee-roundish indented-text big-text"
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
         <div class="ee-attention">
14 14
             <div class="extra-padding-sides">
15 15
                 <?php echo apply_filters(
16
-                    'FHEE__thank_you_page_overview_template__order_conf_desc',
17
-                    sprintf(
18
-                        $order_conf_desc,
19
-                        '<h3 class="">',
20
-                        '</h3>',
21
-                        '<br />'
22
-                    )
23
-                );
24
-                if (! empty($TXN_receipt_url)) : ?>
16
+					'FHEE__thank_you_page_overview_template__order_conf_desc',
17
+					sprintf(
18
+						$order_conf_desc,
19
+						'<h3 class="">',
20
+						'</h3>',
21
+						'<br />'
22
+					)
23
+				);
24
+				if (! empty($TXN_receipt_url)) : ?>
25 25
                     <br/>
26 26
                     <div class="jst-rght">
27 27
                         <a class="ee-button ee-roundish indented-text big-text"
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
                         >
30 30
                             <span class="ee-icon ee-icon-PDF-file-type"></span>
31 31
                             <?php echo apply_filters(
32
-                                'FHEE__thank_you_page_overview_template__order_conf_button_text',
33
-                                esc_html__('View Full Order Confirmation Receipt', 'event_espresso')
34
-                            ); ?>
32
+								'FHEE__thank_you_page_overview_template__order_conf_button_text',
33
+								esc_html__('View Full Order Confirmation Receipt', 'event_espresso')
34
+							); ?>
35 35
                         </a>
36 36
                     </div>
37 37
                 <?php endif; ?>
Please login to merge, or discard this patch.
thank_you_page/templates/thank-you-page-payment-details.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 
6 6
 <div id="espresso-thank-you-page-payment-details-dv">
7 7
     <?php
8
-    if (! empty($payments)) { ?>
8
+    if ( ! empty($payments)) { ?>
9 9
         <table class="ee-table">
10 10
             <thead>
11 11
             <tr>
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 <div id="espresso-thank-you-page-payment-details-dv">
15 15
     <?php
16
-    if (! empty($payments)) { ?>
16
+	if (! empty($payments)) { ?>
17 17
         <table class="ee-table">
18 18
             <thead>
19 19
             <tr>
@@ -33,37 +33,37 @@  discard block
 block discarded – undo
33 33
             </thead>
34 34
             <tbody>
35 35
             <?php
36
-            foreach ($payments as $payment) {
37
-                echo $payment; // already escaped
38
-            }
39
-            ?>
36
+			foreach ($payments as $payment) {
37
+				echo $payment; // already escaped
38
+			}
39
+			?>
40 40
             </tbody>
41 41
         </table>
42 42
         <?php
43
-    } else {
44
-        if ($transaction->total()) {
45
-            echo apply_filters(
46
-                'FHEE__payment_overview_template__no_payments_made',
47
-                sprintf(
48
-                    esc_html__('%sNo payments towards this transaction have been received.%s', 'event_espresso'),
49
-                    '<p class="important-notice">',
50
-                    '</p>'
51
-                )
52
-            );
53
-            do_action('AHEE__thank_you_page_payment_details_template__no_payments_made', $transaction);
54
-        } else {
55
-            echo apply_filters(
56
-                'FHEE__payment_overview_template__no_payment_required',
57
-                sprintf(
58
-                    esc_html__('%sNo payment is required for this transaction.%s', 'event_espresso'),
59
-                    '<p>',
60
-                    '</p>'
61
-                )
62
-            );
63
-            do_action('AHEE__thank_you_page_payment_details_template__no_payment_required');
64
-        }
65
-    }
66
-    echo $gateway_content; // already escaped
67
-    do_action('AHEE__thank_you_page_payment_details_template__after_gateway_content', $gateway_content);
68
-    echo '<br/>';
69
-    do_action('AHEE__thank_you_page_payment_details_template__after_payment_details');
43
+	} else {
44
+		if ($transaction->total()) {
45
+			echo apply_filters(
46
+				'FHEE__payment_overview_template__no_payments_made',
47
+				sprintf(
48
+					esc_html__('%sNo payments towards this transaction have been received.%s', 'event_espresso'),
49
+					'<p class="important-notice">',
50
+					'</p>'
51
+				)
52
+			);
53
+			do_action('AHEE__thank_you_page_payment_details_template__no_payments_made', $transaction);
54
+		} else {
55
+			echo apply_filters(
56
+				'FHEE__payment_overview_template__no_payment_required',
57
+				sprintf(
58
+					esc_html__('%sNo payment is required for this transaction.%s', 'event_espresso'),
59
+					'<p>',
60
+					'</p>'
61
+				)
62
+			);
63
+			do_action('AHEE__thank_you_page_payment_details_template__no_payment_required');
64
+		}
65
+	}
66
+	echo $gateway_content; // already escaped
67
+	do_action('AHEE__thank_you_page_payment_details_template__after_gateway_content', $gateway_content);
68
+	echo '<br/>';
69
+	do_action('AHEE__thank_you_page_payment_details_template__after_payment_details');
Please login to merge, or discard this patch.
core/services/collections/CollectionInterface.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -16,159 +16,159 @@
 block discarded – undo
16 16
 interface CollectionInterface extends Countable, Iterator, Serializable, ArrayAccess
17 17
 {
18 18
 
19
-    /**
20
-     * add
21
-     * attaches an object to the Collection
22
-     * and sets any supplied data associated with the current iterator entry
23
-     * by calling EE_Object_Collection::set_identifier()
24
-     *
25
-     * @access public
26
-     * @param        $object
27
-     * @param  mixed $identifier
28
-     * @return bool
29
-     */
30
-    public function add($object, $identifier = null);
31
-
32
-    /**
33
-     * setIdentifier
34
-     * Sets the data associated with an object in the Collection
35
-     * if no $identifier is supplied, then the spl_object_hash() is used
36
-     *
37
-     * @access public
38
-     * @param        $object
39
-     * @param  mixed $identifier
40
-     * @return bool
41
-     */
42
-    public function setIdentifier($object, $identifier = null);
43
-
44
-    /**
45
-     * get
46
-     * finds and returns an object in the Collection based on the identifier that was set using addObject()
47
-     * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
48
-     *
49
-     * @access public
50
-     * @param mixed $identifier
51
-     * @return mixed
52
-     */
53
-    public function get($identifier);
54
-
55
-    /**
56
-     * has
57
-     * returns TRUE or FALSE
58
-     * depending on whether the object is within the Collection
59
-     * based on the supplied $identifier
60
-     *
61
-     * @access public
62
-     * @param  mixed $identifier
63
-     * @return bool
64
-     */
65
-    public function has($identifier);
66
-
67
-    /**
68
-     * hasObject
69
-     * returns TRUE or FALSE depending on whether the supplied object is within the Collection
70
-     *
71
-     * @access public
72
-     * @param $object
73
-     * @return bool
74
-     */
75
-    public function hasObject($object);
76
-
77
-    /**
78
-     * remove
79
-     * detaches an object from the Collection
80
-     *
81
-     * @access public
82
-     * @param $object
83
-     * @return bool
84
-     */
85
-    public function remove($object);
86
-
87
-    /**
88
-     * setCurrent
89
-     * advances pointer to the object whose identifier matches that which was provided
90
-     *
91
-     * @access public
92
-     * @param mixed $identifier
93
-     * @return boolean
94
-     */
95
-    public function setCurrent($identifier);
96
-
97
-    /**
98
-     * setCurrentUsingObject
99
-     * advances pointer to the provided object
100
-     *
101
-     * @access public
102
-     * @param $object
103
-     * @return boolean
104
-     */
105
-    public function setCurrentUsingObject($object);
106
-
107
-    /**
108
-     * Returns the object occupying the index before the current object,
109
-     * unless this is already the first object, in which case it just returns the first object
110
-     *
111
-     * @return mixed
112
-     */
113
-    public function previous();
114
-
115
-        /**
116
-     * Returns the index of a given object, or false if not found
117
-     *
118
-     * @see http://stackoverflow.com/a/8736013
119
-     * @param $object
120
-     * @return boolean|int|string
121
-     */
122
-    public function indexOf($object);
123
-
124
-
125
-    /**
126
-     * Returns the object at the given index
127
-     *
128
-     * @see http://stackoverflow.com/a/8736013
129
-     * @param $index
130
-     * @return mixed
131
-     */
132
-    public function objectAtIndex($index);
133
-
134
-    /**
135
-     * Returns the sequence of objects as specified by the offset and length
136
-     *
137
-     * @see http://stackoverflow.com/a/8736013
138
-     * @param int $offset
139
-     * @param int $length
140
-     * @return array
141
-     */
142
-    public function slice($offset, $length);
143
-
144
-    /**
145
-     * Inserts an object (or an array of objects) at a certain point
146
-     *
147
-     * @see http://stackoverflow.com/a/8736013
148
-     * @param mixed   $objects A single object or an array of objects
149
-     * @param integer $index
150
-     */
151
-    public function insertAt($objects, $index);
152
-
153
-    /**
154
-     * Removes the object at the given index
155
-     *
156
-     * @see http://stackoverflow.com/a/8736013
157
-     * @param integer $index
158
-     */
159
-    public function removeAt($index);
160
-
161
-
162
-
163
-    /**
164
-     * detaches ALL objects from the Collection
165
-     */
166
-    public function detachAll();
167
-
168
-
169
-
170
-    /**
171
-     * unsets and detaches ALL objects from the Collection
172
-     */
173
-    public function trashAndDetachAll();
19
+	/**
20
+	 * add
21
+	 * attaches an object to the Collection
22
+	 * and sets any supplied data associated with the current iterator entry
23
+	 * by calling EE_Object_Collection::set_identifier()
24
+	 *
25
+	 * @access public
26
+	 * @param        $object
27
+	 * @param  mixed $identifier
28
+	 * @return bool
29
+	 */
30
+	public function add($object, $identifier = null);
31
+
32
+	/**
33
+	 * setIdentifier
34
+	 * Sets the data associated with an object in the Collection
35
+	 * if no $identifier is supplied, then the spl_object_hash() is used
36
+	 *
37
+	 * @access public
38
+	 * @param        $object
39
+	 * @param  mixed $identifier
40
+	 * @return bool
41
+	 */
42
+	public function setIdentifier($object, $identifier = null);
43
+
44
+	/**
45
+	 * get
46
+	 * finds and returns an object in the Collection based on the identifier that was set using addObject()
47
+	 * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
48
+	 *
49
+	 * @access public
50
+	 * @param mixed $identifier
51
+	 * @return mixed
52
+	 */
53
+	public function get($identifier);
54
+
55
+	/**
56
+	 * has
57
+	 * returns TRUE or FALSE
58
+	 * depending on whether the object is within the Collection
59
+	 * based on the supplied $identifier
60
+	 *
61
+	 * @access public
62
+	 * @param  mixed $identifier
63
+	 * @return bool
64
+	 */
65
+	public function has($identifier);
66
+
67
+	/**
68
+	 * hasObject
69
+	 * returns TRUE or FALSE depending on whether the supplied object is within the Collection
70
+	 *
71
+	 * @access public
72
+	 * @param $object
73
+	 * @return bool
74
+	 */
75
+	public function hasObject($object);
76
+
77
+	/**
78
+	 * remove
79
+	 * detaches an object from the Collection
80
+	 *
81
+	 * @access public
82
+	 * @param $object
83
+	 * @return bool
84
+	 */
85
+	public function remove($object);
86
+
87
+	/**
88
+	 * setCurrent
89
+	 * advances pointer to the object whose identifier matches that which was provided
90
+	 *
91
+	 * @access public
92
+	 * @param mixed $identifier
93
+	 * @return boolean
94
+	 */
95
+	public function setCurrent($identifier);
96
+
97
+	/**
98
+	 * setCurrentUsingObject
99
+	 * advances pointer to the provided object
100
+	 *
101
+	 * @access public
102
+	 * @param $object
103
+	 * @return boolean
104
+	 */
105
+	public function setCurrentUsingObject($object);
106
+
107
+	/**
108
+	 * Returns the object occupying the index before the current object,
109
+	 * unless this is already the first object, in which case it just returns the first object
110
+	 *
111
+	 * @return mixed
112
+	 */
113
+	public function previous();
114
+
115
+		/**
116
+		 * Returns the index of a given object, or false if not found
117
+		 *
118
+		 * @see http://stackoverflow.com/a/8736013
119
+		 * @param $object
120
+		 * @return boolean|int|string
121
+		 */
122
+	public function indexOf($object);
123
+
124
+
125
+	/**
126
+	 * Returns the object at the given index
127
+	 *
128
+	 * @see http://stackoverflow.com/a/8736013
129
+	 * @param $index
130
+	 * @return mixed
131
+	 */
132
+	public function objectAtIndex($index);
133
+
134
+	/**
135
+	 * Returns the sequence of objects as specified by the offset and length
136
+	 *
137
+	 * @see http://stackoverflow.com/a/8736013
138
+	 * @param int $offset
139
+	 * @param int $length
140
+	 * @return array
141
+	 */
142
+	public function slice($offset, $length);
143
+
144
+	/**
145
+	 * Inserts an object (or an array of objects) at a certain point
146
+	 *
147
+	 * @see http://stackoverflow.com/a/8736013
148
+	 * @param mixed   $objects A single object or an array of objects
149
+	 * @param integer $index
150
+	 */
151
+	public function insertAt($objects, $index);
152
+
153
+	/**
154
+	 * Removes the object at the given index
155
+	 *
156
+	 * @see http://stackoverflow.com/a/8736013
157
+	 * @param integer $index
158
+	 */
159
+	public function removeAt($index);
160
+
161
+
162
+
163
+	/**
164
+	 * detaches ALL objects from the Collection
165
+	 */
166
+	public function detachAll();
167
+
168
+
169
+
170
+	/**
171
+	 * unsets and detaches ALL objects from the Collection
172
+	 */
173
+	public function trashAndDetachAll();
174 174
 }
Please login to merge, or discard this patch.
core/domain/services/admin/privacy/policy/PrivacyPolicy.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
         }
74 74
         $session_lifespan_in_hours = round($this->session_lifespan->inSeconds() / HOUR_IN_SECONDS);
75 75
         return (string) EEH_Template::display_template(
76
-            __DIR__ . '/privacy_policy.template.php',
76
+            __DIR__.'/privacy_policy.template.php',
77 77
             array(
78 78
                 'active_onsite_payment_methods' => $active_onsite_pms,
79 79
                 'active_offsite_payment_methods' => $active_offsite_pms,
Please login to merge, or discard this patch.
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -20,80 +20,80 @@
 block discarded – undo
20 20
 class PrivacyPolicy implements PrivacyPolicyInterface
21 21
 {
22 22
 
23
-    /**
24
-     * @var EEM_Payment_Method
25
-     */
26
-    protected $payment_method_model;
23
+	/**
24
+	 * @var EEM_Payment_Method
25
+	 */
26
+	protected $payment_method_model;
27 27
 
28
-    /**
29
-     * @var SessionLifespan
30
-     */
31
-    protected $session_lifespan;
28
+	/**
29
+	 * @var SessionLifespan
30
+	 */
31
+	protected $session_lifespan;
32 32
 
33
-    /**
34
-     * PrivacyPolicy constructor.
35
-     *
36
-     * @param EEM_Payment_Method $payment_method_model
37
-     * @param SessionLifespan    $session_lifespan
38
-     */
39
-    public function __construct(EEM_Payment_Method $payment_method_model, SessionLifespan $session_lifespan)
40
-    {
41
-        $this->payment_method_model = $payment_method_model;
42
-        $this->session_lifespan = $session_lifespan;
43
-    }
33
+	/**
34
+	 * PrivacyPolicy constructor.
35
+	 *
36
+	 * @param EEM_Payment_Method $payment_method_model
37
+	 * @param SessionLifespan    $session_lifespan
38
+	 */
39
+	public function __construct(EEM_Payment_Method $payment_method_model, SessionLifespan $session_lifespan)
40
+	{
41
+		$this->payment_method_model = $payment_method_model;
42
+		$this->session_lifespan = $session_lifespan;
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * Returns the name of the plugin and will be shown in the privacy policy's postbox header
48
-     *
49
-     * @return string
50
-     */
51
-    public function getName()
52
-    {
53
-        return esc_html__('Event Espresso', 'event_espresso');
54
-    }
46
+	/**
47
+	 * Returns the name of the plugin and will be shown in the privacy policy's postbox header
48
+	 *
49
+	 * @return string
50
+	 */
51
+	public function getName()
52
+	{
53
+		return esc_html__('Event Espresso', 'event_espresso');
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * Gets the HTML for the privacy policy. May be dynamic
59
-     *
60
-     * @return string
61
-     */
62
-    public function getContent()
63
-    {
64
-        // do they have any offsite payment methods? or onsite payment methods?
65
-        $active_payment_methods = $this->payment_method_model->get_all_active(EEM_Payment_Method::scope_cart);
66
-        $active_onsite_pms = array();
67
-        $active_offsite_pms = array();
68
-        foreach ($active_payment_methods as $payment_method) {
69
-            if ($payment_method->type_obj() instanceof \EE_PMT_Base) {
70
-                if ($payment_method->type_obj()->get_gateway() instanceof EE_Onsite_Gateway) {
71
-                    $active_onsite_pms[] = $payment_method->name();
72
-                } elseif ($payment_method->type_obj()->get_gateway() instanceof EE_Offsite_Gateway) {
73
-                    $active_offsite_pms[] = $payment_method->name();
74
-                }
75
-            }
76
-        }
77
-        $session_lifespan_in_hours = round($this->session_lifespan->inSeconds() / HOUR_IN_SECONDS);
78
-        return (string) EEH_Template::display_template(
79
-            __DIR__ . '/privacy_policy.template.php',
80
-            array(
81
-                'active_onsite_payment_methods' => $active_onsite_pms,
82
-                'active_offsite_payment_methods' => $active_offsite_pms,
83
-                'session_lifespan' => sprintf(
84
-                    _nx(
85
-                        '%1$s hour',
86
-                        '%1$s hours',
87
-                        $session_lifespan_in_hours,
88
-                        '2 hours',
89
-                        'event_espresso'
90
-                    ),
91
-                    $session_lifespan_in_hours
92
-                )
93
-            ),
94
-            true
95
-        );
96
-    }
57
+	/**
58
+	 * Gets the HTML for the privacy policy. May be dynamic
59
+	 *
60
+	 * @return string
61
+	 */
62
+	public function getContent()
63
+	{
64
+		// do they have any offsite payment methods? or onsite payment methods?
65
+		$active_payment_methods = $this->payment_method_model->get_all_active(EEM_Payment_Method::scope_cart);
66
+		$active_onsite_pms = array();
67
+		$active_offsite_pms = array();
68
+		foreach ($active_payment_methods as $payment_method) {
69
+			if ($payment_method->type_obj() instanceof \EE_PMT_Base) {
70
+				if ($payment_method->type_obj()->get_gateway() instanceof EE_Onsite_Gateway) {
71
+					$active_onsite_pms[] = $payment_method->name();
72
+				} elseif ($payment_method->type_obj()->get_gateway() instanceof EE_Offsite_Gateway) {
73
+					$active_offsite_pms[] = $payment_method->name();
74
+				}
75
+			}
76
+		}
77
+		$session_lifespan_in_hours = round($this->session_lifespan->inSeconds() / HOUR_IN_SECONDS);
78
+		return (string) EEH_Template::display_template(
79
+			__DIR__ . '/privacy_policy.template.php',
80
+			array(
81
+				'active_onsite_payment_methods' => $active_onsite_pms,
82
+				'active_offsite_payment_methods' => $active_offsite_pms,
83
+				'session_lifespan' => sprintf(
84
+					_nx(
85
+						'%1$s hour',
86
+						'%1$s hours',
87
+						$session_lifespan_in_hours,
88
+						'2 hours',
89
+						'event_espresso'
90
+					),
91
+					$session_lifespan_in_hours
92
+				)
93
+			),
94
+			true
95
+		);
96
+	}
97 97
 }
98 98
 // End of file PrivacyPolicy.php
99 99
 // Location: EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy.php
Please login to merge, or discard this patch.