Completed
Branch BUG-10059-allow-multiple-invoi... (76c0cc)
by
unknown
40:24 queued 26:41
created
admin_pages/support/Support_Admin_Page.core.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 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
 /**
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 class Support_Admin_Page extends EE_Admin_Page {
31 31
 
32 32
 
33
-	public function __construct( $routing = TRUE ) {
34
-		parent::__construct( $routing );
33
+	public function __construct($routing = TRUE) {
34
+		parent::__construct($routing);
35 35
 	}
36 36
 
37 37
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 				'nav' => array(
85 85
 					'label' => __('Support', 'event_espresso'),
86 86
 					'order' => 30),
87
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_support_boxes' ) ),
87
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
88 88
 				'require_nonce' => FALSE
89 89
 				),
90 90
 			'developers' => array(
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 				'nav' => array(
99 99
 					'label' => __('Shortcodes', 'event_espresso'),
100 100
 					'order' => 60),
101
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_shortcodes_boxes' ) ),
101
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
102 102
 				'require_nonce' => FALSE
103 103
 				),
104 104
 			);
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 
120 120
 
121 121
 	protected function _installation() {
122
-		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
123
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, '', TRUE);
122
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_installation.template.php';
123
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', TRUE);
124 124
 		$this->display_admin_page_with_sidebar();
125 125
 	}
126 126
 
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 			'other_resources' => __('Other Resources', 'event_espresso')
146 146
 			);
147 147
 
148
-		foreach ( $boxes as $box => $label ) {
149
-			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php';
148
+		foreach ($boxes as $box => $label) {
149
+			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php';
150 150
 			$callback_args = array('template_path' => $template_path);
151
-			add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args);
151
+			add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args);
152 152
 		}
153 153
 	}
154 154
 
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
 			'shortcodes_event_listings' => __('Event Listings', 'event_espresso'),
170 170
 			'shortcodes_ticket_selector' => __('Event Ticket Selector', 'event_espresso'),
171 171
 			'shortcodes_category' => __('Event Categories', 'event_espresso'),
172
-			'shortcodes_attendee' => __( 'Event Attendees', 'event_espresso' )
172
+			'shortcodes_attendee' => __('Event Attendees', 'event_espresso')
173 173
 			/*'shortcodes_single_events' => __('Single Events', 'event_espresso'),*/
174 174
 			/*'shortcodes_attendee_listings' => __('Attendee Listings', 'event_espresso'),*/
175 175
 			);
176 176
 
177
-		foreach ( $boxes as $box => $label ) {
178
-			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php';
177
+		foreach ($boxes as $box => $label) {
178
+			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php';
179 179
 			$callback_args = array('template_path' => $template_path);
180
-			add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args);
180
+			add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args);
181 181
 		}
182 182
 	}
183 183
 
@@ -196,17 +196,17 @@  discard block
 block discarded – undo
196 196
 			'important_information' => __('Important Information', 'event_espresso')
197 197
 			);
198 198
 
199
-		foreach ( $boxes as $box => $label ) {
200
-			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php';
199
+		foreach ($boxes as $box => $label) {
200
+			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php';
201 201
 			$callback_args = array('template_path' => $template_path, 'template_args' => $this->_template_args);
202
-			add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args);
202
+			add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args);
203 203
 		}
204 204
 	}
205 205
 
206 206
 
207 207
 	protected function _developers() {
208
-		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php';
209
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true );
208
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'developers_admin_details.template.php';
209
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true);
210 210
 		$this->display_admin_page_with_sidebar();
211 211
 	}
212 212
 } //end Support_Admin_Page class
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EEG_Paypal_Standard.gateway.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -274,26 +274,26 @@  discard block
 block discarded – undo
274 274
 		if ( ! $this->validate_ipn( $update_info, $payment ) ) {
275 275
 			return $payment;
276 276
 		}
277
-        // kill request here if this is a refund, we don't support them yet (we'd need to adjust the transaction,
278
-        // registrations, ticket counts, etc)
279
-        if (
280
-            (
281
-                $update_info[ 'payment_status' ] === 'Refunded'
282
-                || $update_info[ 'payment_status' ] === 'Partially_Refunded'
283
-            )
284
-            && apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true )
285
-        ) {
286
-            throw new EventEspresso\core\exceptions\IpnException(
287
-                sprintf(
288
-                    esc_html__( 'Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'),
289
-                    $update_info['payment_status']
290
-                ),
291
-                EventEspresso\core\exceptions\IpnException::UNSUPPORTED,
292
-                null,
293
-                $payment,
294
-                $update_info
295
-            );
296
-        }
277
+		// kill request here if this is a refund, we don't support them yet (we'd need to adjust the transaction,
278
+		// registrations, ticket counts, etc)
279
+		if (
280
+			(
281
+				$update_info[ 'payment_status' ] === 'Refunded'
282
+				|| $update_info[ 'payment_status' ] === 'Partially_Refunded'
283
+			)
284
+			&& apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true )
285
+		) {
286
+			throw new EventEspresso\core\exceptions\IpnException(
287
+				sprintf(
288
+					esc_html__( 'Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'),
289
+					$update_info['payment_status']
290
+				),
291
+				EventEspresso\core\exceptions\IpnException::UNSUPPORTED,
292
+				null,
293
+				$payment,
294
+				$update_info
295
+			);
296
+		}
297 297
 		//ok, well let's process this payment then!
298 298
 		switch ( $update_info[ 'payment_status' ] ) {
299 299
 
@@ -541,17 +541,17 @@  discard block
 block discarded – undo
541 541
 
542 542
 		//might paypal have changed the taxes?
543 543
 		if( $this->_paypal_taxes && $payment_was_itemized ) {
544
-            // note that we're doing this BEFORE adding shipping;
544
+			// note that we're doing this BEFORE adding shipping;
545 545
 			// we actually want PayPal's shipping to remain non-taxable
546
-            $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' );
547
-            $this->_line_item->set_total_tax_to(
548
-	            $transaction_total_line_item,
549
-                (float)$update_info['tax'],
550
-                esc_html__( 'Taxes', 'event_espresso' ),
551
-                esc_html__( 'Calculated by Paypal', 'event_espresso' ),
552
-                'paypal_tax'
553
-            );
554
-            $grand_total_needs_resaving = TRUE;
546
+			$this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' );
547
+			$this->_line_item->set_total_tax_to(
548
+				$transaction_total_line_item,
549
+				(float)$update_info['tax'],
550
+				esc_html__( 'Taxes', 'event_espresso' ),
551
+				esc_html__( 'Calculated by Paypal', 'event_espresso' ),
552
+				'paypal_tax'
553
+			);
554
+			$grand_total_needs_resaving = TRUE;
555 555
 		}
556 556
 
557 557
 		$shipping_amount = (float)$update_info[ 'mc_shipping' ];
Please login to merge, or discard this patch.
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * @return EEG_Paypal_Standard
71 71
 	 */
72 72
 	public function __construct() {
73
-		$this->set_uses_separate_IPN_request( true ) ;
73
+		$this->set_uses_separate_IPN_request(true);
74 74
 		parent::__construct();
75 75
 	}
76 76
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * Also sets the gateway url class variable based on whether debug mode is enabled or not
81 81
 	 * @param array $settings_array
82 82
 	 */
83
-	public function set_settings($settings_array){
83
+	public function set_settings($settings_array) {
84 84
 		parent::set_settings($settings_array);
85 85
 		$this->_gateway_url = $this->_debug_mode
86 86
 			? 'https://www.sandbox.paypal.com/cgi-bin/webscr'
@@ -114,42 +114,42 @@  discard block
 block discarded – undo
114 114
 
115 115
 		$total_discounts_to_cart_total = $transaction->paid();
116 116
 		//only itemize the order if we're paying for the rest of the order's amount
117
-		if( EEH_Money::compare_floats( $payment->amount(), $transaction->total(), '==' ) ) {
118
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true );
117
+		if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) {
118
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true);
119 119
 			//this payment is for the remaining transaction amount,
120 120
 			//keep track of exactly how much the itemized order amount equals
121 121
 			$itemized_sum = 0;
122 122
 			$shipping_previously_added = 0;
123 123
 			//so let's show all the line items
124
-			foreach($total_line_item->get_items() as $line_item){
125
-				if ( $line_item instanceof EE_Line_Item ) {
124
+			foreach ($total_line_item->get_items() as $line_item) {
125
+				if ($line_item instanceof EE_Line_Item) {
126 126
 					//it's some kind of discount
127
-					if( $line_item->total() < 0 ) {
128
-						$total_discounts_to_cart_total += abs( $line_item->total() );
127
+					if ($line_item->total() < 0) {
128
+						$total_discounts_to_cart_total += abs($line_item->total());
129 129
 						$itemized_sum += $line_item->total();
130 130
 						continue;
131 131
 					}
132 132
 					//dont include shipping again.
133
-					if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) {
133
+					if (strpos($line_item->code(), 'paypal_shipping_') === 0) {
134 134
 						$shipping_previously_added = $line_item->total();
135 135
 						continue;
136 136
 					}
137
-					$redirect_args[ 'item_name_' . $item_num ] = substr(
138
-						$this->_format_line_item_name( $line_item, $payment ),
137
+					$redirect_args['item_name_'.$item_num] = substr(
138
+						$this->_format_line_item_name($line_item, $payment),
139 139
 						0, 127
140 140
 					);
141
-					$redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price();
142
-					$redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity();
141
+					$redirect_args['amount_'.$item_num] = $line_item->unit_price();
142
+					$redirect_args['quantity_'.$item_num] = $line_item->quantity();
143 143
 					//if we're not letting PayPal calculate shipping, tell them its 0
144
-					if ( ! $this->_paypal_shipping ) {
145
-						$redirect_args[ 'shipping_' . $item_num ] = '0';
146
-						$redirect_args[ 'shipping2_' . $item_num ] = '0';
144
+					if ( ! $this->_paypal_shipping) {
145
+						$redirect_args['shipping_'.$item_num] = '0';
146
+						$redirect_args['shipping2_'.$item_num] = '0';
147 147
 					}
148 148
 					$item_num++;
149 149
 					$itemized_sum += $line_item->total();
150 150
 				}
151 151
 			}
152
-			$taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item );
152
+			$taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item);
153 153
 			//ideally itemized sum equals the transaction total. but if not (which is weird)
154 154
 			//and the itemized sum is LESS than the transaction total
155 155
 			//add another line item
@@ -159,47 +159,47 @@  discard block
 block discarded – undo
159 159
 				$transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added,
160 160
 				2
161 161
 			);
162
-			if( $itemized_sum_diff_from_txn_total < 0 ) {
162
+			if ($itemized_sum_diff_from_txn_total < 0) {
163 163
 				//itemized sum is too big
164
-				$total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total );
165
-			} elseif( $itemized_sum_diff_from_txn_total > 0 ) {
166
-				$redirect_args[ 'item_name_' . $item_num ] = substr(
167
-						__( 'Other charges', 'event_espresso' ), 0, 127 );
168
-				$redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total );
169
-				$redirect_args[ 'quantity_' . $item_num ] = 1;
164
+				$total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total);
165
+			} elseif ($itemized_sum_diff_from_txn_total > 0) {
166
+				$redirect_args['item_name_'.$item_num] = substr(
167
+						__('Other charges', 'event_espresso'), 0, 127 );
168
+				$redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total);
169
+				$redirect_args['quantity_'.$item_num] = 1;
170 170
 				$item_num++;
171 171
 			}
172
-			if( $total_discounts_to_cart_total > 0 ) {
173
-				$redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total );
172
+			if ($total_discounts_to_cart_total > 0) {
173
+				$redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total);
174 174
 			}
175 175
 			//add our taxes to the order if we're NOT using PayPal's
176
-			if( ! $this->_paypal_taxes ){
176
+			if ( ! $this->_paypal_taxes) {
177 177
 				$redirect_args['tax_cart'] = $total_line_item->get_total_tax();
178 178
 			}
179 179
 		} else {
180
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false );
180
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false);
181 181
 			//partial payment that's not for the remaining amount, so we can't send an itemized list
182
-			$redirect_args['item_name_' . $item_num] = substr(
183
-				$this->_format_partial_payment_line_item_name( $payment ),
182
+			$redirect_args['item_name_'.$item_num] = substr(
183
+				$this->_format_partial_payment_line_item_name($payment),
184 184
 				0, 127
185 185
 			);
186
-			$redirect_args['amount_' . $item_num] = $payment->amount();
187
-			$redirect_args['shipping_' . $item_num ] = '0';
188
-			$redirect_args['shipping2_' . $item_num ] = '0';
186
+			$redirect_args['amount_'.$item_num] = $payment->amount();
187
+			$redirect_args['shipping_'.$item_num] = '0';
188
+			$redirect_args['shipping2_'.$item_num] = '0';
189 189
 			$redirect_args['tax_cart'] = '0';
190 190
 			$item_num++;
191 191
 		}
192 192
 
193
-		if($this->_debug_mode){
194
-			$redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode';
195
-			$redirect_args['amount_' . $item_num] = 0;
193
+		if ($this->_debug_mode) {
194
+			$redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode';
195
+			$redirect_args['amount_'.$item_num] = 0;
196 196
 			$redirect_args['on0_'.$item_num] = 'NOTIFY URL';
197
-			$redirect_args['os0_' . $item_num] = $notify_url;
197
+			$redirect_args['os0_'.$item_num] = $notify_url;
198 198
 			$redirect_args['on1_'.$item_num] = 'RETURN URL';
199
-			$redirect_args['os1_' . $item_num] = $return_url;
199
+			$redirect_args['os1_'.$item_num] = $return_url;
200 200
 //			$redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ?
201
-			$redirect_args['shipping_' . $item_num ] = '0';
202
-			$redirect_args['shipping2_' . $item_num ] = '0';
201
+			$redirect_args['shipping_'.$item_num] = '0';
202
+			$redirect_args['shipping2_'.$item_num] = '0';
203 203
 		}
204 204
 
205 205
 		$redirect_args['business'] = $this->_paypal_id;
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 		$redirect_args['cmd'] = '_cart';
210 210
 		$redirect_args['upload'] = 1;
211 211
 		$redirect_args['currency_code'] = $payment->currency_code();
212
-		$redirect_args['rm'] = 2;//makes the user return with method=POST
213
-		if($this->_image_url){
212
+		$redirect_args['rm'] = 2; //makes the user return with method=POST
213
+		if ($this->_image_url) {
214 214
 			$redirect_args['image_url'] = $this->_image_url;
215 215
 		}
216 216
 		$redirect_args['no_shipping'] = $this->_shipping_details;
217
-		$redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this
217
+		$redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this
218 218
 
219
-		$redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this );
219
+		$redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this);
220 220
 
221 221
 		$payment->set_redirect_url($this->_gateway_url);
222 222
 		$payment->set_redirect_args($redirect_args);
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		$this->log(
225 225
 			array(
226 226
 				'message'     => sprintf(
227
-					__( 'PayPal payment request initiated.', 'event_espresso' )
227
+					__('PayPal payment request initiated.', 'event_espresso')
228 228
 				),
229 229
 				'transaction' => $transaction->model_field_array(),
230 230
 			),
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 	 * @return \EEI_Payment updated
245 245
 	 * @throws \EE_Error, IpnException
246 246
 	 */
247
-	public function handle_payment_update( $update_info, $transaction ){
247
+	public function handle_payment_update($update_info, $transaction) {
248 248
 		// verify there's payment data that's been sent
249
-		if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) {
249
+		if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) {
250 250
 			// log the results
251 251
 			$this->log(
252 252
 				array(
253 253
 					'message' => sprintf(
254
-						__( 'PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso' )
254
+						__('PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso')
255 255
 					),
256 256
 					'update_info' => $update_info,
257 257
 				),
@@ -259,33 +259,33 @@  discard block
 block discarded – undo
259 259
 			);
260 260
 			// waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/)
261 261
 			// indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes
262
-			if ( isset( $update_info[ 'tx' ] ) ) {
262
+			if (isset($update_info['tx'])) {
263 263
 				return $transaction->last_payment();
264 264
 			} else {
265 265
 				return null;
266 266
 			}
267 267
 		}
268
-		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
269
-		if ( ! $payment instanceof EEI_Payment ) {
268
+		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']);
269
+		if ( ! $payment instanceof EEI_Payment) {
270 270
 			$payment = $transaction->last_payment();
271 271
 		}
272 272
 		// ok, then validate the IPN. Even if we've already processed this payment,
273 273
 		// let PayPal know we don't want to hear from them anymore!
274
-		if ( ! $this->validate_ipn( $update_info, $payment ) ) {
274
+		if ( ! $this->validate_ipn($update_info, $payment)) {
275 275
 			return $payment;
276 276
 		}
277 277
         // kill request here if this is a refund, we don't support them yet (we'd need to adjust the transaction,
278 278
         // registrations, ticket counts, etc)
279 279
         if (
280 280
             (
281
-                $update_info[ 'payment_status' ] === 'Refunded'
282
-                || $update_info[ 'payment_status' ] === 'Partially_Refunded'
281
+                $update_info['payment_status'] === 'Refunded'
282
+                || $update_info['payment_status'] === 'Partially_Refunded'
283 283
             )
284
-            && apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true )
284
+            && apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)
285 285
         ) {
286 286
             throw new EventEspresso\core\exceptions\IpnException(
287 287
                 sprintf(
288
-                    esc_html__( 'Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'),
288
+                    esc_html__('Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'),
289 289
                     $update_info['payment_status']
290 290
                 ),
291 291
                 EventEspresso\core\exceptions\IpnException::UNSUPPORTED,
@@ -295,34 +295,34 @@  discard block
 block discarded – undo
295 295
             );
296 296
         }
297 297
 		//ok, well let's process this payment then!
298
-		switch ( $update_info[ 'payment_status' ] ) {
298
+		switch ($update_info['payment_status']) {
299 299
 
300 300
 			case 'Completed' :
301 301
 				$status = $this->_pay_model->approved_status();
302
-				$gateway_response = esc_html__( 'The payment is approved.', 'event_espresso' );
302
+				$gateway_response = esc_html__('The payment is approved.', 'event_espresso');
303 303
 				break;
304 304
 
305 305
 			case 'Pending' :
306 306
 				$status = $this->_pay_model->pending_status();
307
-				$gateway_response = esc_html__( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' );
307
+				$gateway_response = esc_html__('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso');
308 308
 				break;
309 309
 
310 310
 			case 'Denied' :
311 311
 				$status = $this->_pay_model->declined_status();
312
-				$gateway_response = esc_html__( 'The payment has been declined.', 'event_espresso' );
312
+				$gateway_response = esc_html__('The payment has been declined.', 'event_espresso');
313 313
 				break;
314 314
 
315 315
 			case 'Expired' :
316 316
 			case 'Failed' :
317 317
 				$status = $this->_pay_model->failed_status();
318
-				$gateway_response = esc_html__( 'The payment failed for technical reasons or expired.', 'event_espresso' );
318
+				$gateway_response = esc_html__('The payment failed for technical reasons or expired.', 'event_espresso');
319 319
 				break;
320 320
 
321 321
 			case 'Refunded' :
322 322
 			case 'Partially_Refunded' :
323 323
 				// even though it's a refund, we consider the payment as approved, it just has a negative value
324 324
 				$status = $this->_pay_model->approved_status();
325
-				$gateway_response = esc_html__( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' );
325
+				$gateway_response = esc_html__('The payment has been refunded. Please update registrations accordingly.', 'event_espresso');
326 326
 				break;
327 327
 
328 328
 			case 'Voided' :
@@ -330,19 +330,19 @@  discard block
 block discarded – undo
330 330
 			case 'Canceled_Reversal' :
331 331
 			default :
332 332
 				$status = $this->_pay_model->cancelled_status();
333
-				$gateway_response = esc_html__( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' );
333
+				$gateway_response = esc_html__('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso');
334 334
 				break;
335 335
 
336 336
 		}
337 337
 
338 338
 		//check if we've already processed this payment
339
-		if ( $payment instanceof EEI_Payment ) {
339
+		if ($payment instanceof EEI_Payment) {
340 340
 			//payment exists. if this has the exact same status and amount, don't bother updating. just return
341
-			if ( $payment->status() === $status && (float)$payment->amount() === (float)$update_info[ 'mc_gross' ] ) {
341
+			if ($payment->status() === $status && (float) $payment->amount() === (float) $update_info['mc_gross']) {
342 342
 				// DUPLICATED IPN! don't bother updating transaction
343 343
 				throw new IpnException(
344 344
 					sprintf(
345
-						esc_html__( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ),
345
+						esc_html__('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'),
346 346
 						$payment->ID()
347 347
 					),
348 348
 					IpnException::DUPLICATE,
@@ -352,14 +352,14 @@  discard block
 block discarded – undo
352 352
 				);
353 353
 			} else {
354 354
 				// new payment yippee !!!
355
-				$payment->set_status( $status );
356
-				$payment->set_amount( (float)$update_info[ 'mc_gross' ] );
357
-				$payment->set_gateway_response( $gateway_response );
358
-				$payment->set_details( $update_info );
359
-				$payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
355
+				$payment->set_status($status);
356
+				$payment->set_amount((float) $update_info['mc_gross']);
357
+				$payment->set_gateway_response($gateway_response);
358
+				$payment->set_details($update_info);
359
+				$payment->set_txn_id_chq_nmbr($update_info['txn_id']);
360 360
 				$this->log(
361 361
 					array(
362
-						'message'  => esc_html__( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' ),
362
+						'message'  => esc_html__('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso'),
363 363
 						'url'      => $this->_process_response_url(),
364 364
 						'payment'  => $payment->model_field_array(),
365 365
 						'IPN_data' => $update_info
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 			}
370 370
 
371 371
 		}
372
-		do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this );
372
+		do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this);
373 373
 		return $payment;
374 374
 	}
375 375
 
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 	 * @return boolean
385 385
 	 * @throws \EE_Error
386 386
 	 */
387
-	public function validate_ipn( $update_info, $payment ) {
387
+	public function validate_ipn($update_info, $payment) {
388 388
 		//allow us to skip validating IPNs with PayPal (useful for testing)
389
-		if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) {
389
+		if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) {
390 390
 			return true;
391 391
 		}
392 392
 		//...otherwise, we actually don't care what the $update_info is, we need to look
@@ -394,22 +394,22 @@  discard block
 block discarded – undo
394 394
 		// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
395 395
 		// Instead, read raw POST data from the input stream.
396 396
 		// @see https://gist.github.com/xcommerce-gists/3440401
397
-		$raw_post_data = file_get_contents( 'php://input' );
398
-		$raw_post_array = explode( '&', $raw_post_data );
397
+		$raw_post_data = file_get_contents('php://input');
398
+		$raw_post_array = explode('&', $raw_post_data);
399 399
 		$update_info = array();
400
-		foreach ( $raw_post_array as $keyval ) {
401
-			$keyval = explode( '=', $keyval );
402
-			if ( count( $keyval ) === 2 ) {
403
-				$update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] );
400
+		foreach ($raw_post_array as $keyval) {
401
+			$keyval = explode('=', $keyval);
402
+			if (count($keyval) === 2) {
403
+				$update_info[$keyval[0]] = urldecode($keyval[1]);
404 404
 			}
405 405
 		}
406 406
 		// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
407 407
 		$req = 'cmd=_notify-validate';
408
-		$uses_get_magic_quotes = function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() === 1
408
+		$uses_get_magic_quotes = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() === 1
409 409
 			? true
410 410
 			: false;
411
-		foreach ( $update_info as $key => $value ) {
412
-			$value = $uses_get_magic_quotes ? urlencode( stripslashes( $value ) ) : urlencode( $value );
411
+		foreach ($update_info as $key => $value) {
412
+			$value = $uses_get_magic_quotes ? urlencode(stripslashes($value)) : urlencode($value);
413 413
 			$req .= "&$key=$value";
414 414
 		}
415 415
 		// HTTP POST the complete, unaltered IPN back to PayPal
@@ -418,38 +418,38 @@  discard block
 block discarded – undo
418 418
 			array(
419 419
 				'body' 				=> $req,
420 420
 				'sslverify' 		=> false,
421
-				'timeout' 		=> 60 ,
421
+				'timeout' 		=> 60,
422 422
 				// make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal
423 423
 				// plz see: https://github.com/websharks/s2member/issues/610
424
-				'user-agent' 	=> 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(),
424
+				'user-agent' 	=> 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(),
425 425
 				'httpversion' => '1.1'
426 426
 			)
427 427
 		);
428 428
 		// then check the response
429 429
 		if (
430
-			array_key_exists( 'body', $response )
431
-			&& ! is_wp_error( $response )
432
-			&& strcmp( $response[ 'body' ], "VERIFIED" ) === 0
430
+			array_key_exists('body', $response)
431
+			&& ! is_wp_error($response)
432
+			&& strcmp($response['body'], "VERIFIED") === 0
433 433
 		) {
434 434
 			return true;
435 435
 		}
436 436
 		// huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly,
437 437
 		// or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html
438
-		if( $response instanceof WP_Error ) {
438
+		if ($response instanceof WP_Error) {
439 439
 			$error_msg = sprintf(
440
-				esc_html__( 'WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso' ),
440
+				esc_html__('WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso'),
441 441
 				$response->get_error_code(),
442 442
 				$response->get_error_message(),
443
-				print_r( $response->get_error_data(), true )
443
+				print_r($response->get_error_data(), true)
444 444
 			);
445
-		} elseif( is_array( $response ) && isset( $response[ 'body' ] ) ) {
446
-			$error_msg = $response[ 'body' ];
445
+		} elseif (is_array($response) && isset($response['body'])) {
446
+			$error_msg = $response['body'];
447 447
 		} else {
448
-			$error_msg = print_r( $response, true );
448
+			$error_msg = print_r($response, true);
449 449
 		}
450
-		$payment->set_gateway_response( sprintf( esc_html__( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $error_msg ) );
451
-		$payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) );
452
-		$payment->set_status( EEM_Payment::status_id_failed );
450
+		$payment->set_gateway_response(sprintf(esc_html__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $error_msg));
451
+		$payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response));
452
+		$payment->set_status(EEM_Payment::status_id_failed);
453 453
 		// log the results
454 454
 		$this->log(
455 455
 			array(
@@ -469,9 +469,9 @@  discard block
 block discarded – undo
469 469
 	 * @return string
470 470
 	 */
471 471
 	protected function _process_response_url() {
472
-		if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) {
472
+		if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
473 473
 			$url = is_ssl() ? 'https://' : 'http://';
474
-			$url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' );
474
+			$url .= EEH_URL::filter_input_server_url('HTTP_HOST');
475 475
 			$url .= EEH_URL::filter_input_server_url();
476 476
 		} else {
477 477
 			$url = 'unknown';
@@ -488,12 +488,12 @@  discard block
 block discarded – undo
488 488
 	 * @param EEI_Payment $payment
489 489
 	 * @throws \EE_Error
490 490
 	 */
491
-	public function update_txn_based_on_payment( $payment ) {
491
+	public function update_txn_based_on_payment($payment) {
492 492
 		$update_info = $payment->details();
493 493
 		/** @var EE_Transaction $transaction */
494 494
 		$transaction = $payment->transaction();
495
-		$payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false );
496
-		if( ! $transaction ){
495
+		$payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false);
496
+		if ( ! $transaction) {
497 497
 			$this->log(
498 498
 				esc_html__(
499 499
 					'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly',
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 			);
504 504
 			return;
505 505
 		}
506
-		if(
507
-			! is_array( $update_info )
508
-			|| ! isset( $update_info[ 'mc_shipping' ] )
509
-			|| ! isset( $update_info[ 'tax' ] )
506
+		if (
507
+			! is_array($update_info)
508
+			|| ! isset($update_info['mc_shipping'])
509
+			|| ! isset($update_info['tax'])
510 510
 		) {
511 511
 			$this->log(
512 512
 				array(
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 			);
522 522
 			return;
523 523
 		}
524
-		if( $payment->status() !== $this->_pay_model->approved_status() ) {
524
+		if ($payment->status() !== $this->_pay_model->approved_status()) {
525 525
 			$this->log(
526 526
 				array(
527 527
 					'message' => esc_html__(
@@ -540,44 +540,44 @@  discard block
 block discarded – undo
540 540
 		$transaction_total_line_item = $transaction->total_line_item();
541 541
 
542 542
 		//might paypal have changed the taxes?
543
-		if( $this->_paypal_taxes && $payment_was_itemized ) {
543
+		if ($this->_paypal_taxes && $payment_was_itemized) {
544 544
             // note that we're doing this BEFORE adding shipping;
545 545
 			// we actually want PayPal's shipping to remain non-taxable
546
-            $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' );
546
+            $this->_line_item->set_line_items_taxable($transaction_total_line_item, true, 'paypal_shipping');
547 547
             $this->_line_item->set_total_tax_to(
548 548
 	            $transaction_total_line_item,
549
-                (float)$update_info['tax'],
550
-                esc_html__( 'Taxes', 'event_espresso' ),
551
-                esc_html__( 'Calculated by Paypal', 'event_espresso' ),
549
+                (float) $update_info['tax'],
550
+                esc_html__('Taxes', 'event_espresso'),
551
+                esc_html__('Calculated by Paypal', 'event_espresso'),
552 552
                 'paypal_tax'
553 553
             );
554 554
             $grand_total_needs_resaving = TRUE;
555 555
 		}
556 556
 
557
-		$shipping_amount = (float)$update_info[ 'mc_shipping' ];
557
+		$shipping_amount = (float) $update_info['mc_shipping'];
558 558
 		//might paypal have added shipping?
559
-		if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){
559
+		if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) {
560 560
 			$this->_line_item->add_unrelated_item(
561 561
 				$transaction_total_line_item,
562
-				sprintf( esc_html__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ),
562
+				sprintf(esc_html__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()),
563 563
 				$shipping_amount,
564 564
 				esc_html__('Shipping charges calculated by Paypal', 'event_espresso'),
565 565
 				1,
566 566
 				false,
567
-				'paypal_shipping_' . $transaction->ID()
567
+				'paypal_shipping_'.$transaction->ID()
568 568
 			);
569 569
 			$grand_total_needs_resaving = true;
570 570
 		}
571 571
 
572
-		if( $grand_total_needs_resaving ){
573
-			$transaction_total_line_item->save_this_and_descendants_to_txn( $transaction->ID() );
572
+		if ($grand_total_needs_resaving) {
573
+			$transaction_total_line_item->save_this_and_descendants_to_txn($transaction->ID());
574 574
 			/** @var EE_Registration_Processor $registration_processor */
575
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
576
-			$registration_processor->update_registration_final_prices( $transaction );
575
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
576
+			$registration_processor->update_registration_final_prices($transaction);
577 577
 		}
578 578
 		$this->log(
579 579
 			array(
580
-				'message'                     => esc_html__( 'Updated transaction related to payment', 'event_espresso' ),
580
+				'message'                     => esc_html__('Updated transaction related to payment', 'event_espresso'),
581 581
 				'url'                         => $this->_process_response_url(),
582 582
 				'transaction (updated)'       => $transaction->model_field_array(),
583 583
 				'payment (updated)'           => $payment->model_field_array(),
Please login to merge, or discard this patch.
core/EE_Payment_Processor.core.php 2 patches
Indentation   +35 added lines, -37 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class EE_Payment_Processor extends EE_Processor_Base {
15 15
 	/**
16
-     * 	@var EE_Payment_Processor $_instance
16
+	 * 	@var EE_Payment_Processor $_instance
17 17
 	 * 	@access 	private
18
-     */
18
+	 */
19 19
 	private static $_instance;
20 20
 
21 21
 
@@ -50,7 +50,6 @@  discard block
 block discarded – undo
50 50
 	/**
51 51
 	 * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately.
52 52
 	 * Saves the payment that is generated
53
-
54 53
 	 *
55 54
 *@param EE_Payment_Method    $payment_method
56 55
 	 * @param EE_Transaction       $transaction
@@ -130,7 +129,6 @@  discard block
 block discarded – undo
130 129
 
131 130
 
132 131
 	/**
133
-
134 132
 	 * @param EE_Transaction|int $transaction
135 133
 	 * @param EE_Payment_Method $payment_method
136 134
 	 * @throws EE_Error
@@ -221,22 +219,22 @@  discard block
 block discarded – undo
221 219
 				/** @type EE_Payment_Method $payment_method */
222 220
 				$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method);
223 221
 				if ( $payment_method->type_obj() instanceof EE_PMT_Base ) {
224
-				    try {
225
-                        $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction);
226
-                        $log->set_object($payment);
227
-                    } catch( EventEspresso\core\exceptions\IpnException $e ) {
228
-                        EEM_Change_Log::instance()->log(
229
-                            EEM_Change_Log::type_gateway,
230
-                            array(
231
-                                'message' => 'IPN Exception: ' . $e->getMessage(),
232
-                                'current_url' => EEH_URL::current_url(),
233
-                                'payment' => $e->getPaymentProperties(),
234
-                                'IPN_data' => $e->getIpnData()
235
-                            ),
236
-                            $obj_for_log
237
-                        );
238
-                        return $e->getPayment();
239
-                    }
222
+					try {
223
+						$payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction);
224
+						$log->set_object($payment);
225
+					} catch( EventEspresso\core\exceptions\IpnException $e ) {
226
+						EEM_Change_Log::instance()->log(
227
+							EEM_Change_Log::type_gateway,
228
+							array(
229
+								'message' => 'IPN Exception: ' . $e->getMessage(),
230
+								'current_url' => EEH_URL::current_url(),
231
+								'payment' => $e->getPaymentProperties(),
232
+								'IPN_data' => $e->getIpnData()
233
+							),
234
+							$obj_for_log
235
+						);
236
+						return $e->getPayment();
237
+					}
240 238
 				} else {
241 239
 					// not a payment
242 240
 					EE_Error::add_error(
@@ -262,18 +260,18 @@  discard block
 block discarded – undo
262 260
 						);
263 261
 						break;
264 262
 					} catch( EventEspresso\core\exceptions\IpnException $e ) {
265
-                        EEM_Change_Log::instance()->log(
266
-                            EEM_Change_Log::type_gateway,
267
-                            array(
268
-                                'message' => 'IPN Exception: ' . $e->getMessage(),
269
-                                'current_url' => EEH_URL::current_url(),
270
-                                'payment' => $e->getPaymentProperties(),
271
-                                'IPN_data' => $e->getIpnData()
272
-                            ),
273
-                            $obj_for_log
274
-                        );
275
-                        return $e->getPayment();
276
-                    } catch( EE_Error $e ) {
263
+						EEM_Change_Log::instance()->log(
264
+							EEM_Change_Log::type_gateway,
265
+							array(
266
+								'message' => 'IPN Exception: ' . $e->getMessage(),
267
+								'current_url' => EEH_URL::current_url(),
268
+								'payment' => $e->getPaymentProperties(),
269
+								'IPN_data' => $e->getIpnData()
270
+							),
271
+							$obj_for_log
272
+						);
273
+						return $e->getPayment();
274
+					} catch( EE_Error $e ) {
277 275
 						//that's fine- it apparently couldn't handle the IPN
278 276
 					}
279 277
 				}
@@ -709,12 +707,12 @@  discard block
 block discarded – undo
709 707
 	}
710 708
 	
711 709
 	/**
712
- 	 * Force posts to PayPal to use TLS v1.2. See:
713
- 	 * https://core.trac.wordpress.org/ticket/36320
714
- 	 * https://core.trac.wordpress.org/ticket/34924#comment:15
715
- 	 * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US
710
+	 * Force posts to PayPal to use TLS v1.2. See:
711
+	 * https://core.trac.wordpress.org/ticket/36320
712
+	 * https://core.trac.wordpress.org/ticket/34924#comment:15
713
+	 * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US
716 714
 	 * This will affect paypal standard, pro, express, and payflow.
717
- 	 */
715
+	 */
718 716
  	public static function _curl_requests_to_paypal_use_tls( $handle, $r, $url ) {
719 717
  		if ( strstr( $url, 'https://' ) && strstr( $url, '.paypal.com' ) ) {
720 718
 			//Use the value of the constant CURL_SSLVERSION_TLSv1 = 1
Please login to merge, or discard this patch.
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
-EE_Registry::instance()->load_class( 'Processor_Base' );
2
+EE_Registry::instance()->load_class('Processor_Base');
3 3
 /**
4 4
  *
5 5
  * EE_Payment_Processor
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function instance() {
29 29
 		// check if class object is instantiated
30
-		if ( ! self::$_instance instanceof EE_Payment_Processor ) {
30
+		if ( ! self::$_instance instanceof EE_Payment_Processor) {
31 31
 			self::$_instance = new self();
32 32
 		}
33 33
 		return self::$_instance;
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	 *@access private
42 42
 	 */
43 43
 	private function __construct() {
44
-		do_action( 'AHEE__EE_Payment_Processor__construct' );
45
-		add_action( 'http_api_curl', array( $this, '_curl_requests_to_paypal_use_tls' ), 10, 3 );
44
+		do_action('AHEE__EE_Payment_Processor__construct');
45
+		add_action('http_api_curl', array($this, '_curl_requests_to_paypal_use_tls'), 10, 3);
46 46
 	}
47 47
 
48 48
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		$update_txn = true,
82 82
 		$cancel_url = ''
83 83
 	) {
84
-		if( (float)$amount < 0 ) {
84
+		if ((float) $amount < 0) {
85 85
 			throw new EE_Error(
86 86
 				sprintf(
87 87
 					__(
@@ -94,33 +94,33 @@  discard block
 block discarded – undo
94 94
 			);
95 95
 		}
96 96
 		// verify payment method
97
-		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE );
97
+		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE);
98 98
 		// verify transaction
99
-		EEM_Transaction::instance()->ensure_is_obj( $transaction );
100
-		$transaction->set_payment_method_ID( $payment_method->ID() );
99
+		EEM_Transaction::instance()->ensure_is_obj($transaction);
100
+		$transaction->set_payment_method_ID($payment_method->ID());
101 101
 		// verify payment method type
102
-		if ( $payment_method->type_obj() instanceof EE_PMT_Base ) {
102
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
103 103
 			$payment = $payment_method->type_obj()->process_payment(
104 104
 				$transaction,
105
-				min( $amount, $transaction->remaining() ),//make sure we don't overcharge
105
+				min($amount, $transaction->remaining()), //make sure we don't overcharge
106 106
 				$billing_form,
107 107
 				$return_url,
108
-				add_query_arg( array( 'ee_cancel_payment' => true ), $cancel_url ),
108
+				add_query_arg(array('ee_cancel_payment' => true), $cancel_url),
109 109
 				$method,
110 110
 				$by_admin
111 111
 			);
112 112
 			// check if payment method uses an off-site gateway
113
-			if ( $payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite ) {
113
+			if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) {
114 114
 				// don't process payments for off-site gateways yet because no payment has occurred yet
115
-				$this->update_txn_based_on_payment( $transaction, $payment, $update_txn );
115
+				$this->update_txn_based_on_payment($transaction, $payment, $update_txn);
116 116
 			}
117 117
 			return $payment;
118 118
 		} else {
119 119
 			EE_Error::add_error(
120 120
 				sprintf(
121
-					__( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
121
+					__('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
122 122
 					'<br/>',
123
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
123
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
124 124
 				), __FILE__, __FUNCTION__, __LINE__
125 125
 			);
126 126
 			return NULL;
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 	 * @throws EE_Error
137 137
 	 * @return string
138 138
 	 */
139
-	public function get_ipn_url_for_payment_method( $transaction, $payment_method ){
139
+	public function get_ipn_url_for_payment_method($transaction, $payment_method) {
140 140
 		/** @type \EE_Transaction $transaction */
141
-		$transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction );
141
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
142 142
 		$primary_reg = $transaction->primary_registration();
143
-		if( ! $primary_reg instanceof EE_Registration ){
143
+		if ( ! $primary_reg instanceof EE_Registration) {
144 144
 			throw new EE_Error(
145 145
 				sprintf(
146 146
 					__(
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 				)
152 152
 			);
153 153
 		}
154
-		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true);
154
+		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true);
155 155
 		$url = add_query_arg(
156 156
 			array(
157 157
 				'e_reg_url_link'=>$primary_reg->reg_url_link(),
@@ -188,47 +188,47 @@  discard block
 block discarded – undo
188 188
 		$update_txn = true,
189 189
 		$separate_IPN_request = true
190 190
 	) {
191
-		EE_Registry::instance()->load_model( 'Change_Log' );
192
-		$_req_data = $this->_remove_unusable_characters_from_array( (array)$_req_data );
193
-		EE_Processor_Base::set_IPN( $separate_IPN_request );
191
+		EE_Registry::instance()->load_model('Change_Log');
192
+		$_req_data = $this->_remove_unusable_characters_from_array((array) $_req_data);
193
+		EE_Processor_Base::set_IPN($separate_IPN_request);
194 194
 		$obj_for_log = null;
195
-		if( $transaction instanceof EE_Transaction ){
195
+		if ($transaction instanceof EE_Transaction) {
196 196
 			$obj_for_log = $transaction;
197
-			if( $payment_method instanceof EE_Payment_Method ) {
197
+			if ($payment_method instanceof EE_Payment_Method) {
198 198
 				$obj_for_log = EEM_Payment::instance()->get_one(
199 199
 					array(
200
-						array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ),
201
-						'order_by' => array( 'PAY_timestamp' => 'desc' )
200
+						array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()),
201
+						'order_by' => array('PAY_timestamp' => 'desc')
202 202
 					)
203 203
 				);
204 204
 			}
205
-		} else if( $payment_method instanceof EE_Payment ) {
205
+		} else if ($payment_method instanceof EE_Payment) {
206 206
 			$obj_for_log = $payment_method;
207 207
 		}
208 208
 		$log = EEM_Change_Log::instance()->log(
209 209
 			EEM_Change_Log::type_gateway,
210
-			array( 'IPN data received' => $_req_data ),
210
+			array('IPN data received' => $_req_data),
211 211
 			$obj_for_log
212 212
 		);
213
-		try{
213
+		try {
214 214
 			/**
215 215
 			 * @var EE_Payment $payment
216 216
 			 */
217 217
 			$payment = NULL;
218
-			if($transaction && $payment_method){
218
+			if ($transaction && $payment_method) {
219 219
 				/** @type EE_Transaction $transaction */
220 220
 				$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
221 221
 				/** @type EE_Payment_Method $payment_method */
222 222
 				$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method);
223
-				if ( $payment_method->type_obj() instanceof EE_PMT_Base ) {
223
+				if ($payment_method->type_obj() instanceof EE_PMT_Base) {
224 224
 				    try {
225 225
                         $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction);
226 226
                         $log->set_object($payment);
227
-                    } catch( EventEspresso\core\exceptions\IpnException $e ) {
227
+                    } catch (EventEspresso\core\exceptions\IpnException $e) {
228 228
                         EEM_Change_Log::instance()->log(
229 229
                             EEM_Change_Log::type_gateway,
230 230
                             array(
231
-                                'message' => 'IPN Exception: ' . $e->getMessage(),
231
+                                'message' => 'IPN Exception: '.$e->getMessage(),
232 232
                                 'current_url' => EEH_URL::current_url(),
233 233
                                 'payment' => $e->getPaymentProperties(),
234 234
                                 'IPN_data' => $e->getIpnData()
@@ -241,31 +241,31 @@  discard block
 block discarded – undo
241 241
 					// not a payment
242 242
 					EE_Error::add_error(
243 243
 						sprintf(
244
-							__( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ),
244
+							__('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'),
245 245
 							'<br/>',
246
-							EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
246
+							EE_Registry::instance()->CFG->organization->get_pretty('email')
247 247
 						),
248 248
 						__FILE__, __FUNCTION__, __LINE__
249 249
 					);
250 250
 				}
251
-			}else{
251
+			} else {
252 252
 				//that's actually pretty ok. The IPN just wasn't able
253 253
 				//to identify which transaction or payment method this was for
254 254
 				// give all active payment methods a chance to claim it
255 255
 				$active_payment_methods = EEM_Payment_Method::instance()->get_all_active();
256
-				foreach( $active_payment_methods as $active_payment_method ){
257
-					try{
258
-						$payment = $active_payment_method->type_obj()->handle_unclaimed_ipn( $_req_data );
256
+				foreach ($active_payment_methods as $active_payment_method) {
257
+					try {
258
+						$payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data);
259 259
 						$payment_method = $active_payment_method;
260 260
 						EEM_Change_Log::instance()->log(
261 261
 							EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment
262 262
 						);
263 263
 						break;
264
-					} catch( EventEspresso\core\exceptions\IpnException $e ) {
264
+					} catch (EventEspresso\core\exceptions\IpnException $e) {
265 265
                         EEM_Change_Log::instance()->log(
266 266
                             EEM_Change_Log::type_gateway,
267 267
                             array(
268
-                                'message' => 'IPN Exception: ' . $e->getMessage(),
268
+                                'message' => 'IPN Exception: '.$e->getMessage(),
269 269
                                 'current_url' => EEH_URL::current_url(),
270 270
                                 'payment' => $e->getPaymentProperties(),
271 271
                                 'IPN_data' => $e->getIpnData()
@@ -273,33 +273,33 @@  discard block
 block discarded – undo
273 273
                             $obj_for_log
274 274
                         );
275 275
                         return $e->getPayment();
276
-                    } catch( EE_Error $e ) {
276
+                    } catch (EE_Error $e) {
277 277
 						//that's fine- it apparently couldn't handle the IPN
278 278
 					}
279 279
 				}
280 280
 
281 281
 			}
282 282
 // 			EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method);
283
-			if( $payment instanceof EE_Payment){
283
+			if ($payment instanceof EE_Payment) {
284 284
 				$payment->save();
285 285
 				//  update the TXN
286
-				$this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request );
287
-			}else{
286
+				$this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request);
287
+			} else {
288 288
 				//we couldn't find the payment for this IPN... let's try and log at least SOMETHING
289
-				if($payment_method){
289
+				if ($payment_method) {
290 290
 					EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method);
291
-				}elseif($transaction){
291
+				}elseif ($transaction) {
292 292
 					EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction);
293 293
 				}
294 294
 			}
295 295
 			return $payment;
296 296
 
297
-		} catch( EE_Error $e ) {
297
+		} catch (EE_Error $e) {
298 298
 			do_action(
299 299
 				'AHEE__log', __FILE__, __FUNCTION__, sprintf(
300
-					__( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ),
301
-					print_r( $transaction, TRUE ),
302
-					print_r( $_req_data, TRUE ),
300
+					__('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'),
301
+					print_r($transaction, TRUE),
302
+					print_r($_req_data, TRUE),
303 303
 					$e->getMessage()
304 304
 				)
305 305
 			);
@@ -314,10 +314,10 @@  discard block
 block discarded – undo
314 314
 	 * @param  array $request_data
315 315
 	 * @return array
316 316
 	 */
317
-	protected function _remove_unusable_characters_from_array( array $request_data ) {
317
+	protected function _remove_unusable_characters_from_array(array $request_data) {
318 318
 		$return_data = array();
319
-		foreach( $request_data as $key => $value ) {
320
-			$return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value );
319
+		foreach ($request_data as $key => $value) {
320
+			$return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value);
321 321
 		}
322 322
 		return $return_data;
323 323
 	}
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 	 * @param string $request_data
330 330
 	 * @return string
331 331
 	 */
332
-	protected function _remove_unusable_characters( $request_data ) {
333
-		return preg_replace( '/[^[:print:]]/', '', $request_data );
332
+	protected function _remove_unusable_characters($request_data) {
333
+		return preg_replace('/[^[:print:]]/', '', $request_data);
334 334
 	}
335 335
 
336 336
 
@@ -352,13 +352,13 @@  discard block
 block discarded – undo
352 352
 	 * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO,
353 353
 	 *                                      to call handle_ipn() for offsite gateways that don't receive separate IPNs
354 354
 	 */
355
-	public function finalize_payment_for( $transaction, $update_txn = TRUE ){
355
+	public function finalize_payment_for($transaction, $update_txn = TRUE) {
356 356
 		/** @var $transaction EE_Transaction */
357
-		$transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction );
357
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
358 358
 		$last_payment_method = $transaction->payment_method();
359
-		if ( $last_payment_method instanceof EE_Payment_Method ) {
360
-			$payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction );
361
-			$this->update_txn_based_on_payment( $transaction, $payment, $update_txn );
359
+		if ($last_payment_method instanceof EE_Payment_Method) {
360
+			$payment = $last_payment_method->type_obj()->finalize_payment_for($transaction);
361
+			$this->update_txn_based_on_payment($transaction, $payment, $update_txn);
362 362
 			return $payment;
363 363
 		} else {
364 364
 			return NULL;
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
 		EE_Payment $payment_to_refund,
382 382
 		$refund_info = array()
383 383
 	) {
384
-		if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) {
385
-			$payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info );
386
-			$this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund );
384
+		if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) {
385
+			$payment_method->type_obj()->process_refund($payment_to_refund, $refund_info);
386
+			$this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund);
387 387
 		}
388 388
 		return $payment_to_refund;
389 389
 	}
@@ -424,12 +424,12 @@  discard block
 block discarded – undo
424 424
 	 *                        TXN is locked before updating
425 425
 	 * @throws \EE_Error
426 426
 	 */
427
-	public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){
427
+	public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) {
428 428
 		$do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful';
429 429
 		/** @type EE_Transaction $transaction */
430
-		$transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction );
430
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
431 431
 		// can we freely update the TXN at this moment?
432
-		if ( $IPN && $transaction->is_locked() ) {
432
+		if ($IPN && $transaction->is_locked()) {
433 433
 			// don't update the transaction at this exact moment
434 434
 			// because the TXN is active in another request
435 435
 			EE_Cron_Tasks::schedule_update_transaction_with_payment(
@@ -439,38 +439,38 @@  discard block
 block discarded – undo
439 439
 			);
440 440
 		} else {
441 441
 			// verify payment and that it has been saved
442
-			if ( $payment instanceof EE_Payment && $payment->ID() ) {
443
-				if(
442
+			if ($payment instanceof EE_Payment && $payment->ID()) {
443
+				if (
444 444
 					$payment->payment_method() instanceof EE_Payment_Method
445 445
 					&& $payment->payment_method()->type_obj() instanceof EE_PMT_Base
446
-				){
447
-					$payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment );
446
+				) {
447
+					$payment->payment_method()->type_obj()->update_txn_based_on_payment($payment);
448 448
 					// update TXN registrations with payment info
449
-					$this->process_registration_payments( $transaction, $payment );
449
+					$this->process_registration_payments($transaction, $payment);
450 450
 				}
451 451
 				$do_action = $payment->just_approved()
452 452
 					? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful'
453 453
 					: $do_action;
454 454
 			} else {
455 455
 				// send out notifications
456
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
456
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
457 457
 				$do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made';
458 458
 			}
459
-			if ( $payment->status() !== EEM_Payment::status_id_failed ) {
459
+			if ($payment->status() !== EEM_Payment::status_id_failed) {
460 460
 				/** @type EE_Transaction_Payments $transaction_payments */
461
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
461
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
462 462
 				// set new value for total paid
463
-				$transaction_payments->calculate_total_payments_and_update_status( $transaction );
463
+				$transaction_payments->calculate_total_payments_and_update_status($transaction);
464 464
 				// call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ???
465
-				if ( $update_txn ) {
466
-					$this->_post_payment_processing( $transaction, $payment, $IPN );
465
+				if ($update_txn) {
466
+					$this->_post_payment_processing($transaction, $payment, $IPN);
467 467
 				}
468 468
 			}
469 469
 			// granular hook for others to use.
470
-			do_action( $do_action, $transaction, $payment );
471
-			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' );
470
+			do_action($do_action, $transaction, $payment);
471
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action');
472 472
 			//global hook for others to use.
473
-			do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment );
473
+			do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment);
474 474
 		}
475 475
 	}
476 476
 
@@ -490,25 +490,25 @@  discard block
 block discarded – undo
490 490
 		$registrations = array()
491 491
 	) {
492 492
 		// only process if payment was successful
493
-		if ( $payment->status() !== EEM_Payment::status_id_approved ) {
493
+		if ($payment->status() !== EEM_Payment::status_id_approved) {
494 494
 			return;
495 495
 		}
496 496
 		//EEM_Registration::instance()->show_next_x_db_queries();
497
-		if ( empty( $registrations )) {
497
+		if (empty($registrations)) {
498 498
 			// find registrations with monies owing that can receive a payment
499 499
 			$registrations = $transaction->registrations(
500 500
 				array(
501 501
 					array(
502 502
 						// only these reg statuses can receive payments
503
-						'STS_ID'           => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ),
504
-						'REG_final_price'  => array( '!=', 0 ),
505
-						'REG_final_price*' => array( '!=', 'REG_paid', true ),
503
+						'STS_ID'           => array('IN', EEM_Registration::reg_statuses_that_allow_payment()),
504
+						'REG_final_price'  => array('!=', 0),
505
+						'REG_final_price*' => array('!=', 'REG_paid', true),
506 506
 					)
507 507
 				)
508 508
 			);
509 509
 		}
510 510
 		// still nothing ??!??
511
-		if ( empty( $registrations )) {
511
+		if (empty($registrations)) {
512 512
 			return;
513 513
 		}
514 514
 		// todo: break out the following logic into a separate strategy class
@@ -520,28 +520,28 @@  discard block
 block discarded – undo
520 520
 
521 521
 		$refund = $payment->is_a_refund();
522 522
 		// how much is available to apply to registrations?
523
-		$available_payment_amount = abs( $payment->amount() );
524
-		foreach ( $registrations as $registration ) {
525
-			if ( $registration instanceof EE_Registration ) {
523
+		$available_payment_amount = abs($payment->amount());
524
+		foreach ($registrations as $registration) {
525
+			if ($registration instanceof EE_Registration) {
526 526
 				// nothing left?
527
-				if ( $available_payment_amount <= 0 ) {
527
+				if ($available_payment_amount <= 0) {
528 528
 					break;
529 529
 				}
530
-				if ( $refund ) {
531
-					$available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount );
530
+				if ($refund) {
531
+					$available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount);
532 532
 				} else {
533
-					$available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount );
533
+					$available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount);
534 534
 				}
535 535
 			}
536 536
 		}
537
-		if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) {
537
+		if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) {
538 538
 			EE_Error::add_attention(
539 539
 				sprintf(
540
-					__( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ),
541
-					EEH_Template::format_currency( $available_payment_amount ),
542
-					implode( ', ',  array_keys( $registrations ) ),
540
+					__('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'),
541
+					EEH_Template::format_currency($available_payment_amount),
542
+					implode(', ', array_keys($registrations)),
543 543
 					'<br/>',
544
-					EEH_Template::format_currency( $payment->amount() )
544
+					EEH_Template::format_currency($payment->amount())
545 545
 				),
546 546
 				__FILE__, __FUNCTION__, __LINE__
547 547
 			);
@@ -559,17 +559,17 @@  discard block
 block discarded – undo
559 559
 	 * @return float
560 560
 	 * @throws \EE_Error
561 561
 	 */
562
-	public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) {
562
+	public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) {
563 563
 		$owing = $registration->final_price() - $registration->paid();
564
-		if ( $owing > 0 ) {
564
+		if ($owing > 0) {
565 565
 			// don't allow payment amount to exceed the available payment amount, OR the amount owing
566
-			$payment_amount = min( $available_payment_amount, $owing );
566
+			$payment_amount = min($available_payment_amount, $owing);
567 567
 			// update $available_payment_amount
568 568
 			$available_payment_amount -= $payment_amount;
569 569
 			//calculate and set new REG_paid
570
-			$registration->set_paid( $registration->paid() + $payment_amount );
570
+			$registration->set_paid($registration->paid() + $payment_amount);
571 571
 			// now save it
572
-			$this->_apply_registration_payment( $registration, $payment, $payment_amount );
572
+			$this->_apply_registration_payment($registration, $payment, $payment_amount);
573 573
 		}
574 574
 		return $available_payment_amount;
575 575
 	}
@@ -585,19 +585,19 @@  discard block
 block discarded – undo
585 585
 	 * @return void
586 586
 	 * @throws \EE_Error
587 587
 	 */
588
-	protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) {
588
+	protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) {
589 589
 		// find any existing reg payment records for this registration and payment
590 590
 		$existing_reg_payment = EEM_Registration_Payment::instance()->get_one(
591
-			array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) )
591
+			array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID()))
592 592
 		);
593 593
 		// if existing registration payment exists
594
-		if ( $existing_reg_payment instanceof EE_Registration_Payment ) {
594
+		if ($existing_reg_payment instanceof EE_Registration_Payment) {
595 595
 			// then update that record
596
-			$existing_reg_payment->set_amount( $payment_amount );
596
+			$existing_reg_payment->set_amount($payment_amount);
597 597
 			$existing_reg_payment->save();
598 598
 		} else {
599 599
 			// or add new relation between registration and payment and set amount
600
-			$registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) );
600
+			$registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount));
601 601
 			// make it stick
602 602
 			$registration->save();
603 603
 		}
@@ -614,21 +614,21 @@  discard block
 block discarded – undo
614 614
 	 * @return float
615 615
 	 * @throws \EE_Error
616 616
 	 */
617
-	public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) {
617
+	public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) {
618 618
 		//EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ );
619
-		if ( $registration->paid() > 0 ) {
619
+		if ($registration->paid() > 0) {
620 620
 			// ensure $available_refund_amount is NOT negative
621
-			$available_refund_amount = (float)abs( $available_refund_amount );
621
+			$available_refund_amount = (float) abs($available_refund_amount);
622 622
 			// don't allow refund amount to exceed the available payment amount, OR the amount paid
623
-			$refund_amount = min( $available_refund_amount, (float)$registration->paid() );
623
+			$refund_amount = min($available_refund_amount, (float) $registration->paid());
624 624
 			// update $available_payment_amount
625 625
 			$available_refund_amount -= $refund_amount;
626 626
 			//calculate and set new REG_paid
627
-			$registration->set_paid( $registration->paid() - $refund_amount );
627
+			$registration->set_paid($registration->paid() - $refund_amount);
628 628
 			// convert payment amount back to a negative value for storage in the db
629
-			$refund_amount = (float)abs( $refund_amount ) * -1;
629
+			$refund_amount = (float) abs($refund_amount) * -1;
630 630
 			// now save it
631
-			$this->_apply_registration_payment( $registration, $payment, $refund_amount );
631
+			$this->_apply_registration_payment($registration, $payment, $refund_amount);
632 632
 		}
633 633
 		return $available_refund_amount;
634 634
 	}
@@ -647,53 +647,53 @@  discard block
 block discarded – undo
647 647
 	 * @param bool           $IPN
648 648
 	 * @throws \EE_Error
649 649
 	 */
650
-	protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) {
650
+	protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) {
651 651
 
652 652
 		/** @type EE_Transaction_Processor $transaction_processor */
653
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
653
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
654 654
 		// is the Payment Options Reg Step completed ?
655
-		$payment_options_step_completed = $transaction->reg_step_completed( 'payment_options' );
655
+		$payment_options_step_completed = $transaction->reg_step_completed('payment_options');
656 656
 		// if the Payment Options Reg Step is completed...
657 657
 		$revisit = $payment_options_step_completed === true ? true : false;
658 658
 		// then this is kinda sorta a revisit with regards to payments at least
659
-		$transaction_processor->set_revisit( $revisit );
659
+		$transaction_processor->set_revisit($revisit);
660 660
 		// if this is an IPN, let's consider the Payment Options Reg Step completed if not already
661 661
 		if (
662 662
 			$IPN &&
663 663
 			$payment_options_step_completed !== true &&
664
-			( $payment->is_approved() || $payment->is_pending() )
664
+			($payment->is_approved() || $payment->is_pending())
665 665
 		) {
666 666
 			$payment_options_step_completed = $transaction->set_reg_step_completed(
667 667
 				'payment_options'
668 668
 			);
669 669
 		}
670 670
 		// maybe update status, but don't save transaction just yet
671
-		$transaction->update_status_based_on_total_paid( false );
671
+		$transaction->update_status_based_on_total_paid(false);
672 672
 		// check if 'finalize_registration' step has been completed...
673
-		$finalized = $transaction->reg_step_completed( 'finalize_registration' );
673
+		$finalized = $transaction->reg_step_completed('finalize_registration');
674 674
 		//  if this is an IPN and the final step has not been initiated
675
-		if ( $IPN && $payment_options_step_completed && $finalized === false ) {
675
+		if ($IPN && $payment_options_step_completed && $finalized === false) {
676 676
 			// and if it hasn't already been set as being started...
677
-			$finalized = $transaction->set_reg_step_initiated( 'finalize_registration' );
677
+			$finalized = $transaction->set_reg_step_initiated('finalize_registration');
678 678
 		}
679 679
 		$transaction->save();
680 680
 		// because the above will return false if the final step was not fully completed, we need to check again...
681
-		if ( $IPN && $finalized !== false ) {
681
+		if ($IPN && $finalized !== false) {
682 682
 			// and if we are all good to go, then send out notifications
683
-			add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
683
+			add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
684 684
 			//ok, now process the transaction according to the payment
685
-			$transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment );
685
+			$transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment);
686 686
 		}
687 687
 		// DEBUG LOG
688 688
 		$payment_method = $payment->payment_method();
689
-		if ( $payment_method instanceof EE_Payment_Method ) {
689
+		if ($payment_method instanceof EE_Payment_Method) {
690 690
 			$payment_method_type_obj = $payment_method->type_obj();
691
-			if ( $payment_method_type_obj instanceof EE_PMT_Base ) {
691
+			if ($payment_method_type_obj instanceof EE_PMT_Base) {
692 692
 				$gateway = $payment_method_type_obj->get_gateway();
693
-				if ( $gateway instanceof EE_Gateway ){
693
+				if ($gateway instanceof EE_Gateway) {
694 694
 					$gateway->log(
695 695
 						array(
696
-							'message'               => __( 'Post Payment Transaction Details', 'event_espresso' ),
696
+							'message'               => __('Post Payment Transaction Details', 'event_espresso'),
697 697
 							'transaction'           => $transaction->model_field_array(),
698 698
 							'finalized'             => $finalized,
699 699
 							'IPN'                   => $IPN,
@@ -715,11 +715,11 @@  discard block
 block discarded – undo
715 715
  	 * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US
716 716
 	 * This will affect paypal standard, pro, express, and payflow.
717 717
  	 */
718
- 	public static function _curl_requests_to_paypal_use_tls( $handle, $r, $url ) {
719
- 		if ( strstr( $url, 'https://' ) && strstr( $url, '.paypal.com' ) ) {
718
+ 	public static function _curl_requests_to_paypal_use_tls($handle, $r, $url) {
719
+ 		if (strstr($url, 'https://') && strstr($url, '.paypal.com')) {
720 720
 			//Use the value of the constant CURL_SSLVERSION_TLSv1 = 1
721 721
 			//instead of the constant because it might not be defined
722
- 			curl_setopt( $handle, CURLOPT_SSLVERSION, 1 );
722
+ 			curl_setopt($handle, CURLOPT_SSLVERSION, 1);
723 723
  		}
724 724
  	}
725 725
  }
Please login to merge, or discard this patch.
core/exceptions/IpnException.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\core\exceptions;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -21,71 +21,71 @@  discard block
 block discarded – undo
21 21
 class IpnException extends \LogicException
22 22
 {
23 23
 
24
-    const DUPLICATE          = 1;
24
+	const DUPLICATE          = 1;
25 25
 
26
-    const UNABLE_TO_VALIDATE = 2;
26
+	const UNABLE_TO_VALIDATE = 2;
27 27
 
28
-    const UNSUPPORTED        = 3;
28
+	const UNSUPPORTED        = 3;
29 29
 
30
-    /**
31
-     * @var \EE_Payment
32
-     */
33
-    protected $payment;
30
+	/**
31
+	 * @var \EE_Payment
32
+	 */
33
+	protected $payment;
34 34
 
35
-    /**
36
-     * @var mixed IPN data, usually an array or object
37
-     */
38
-    protected $ipn_data;
35
+	/**
36
+	 * @var mixed IPN data, usually an array or object
37
+	 */
38
+	protected $ipn_data;
39 39
 
40 40
 
41 41
 
42
-    public function __construct(
43
-        $message,
44
-        $code = 0,
45
-        \Exception $previous = null,
46
-        \EE_Payment $payment = null,
47
-        $ipn_data = array()
48
-    ) {
49
-        parent::__construct($message, $code, $previous);
50
-        $this->payment = $payment;
51
-        $this->ipn_data = $ipn_data;
52
-    }
42
+	public function __construct(
43
+		$message,
44
+		$code = 0,
45
+		\Exception $previous = null,
46
+		\EE_Payment $payment = null,
47
+		$ipn_data = array()
48
+	) {
49
+		parent::__construct($message, $code, $previous);
50
+		$this->payment = $payment;
51
+		$this->ipn_data = $ipn_data;
52
+	}
53 53
 
54 54
 
55 55
 
56
-    /**
57
-     * Gets the payment associated with this IPN, if known
58
-     *
59
-     * @return \EE_Payment
60
-     */
61
-    public function getPayment()
62
-    {
63
-        return $this->payment;
64
-    }
56
+	/**
57
+	 * Gets the payment associated with this IPN, if known
58
+	 *
59
+	 * @return \EE_Payment
60
+	 */
61
+	public function getPayment()
62
+	{
63
+		return $this->payment;
64
+	}
65 65
 
66 66
 
67 67
 
68
-    /**
69
-     * Returns the payment's properties as an array (even if there is no payment, in which case it's an empty array)
70
-     *
71
-     * @return array
72
-     * @throws \EE_Error
73
-     */
74
-    public function getPaymentProperties()
75
-    {
76
-        return $this->getPayment() instanceof \EE_Payment ? $this->getPayment()->model_field_array() : array();
77
-    }
68
+	/**
69
+	 * Returns the payment's properties as an array (even if there is no payment, in which case it's an empty array)
70
+	 *
71
+	 * @return array
72
+	 * @throws \EE_Error
73
+	 */
74
+	public function getPaymentProperties()
75
+	{
76
+		return $this->getPayment() instanceof \EE_Payment ? $this->getPayment()->model_field_array() : array();
77
+	}
78 78
 
79 79
 
80 80
 
81
-    /**
82
-     * Returns an array, object, or string, however, the IPN data was received
83
-     *
84
-     * @return mixed
85
-     */
86
-    public function getIpnData()
87
-    {
88
-        return $this->ipn_data;
89
-    }
81
+	/**
82
+	 * Returns an array, object, or string, however, the IPN data was received
83
+	 *
84
+	 * @return mixed
85
+	 */
86
+	public function getIpnData()
87
+	{
88
+		return $this->ipn_data;
89
+	}
90 90
 
91 91
 }
92 92
\ No newline at end of file
Please login to merge, or discard this patch.
reg_steps/payment_options/EE_SPCO_Reg_Step_Payment_Options.class.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -466,38 +466,38 @@  discard block
 block discarded – undo
466 466
 	 * @throws \EE_Error
467 467
 	 */
468 468
 	public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) {
469
-        // registrations per event
469
+		// registrations per event
470 470
 		$event_reg_count = array();
471 471
 		// spaces left per event
472 472
 		$event_spaces_remaining = array();
473
-        // tickets left sorted by ID
474
-        $tickets_remaining = array();
475
-        // registrations that have lost their space
473
+		// tickets left sorted by ID
474
+		$tickets_remaining = array();
475
+		// registrations that have lost their space
476 476
 		$ejected_registrations = array();
477 477
 		foreach ( $registrations as $REG_ID => $registration ) {
478 478
 			if ( $registration->status_ID() === EEM_Registration::status_id_approved ) {
479 479
 				continue;
480 480
 			}
481 481
 			$EVT_ID = $registration->event_ID();
482
-            $ticket = $registration->ticket();
483
-            if ( ! isset($tickets_remaining[$ticket->ID()])) {
484
-                $tickets_remaining[$ticket->ID()] = $ticket->remaining();
485
-            }
486
-            if ($tickets_remaining[$ticket->ID()] > 0) {
487
-                if ( ! isset($event_reg_count[$EVT_ID])) {
488
-                    $event_reg_count[$EVT_ID] = 0;
489
-                }
490
-                $event_reg_count[$EVT_ID]++;
491
-                if ( ! isset($event_spaces_remaining[$EVT_ID])) {
492
-                    $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale();
493
-                }
494
-            }
482
+			$ticket = $registration->ticket();
483
+			if ( ! isset($tickets_remaining[$ticket->ID()])) {
484
+				$tickets_remaining[$ticket->ID()] = $ticket->remaining();
485
+			}
486
+			if ($tickets_remaining[$ticket->ID()] > 0) {
487
+				if ( ! isset($event_reg_count[$EVT_ID])) {
488
+					$event_reg_count[$EVT_ID] = 0;
489
+				}
490
+				$event_reg_count[$EVT_ID]++;
491
+				if ( ! isset($event_spaces_remaining[$EVT_ID])) {
492
+					$event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale();
493
+				}
494
+			}
495 495
 			if (
496 496
 				$revisit
497 497
 				&& (
498
-                    $tickets_remaining[$ticket->ID()] === 0
499
-				    || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
500
-                )
498
+					$tickets_remaining[$ticket->ID()] === 0
499
+					|| $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
500
+				)
501 501
 			) {
502 502
 				$ejected_registrations[ $REG_ID ] = $registration->event();
503 503
 				if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) {
@@ -572,9 +572,9 @@  discard block
 block discarded – undo
572 572
 				'layout_strategy' => new EE_Template_Layout(
573 573
 					array(
574 574
 						'layout_template_file' => SPCO_REG_STEPS_PATH
575
-						                          . $this->_slug
576
-						                          . DS
577
-						                          . 'sold_out_events.template.php',
575
+												  . $this->_slug
576
+												  . DS
577
+												  . 'sold_out_events.template.php',
578 578
 						'template_args'        => apply_filters(
579 579
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
580 580
 							array(
@@ -625,9 +625,9 @@  discard block
 block discarded – undo
625 625
 				'layout_strategy' => new EE_Template_Layout(
626 626
 					array(
627 627
 						'layout_template_file' => SPCO_REG_STEPS_PATH
628
-						                          . $this->_slug
629
-						                          . DS
630
-						                          . 'sold_out_events.template.php',
628
+												  . $this->_slug
629
+												  . DS
630
+												  . 'sold_out_events.template.php',
631 631
 						'template_args'        => apply_filters(
632 632
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args',
633 633
 							array(
@@ -679,9 +679,9 @@  discard block
 block discarded – undo
679 679
 				'layout_strategy' => new EE_Template_Layout(
680 680
 					array(
681 681
 						'layout_template_file' => SPCO_REG_STEPS_PATH
682
-						                          . $this->_slug
683
-						                          . DS
684
-						                          . 'events_requiring_pre_approval.template.php', // layout_template
682
+												  . $this->_slug
683
+												  . DS
684
+												  . 'events_requiring_pre_approval.template.php', // layout_template
685 685
 						'template_args'        => apply_filters(
686 686
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
687 687
 							array(
@@ -723,9 +723,9 @@  discard block
 block discarded – undo
723 723
 				'layout_strategy' => new EE_Template_Layout(
724 724
 					array(
725 725
 						'layout_template_file' => SPCO_REG_STEPS_PATH
726
-						                          . $this->_slug
727
-						                          . DS
728
-						                          . 'no_payment_required.template.php', // layout_template
726
+												  . $this->_slug
727
+												  . DS
728
+												  . 'no_payment_required.template.php', // layout_template
729 729
 						'template_args'        => apply_filters(
730 730
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args',
731 731
 							array(
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 					$available_payment_method_options[ $payment_method->slug() ] = $payment_method_button;
956 956
 				}
957 957
 				$payment_methods_billing_info[ $payment_method->slug()
958
-				                               . '-info' ] = $this->_payment_method_billing_info(
958
+											   . '-info' ] = $this->_payment_method_billing_info(
959 959
 					$payment_method
960 960
 				);
961 961
 			}
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 		// fill form with attendee info if applicable
1144 1144
 		if (
1145 1145
 			$payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form
1146
-		    && $this->checkout->transaction_has_primary_registrant()
1146
+			&& $this->checkout->transaction_has_primary_registrant()
1147 1147
 		) {
1148 1148
 			$payment_method_billing_form->populate_from_attendee(
1149 1149
 				$this->checkout->transaction->primary_registration()->attendee()
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 		// and debug content
1153 1153
 		if (
1154 1154
 			$payment_method_billing_form instanceof EE_Billing_Info_Form
1155
-		    && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1155
+			&& $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1156 1156
 		) {
1157 1157
 			$payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
1158 1158
 				$payment_method_billing_form
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 		}
1328 1328
 		// and debug content
1329 1329
 		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form
1330
-		     && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1330
+			 && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1331 1331
 		) {
1332 1332
 			$this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
1333 1333
 				$this->checkout->billing_form
@@ -1461,8 +1461,8 @@  discard block
 block discarded – undo
1461 1461
 		}
1462 1462
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
1463 1463
 		if ( ! empty( $attendee_data['ATT_fname'] )
1464
-		     && ! empty( $attendee_data['ATT_lname'] )
1465
-		     && ! empty( $attendee_data['ATT_email'] )
1464
+			 && ! empty( $attendee_data['ATT_lname'] )
1465
+			 && ! empty( $attendee_data['ATT_email'] )
1466 1466
 		) {
1467 1467
 			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(
1468 1468
 				array(
@@ -1702,7 +1702,7 @@  discard block
 block discarded – undo
1702 1702
 			$payment_status = $payment->status();
1703 1703
 			if (
1704 1704
 				$payment_status === EEM_Payment::status_id_approved
1705
-			    || $payment_status === EEM_Payment::status_id_pending
1705
+				|| $payment_status === EEM_Payment::status_id_pending
1706 1706
 			) {
1707 1707
 				return true;
1708 1708
 			} else {
@@ -1888,8 +1888,8 @@  discard block
 block discarded – undo
1888 1888
 			return false;
1889 1889
 		}
1890 1890
 		if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' )
1891
-		       instanceof
1892
-		       EE_Attendee
1891
+			   instanceof
1892
+			   EE_Attendee
1893 1893
 		) {
1894 1894
 			EE_Error::add_error(
1895 1895
 				sprintf(
@@ -2607,19 +2607,19 @@  discard block
 block discarded – undo
2607 2607
 
2608 2608
 
2609 2609
 
2610
-    /**
2611
-     *    __sleep
2612
-     * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization
2613
-     * EE_Checkout will handle the reimplementation of itself upon waking,
2614
-     * but we won't bother with the reg form, because if needed, it will be regenerated anyways
2615
-     *
2616
-     * @return array
2617
-     */
2618
-    public function __sleep()
2619
-    {
2620
-        // remove the reg form and the checkout
2621
-        return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) );
2622
-    }
2610
+	/**
2611
+	 *    __sleep
2612
+	 * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization
2613
+	 * EE_Checkout will handle the reimplementation of itself upon waking,
2614
+	 * but we won't bother with the reg form, because if needed, it will be regenerated anyways
2615
+	 *
2616
+	 * @return array
2617
+	 */
2618
+	public function __sleep()
2619
+	{
2620
+		// remove the reg form and the checkout
2621
+		return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) );
2622
+	}
2623 2623
 
2624 2624
 
2625 2625
 
Please login to merge, or discard this patch.
Spacing   +348 added lines, -348 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -38,32 +38,32 @@  discard block
 block discarded – undo
38 38
 	public static function set_hooks() {
39 39
 		add_filter(
40 40
 			'FHEE__SPCO__EE_Line_Item_Filter_Collection',
41
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' )
41
+			array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters')
42 42
 		);
43 43
 		add_action(
44 44
 			'wp_ajax_switch_spco_billing_form',
45
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )
45
+			array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
46 46
 		);
47 47
 		add_action(
48 48
 			'wp_ajax_nopriv_switch_spco_billing_form',
49
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )
49
+			array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
50 50
 		);
51
-		add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) );
51
+		add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details'));
52 52
 		add_action(
53 53
 			'wp_ajax_nopriv_save_payer_details',
54
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )
54
+			array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')
55 55
 		);
56 56
 		add_action(
57 57
 			'wp_ajax_get_transaction_details_for_gateways',
58
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' )
58
+			array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
59 59
 		);
60 60
 		add_action(
61 61
 			'wp_ajax_nopriv_get_transaction_details_for_gateways',
62
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' )
62
+			array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
63 63
 		);
64 64
 		add_filter(
65 65
 			'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array',
66
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ),
66
+			array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'),
67 67
 			10,
68 68
 			1
69 69
 		);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @throws \EE_Error
78 78
 	 */
79 79
 	public static function switch_spco_billing_form() {
80
-		EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' );
80
+		EED_Single_Page_Checkout::process_ajax_request('switch_payment_method');
81 81
 	}
82 82
 
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @throws \EE_Error
89 89
 	 */
90 90
 	public static function save_payer_details() {
91
-		EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' );
91
+		EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax');
92 92
 	}
93 93
 
94 94
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 * @throws \EE_Error
100 100
 	 */
101 101
 	public static function get_transaction_details() {
102
-		EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' );
102
+		EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways');
103 103
 	}
104 104
 
105 105
 
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 	 * @access    public
127 127
 	 * @param    EE_Checkout $checkout
128 128
 	 */
129
-	public function __construct( EE_Checkout $checkout ) {
129
+	public function __construct(EE_Checkout $checkout) {
130 130
 		$this->_slug = 'payment_options';
131
-		$this->_name = __( 'Payment Options', 'event_espresso' );
132
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php';
131
+		$this->_name = __('Payment Options', 'event_espresso');
132
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php';
133 133
 		$this->checkout = $checkout;
134 134
 		$this->_reset_success_message();
135 135
 		$this->set_instructions(
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	/**
155 155
 	 * @param null $line_item_display
156 156
 	 */
157
-	public function set_line_item_display( $line_item_display ) {
157
+	public function set_line_item_display($line_item_display) {
158 158
 		$this->line_item_display = $line_item_display;
159 159
 	}
160 160
 
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	/**
173 173
 	 * @param boolean $handle_IPN_in_this_request
174 174
 	 */
175
-	public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) {
176
-		$this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN );
175
+	public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) {
176
+		$this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN);
177 177
 	}
178 178
 
179 179
 
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 	public function enqueue_styles_and_scripts() {
209 209
 		$transaction = $this->checkout->transaction;
210 210
 		//if the transaction isn't set or nothing is owed on it, don't enqueue any JS
211
-		if( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats( $transaction->remaining(), 0 ) ) {
211
+		if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) {
212 212
 			return;
213 213
 		}
214
-		foreach( EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ) as $payment_method ) {
214
+		foreach (EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart) as $payment_method) {
215 215
 			$type_obj = $payment_method->type_obj();
216
-			if( $type_obj instanceof EE_PMT_Base ) {
217
-				$billing_form = $type_obj->generate_new_billing_form( $transaction );
218
-				if( $billing_form instanceof EE_Form_Section_Proper ) {
216
+			if ($type_obj instanceof EE_PMT_Base) {
217
+				$billing_form = $type_obj->generate_new_billing_form($transaction);
218
+				if ($billing_form instanceof EE_Form_Section_Proper) {
219 219
 					$billing_form->enqueue_js();
220 220
 				}
221 221
 			}
@@ -240,20 +240,20 @@  discard block
 block discarded – undo
240 240
 			// 	$ 0.00 transactions (no payment required)
241 241
 			! $this->checkout->payment_required()
242 242
 			// but do NOT remove if current action being called belongs to this reg step
243
-			&& ! is_callable( array( $this, $this->checkout->action ) )
243
+			&& ! is_callable(array($this, $this->checkout->action))
244 244
 			&& ! $this->completed()
245 245
 		) {
246 246
 			// and if so, then we no longer need the Payment Options step
247
-			if ( $this->is_current_step() ) {
247
+			if ($this->is_current_step()) {
248 248
 				$this->checkout->generate_reg_form = false;
249 249
 			}
250
-			$this->checkout->remove_reg_step( $this->_slug );
250
+			$this->checkout->remove_reg_step($this->_slug);
251 251
 			// DEBUG LOG
252 252
 			//$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
253 253
 			return false;
254 254
 		}
255 255
 		// load EEM_Payment_Method
256
-		EE_Registry::instance()->load_model( 'Payment_Method' );
256
+		EE_Registry::instance()->load_model('Payment_Method');
257 257
 		// get all active payment methods
258 258
 		$this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction(
259 259
 			$this->checkout->transaction,
@@ -280,15 +280,15 @@  discard block
 block discarded – undo
280 280
 		$insufficient_spaces_available = array();
281 281
 		$reg_count = 0;
282 282
 		// loop thru registrations to gather info
283
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
283
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
284 284
 		$ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
285 285
 			$registrations,
286 286
 			$this->checkout->revisit
287 287
 		);
288
-		foreach ( $registrations as $REG_ID => $registration ) {
288
+		foreach ($registrations as $REG_ID => $registration) {
289 289
 			// has this registration lost it's space ?
290
-			if ( isset( $ejected_registrations[ $REG_ID ] ) ) {
291
-				$insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event();
290
+			if (isset($ejected_registrations[$REG_ID])) {
291
+				$insufficient_spaces_available[$registration->event()->ID()] = $registration->event();
292 292
 				continue;
293 293
 			}
294 294
 			/** @var $registration EE_Registration */
@@ -300,9 +300,9 @@  discard block
 block discarded – undo
300 300
 				&& $registration->status_ID() === EEM_Registration::status_id_approved
301 301
 			)
302 302
 			) {
303
-				if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true ) ) {
303
+				if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) {
304 304
 					// add event to list of events that are sold out
305
-					$sold_out_events[ $registration->event()->ID() ] = $registration->event();
305
+					$sold_out_events[$registration->event()->ID()] = $registration->event();
306 306
 					do_action(
307 307
 						'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
308 308
 						$registration->event(),
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 					continue;
312 312
 				}
313 313
 				// event requires admin approval
314
-				if ( $registration->status_ID() === EEM_Registration::status_id_not_approved ) {
314
+				if ($registration->status_ID() === EEM_Registration::status_id_not_approved) {
315 315
 					// add event to list of events with pre-approval reg status
316
-					$registrations_requiring_pre_approval[ $REG_ID ] = $registration;
316
+					$registrations_requiring_pre_approval[$REG_ID] = $registration;
317 317
 					do_action(
318 318
 						'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
319 319
 						$registration->event(),
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
 				}
323 323
 			}
324 324
 			// are they allowed to pay now and is there monies owing?
325
-			if ( $registration->owes_monies_and_can_pay() ) {
326
-				$registrations_requiring_payment[ $REG_ID ] = $registration;
325
+			if ($registration->owes_monies_and_can_pay()) {
326
+				$registrations_requiring_payment[$REG_ID] = $registration;
327 327
 				do_action(
328 328
 					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment',
329 329
 					$registration->event(),
@@ -334,29 +334,29 @@  discard block
 block discarded – undo
334 334
 				&& $registration->status_ID() !== EEM_Registration::status_id_not_approved
335 335
 				&& $registration->ticket()->is_free()
336 336
 			) {
337
-				$registrations_for_free_events[ $registration->event()->ID() ] = $registration;
337
+				$registrations_for_free_events[$registration->event()->ID()] = $registration;
338 338
 			}
339 339
 		}
340 340
 		$subsections = array();
341 341
 		// now decide which template to load
342
-		if ( ! empty( $sold_out_events ) ) {
343
-			$subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events );
342
+		if ( ! empty($sold_out_events)) {
343
+			$subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
344 344
 		}
345
-		if ( ! empty( $insufficient_spaces_available ) ) {
345
+		if ( ! empty($insufficient_spaces_available)) {
346 346
 			$subsections['insufficient_space'] = $this->_insufficient_spaces_available(
347 347
 				$insufficient_spaces_available
348 348
 			);
349 349
 		}
350
-		if ( ! empty( $registrations_requiring_pre_approval ) ) {
350
+		if ( ! empty($registrations_requiring_pre_approval)) {
351 351
 			$subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval(
352 352
 				$registrations_requiring_pre_approval
353 353
 			);
354 354
 		}
355
-		if ( ! empty( $registrations_for_free_events ) ) {
356
-			$subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events );
355
+		if ( ! empty($registrations_for_free_events)) {
356
+			$subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
357 357
 		}
358
-		if ( ! empty( $registrations_requiring_payment ) ) {
359
-			if ( $this->checkout->amount_owing > 0 ) {
358
+		if ( ! empty($registrations_requiring_payment)) {
359
+			if ($this->checkout->amount_owing > 0) {
360 360
 				// autoload Line_Item_Display classes
361 361
 				EEH_Autoloader::register_line_item_filter_autoloaders();
362 362
 				$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
@@ -369,15 +369,15 @@  discard block
 block discarded – undo
369 369
 				/** @var EE_Line_Item $filtered_line_item_tree */
370 370
 				$filtered_line_item_tree = $line_item_filter_processor->process();
371 371
 				EEH_Autoloader::register_line_item_display_autoloaders();
372
-				$this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) );
372
+				$this->set_line_item_display(new EE_Line_Item_Display('spco'));
373 373
 				$subsections['payment_options'] = $this->_display_payment_options(
374 374
 					$this->line_item_display->display_line_item(
375 375
 						$filtered_line_item_tree,
376
-						array( 'registrations' => $registrations )
376
+						array('registrations' => $registrations)
377 377
 					)
378 378
 				);
379 379
 				$this->checkout->amount_owing = $filtered_line_item_tree->total();
380
-				$this->_apply_registration_payments_to_amount_owing( $registrations );
380
+				$this->_apply_registration_payments_to_amount_owing($registrations);
381 381
 			}
382 382
 		} else {
383 383
 			$this->_hide_reg_step_submit_button_if_revisit();
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 	 * @return \EE_Line_Item_Filter_Collection
409 409
 	 * @throws \EE_Error
410 410
 	 */
411
-	public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) {
411
+	public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) {
412 412
 		$line_item_filter_collection->add(
413 413
 			new EE_Billable_Line_Item_Filter(
414 414
 				EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations(
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 				)
419 419
 			)
420 420
 		);
421
-		$line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() );
421
+		$line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter());
422 422
 		return $line_item_filter_collection;
423 423
 	}
424 424
 
@@ -434,15 +434,15 @@  discard block
 block discarded – undo
434 434
 	 * @return \EE_Registration[]
435 435
 	 * @throws \EE_Error
436 436
 	 */
437
-	public static function remove_ejected_registrations( array $registrations ) {
437
+	public static function remove_ejected_registrations(array $registrations) {
438 438
 		$ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
439 439
 			$registrations,
440 440
 			EE_Registry::instance()->SSN->checkout()->revisit
441 441
 		);
442
-		foreach ( $registrations as $REG_ID => $registration ) {
442
+		foreach ($registrations as $REG_ID => $registration) {
443 443
 			// has this registration lost it's space ?
444
-			if ( isset( $ejected_registrations[ $REG_ID ] ) ) {
445
-				unset( $registrations[ $REG_ID ] );
444
+			if (isset($ejected_registrations[$REG_ID])) {
445
+				unset($registrations[$REG_ID]);
446 446
 				continue;
447 447
 			}
448 448
 		}
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 	 * @return array
466 466
 	 * @throws \EE_Error
467 467
 	 */
468
-	public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) {
468
+	public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false) {
469 469
         // registrations per event
470 470
 		$event_reg_count = array();
471 471
 		// spaces left per event
@@ -474,8 +474,8 @@  discard block
 block discarded – undo
474 474
         $tickets_remaining = array();
475 475
         // registrations that have lost their space
476 476
 		$ejected_registrations = array();
477
-		foreach ( $registrations as $REG_ID => $registration ) {
478
-			if ( $registration->status_ID() === EEM_Registration::status_id_approved ) {
477
+		foreach ($registrations as $REG_ID => $registration) {
478
+			if ($registration->status_ID() === EEM_Registration::status_id_approved) {
479 479
 				continue;
480 480
 			}
481 481
 			$EVT_ID = $registration->event_ID();
@@ -496,13 +496,13 @@  discard block
 block discarded – undo
496 496
 				$revisit
497 497
 				&& (
498 498
                     $tickets_remaining[$ticket->ID()] === 0
499
-				    || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
499
+				    || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID]
500 500
                 )
501 501
 			) {
502
-				$ejected_registrations[ $REG_ID ] = $registration->event();
503
-				if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) {
502
+				$ejected_registrations[$REG_ID] = $registration->event();
503
+				if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) {
504 504
 					/** @type EE_Registration_Processor $registration_processor */
505
-					$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
505
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
506 506
 					// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
507 507
 					$registration_processor->manually_update_registration_status(
508 508
 						$registration,
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
 	 * @return void
538 538
 	 */
539 539
 	protected function _hide_reg_step_submit_button_if_revisit() {
540
-		if ( $this->checkout->revisit ) {
541
-			add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' );
540
+		if ($this->checkout->revisit) {
541
+			add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string');
542 542
 		}
543 543
 	}
544 544
 
@@ -552,13 +552,13 @@  discard block
 block discarded – undo
552 552
 	 * @return \EE_Form_Section_Proper
553 553
 	 * @throws \EE_Error
554 554
 	 */
555
-	private function _sold_out_events( $sold_out_events_array = array() ) {
555
+	private function _sold_out_events($sold_out_events_array = array()) {
556 556
 		// set some defaults
557 557
 		$this->checkout->selected_method_of_payment = 'events_sold_out';
558 558
 		$sold_out_events = '';
559
-		foreach ( $sold_out_events_array as $sold_out_event ) {
559
+		foreach ($sold_out_events_array as $sold_out_event) {
560 560
 			$sold_out_events .= EEH_HTML::li(
561
-				EEH_HTML::span( '  ' .$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' )
561
+				EEH_HTML::span('  '.$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
562 562
 			);
563 563
 		}
564 564
 		return new EE_Form_Section_Proper(
@@ -605,14 +605,14 @@  discard block
 block discarded – undo
605 605
 	 * @return \EE_Form_Section_Proper
606 606
 	 * @throws \EE_Error
607 607
 	 */
608
-	private function _insufficient_spaces_available( $insufficient_spaces_events_array = array() ) {
608
+	private function _insufficient_spaces_available($insufficient_spaces_events_array = array()) {
609 609
 		// set some defaults
610 610
 		$this->checkout->selected_method_of_payment = 'invoice';
611 611
 		$insufficient_space_events = '';
612
-		foreach ( $insufficient_spaces_events_array as $event ) {
613
-			if ( $event instanceof EE_Event ) {
612
+		foreach ($insufficient_spaces_events_array as $event) {
613
+			if ($event instanceof EE_Event) {
614 614
 				$insufficient_space_events .= EEH_HTML::li(
615
-					EEH_HTML::span( ' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' )
615
+					EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
616 616
 				);
617 617
 			}
618 618
 		}
@@ -656,17 +656,17 @@  discard block
 block discarded – undo
656 656
 	 * @return \EE_Form_Section_Proper
657 657
 	 * @throws \EE_Error
658 658
 	 */
659
-	private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) {
659
+	private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) {
660 660
 		$events_requiring_pre_approval = '';
661
-		foreach ( $registrations_requiring_pre_approval as $registration ) {
662
-			if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) {
663
-				$events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li(
661
+		foreach ($registrations_requiring_pre_approval as $registration) {
662
+			if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) {
663
+				$events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li(
664 664
 					EEH_HTML::span(
665 665
 						'',
666 666
 						'',
667 667
 						'dashicons dashicons-marker ee-icon-size-16 orange-text'
668 668
 					)
669
-					. EEH_HTML::span( $registration->event()->name(), '', 'orange-text' )
669
+					. EEH_HTML::span($registration->event()->name(), '', 'orange-text')
670 670
 				);
671 671
 			}
672 672
 		}
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 						'template_args'        => apply_filters(
686 686
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
687 687
 							array(
688
-								'events_requiring_pre_approval'     => implode( '', $events_requiring_pre_approval ),
688
+								'events_requiring_pre_approval'     => implode('', $events_requiring_pre_approval),
689 689
 								'events_requiring_pre_approval_msg' => apply_filters(
690 690
 									'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg',
691 691
 									__(
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 	 * @return \EE_Form_Section_Proper
711 711
 	 * @throws \EE_Error
712 712
 	 */
713
-	private function _no_payment_required( $registrations_for_free_events = array() ) {
713
+	private function _no_payment_required($registrations_for_free_events = array()) {
714 714
 		// set some defaults
715 715
 		$this->checkout->selected_method_of_payment = 'no_payment_required';
716 716
 		// generate no_payment_required form
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 								'ticket_count'                  => array(),
735 735
 								'registrations_for_free_events' => $registrations_for_free_events,
736 736
 								'no_payment_required_msg'       => EEH_HTML::p(
737
-									__( 'This is a free event, so no billing will occur.', 'event_espresso' )
737
+									__('This is a free event, so no billing will occur.', 'event_espresso')
738 738
 								)
739 739
 							)
740 740
 						),
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 	 * @return \EE_Form_Section_Proper
754 754
 	 * @throws \EE_Error
755 755
 	 */
756
-	private function _display_payment_options( $transaction_details = '' ) {
756
+	private function _display_payment_options($transaction_details = '') {
757 757
 		// has method_of_payment been set by no-js user?
758 758
 		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment();
759 759
 		// build payment options form
@@ -765,18 +765,18 @@  discard block
 block discarded – undo
765 765
 						'before_payment_options' => apply_filters(
766 766
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options',
767 767
 							new EE_Form_Section_Proper(
768
-								array( 'layout_strategy' => new EE_Div_Per_Section_Layout() )
768
+								array('layout_strategy' => new EE_Div_Per_Section_Layout())
769 769
 							)
770 770
 						),
771 771
 						'payment_options'        => $this->_setup_payment_options(),
772 772
 						'after_payment_options'  => apply_filters(
773 773
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options',
774 774
 							new EE_Form_Section_Proper(
775
-								array( 'layout_strategy' => new EE_Div_Per_Section_Layout() )
775
+								array('layout_strategy' => new EE_Div_Per_Section_Layout())
776 776
 							)
777 777
 						),
778 778
 						'default_hidden_inputs'  => $this->reg_step_hidden_inputs(),
779
-						'extra_hidden_inputs'    => $this->_extra_hidden_inputs( false )
779
+						'extra_hidden_inputs'    => $this->_extra_hidden_inputs(false)
780 780
 					),
781 781
 					'layout_strategy' => new EE_Template_Layout(
782 782
 						array(
@@ -805,10 +805,10 @@  discard block
 block discarded – undo
805 805
 	 * @return \EE_Form_Section_Proper
806 806
 	 * @throws \EE_Error
807 807
 	 */
808
-	private function _extra_hidden_inputs( $no_payment_required = true ) {
808
+	private function _extra_hidden_inputs($no_payment_required = true) {
809 809
 		return new EE_Form_Section_Proper(
810 810
 			array(
811
-				'html_id'         => 'ee-' . $this->slug() . '-extra-hidden-inputs',
811
+				'html_id'         => 'ee-'.$this->slug().'-extra-hidden-inputs',
812 812
 				'layout_strategy' => new EE_Div_Per_Section_Layout(),
813 813
 				'subsections'     => array(
814 814
 					'spco_no_payment_required' => new EE_Hidden_Input(
@@ -840,16 +840,16 @@  discard block
 block discarded – undo
840 840
 	 * @access protected
841 841
 	 * @param array $registrations
842 842
 	 */
843
-	protected function _apply_registration_payments_to_amount_owing( array $registrations ) {
843
+	protected function _apply_registration_payments_to_amount_owing(array $registrations) {
844 844
 		$payments = array();
845
-		foreach ( $registrations as $registration ) {
846
-			if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) {
845
+		foreach ($registrations as $registration) {
846
+			if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
847 847
 				$payments += $registration->registration_payments();
848 848
 			}
849 849
 		}
850
-		if ( ! empty( $payments ) ) {
851
-			foreach ( $payments as $payment ) {
852
-				if ( $payment instanceof EE_Registration_Payment ) {
850
+		if ( ! empty($payments)) {
851
+			foreach ($payments as $payment) {
852
+				if ($payment instanceof EE_Registration_Payment) {
853 853
 					$this->checkout->amount_owing -= $payment->amount();
854 854
 				}
855 855
 			}
@@ -865,11 +865,11 @@  discard block
 block discarded – undo
865 865
 	 * @param    bool $force_reset
866 866
 	 * @return    void
867 867
 	 */
868
-	private function _reset_selected_method_of_payment( $force_reset = false ) {
868
+	private function _reset_selected_method_of_payment($force_reset = false) {
869 869
 		$reset_payment_method = $force_reset
870 870
 			? true
871
-			: sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) );
872
-		if ( $reset_payment_method ) {
871
+			: sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false));
872
+		if ($reset_payment_method) {
873 873
 			$this->checkout->selected_method_of_payment = null;
874 874
 			$this->checkout->payment_method = null;
875 875
 			$this->checkout->billing_form = null;
@@ -888,12 +888,12 @@  discard block
 block discarded – undo
888 888
 	 * @param string $selected_method_of_payment
889 889
 	 * @return  void
890 890
 	 */
891
-	private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) {
892
-		$selected_method_of_payment = ! empty( $selected_method_of_payment )
891
+	private function _save_selected_method_of_payment($selected_method_of_payment = '') {
892
+		$selected_method_of_payment = ! empty($selected_method_of_payment)
893 893
 			? $selected_method_of_payment
894 894
 			: $this->checkout->selected_method_of_payment;
895 895
 		EE_Registry::instance()->SSN->set_session_data(
896
-			array( 'selected_method_of_payment' => $selected_method_of_payment )
896
+			array('selected_method_of_payment' => $selected_method_of_payment)
897 897
 		);
898 898
 	}
899 899
 
@@ -909,19 +909,19 @@  discard block
 block discarded – undo
909 909
 		// load payment method classes
910 910
 		$this->checkout->available_payment_methods = $this->_get_available_payment_methods();
911 911
 		// switch up header depending on number of available payment methods
912
-		$payment_method_header = count( $this->checkout->available_payment_methods ) > 1
912
+		$payment_method_header = count($this->checkout->available_payment_methods) > 1
913 913
 			? apply_filters(
914 914
 				'FHEE__registration_page_payment_options__method_of_payment_hdr',
915
-				__( 'Please Select Your Method of Payment', 'event_espresso' )
915
+				__('Please Select Your Method of Payment', 'event_espresso')
916 916
 			)
917 917
 			: apply_filters(
918 918
 				'FHEE__registration_page_payment_options__method_of_payment_hdr',
919
-				__( 'Method of Payment', 'event_espresso' )
919
+				__('Method of Payment', 'event_espresso')
920 920
 			);
921 921
 		$available_payment_methods = array(
922 922
 			// display the "Payment Method" header
923 923
 			'payment_method_header' => new EE_Form_Section_HTML(
924
-				EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' )
924
+				EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr')
925 925
 			)
926 926
 		);
927 927
 		// the list of actual payment methods ( invoice, paypal, etc ) in a  ( slug => HTML )  format
@@ -930,32 +930,32 @@  discard block
 block discarded – undo
930 930
 		// additional instructions to be displayed and hidden below payment methods (adding a clearing div to start)
931 931
 		$payment_methods_billing_info = array(
932 932
 			new EE_Form_Section_HTML(
933
-				EEH_HTML::div( '<br />', '', '', 'clear:both;' )
933
+				EEH_HTML::div('<br />', '', '', 'clear:both;')
934 934
 			)
935 935
 		);
936 936
 		// loop through payment methods
937
-		foreach ( $this->checkout->available_payment_methods as $payment_method ) {
938
-			if ( $payment_method instanceof EE_Payment_Method ) {
937
+		foreach ($this->checkout->available_payment_methods as $payment_method) {
938
+			if ($payment_method instanceof EE_Payment_Method) {
939 939
 				$payment_method_button = EEH_HTML::img(
940 940
 					$payment_method->button_url(),
941 941
 					$payment_method->name(),
942
-					'spco-payment-method-' . $payment_method->slug() . '-btn-img',
942
+					'spco-payment-method-'.$payment_method->slug().'-btn-img',
943 943
 					'spco-payment-method-btn-img'
944 944
 				);
945 945
 				// check if any payment methods are set as default
946 946
 				// if payment method is already selected OR nothing is selected and this payment method should be open_by_default
947 947
 				if (
948
-					( $this->checkout->selected_method_of_payment === $payment_method->slug() )
949
-					|| ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() )
948
+					($this->checkout->selected_method_of_payment === $payment_method->slug())
949
+					|| ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())
950 950
 				) {
951 951
 					$this->checkout->selected_method_of_payment = $payment_method->slug();
952 952
 					$this->_save_selected_method_of_payment();
953
-					$default_payment_method_option[ $payment_method->slug() ] = $payment_method_button;
953
+					$default_payment_method_option[$payment_method->slug()] = $payment_method_button;
954 954
 				} else {
955
-					$available_payment_method_options[ $payment_method->slug() ] = $payment_method_button;
955
+					$available_payment_method_options[$payment_method->slug()] = $payment_method_button;
956 956
 				}
957
-				$payment_methods_billing_info[ $payment_method->slug()
958
-				                               . '-info' ] = $this->_payment_method_billing_info(
957
+				$payment_methods_billing_info[$payment_method->slug()
958
+				                               . '-info'] = $this->_payment_method_billing_info(
959 959
 					$payment_method
960 960
 				);
961 961
 			}
@@ -985,12 +985,12 @@  discard block
 block discarded – undo
985 985
 	 * @return EE_Payment_Method[]
986 986
 	 */
987 987
 	protected function _get_available_payment_methods() {
988
-		if ( ! empty( $this->checkout->available_payment_methods ) ) {
988
+		if ( ! empty($this->checkout->available_payment_methods)) {
989 989
 			return $this->checkout->available_payment_methods;
990 990
 		}
991 991
 		$available_payment_methods = array();
992 992
 		// load EEM_Payment_Method
993
-		EE_Registry::instance()->load_model( 'Payment_Method' );
993
+		EE_Registry::instance()->load_model('Payment_Method');
994 994
 		/** @type EEM_Payment_Method $EEM_Payment_Method */
995 995
 		$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
996 996
 		// get all active payment methods
@@ -998,9 +998,9 @@  discard block
 block discarded – undo
998 998
 			$this->checkout->transaction,
999 999
 			EEM_Payment_Method::scope_cart
1000 1000
 		);
1001
-		foreach ( $payment_methods as $payment_method ) {
1002
-			if ( $payment_method instanceof EE_Payment_Method ) {
1003
-				$available_payment_methods[ $payment_method->slug() ] = $payment_method;
1001
+		foreach ($payment_methods as $payment_method) {
1002
+			if ($payment_method instanceof EE_Payment_Method) {
1003
+				$available_payment_methods[$payment_method->slug()] = $payment_method;
1004 1004
 			}
1005 1005
 		}
1006 1006
 		return $available_payment_methods;
@@ -1015,14 +1015,14 @@  discard block
 block discarded – undo
1015 1015
 	 * @param    array $available_payment_method_options
1016 1016
 	 * @return    \EE_Form_Section_Proper
1017 1017
 	 */
1018
-	private function _available_payment_method_inputs( $available_payment_method_options = array() ) {
1018
+	private function _available_payment_method_inputs($available_payment_method_options = array()) {
1019 1019
 		// generate inputs
1020 1020
 		return new EE_Form_Section_Proper(
1021 1021
 			array(
1022 1022
 				'html_id'         => 'ee-available-payment-method-inputs',
1023 1023
 				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1024 1024
 				'subsections'     => array(
1025
-					'' => new EE_Radio_Button_Input (
1025
+					'' => new EE_Radio_Button_Input(
1026 1026
 						$available_payment_method_options,
1027 1027
 						array(
1028 1028
 							'html_name'          => 'selected_method_of_payment',
@@ -1047,28 +1047,28 @@  discard block
 block discarded – undo
1047 1047
 	 * @return    \EE_Form_Section_Proper
1048 1048
 	 * @throws \EE_Error
1049 1049
 	 */
1050
-	private function _payment_method_billing_info( EE_Payment_Method $payment_method ) {
1050
+	private function _payment_method_billing_info(EE_Payment_Method $payment_method) {
1051 1051
 		$currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug()
1052 1052
 			? true
1053 1053
 			: false;
1054 1054
 		// generate the billing form for payment method
1055 1055
 		$billing_form = $currently_selected
1056
-			? $this->_get_billing_form_for_payment_method( $payment_method )
1056
+			? $this->_get_billing_form_for_payment_method($payment_method)
1057 1057
 			: new EE_Form_Section_HTML();
1058 1058
 		$this->checkout->billing_form = $currently_selected
1059 1059
 			? $billing_form
1060 1060
 			: $this->checkout->billing_form;
1061 1061
 		// it's all in the details
1062 1062
 		$info_html = EEH_HTML::h3(
1063
-			__( 'Important information regarding your payment', 'event_espresso' ),
1063
+			__('Important information regarding your payment', 'event_espresso'),
1064 1064
 			'',
1065 1065
 			'spco-payment-method-hdr'
1066 1066
 		);
1067 1067
 		// add some info regarding the step, either from what's saved in the admin,
1068 1068
 		// or a default string depending on whether the PM has a billing form or not
1069
-		if ( $payment_method->description() ) {
1069
+		if ($payment_method->description()) {
1070 1070
 			$payment_method_info = $payment_method->description();
1071
-		} elseif ( $billing_form instanceof EE_Billing_Info_Form ) {
1071
+		} elseif ($billing_form instanceof EE_Billing_Info_Form) {
1072 1072
 			$payment_method_info = sprintf(
1073 1073
 				__(
1074 1074
 					'Please provide the following billing information, then click the "%1$s" button below in order to proceed.',
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 			);
1079 1079
 		} else {
1080 1080
 			$payment_method_info = sprintf(
1081
-				__( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ),
1081
+				__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'),
1082 1082
 				$this->submit_button_text()
1083 1083
 			);
1084 1084
 		}
@@ -1092,13 +1092,13 @@  discard block
 block discarded – undo
1092 1092
 		);
1093 1093
 		return new EE_Form_Section_Proper(
1094 1094
 			array(
1095
-				'html_id'         => 'spco-payment-method-info-' . $payment_method->slug(),
1095
+				'html_id'         => 'spco-payment-method-info-'.$payment_method->slug(),
1096 1096
 				'html_class'      => 'spco-payment-method-info-dv',
1097 1097
 				// only display the selected or default PM
1098 1098
 				'html_style'      => $currently_selected ? '' : 'display:none;',
1099 1099
 				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1100 1100
 				'subsections'     => array(
1101
-					'info'         => new EE_Form_Section_HTML( $info_html ),
1101
+					'info'         => new EE_Form_Section_HTML($info_html),
1102 1102
 					'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML()
1103 1103
 				)
1104 1104
 			)
@@ -1116,15 +1116,15 @@  discard block
 block discarded – undo
1116 1116
 	 */
1117 1117
 	public function get_billing_form_html_for_payment_method() {
1118 1118
 		// how have they chosen to pay?
1119
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
1119
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1120 1120
 		$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1121
-		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) {
1121
+		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
1122 1122
 			return false;
1123 1123
 		}
1124
-		if ( apply_filters(
1124
+		if (apply_filters(
1125 1125
 			'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1126 1126
 			false
1127
-		) ) {
1127
+		)) {
1128 1128
 			EE_Error::add_success(
1129 1129
 				apply_filters(
1130 1130
 					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 			);
1140 1140
 		}
1141 1141
 		// now generate billing form for selected method of payment
1142
-		$payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
1142
+		$payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
1143 1143
 		// fill form with attendee info if applicable
1144 1144
 		if (
1145 1145
 			$payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form
@@ -1161,10 +1161,10 @@  discard block
 block discarded – undo
1161 1161
 		$billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper
1162 1162
 			? $payment_method_billing_form->get_html()
1163 1163
 			: '';
1164
-		$this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) );
1164
+		$this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info));
1165 1165
 		// localize validation rules for main form
1166 1166
 		$this->checkout->current_step->reg_form->localize_validation_rules();
1167
-		$this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() );
1167
+		$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1168 1168
 		return true;
1169 1169
 	}
1170 1170
 
@@ -1178,18 +1178,18 @@  discard block
 block discarded – undo
1178 1178
 	 * @return \EE_Billing_Info_Form|\EE_Form_Section_HTML
1179 1179
 	 * @throws \EE_Error
1180 1180
 	 */
1181
-	private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) {
1181
+	private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) {
1182 1182
 		$billing_form = $payment_method->type_obj()->billing_form(
1183 1183
 			$this->checkout->transaction,
1184
-			array( 'amount_owing' => $this->checkout->amount_owing )
1184
+			array('amount_owing' => $this->checkout->amount_owing)
1185 1185
 		);
1186
-		if ( $billing_form instanceof EE_Billing_Info_Form ) {
1186
+		if ($billing_form instanceof EE_Billing_Info_Form) {
1187 1187
 			if (
1188 1188
 				apply_filters(
1189 1189
 					'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1190 1190
 					false
1191 1191
 				)
1192
-				&& EE_Registry::instance()->REQ->is_set( 'payment_method' )
1192
+				&& EE_Registry::instance()->REQ->is_set('payment_method')
1193 1193
 			) {
1194 1194
 				EE_Error::add_success(
1195 1195
 					apply_filters(
@@ -1231,15 +1231,15 @@  discard block
 block discarded – undo
1231 1231
 		$request_param = 'selected_method_of_payment'
1232 1232
 	) {
1233 1233
 		// is selected_method_of_payment set in the request ?
1234
-		$selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false );
1235
-		if ( $selected_method_of_payment ) {
1234
+		$selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false);
1235
+		if ($selected_method_of_payment) {
1236 1236
 			// sanitize it
1237
-			$selected_method_of_payment = is_array( $selected_method_of_payment )
1238
-				? array_shift( $selected_method_of_payment )
1237
+			$selected_method_of_payment = is_array($selected_method_of_payment)
1238
+				? array_shift($selected_method_of_payment)
1239 1239
 				: $selected_method_of_payment;
1240
-			$selected_method_of_payment = sanitize_text_field( $selected_method_of_payment );
1240
+			$selected_method_of_payment = sanitize_text_field($selected_method_of_payment);
1241 1241
 			// store it in the session so that it's available for all subsequent requests including AJAX
1242
-			$this->_save_selected_method_of_payment( $selected_method_of_payment );
1242
+			$this->_save_selected_method_of_payment($selected_method_of_payment);
1243 1243
 		} else {
1244 1244
 			// or is is set in the session ?
1245 1245
 			$selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data(
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 			);
1248 1248
 		}
1249 1249
 		// do ya really really gotta have it?
1250
-		if ( empty( $selected_method_of_payment ) && $required ) {
1250
+		if (empty($selected_method_of_payment) && $required) {
1251 1251
 			EE_Error::add_error(
1252 1252
 				sprintf(
1253 1253
 					__(
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
 					),
1257 1257
 					'<br/>',
1258 1258
 					'<br/>',
1259
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1259
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1260 1260
 				),
1261 1261
 				__FILE__,
1262 1262
 				__FUNCTION__,
@@ -1283,13 +1283,13 @@  discard block
 block discarded – undo
1283 1283
 	 * @throws \EE_Error
1284 1284
 	 */
1285 1285
 	public function switch_payment_method() {
1286
-		if ( ! $this->_verify_payment_method_is_set() ) {
1286
+		if ( ! $this->_verify_payment_method_is_set()) {
1287 1287
 			return false;
1288 1288
 		}
1289
-		if ( apply_filters(
1289
+		if (apply_filters(
1290 1290
 			'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1291 1291
 			false
1292
-		) ) {
1292
+		)) {
1293 1293
 			EE_Error::add_success(
1294 1294
 				apply_filters(
1295 1295
 					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
 			);
1305 1305
 		}
1306 1306
 		// generate billing form for selected method of payment if it hasn't been done already
1307
-		if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) {
1307
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1308 1308
 			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1309 1309
 				$this->checkout->payment_method
1310 1310
 			);
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 			);
1327 1327
 		}
1328 1328
 		// and debug content
1329
-		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form
1329
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form
1330 1330
 		     && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1331 1331
 		) {
1332 1332
 			$this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
@@ -1334,15 +1334,15 @@  discard block
 block discarded – undo
1334 1334
 			);
1335 1335
 		}
1336 1336
 		// get html and validation rules for form
1337
-		if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) {
1337
+		if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) {
1338 1338
 			$this->checkout->json_response->set_return_data(
1339
-				array( 'payment_method_info' => $this->checkout->billing_form->get_html() )
1339
+				array('payment_method_info' => $this->checkout->billing_form->get_html())
1340 1340
 			);
1341 1341
 			// localize validation rules for main form
1342
-			$this->checkout->billing_form->localize_validation_rules( true );
1343
-			$this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() );
1342
+			$this->checkout->billing_form->localize_validation_rules(true);
1343
+			$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1344 1344
 		} else {
1345
-			$this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) );
1345
+			$this->checkout->json_response->set_return_data(array('payment_method_info' => ''));
1346 1346
 		}
1347 1347
 		//prevents advancement to next step
1348 1348
 		$this->checkout->continue_reg = false;
@@ -1359,12 +1359,12 @@  discard block
 block discarded – undo
1359 1359
 	 */
1360 1360
 	protected function _verify_payment_method_is_set() {
1361 1361
 		// generate billing form for selected method of payment if it hasn't been done already
1362
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
1362
+		if (empty($this->checkout->selected_method_of_payment)) {
1363 1363
 			// how have they chosen to pay?
1364
-			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
1364
+			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1365 1365
 		}
1366 1366
 		// verify payment method
1367
-		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) {
1367
+		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
1368 1368
 			// get payment method for selected method of payment
1369 1369
 			$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1370 1370
 		}
@@ -1383,25 +1383,25 @@  discard block
 block discarded – undo
1383 1383
 	 * @throws \EE_Error
1384 1384
 	 */
1385 1385
 	public function save_payer_details_via_ajax() {
1386
-		if ( ! $this->_verify_payment_method_is_set() ) {
1386
+		if ( ! $this->_verify_payment_method_is_set()) {
1387 1387
 			return;
1388 1388
 		}
1389 1389
 		// generate billing form for selected method of payment if it hasn't been done already
1390
-		if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) {
1390
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1391 1391
 			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1392 1392
 				$this->checkout->payment_method
1393 1393
 			);
1394 1394
 		}
1395 1395
 		// generate primary attendee from payer info if applicable
1396
-		if ( ! $this->checkout->transaction_has_primary_registrant() ) {
1396
+		if ( ! $this->checkout->transaction_has_primary_registrant()) {
1397 1397
 			$attendee = $this->_create_attendee_from_request_data();
1398
-			if ( $attendee instanceof EE_Attendee ) {
1399
-				foreach ( $this->checkout->transaction->registrations() as $registration ) {
1400
-					if ( $registration->is_primary_registrant() ) {
1398
+			if ($attendee instanceof EE_Attendee) {
1399
+				foreach ($this->checkout->transaction->registrations() as $registration) {
1400
+					if ($registration->is_primary_registrant()) {
1401 1401
 						$this->checkout->primary_attendee_obj = $attendee;
1402
-						$registration->_add_relation_to( $attendee, 'Attendee' );
1403
-						$registration->set_attendee_id( $attendee->ID() );
1404
-						$registration->update_cache_after_object_save( 'Attendee', $attendee );
1402
+						$registration->_add_relation_to($attendee, 'Attendee');
1403
+						$registration->set_attendee_id($attendee->ID());
1404
+						$registration->update_cache_after_object_save('Attendee', $attendee);
1405 1405
 					}
1406 1406
 				}
1407 1407
 			}
@@ -1419,50 +1419,50 @@  discard block
 block discarded – undo
1419 1419
 	 */
1420 1420
 	protected function _create_attendee_from_request_data() {
1421 1421
 		// get State ID
1422
-		$STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : '';
1423
-		if ( ! empty( $STA_ID ) ) {
1422
+		$STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
1423
+		if ( ! empty($STA_ID)) {
1424 1424
 			// can we get state object from name ?
1425
-			EE_Registry::instance()->load_model( 'State' );
1426
-			$state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' );
1427
-			$STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID;
1425
+			EE_Registry::instance()->load_model('State');
1426
+			$state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
1427
+			$STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID;
1428 1428
 		}
1429 1429
 		// get Country ISO
1430
-		$CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : '';
1431
-		if ( ! empty( $CNT_ISO ) ) {
1430
+		$CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
1431
+		if ( ! empty($CNT_ISO)) {
1432 1432
 			// can we get country object from name ?
1433
-			EE_Registry::instance()->load_model( 'Country' );
1433
+			EE_Registry::instance()->load_model('Country');
1434 1434
 			$country = EEM_Country::instance()->get_col(
1435
-				array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ),
1435
+				array(array('CNT_name' => $CNT_ISO), 'limit' => 1),
1436 1436
 				'CNT_ISO'
1437 1437
 			);
1438
-			$CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO;
1438
+			$CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO;
1439 1439
 		}
1440 1440
 		// grab attendee data
1441 1441
 		$attendee_data = array(
1442
-			'ATT_fname'    => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '',
1443
-			'ATT_lname'    => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '',
1444
-			'ATT_email'    => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '',
1445
-			'ATT_address'  => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '',
1446
-			'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '',
1447
-			'ATT_city'     => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '',
1442
+			'ATT_fname'    => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '',
1443
+			'ATT_lname'    => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '',
1444
+			'ATT_email'    => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '',
1445
+			'ATT_address'  => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '',
1446
+			'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '',
1447
+			'ATT_city'     => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '',
1448 1448
 			'STA_ID'       => $STA_ID,
1449 1449
 			'CNT_ISO'      => $CNT_ISO,
1450
-			'ATT_zip'      => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '',
1451
-			'ATT_phone'    => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '',
1450
+			'ATT_zip'      => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '',
1451
+			'ATT_phone'    => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '',
1452 1452
 		);
1453 1453
 		// validate the email address since it is the most important piece of info
1454
-		if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) {
1454
+		if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) {
1455 1455
 			EE_Error::add_error(
1456
-				__( 'An invalid email address was submitted.', 'event_espresso' ),
1456
+				__('An invalid email address was submitted.', 'event_espresso'),
1457 1457
 				__FILE__,
1458 1458
 				__FUNCTION__,
1459 1459
 				__LINE__
1460 1460
 			);
1461 1461
 		}
1462 1462
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
1463
-		if ( ! empty( $attendee_data['ATT_fname'] )
1464
-		     && ! empty( $attendee_data['ATT_lname'] )
1465
-		     && ! empty( $attendee_data['ATT_email'] )
1463
+		if ( ! empty($attendee_data['ATT_fname'])
1464
+		     && ! empty($attendee_data['ATT_lname'])
1465
+		     && ! empty($attendee_data['ATT_email'])
1466 1466
 		) {
1467 1467
 			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(
1468 1468
 				array(
@@ -1471,19 +1471,19 @@  discard block
 block discarded – undo
1471 1471
 					'ATT_email' => $attendee_data['ATT_email']
1472 1472
 				)
1473 1473
 			);
1474
-			if ( $existing_attendee instanceof EE_Attendee ) {
1474
+			if ($existing_attendee instanceof EE_Attendee) {
1475 1475
 				return $existing_attendee;
1476 1476
 			}
1477 1477
 		}
1478 1478
 		// no existing attendee? kk let's create a new one
1479 1479
 		// kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist
1480
-		$attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] )
1480
+		$attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname'])
1481 1481
 			? $attendee_data['ATT_fname']
1482 1482
 			: $attendee_data['ATT_email'];
1483
-		$attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] )
1483
+		$attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname'])
1484 1484
 			? $attendee_data['ATT_lname']
1485 1485
 			: $attendee_data['ATT_email'];
1486
-		return EE_Attendee::new_instance( $attendee_data );
1486
+		return EE_Attendee::new_instance($attendee_data);
1487 1487
 	}
1488 1488
 
1489 1489
 
@@ -1501,26 +1501,26 @@  discard block
 block discarded – undo
1501 1501
 		// how have they chosen to pay?
1502 1502
 		$this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free()
1503 1503
 			? 'no_payment_required'
1504
-			: $this->_get_selected_method_of_payment( true );
1504
+			: $this->_get_selected_method_of_payment(true);
1505 1505
 		// choose your own adventure based on method_of_payment
1506
-		switch ( $this->checkout->selected_method_of_payment ) {
1506
+		switch ($this->checkout->selected_method_of_payment) {
1507 1507
 
1508 1508
 			case 'events_sold_out' :
1509 1509
 				$this->checkout->redirect = true;
1510 1510
 				$this->checkout->redirect_url = $this->checkout->cancel_page_url;
1511
-				$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1511
+				$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1512 1512
 				// mark this reg step as completed
1513 1513
 				$this->set_completed();
1514 1514
 				return false;
1515 1515
 				break;
1516 1516
 
1517 1517
 			case 'payments_closed' :
1518
-				if ( apply_filters(
1518
+				if (apply_filters(
1519 1519
 					'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success',
1520 1520
 					false
1521
-				) ) {
1521
+				)) {
1522 1522
 					EE_Error::add_success(
1523
-						__( 'no payment required at this time.', 'event_espresso' ),
1523
+						__('no payment required at this time.', 'event_espresso'),
1524 1524
 						__FILE__,
1525 1525
 						__FUNCTION__,
1526 1526
 						__LINE__
@@ -1532,12 +1532,12 @@  discard block
 block discarded – undo
1532 1532
 				break;
1533 1533
 
1534 1534
 			case 'no_payment_required' :
1535
-				if ( apply_filters(
1535
+				if (apply_filters(
1536 1536
 					'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success',
1537 1537
 					false
1538
-				) ) {
1538
+				)) {
1539 1539
 					EE_Error::add_success(
1540
-						__( 'no payment required.', 'event_espresso' ),
1540
+						__('no payment required.', 'event_espresso'),
1541 1541
 						__FILE__,
1542 1542
 						__FUNCTION__,
1543 1543
 						__LINE__
@@ -1557,15 +1557,15 @@  discard block
 block discarded – undo
1557 1557
 					EE_Registry::instance()->SSN->checkout()->revisit
1558 1558
 				);
1559 1559
 				// calculate difference between the two arrays
1560
-				$registrations = array_diff( $registrations, $ejected_registrations );
1561
-				if ( empty( $registrations ) ) {
1560
+				$registrations = array_diff($registrations, $ejected_registrations);
1561
+				if (empty($registrations)) {
1562 1562
 					$this->_redirect_because_event_sold_out();
1563 1563
 					return false;
1564 1564
 				}
1565 1565
 				$payment_successful = $this->_process_payment();
1566
-				if ( $payment_successful ) {
1566
+				if ($payment_successful) {
1567 1567
 					$this->checkout->continue_reg = true;
1568
-					$this->_maybe_set_completed( $this->checkout->payment_method );
1568
+					$this->_maybe_set_completed($this->checkout->payment_method);
1569 1569
 				} else {
1570 1570
 					$this->checkout->continue_reg = false;
1571 1571
 				}
@@ -1586,10 +1586,10 @@  discard block
 block discarded – undo
1586 1586
 		$this->checkout->continue_reg = false;
1587 1587
 		// set redirect URL
1588 1588
 		$this->checkout->redirect_url = add_query_arg(
1589
-			array( 'e_reg_url_link' => $this->checkout->reg_url_link ),
1589
+			array('e_reg_url_link' => $this->checkout->reg_url_link),
1590 1590
 			$this->checkout->current_step->reg_step_url()
1591 1591
 		);
1592
-		$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1592
+		$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1593 1593
 	}
1594 1594
 
1595 1595
 
@@ -1602,8 +1602,8 @@  discard block
 block discarded – undo
1602 1602
 	 * @return void
1603 1603
 	 * @throws \EE_Error
1604 1604
 	 */
1605
-	protected function _maybe_set_completed( EE_Payment_Method $payment_method ) {
1606
-		switch ( $payment_method->type_obj()->payment_occurs() ) {
1605
+	protected function _maybe_set_completed(EE_Payment_Method $payment_method) {
1606
+		switch ($payment_method->type_obj()->payment_occurs()) {
1607 1607
 			case EE_PMT_Base::offsite :
1608 1608
 				break;
1609 1609
 			case EE_PMT_Base::onsite :
@@ -1626,7 +1626,7 @@  discard block
 block discarded – undo
1626 1626
 	public function update_reg_step() {
1627 1627
 		$success = true;
1628 1628
 		// if payment required
1629
-		if ( $this->checkout->transaction->total() > 0 ) {
1629
+		if ($this->checkout->transaction->total() > 0) {
1630 1630
 			do_action(
1631 1631
 				'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway',
1632 1632
 				$this->checkout->transaction
@@ -1634,13 +1634,13 @@  discard block
 block discarded – undo
1634 1634
 			// attempt payment via payment method
1635 1635
 			$success = $this->process_reg_step();
1636 1636
 		}
1637
-		if ( $success && ! $this->checkout->redirect ) {
1637
+		if ($success && ! $this->checkout->redirect) {
1638 1638
 			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn(
1639 1639
 				$this->checkout->transaction->ID()
1640 1640
 			);
1641 1641
 			// set return URL
1642 1642
 			$this->checkout->redirect_url = add_query_arg(
1643
-				array( 'e_reg_url_link' => $this->checkout->reg_url_link ),
1643
+				array('e_reg_url_link' => $this->checkout->reg_url_link),
1644 1644
 				$this->checkout->thank_you_page_url
1645 1645
 			);
1646 1646
 		}
@@ -1660,28 +1660,28 @@  discard block
 block discarded – undo
1660 1660
 		// clear any previous errors related to not selecting a payment method
1661 1661
 //		EE_Error::overwrite_errors();
1662 1662
 		// ya gotta make a choice man
1663
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
1663
+		if (empty($this->checkout->selected_method_of_payment)) {
1664 1664
 			$this->checkout->json_response->set_plz_select_method_of_payment(
1665
-				__( 'Please select a method of payment before proceeding.', 'event_espresso' )
1665
+				__('Please select a method of payment before proceeding.', 'event_espresso')
1666 1666
 			);
1667 1667
 			return false;
1668 1668
 		}
1669 1669
 		// get EE_Payment_Method object
1670
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
1670
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1671 1671
 			return false;
1672 1672
 		}
1673 1673
 		// setup billing form
1674
-		if ( $this->checkout->payment_method->is_on_site() ) {
1674
+		if ($this->checkout->payment_method->is_on_site()) {
1675 1675
 			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1676 1676
 				$this->checkout->payment_method
1677 1677
 			);
1678 1678
 			// bad billing form ?
1679
-			if ( ! $this->_billing_form_is_valid() ) {
1679
+			if ( ! $this->_billing_form_is_valid()) {
1680 1680
 				return false;
1681 1681
 			}
1682 1682
 		}
1683 1683
 		// ensure primary registrant has been fully processed
1684
-		if ( ! $this->_setup_primary_registrant_prior_to_payment() ) {
1684
+		if ( ! $this->_setup_primary_registrant_prior_to_payment()) {
1685 1685
 			return false;
1686 1686
 		}
1687 1687
 		/** @type EE_Transaction_Processor $transaction_processor */
@@ -1689,12 +1689,12 @@  discard block
 block discarded – undo
1689 1689
 		// in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved
1690 1690
 		//$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params );
1691 1691
 		// attempt payment
1692
-		$payment = $this->_attempt_payment( $this->checkout->payment_method );
1692
+		$payment = $this->_attempt_payment($this->checkout->payment_method);
1693 1693
 		// process results
1694
-		$payment = $this->_validate_payment( $payment );
1695
-		$payment = $this->_post_payment_processing( $payment );
1694
+		$payment = $this->_validate_payment($payment);
1695
+		$payment = $this->_post_payment_processing($payment);
1696 1696
 		// verify payment
1697
-		if ( $payment instanceof EE_Payment ) {
1697
+		if ($payment instanceof EE_Payment) {
1698 1698
 			// store that for later
1699 1699
 			$this->checkout->payment = $payment;
1700 1700
 			// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
 			} else {
1709 1709
 				return false;
1710 1710
 			}
1711
-		} else if ( $payment === true ) {
1711
+		} else if ($payment === true) {
1712 1712
 			// please note that offline payment methods will NOT make a payment,
1713 1713
 			// but instead just mark themselves as the PMD_ID on the transaction, and return true
1714 1714
 			$this->checkout->payment = $payment;
@@ -1733,7 +1733,7 @@  discard block
 block discarded – undo
1733 1733
 		);
1734 1734
 		$html = $payment_method_billing_info->get_html();
1735 1735
 		$html .= $this->checkout->redirect_form;
1736
-		EE_Registry::instance()->REQ->add_output( $html );
1736
+		EE_Registry::instance()->REQ->add_output($html);
1737 1737
 		return true;
1738 1738
 	}
1739 1739
 
@@ -1747,28 +1747,28 @@  discard block
 block discarded – undo
1747 1747
 	 * @throws \EE_Error
1748 1748
 	 */
1749 1749
 	private function _billing_form_is_valid() {
1750
-		if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) {
1750
+		if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1751 1751
 			return true;
1752 1752
 		}
1753
-		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) {
1754
-			if ( $this->checkout->billing_form->was_submitted() ) {
1753
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) {
1754
+			if ($this->checkout->billing_form->was_submitted()) {
1755 1755
 				$this->checkout->billing_form->receive_form_submission();
1756
-				if ( $this->checkout->billing_form->is_valid() ) {
1756
+				if ($this->checkout->billing_form->is_valid()) {
1757 1757
 					return true;
1758 1758
 				}
1759 1759
 				$validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated();
1760 1760
 				$error_strings = array();
1761
-				foreach ( $validation_errors as $validation_error ) {
1762
-					if ( $validation_error instanceof EE_Validation_Error ) {
1761
+				foreach ($validation_errors as $validation_error) {
1762
+					if ($validation_error instanceof EE_Validation_Error) {
1763 1763
 						$form_section = $validation_error->get_form_section();
1764
-						if ( $form_section instanceof EE_Form_Input_Base ) {
1764
+						if ($form_section instanceof EE_Form_Input_Base) {
1765 1765
 							$label = $form_section->html_label_text();
1766
-						} elseif ( $form_section instanceof EE_Form_Section_Base ) {
1766
+						} elseif ($form_section instanceof EE_Form_Section_Base) {
1767 1767
 							$label = $form_section->name();
1768 1768
 						} else {
1769
-							$label = __( 'Validation Error', 'event_espresso' );
1769
+							$label = __('Validation Error', 'event_espresso');
1770 1770
 						}
1771
-						$error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() );
1771
+						$error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage());
1772 1772
 					}
1773 1773
 				}
1774 1774
 				EE_Error::add_error(
@@ -1778,7 +1778,7 @@  discard block
 block discarded – undo
1778 1778
 							'event_espresso'
1779 1779
 						),
1780 1780
 						'<br/>',
1781
-						implode( '<br/>', $error_strings )
1781
+						implode('<br/>', $error_strings)
1782 1782
 					),
1783 1783
 					__FILE__,
1784 1784
 					__FUNCTION__,
@@ -1797,7 +1797,7 @@  discard block
 block discarded – undo
1797 1797
 			}
1798 1798
 		} else {
1799 1799
 			EE_Error::add_error(
1800
-				__( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ),
1800
+				__('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'),
1801 1801
 				__FILE__,
1802 1802
 				__FUNCTION__,
1803 1803
 				__LINE__
@@ -1836,7 +1836,7 @@  discard block
 block discarded – undo
1836 1836
 		// save the TXN ( which clears cached copy of primary_registration)
1837 1837
 		$this->checkout->transaction->save();
1838 1838
 		// grab TXN ID and save it to the primary_registration
1839
-		$primary_registration->set_transaction_id( $this->checkout->transaction->ID() );
1839
+		$primary_registration->set_transaction_id($this->checkout->transaction->ID());
1840 1840
 		// save what we have so far
1841 1841
 		$primary_registration->save();
1842 1842
 		return true;
@@ -1854,7 +1854,7 @@  discard block
 block discarded – undo
1854 1854
 	private function _capture_primary_registration_data_from_billing_form() {
1855 1855
 		// convert billing form data into an attendee
1856 1856
 		$this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data();
1857
-		if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) {
1857
+		if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
1858 1858
 			EE_Error::add_error(
1859 1859
 				sprintf(
1860 1860
 					__(
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
 						'event_espresso'
1863 1863
 					),
1864 1864
 					'<br/>',
1865
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1865
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1866 1866
 				),
1867 1867
 				__FILE__,
1868 1868
 				__FUNCTION__,
@@ -1871,7 +1871,7 @@  discard block
 block discarded – undo
1871 1871
 			return false;
1872 1872
 		}
1873 1873
 		$primary_registration = $this->checkout->transaction->primary_registration();
1874
-		if ( ! $primary_registration instanceof EE_Registration ) {
1874
+		if ( ! $primary_registration instanceof EE_Registration) {
1875 1875
 			EE_Error::add_error(
1876 1876
 				sprintf(
1877 1877
 					__(
@@ -1879,7 +1879,7 @@  discard block
 block discarded – undo
1879 1879
 						'event_espresso'
1880 1880
 					),
1881 1881
 					'<br/>',
1882
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1882
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1883 1883
 				),
1884 1884
 				__FILE__,
1885 1885
 				__FUNCTION__,
@@ -1887,7 +1887,7 @@  discard block
 block discarded – undo
1887 1887
 			);
1888 1888
 			return false;
1889 1889
 		}
1890
-		if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' )
1890
+		if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee')
1891 1891
 		       instanceof
1892 1892
 		       EE_Attendee
1893 1893
 		) {
@@ -1898,7 +1898,7 @@  discard block
 block discarded – undo
1898 1898
 						'event_espresso'
1899 1899
 					),
1900 1900
 					'<br/>',
1901
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1901
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1902 1902
 				),
1903 1903
 				__FILE__,
1904 1904
 				__FUNCTION__,
@@ -1907,9 +1907,9 @@  discard block
 block discarded – undo
1907 1907
 			return false;
1908 1908
 		}
1909 1909
 		/** @type EE_Registration_Processor $registration_processor */
1910
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1910
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1911 1911
 		// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1912
-		$registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration );
1912
+		$registration_processor->toggle_incomplete_registration_status_to_default($primary_registration);
1913 1913
 		return true;
1914 1914
 	}
1915 1915
 
@@ -1924,22 +1924,22 @@  discard block
 block discarded – undo
1924 1924
 	 * @throws \EE_Error
1925 1925
 	 */
1926 1926
 	private function _get_payment_method_for_selected_method_of_payment() {
1927
-		if ( $this->checkout->selected_method_of_payment === 'events_sold_out' ) {
1927
+		if ($this->checkout->selected_method_of_payment === 'events_sold_out') {
1928 1928
 			$this->_redirect_because_event_sold_out();
1929 1929
 			return null;
1930 1930
 		}
1931 1931
 		// get EE_Payment_Method object
1932
-		if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) {
1933
-			$payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ];
1932
+		if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) {
1933
+			$payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment];
1934 1934
 		} else {
1935 1935
 			// load EEM_Payment_Method
1936
-			EE_Registry::instance()->load_model( 'Payment_Method' );
1936
+			EE_Registry::instance()->load_model('Payment_Method');
1937 1937
 			/** @type EEM_Payment_Method $EEM_Payment_Method */
1938 1938
 			$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
1939
-			$payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment );
1939
+			$payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment);
1940 1940
 		}
1941 1941
 		// verify $payment_method
1942
-		if ( ! $payment_method instanceof EE_Payment_Method ) {
1942
+		if ( ! $payment_method instanceof EE_Payment_Method) {
1943 1943
 			// not a payment
1944 1944
 			EE_Error::add_error(
1945 1945
 				sprintf(
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
 						'event_espresso'
1949 1949
 					),
1950 1950
 					'<br/>',
1951
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1951
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1952 1952
 				),
1953 1953
 				__FILE__,
1954 1954
 				__FUNCTION__,
@@ -1957,7 +1957,7 @@  discard block
 block discarded – undo
1957 1957
 			return null;
1958 1958
 		}
1959 1959
 		// and verify it has a valid Payment_Method Type object
1960
-		if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) {
1960
+		if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) {
1961 1961
 			// not a payment
1962 1962
 			EE_Error::add_error(
1963 1963
 				sprintf(
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
 						'event_espresso'
1967 1967
 					),
1968 1968
 					'<br/>',
1969
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1969
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1970 1970
 				),
1971 1971
 				__FILE__,
1972 1972
 				__FUNCTION__,
@@ -1987,29 +1987,29 @@  discard block
 block discarded – undo
1987 1987
 	 * @return    mixed    EE_Payment | boolean
1988 1988
 	 * @throws \EE_Error
1989 1989
 	 */
1990
-	private function _attempt_payment( EE_Payment_Method $payment_method ) {
1990
+	private function _attempt_payment(EE_Payment_Method $payment_method) {
1991 1991
 		$payment = null;
1992 1992
 		$this->checkout->transaction->save();
1993
-		$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1994
-		if ( ! $payment_processor instanceof EE_Payment_Processor ) {
1993
+		$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1994
+		if ( ! $payment_processor instanceof EE_Payment_Processor) {
1995 1995
 			return false;
1996 1996
 		}
1997 1997
 		try {
1998
-			$payment_processor->set_revisit( $this->checkout->revisit );
1998
+			$payment_processor->set_revisit($this->checkout->revisit);
1999 1999
 			// generate payment object
2000 2000
 			$payment = $payment_processor->process_payment(
2001 2001
 				$payment_method,
2002 2002
 				$this->checkout->transaction,
2003 2003
 				$this->checkout->amount_owing,
2004 2004
 				$this->checkout->billing_form,
2005
-				$this->_get_return_url( $payment_method ),
2005
+				$this->_get_return_url($payment_method),
2006 2006
 				'CART',
2007 2007
 				$this->checkout->admin_request,
2008 2008
 				true,
2009 2009
 				$this->reg_step_url()
2010 2010
 			);
2011
-		} catch ( Exception $e ) {
2012
-			$this->_handle_payment_processor_exception( $e );
2011
+		} catch (Exception $e) {
2012
+			$this->_handle_payment_processor_exception($e);
2013 2013
 		}
2014 2014
 		return $payment;
2015 2015
 	}
@@ -2024,7 +2024,7 @@  discard block
 block discarded – undo
2024 2024
 	 * @return void
2025 2025
 	 * @throws \EE_Error
2026 2026
 	 */
2027
-	protected function _handle_payment_processor_exception( Exception $e ) {
2027
+	protected function _handle_payment_processor_exception(Exception $e) {
2028 2028
 		EE_Error::add_error(
2029 2029
 			sprintf(
2030 2030
 				__(
@@ -2032,7 +2032,7 @@  discard block
 block discarded – undo
2032 2032
 					'event_espresso'
2033 2033
 				),
2034 2034
 				'<br/>',
2035
-				EE_Registry::instance()->CFG->organization->get_pretty( 'email' ),
2035
+				EE_Registry::instance()->CFG->organization->get_pretty('email'),
2036 2036
 				$e->getMessage(),
2037 2037
 				$e->getFile(),
2038 2038
 				$e->getLine()
@@ -2053,9 +2053,9 @@  discard block
 block discarded – undo
2053 2053
 	 * @return string
2054 2054
 	 * @throws \EE_Error
2055 2055
 	 */
2056
-	protected function _get_return_url( EE_Payment_Method $payment_method ) {
2056
+	protected function _get_return_url(EE_Payment_Method $payment_method) {
2057 2057
 		$return_url = '';
2058
-		switch ( $payment_method->type_obj()->payment_occurs() ) {
2058
+		switch ($payment_method->type_obj()->payment_occurs()) {
2059 2059
 			case EE_PMT_Base::offsite :
2060 2060
 				$return_url = add_query_arg(
2061 2061
 					array(
@@ -2084,12 +2084,12 @@  discard block
 block discarded – undo
2084 2084
 	 * @return EE_Payment | FALSE
2085 2085
 	 * @throws \EE_Error
2086 2086
 	 */
2087
-	private function _validate_payment( $payment = null ) {
2088
-		if ( $this->checkout->payment_method->is_off_line() ) {
2087
+	private function _validate_payment($payment = null) {
2088
+		if ($this->checkout->payment_method->is_off_line()) {
2089 2089
 			return true;
2090 2090
 		}
2091 2091
 		// verify payment object
2092
-		if ( ! $payment instanceof EE_Payment ) {
2092
+		if ( ! $payment instanceof EE_Payment) {
2093 2093
 			// not a payment
2094 2094
 			EE_Error::add_error(
2095 2095
 				sprintf(
@@ -2098,7 +2098,7 @@  discard block
 block discarded – undo
2098 2098
 						'event_espresso'
2099 2099
 					),
2100 2100
 					'<br/>',
2101
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2101
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2102 2102
 				),
2103 2103
 				__FILE__,
2104 2104
 				__FUNCTION__,
@@ -2119,27 +2119,27 @@  discard block
 block discarded – undo
2119 2119
 	 * @return bool
2120 2120
 	 * @throws \EE_Error
2121 2121
 	 */
2122
-	private function _post_payment_processing( $payment = null ) {
2122
+	private function _post_payment_processing($payment = null) {
2123 2123
 		// Off-Line payment?
2124
-		if ( $payment === true ) {
2124
+		if ($payment === true) {
2125 2125
 			//$this->_setup_redirect_for_next_step();
2126 2126
 			return true;
2127 2127
 		// On-Site payment?
2128
-		} else if ( $this->checkout->payment_method->is_on_site() ) {
2129
-			if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) {
2128
+		} else if ($this->checkout->payment_method->is_on_site()) {
2129
+			if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
2130 2130
 				//$this->_setup_redirect_for_next_step();
2131 2131
 				$this->checkout->continue_reg = false;
2132 2132
 			}
2133 2133
 		// Off-Site payment?
2134
-		} else if ( $this->checkout->payment_method->is_off_site() ) {
2134
+		} else if ($this->checkout->payment_method->is_off_site()) {
2135 2135
 			// if a payment object was made and it specifies a redirect url, then we'll setup that redirect info
2136
-			if ( $payment instanceof EE_Payment && $payment->redirect_url() ) {
2137
-				do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' );
2136
+			if ($payment instanceof EE_Payment && $payment->redirect_url()) {
2137
+				do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()');
2138 2138
 				$this->checkout->redirect = true;
2139 2139
 				$this->checkout->redirect_form = $payment->redirect_form();
2140
-				$this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' );
2140
+				$this->checkout->redirect_url = $this->reg_step_url('redirect_form');
2141 2141
 				// set JSON response
2142
-				$this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form );
2142
+				$this->checkout->json_response->set_redirect_form($this->checkout->redirect_form);
2143 2143
 				// set cron job for finalizing the TXN
2144 2144
 				// in case the user does not return from the off-site gateway
2145 2145
 				EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
@@ -2147,7 +2147,7 @@  discard block
 block discarded – undo
2147 2147
 					$this->checkout->transaction->ID()
2148 2148
 				);
2149 2149
 				// and lastly, let's bump the payment status to pending
2150
-				$payment->set_status( EEM_Payment::status_id_pending );
2150
+				$payment->set_status(EEM_Payment::status_id_pending);
2151 2151
 				$payment->save();
2152 2152
 			} else {
2153 2153
 				// not a payment
@@ -2159,7 +2159,7 @@  discard block
 block discarded – undo
2159 2159
 							'event_espresso'
2160 2160
 						),
2161 2161
 						'<br/>',
2162
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2162
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
2163 2163
 					),
2164 2164
 					__FILE__,
2165 2165
 					__FUNCTION__,
@@ -2197,21 +2197,21 @@  discard block
 block discarded – undo
2197 2197
 	 * @return bool
2198 2198
 	 * @throws \EE_Error
2199 2199
 	 */
2200
-	private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) {
2200
+	private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) {
2201 2201
 		// off-line payment? carry on
2202
-		if ( $payment_occurs === EE_PMT_Base::offline ) {
2202
+		if ($payment_occurs === EE_PMT_Base::offline) {
2203 2203
 			return true;
2204 2204
 		}
2205 2205
 		// verify payment validity
2206
-		if ( $payment instanceof EE_Payment ) {
2207
-			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' );
2206
+		if ($payment instanceof EE_Payment) {
2207
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()');
2208 2208
 			$msg = $payment->gateway_response();
2209 2209
 			// check results
2210
-			switch ( $payment->status() ) {
2210
+			switch ($payment->status()) {
2211 2211
 				// good payment
2212 2212
 				case EEM_Payment::status_id_approved :
2213 2213
 					EE_Error::add_success(
2214
-						__( 'Your payment was processed successfully.', 'event_espresso' ),
2214
+						__('Your payment was processed successfully.', 'event_espresso'),
2215 2215
 						__FILE__,
2216 2216
 						__FUNCTION__,
2217 2217
 						__LINE__
@@ -2220,45 +2220,45 @@  discard block
 block discarded – undo
2220 2220
 					break;
2221 2221
 				// slow payment
2222 2222
 				case EEM_Payment::status_id_pending :
2223
-					if ( empty( $msg ) ) {
2223
+					if (empty($msg)) {
2224 2224
 						$msg = __(
2225 2225
 							'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.',
2226 2226
 							'event_espresso'
2227 2227
 						);
2228 2228
 					}
2229
-					EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ );
2229
+					EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
2230 2230
 					return true;
2231 2231
 					break;
2232 2232
 				// don't wanna payment
2233 2233
 				case EEM_Payment::status_id_cancelled :
2234
-					if ( empty( $msg ) ) {
2234
+					if (empty($msg)) {
2235 2235
 						$msg = _n(
2236 2236
 							'Payment cancelled. Please try again.',
2237 2237
 							'Payment cancelled. Please try again or select another method of payment.',
2238
-							count( $this->checkout->available_payment_methods ),
2238
+							count($this->checkout->available_payment_methods),
2239 2239
 							'event_espresso'
2240 2240
 						);
2241 2241
 					}
2242
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
2242
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2243 2243
 					return false;
2244 2244
 					break;
2245 2245
 				// not enough payment
2246 2246
 				case EEM_Payment::status_id_declined :
2247
-					if ( empty( $msg ) ) {
2247
+					if (empty($msg)) {
2248 2248
 						$msg = _n(
2249 2249
 							'We\'re sorry but your payment was declined. Please try again.',
2250 2250
 							'We\'re sorry but your payment was declined. Please try again or select another method of payment.',
2251
-							count( $this->checkout->available_payment_methods ),
2251
+							count($this->checkout->available_payment_methods),
2252 2252
 							'event_espresso'
2253 2253
 						);
2254 2254
 					}
2255
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
2255
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2256 2256
 					return false;
2257 2257
 					break;
2258 2258
 				// bad payment
2259 2259
 				case EEM_Payment::status_id_failed :
2260
-					if ( ! empty( $msg ) ) {
2261
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2260
+					if ( ! empty($msg)) {
2261
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2262 2262
 						return false;
2263 2263
 					}
2264 2264
 					// default to error below
@@ -2267,7 +2267,7 @@  discard block
 block discarded – undo
2267 2267
 		}
2268 2268
 		// off-site payment gateway responses are too unreliable, so let's just assume that
2269 2269
 		// the payment processing is just running slower than the registrant's request
2270
-		if ( $payment_occurs === EE_PMT_Base::offsite ) {
2270
+		if ($payment_occurs === EE_PMT_Base::offsite) {
2271 2271
 			return true;
2272 2272
 		}
2273 2273
 		EE_Error::add_error(
@@ -2277,7 +2277,7 @@  discard block
 block discarded – undo
2277 2277
 					'event_espresso'
2278 2278
 				),
2279 2279
 				'<br/>',
2280
-				EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2280
+				EE_Registry::instance()->CFG->organization->get_pretty('email')
2281 2281
 			),
2282 2282
 			__FILE__,
2283 2283
 			__FUNCTION__,
@@ -2310,13 +2310,13 @@  discard block
 block discarded – undo
2310 2310
 	public function process_gateway_response() {
2311 2311
 		$payment = null;
2312 2312
 		// how have they chosen to pay?
2313
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
2313
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
2314 2314
 		// get EE_Payment_Method object
2315
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
2315
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
2316 2316
 			$this->checkout->continue_reg = false;
2317 2317
 			return false;
2318 2318
 		}
2319
-		if ( ! $this->checkout->payment_method->is_off_site() ) {
2319
+		if ( ! $this->checkout->payment_method->is_off_site()) {
2320 2320
 			return false;
2321 2321
 		}
2322 2322
 		$this->_validate_offsite_return();
@@ -2330,23 +2330,23 @@  discard block
 block discarded – undo
2330 2330
 		//	true
2331 2331
 		//);
2332 2332
 		// verify TXN
2333
-		if ( $this->checkout->transaction instanceof EE_Transaction ) {
2333
+		if ($this->checkout->transaction instanceof EE_Transaction) {
2334 2334
 			$gateway = $this->checkout->payment_method->type_obj()->get_gateway();
2335
-			if ( ! $gateway instanceof EE_Offsite_Gateway ) {
2335
+			if ( ! $gateway instanceof EE_Offsite_Gateway) {
2336 2336
 				$this->checkout->continue_reg = false;
2337 2337
 				return false;
2338 2338
 			}
2339
-			$payment = $this->_process_off_site_payment( $gateway );
2340
-			$payment = $this->_process_cancelled_payments( $payment );
2341
-			$payment = $this->_validate_payment( $payment );
2339
+			$payment = $this->_process_off_site_payment($gateway);
2340
+			$payment = $this->_process_cancelled_payments($payment);
2341
+			$payment = $this->_validate_payment($payment);
2342 2342
 			// if payment was not declined by the payment gateway or cancelled by the registrant
2343
-			if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) {
2343
+			if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) {
2344 2344
 				//$this->_setup_redirect_for_next_step();
2345 2345
 				// store that for later
2346 2346
 				$this->checkout->payment = $payment;
2347 2347
 				// mark this reg step as completed, as long as gateway doesn't use a separate IPN request,
2348 2348
 				// because we will complete this step during the IPN processing then
2349
-				if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) {
2349
+				if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) {
2350 2350
 					$this->set_completed();
2351 2351
 				}
2352 2352
 				return true;
@@ -2370,21 +2370,21 @@  discard block
 block discarded – undo
2370 2370
 	 * @throws \EE_Error
2371 2371
 	 */
2372 2372
 	private function _validate_offsite_return() {
2373
-		$TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 );
2374
-		if ( $TXN_ID !== $this->checkout->transaction->ID() ) {
2373
+		$TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0);
2374
+		if ($TXN_ID !== $this->checkout->transaction->ID()) {
2375 2375
 			// Houston... we might have a problem
2376 2376
 			$invalid_TXN = false;
2377 2377
 			// first gather some info
2378
-			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
2378
+			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2379 2379
 			$primary_registrant = $valid_TXN instanceof EE_Transaction
2380 2380
 				? $valid_TXN->primary_registration()
2381 2381
 				: null;
2382 2382
 			// let's start by retrieving the cart for this TXN
2383
-			$cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction );
2384
-			if ( $cart instanceof EE_Cart ) {
2383
+			$cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction);
2384
+			if ($cart instanceof EE_Cart) {
2385 2385
 				// verify that the current cart has tickets
2386 2386
 				$tickets = $cart->get_tickets();
2387
-				if ( empty( $tickets ) ) {
2387
+				if (empty($tickets)) {
2388 2388
 					$invalid_TXN = true;
2389 2389
 				}
2390 2390
 			} else {
@@ -2394,35 +2394,35 @@  discard block
 block discarded – undo
2394 2394
 				? $primary_registrant->session_ID()
2395 2395
 				: null;
2396 2396
 			// validate current Session ID and compare against valid TXN session ID
2397
-			if ( EE_Session::instance()->id() === null ) {
2397
+			if (EE_Session::instance()->id() === null) {
2398 2398
 				$invalid_TXN = true;
2399
-			} else if ( EE_Session::instance()->id() === $valid_TXN_SID ) {
2399
+			} else if (EE_Session::instance()->id() === $valid_TXN_SID) {
2400 2400
 				// WARNING !!!
2401 2401
 				// this could be PayPal sending back duplicate requests (ya they do that)
2402 2402
 				// or it **could** mean someone is simply registering AGAIN after having just done so
2403 2403
 				// so now we need to determine if this current TXN looks valid or not
2404 2404
 				// has this step even been started ?
2405
-				if ( $this->checkout->transaction->reg_step_completed( $this->slug() === false )
2405
+				if ($this->checkout->transaction->reg_step_completed($this->slug() === false)
2406 2406
 				) {
2407 2407
 					// really? you're half way through this reg step, but you never started it ?
2408 2408
 					$invalid_TXN = true;
2409 2409
 				}
2410 2410
 			}
2411
-			if ( $invalid_TXN ) {
2411
+			if ($invalid_TXN) {
2412 2412
 				// is the valid TXN completed ?
2413
-				if ( $valid_TXN instanceof EE_Transaction ) {
2413
+				if ($valid_TXN instanceof EE_Transaction) {
2414 2414
 					// has this step even been started ?
2415
-					$reg_step_completed = $valid_TXN->reg_step_completed( $this->slug() );
2416
-					if ( $reg_step_completed !== false && $reg_step_completed !== true ) {
2415
+					$reg_step_completed = $valid_TXN->reg_step_completed($this->slug());
2416
+					if ($reg_step_completed !== false && $reg_step_completed !== true) {
2417 2417
 						// so it **looks** like this is a double request from PayPal
2418 2418
 						// so let's try to pick up where we left off
2419 2419
 						$this->checkout->transaction = $valid_TXN;
2420
-						$this->checkout->refresh_all_entities( true );
2420
+						$this->checkout->refresh_all_entities(true);
2421 2421
 						return;
2422 2422
 					}
2423 2423
 				}
2424 2424
 				// you appear to be lost?
2425
-				$this->_redirect_wayward_request( $primary_registrant );
2425
+				$this->_redirect_wayward_request($primary_registrant);
2426 2426
 			}
2427 2427
 		}
2428 2428
 	}
@@ -2437,14 +2437,14 @@  discard block
 block discarded – undo
2437 2437
 	 * @return bool
2438 2438
 	 * @throws \EE_Error
2439 2439
 	 */
2440
-	private function _redirect_wayward_request( EE_Registration $primary_registrant ) {
2441
-		if ( ! $primary_registrant instanceof EE_Registration ) {
2440
+	private function _redirect_wayward_request(EE_Registration $primary_registrant) {
2441
+		if ( ! $primary_registrant instanceof EE_Registration) {
2442 2442
 			// try redirecting based on the current TXN
2443 2443
 			$primary_registrant = $this->checkout->transaction instanceof EE_Transaction
2444 2444
 				? $this->checkout->transaction->primary_registration()
2445 2445
 				: null;
2446 2446
 		}
2447
-		if ( ! $primary_registrant instanceof EE_Registration ) {
2447
+		if ( ! $primary_registrant instanceof EE_Registration) {
2448 2448
 			EE_Error::add_error(
2449 2449
 				sprintf(
2450 2450
 					__(
@@ -2452,7 +2452,7 @@  discard block
 block discarded – undo
2452 2452
 						'event_espresso'
2453 2453
 					),
2454 2454
 					'<br/>',
2455
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2455
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2456 2456
 				),
2457 2457
 				__FILE__,
2458 2458
 				__FUNCTION__,
@@ -2483,17 +2483,17 @@  discard block
 block discarded – undo
2483 2483
 	 * @return \EE_Payment
2484 2484
 	 * @throws \EE_Error
2485 2485
 	 */
2486
-	private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) {
2486
+	private function _process_off_site_payment(EE_Offsite_Gateway $gateway) {
2487 2487
 		try {
2488 2488
 			$request_data = \EE_Registry::instance()->REQ->params();
2489 2489
 			// if gateway uses_separate_IPN_request, then we don't have to process the IPN manually
2490 2490
 			$this->set_handle_IPN_in_this_request(
2491
-				$gateway->handle_IPN_in_this_request( $request_data, false )
2491
+				$gateway->handle_IPN_in_this_request($request_data, false)
2492 2492
 			);
2493
-			if ( $this->handle_IPN_in_this_request() ) {
2493
+			if ($this->handle_IPN_in_this_request()) {
2494 2494
 				// get payment details and process results
2495 2495
 				/** @type EE_Payment_Processor $payment_processor */
2496
-				$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
2496
+				$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2497 2497
 				$payment = $payment_processor->process_ipn(
2498 2498
 					$request_data,
2499 2499
 					$this->checkout->transaction,
@@ -2506,14 +2506,14 @@  discard block
 block discarded – undo
2506 2506
 				$payment = $this->checkout->transaction->last_payment();
2507 2507
 				//$payment_source = 'last_payment';
2508 2508
 			}
2509
-		} catch ( Exception $e ) {
2509
+		} catch (Exception $e) {
2510 2510
 			// let's just eat the exception and try to move on using any previously set payment info
2511 2511
 			$payment = $this->checkout->transaction->last_payment();
2512 2512
 			//$payment_source = 'last_payment after Exception';
2513 2513
 			// but if we STILL don't have a payment object
2514
-			if ( ! $payment instanceof EE_Payment ) {
2514
+			if ( ! $payment instanceof EE_Payment) {
2515 2515
 				// then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
2516
-				$this->_handle_payment_processor_exception( $e );
2516
+				$this->_handle_payment_processor_exception($e);
2517 2517
 			}
2518 2518
 		}
2519 2519
 		// DEBUG LOG
@@ -2538,13 +2538,13 @@  discard block
 block discarded – undo
2538 2538
 	 * @return EE_Payment | FALSE
2539 2539
 	 * @throws \EE_Error
2540 2540
 	 */
2541
-	private function _process_cancelled_payments( $payment = null ) {
2541
+	private function _process_cancelled_payments($payment = null) {
2542 2542
 		if (
2543 2543
 			$payment instanceof EE_Payment
2544
-			&& isset( $_REQUEST['ee_cancel_payment'] )
2544
+			&& isset($_REQUEST['ee_cancel_payment'])
2545 2545
 			&& $payment->status() === EEM_Payment::status_id_failed
2546 2546
 		) {
2547
-			$payment->set_status( EEM_Payment::status_id_cancelled );
2547
+			$payment->set_status(EEM_Payment::status_id_cancelled);
2548 2548
 		}
2549 2549
 		return $payment;
2550 2550
 	}
@@ -2561,14 +2561,14 @@  discard block
 block discarded – undo
2561 2561
 	public function get_transaction_details_for_gateways() {
2562 2562
 		$txn_details = array();
2563 2563
 		// ya gotta make a choice man
2564
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
2564
+		if (empty($this->checkout->selected_method_of_payment)) {
2565 2565
 			$txn_details = array(
2566
-				'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' )
2566
+				'error' => __('Please select a method of payment before proceeding.', 'event_espresso')
2567 2567
 			);
2568 2568
 		}
2569 2569
 		// get EE_Payment_Method object
2570 2570
 		if (
2571
-			empty( $txn_details )
2571
+			empty($txn_details)
2572 2572
 			&&
2573 2573
 			! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()
2574 2574
 		) {
@@ -2580,8 +2580,8 @@  discard block
 block discarded – undo
2580 2580
 				)
2581 2581
 			);
2582 2582
 		}
2583
-		if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) {
2584
-			$return_url = $this->_get_return_url( $this->checkout->payment_method );
2583
+		if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) {
2584
+			$return_url = $this->_get_return_url($this->checkout->payment_method);
2585 2585
 			$txn_details = array(
2586 2586
 				'TXN_ID'         => $this->checkout->transaction->ID(),
2587 2587
 				'TXN_timestamp'  => $this->checkout->transaction->datetime(),
@@ -2592,7 +2592,7 @@  discard block
 block discarded – undo
2592 2592
 				'PMD_ID'         => $this->checkout->transaction->payment_method_ID(),
2593 2593
 				'payment_amount' => $this->checkout->amount_owing,
2594 2594
 				'return_url'     => $return_url,
2595
-				'cancel_url'     => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ),
2595
+				'cancel_url'     => add_query_arg(array('ee_cancel_payment' => true), $return_url),
2596 2596
 				'notify_url'     => EE_Config::instance()->core->txn_page_url(
2597 2597
 					array(
2598 2598
 						'e_reg_url_link'    => $this->checkout->transaction->primary_registration()->reg_url_link(),
@@ -2601,7 +2601,7 @@  discard block
 block discarded – undo
2601 2601
 				)
2602 2602
 			);
2603 2603
 		}
2604
-		echo json_encode( $txn_details );
2604
+		echo json_encode($txn_details);
2605 2605
 		exit();
2606 2606
 	}
2607 2607
 
@@ -2618,7 +2618,7 @@  discard block
 block discarded – undo
2618 2618
     public function __sleep()
2619 2619
     {
2620 2620
         // remove the reg form and the checkout
2621
-        return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) );
2621
+        return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display'));
2622 2622
     }
2623 2623
 
2624 2624
 
Please login to merge, or discard this patch.
modules/invalid_checkout_access/EED_Invalid_Checkout_Access.module.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use EventEspresso\modules\invalid_checkout_access\InvalidCheckoutAccess;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	public static function set_hooks_admin() {
37 37
 		add_action(
38 38
 			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
39
-			array( 'EED_Invalid_Checkout_Access', 'display_invalid_checkout_access_form' ),
39
+			array('EED_Invalid_Checkout_Access', 'display_invalid_checkout_access_form'),
40 40
 			15
41 41
 		);
42 42
 		add_filter(
43 43
 			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
44
-			array( 'EED_Invalid_Checkout_Access', 'process_invalid_checkout_access_form' )
44
+			array('EED_Invalid_Checkout_Access', 'process_invalid_checkout_access_form')
45 45
 		);
46 46
 	}
47 47
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @var WP $WP
55 55
 	 */
56
-	public function run( $WP ) {
56
+	public function run($WP) {
57 57
 		// TODO: Implement run() method.
58 58
 	}
59 59
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @return InvalidCheckoutAccess
64 64
 	 */
65 65
 	public static function getInvalidCheckoutAccess() {
66
-		if ( ! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess ) {
66
+		if ( ! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) {
67 67
 			self::$invalid_checkout_access_form = new InvalidCheckoutAccess();
68 68
 		}
69 69
 		return self::$invalid_checkout_access_form;
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	 * @param \EE_Registration_Config $EE_Registration_Config
91 91
 	 * @return \EE_Registration_Config
92 92
 	 */
93
-	public static function process_invalid_checkout_access_form( \EE_Registration_Config $EE_Registration_Config ) {
93
+	public static function process_invalid_checkout_access_form(\EE_Registration_Config $EE_Registration_Config) {
94 94
 		$invalid_checkout_access_form = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
95
-		return $invalid_checkout_access_form->processForm( $EE_Registration_Config );
95
+		return $invalid_checkout_access_form->processForm($EE_Registration_Config);
96 96
 	}
97 97
 
98 98
 
Please login to merge, or discard this patch.
core/EE_Session.core.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -341,7 +341,7 @@
 block discarded – undo
341 341
 		}
342 342
 		 if ( ! empty( $key ))  {
343 343
 			return  isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL;
344
-		}  else  {
344
+		} else  {
345 345
 			return $this->_session_data;
346 346
 		}
347 347
 	}
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 				}
415 415
 			}
416 416
 			// decode the data ?
417
-            $session_data = $this->valid_base_64($session_data) ? base64_decode($session_data) : $session_data;
417
+			$session_data = $this->valid_base_64($session_data) ? base64_decode($session_data) : $session_data;
418 418
 			// un-encrypt the data ?
419 419
 			$session_data = $this->_use_encryption ? $this->encryption->decrypt( $session_data ) : $session_data;
420 420
 			if ( ! is_array( $session_data ) ) {
@@ -684,12 +684,12 @@  discard block
 block discarded – undo
684 684
 		) {
685 685
 			return false;
686 686
 		}
687
-        // then serialize all of our session data
688
-        $session_data = serialize($this->_session_data);
689
-        // do we need to also encode it to avoid corrupted data when saved to the db?
690
-        if (EE_Registry::instance()->CFG->admin->encode_session_data()) {
691
-            $session_data = base64_encode($session_data);
692
-        }
687
+		// then serialize all of our session data
688
+		$session_data = serialize($this->_session_data);
689
+		// do we need to also encode it to avoid corrupted data when saved to the db?
690
+		if (EE_Registry::instance()->CFG->admin->encode_session_data()) {
691
+			$session_data = base64_encode($session_data);
692
+		}
693 693
 		// encrypt it if we are using encryption
694 694
 		$session_data = $this->_use_encryption ? $this->encryption->encrypt( $session_data ) : $session_data;
695 695
 		// maybe save hash check
@@ -969,10 +969,10 @@  discard block
 block discarded – undo
969 969
 	  * @return bool
970 970
 	  */
971 971
 	 private function valid_base_64( $string ) {
972
-         // ensure data is a string
973
-         if ( ! is_string($string)) {
974
-             return false;
975
-         }
972
+		 // ensure data is a string
973
+		 if ( ! is_string($string)) {
974
+			 return false;
975
+		 }
976 976
 		 $decoded = base64_decode( $string, true );
977 977
 		 // Check if there is no invalid character in string
978 978
 		 if ( ! preg_match( '/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string ) ) {
Please login to merge, or discard this patch.
Spacing   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\exceptions\InvalidSessionDataException;
2 2
 
3
-if (!defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
4 4
 /**
5 5
  *
6 6
  * EE_Session class
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	  * array for defining default session vars
92 92
 	  * @var array
93 93
 	  */
94
-	 private $_default_session_vars = array (
94
+	 private $_default_session_vars = array(
95 95
 		'id' => NULL,
96 96
 		'user_id' => NULL,
97 97
 		'ip_address' => NULL,
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
 	  * @throws InvalidSessionDataException
112 112
 	  * @throws \EE_Error
113 113
 	  */
114
-	public static function instance( EE_Encryption $encryption = null ) {
114
+	public static function instance(EE_Encryption $encryption = null) {
115 115
 		// check if class object is instantiated
116 116
 		// session loading is turned ON by default, but prior to the init hook, can be turned back OFF via:
117 117
 		// add_filter( 'FHEE_load_EE_Session', '__return_false' );
118
-		if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) {
119
-			self::$_instance = new self( $encryption );
118
+		if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) {
119
+			self::$_instance = new self($encryption);
120 120
 		}
121 121
 		return self::$_instance;
122 122
 	}
@@ -132,15 +132,15 @@  discard block
 block discarded – undo
132 132
 	  * @throws \EE_Error
133 133
 	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
134 134
 	  */
135
-	 protected function __construct( EE_Encryption $encryption = null ) {
135
+	 protected function __construct(EE_Encryption $encryption = null) {
136 136
 
137 137
 		// session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' );
138
-		if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) {
138
+		if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) {
139 139
 			return;
140 140
 		}
141
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
142
-		if ( ! defined( 'ESPRESSO_SESSION' ) ) {
143
-			define( 'ESPRESSO_SESSION', true );
141
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
142
+		if ( ! defined('ESPRESSO_SESSION')) {
143
+			define('ESPRESSO_SESSION', true);
144 144
 		}
145 145
 		// default session lifespan in seconds
146 146
 		$this->_lifespan = apply_filters(
@@ -154,36 +154,36 @@  discard block
 block discarded – undo
154 154
 		 * 		}
155 155
 		 */
156 156
 		// retrieve session options from db
157
-		$session_settings = get_option( 'ee_session_settings' );
158
-		if ( $session_settings !== FALSE ) {
157
+		$session_settings = get_option('ee_session_settings');
158
+		if ($session_settings !== FALSE) {
159 159
 			// cycle though existing session options
160
-			foreach ( $session_settings as $var_name => $session_setting ) {
160
+			foreach ($session_settings as $var_name => $session_setting) {
161 161
 				// set values for class properties
162
-				$var_name = '_' . $var_name;
162
+				$var_name = '_'.$var_name;
163 163
 				$this->{$var_name} = $session_setting;
164 164
 			}
165 165
 		}
166 166
 		// are we using encryption?
167
-		if ( $this->_use_encryption && $encryption instanceof EE_Encryption ) {
167
+		if ($this->_use_encryption && $encryption instanceof EE_Encryption) {
168 168
 			// encrypt data via: $this->encryption->encrypt();
169 169
 			$this->encryption = $encryption;
170 170
 		}
171 171
 		// filter hook allows outside functions/classes/plugins to change default empty cart
172
-		$extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() );
173
-		array_merge( $this->_default_session_vars, $extra_default_session_vars );
172
+		$extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array());
173
+		array_merge($this->_default_session_vars, $extra_default_session_vars);
174 174
 		// apply default session vars
175 175
 		$this->_set_defaults();
176 176
 		// check for existing session and retrieve it from db
177
-		if ( ! $this->_espresso_session() ) {
177
+		if ( ! $this->_espresso_session()) {
178 178
 			// or just start a new one
179 179
 			$this->_create_espresso_session();
180 180
 		}
181 181
 		// check request for 'clear_session' param
182
-		add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' ));
182
+		add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded'));
183 183
 		// once everything is all said and done,
184
-		add_action( 'shutdown', array( $this, 'update' ), 100 );
185
-		add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 );
186
-		add_filter( 'wp_redirect', array( $this, 'update_on_redirect' ), 100, 1 );
184
+		add_action('shutdown', array($this, 'update'), 100);
185
+		add_action('shutdown', array($this, 'garbage_collection'), 999);
186
+		add_filter('wp_redirect', array($this, 'update_on_redirect'), 100, 1);
187 187
 	}
188 188
 
189 189
 
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	private function _set_defaults() {
216 216
 		// set some defaults
217
-		foreach ( $this->_default_session_vars as $key => $default_var ) {
218
-			if ( is_array( $default_var )) {
219
-				$this->_session_data[ $key ] = array();
217
+		foreach ($this->_default_session_vars as $key => $default_var) {
218
+			if (is_array($default_var)) {
219
+				$this->_session_data[$key] = array();
220 220
 			} else {
221
-				$this->_session_data[ $key ] = '';
221
+				$this->_session_data[$key] = '';
222 222
 			}
223 223
 		}
224 224
 	}
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	  * @param \EE_Cart $cart
241 241
 	  * @return bool
242 242
 	  */
243
-	 public function set_cart( EE_Cart $cart ) {
243
+	 public function set_cart(EE_Cart $cart) {
244 244
 		 $this->_session_data['cart'] = $cart;
245 245
 		 return TRUE;
246 246
 	 }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	  * @return \EE_Cart
261 261
 	  */
262 262
 	 public function cart() {
263
-		 return isset( $this->_session_data['cart'] ) ? $this->_session_data['cart'] : NULL;
263
+		 return isset($this->_session_data['cart']) ? $this->_session_data['cart'] : NULL;
264 264
 	 }
265 265
 
266 266
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	  * @param \EE_Checkout $checkout
270 270
 	  * @return bool
271 271
 	  */
272
-	 public function set_checkout( EE_Checkout $checkout ) {
272
+	 public function set_checkout(EE_Checkout $checkout) {
273 273
 		 $this->_session_data['checkout'] = $checkout;
274 274
 		 return TRUE;
275 275
 	 }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	  * @return \EE_Checkout
290 290
 	  */
291 291
 	 public function checkout() {
292
-		 return isset( $this->_session_data['checkout'] ) ? $this->_session_data['checkout'] : NULL;
292
+		 return isset($this->_session_data['checkout']) ? $this->_session_data['checkout'] : NULL;
293 293
 	 }
294 294
 
295 295
 
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 	  * @return bool
300 300
 	  * @throws \EE_Error
301 301
 	  */
302
-	 public function set_transaction( EE_Transaction $transaction ) {
302
+	 public function set_transaction(EE_Transaction $transaction) {
303 303
 		 // first remove the session from the transaction before we save the transaction in the session
304
-		 $transaction->set_txn_session_data( NULL );
304
+		 $transaction->set_txn_session_data(NULL);
305 305
 		 $this->_session_data['transaction'] = $transaction;
306 306
 		 return TRUE;
307 307
 	 }
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	  * @return \EE_Transaction
322 322
 	  */
323 323
 	 public function transaction() {
324
-		 return isset( $this->_session_data['transaction'] ) ? $this->_session_data['transaction'] : NULL;
324
+		 return isset($this->_session_data['transaction']) ? $this->_session_data['transaction'] : NULL;
325 325
 	 }
326 326
 
327 327
 
@@ -333,15 +333,15 @@  discard block
 block discarded – undo
333 333
 	  * @param bool $reset_cache
334 334
 	  * @return    array
335 335
 	  */
336
-	public function get_session_data( $key = NULL, $reset_cache = FALSE ) {
337
-		if ( $reset_cache ) {
336
+	public function get_session_data($key = NULL, $reset_cache = FALSE) {
337
+		if ($reset_cache) {
338 338
 			$this->reset_cart();
339 339
 			$this->reset_checkout();
340 340
 			$this->reset_transaction();
341 341
 		}
342
-		 if ( ! empty( $key ))  {
343
-			return  isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL;
344
-		}  else  {
342
+		 if ( ! empty($key)) {
343
+			return  isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL;
344
+		} else {
345 345
 			return $this->_session_data;
346 346
 		}
347 347
 	}
@@ -354,20 +354,20 @@  discard block
 block discarded – undo
354 354
 	  * @param 	array $data
355 355
 	  * @return 	TRUE on success, FALSE on fail
356 356
 	  */
357
-	public function set_session_data( $data ) {
357
+	public function set_session_data($data) {
358 358
 
359 359
 		// nothing ??? bad data ??? go home!
360
-		if ( empty( $data ) || ! is_array( $data )) {
361
-			EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
360
+		if (empty($data) || ! is_array($data)) {
361
+			EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
362 362
 			return FALSE;
363 363
 		}
364 364
 
365
-		foreach ( $data as $key =>$value ) {
366
-			if ( isset( $this->_default_session_vars[ $key ] )) {
367
-				EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ );
365
+		foreach ($data as $key =>$value) {
366
+			if (isset($this->_default_session_vars[$key])) {
367
+				EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__);
368 368
 				return FALSE;
369 369
 			} else {
370
-				$this->_session_data[ $key ] = $value;
370
+				$this->_session_data[$key] = $value;
371 371
 			}
372 372
 		}
373 373
 
@@ -385,9 +385,9 @@  discard block
 block discarded – undo
385 385
 	  * @throws \EE_Error
386 386
 	  */
387 387
 	private function _espresso_session() {
388
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
388
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
389 389
 		// check that session has started
390
-		if ( session_id() === '' ) {
390
+		if (session_id() === '') {
391 391
 			//starts a new session if one doesn't already exist, or re-initiates an existing one
392 392
 			session_start();
393 393
 		}
@@ -396,18 +396,18 @@  discard block
 block discarded – undo
396 396
 		// and the visitors IP
397 397
 		$this->_ip_address = $this->_visitor_ip();
398 398
 		// set the "user agent"
399
-		$this->_user_agent = ( isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE;
399
+		$this->_user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE;
400 400
 		// now let's retrieve what's in the db
401 401
 		// we're using WP's Transient API to store session data using the PHP session ID as the option name
402
-		$session_data = get_transient( EE_Session::session_id_prefix . $this->_sid );
403
-		if ( $session_data ) {
404
-			if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
405
-				$hash_check = get_transient( EE_Session::hash_check_prefix . $this->_sid );
406
-				if ( $hash_check && $hash_check !== md5( $session_data ) ) {
402
+		$session_data = get_transient(EE_Session::session_id_prefix.$this->_sid);
403
+		if ($session_data) {
404
+			if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
405
+				$hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid);
406
+				if ($hash_check && $hash_check !== md5($session_data)) {
407 407
 					EE_Error::add_error(
408 408
 						sprintf(
409
-							__( 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso' ),
410
-							EE_Session::session_id_prefix . $this->_sid
409
+							__('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'),
410
+							EE_Session::session_id_prefix.$this->_sid
411 411
 						),
412 412
 						__FILE__, __FUNCTION__, __LINE__
413 413
 					);
@@ -416,33 +416,33 @@  discard block
 block discarded – undo
416 416
 			// decode the data ?
417 417
             $session_data = $this->valid_base_64($session_data) ? base64_decode($session_data) : $session_data;
418 418
 			// un-encrypt the data ?
419
-			$session_data = $this->_use_encryption ? $this->encryption->decrypt( $session_data ) : $session_data;
420
-			if ( ! is_array( $session_data ) ) {
419
+			$session_data = $this->_use_encryption ? $this->encryption->decrypt($session_data) : $session_data;
420
+			if ( ! is_array($session_data)) {
421 421
 				try {
422
-					$session_data = maybe_unserialize( $session_data );
423
-				} catch ( Exception $e ) {
422
+					$session_data = maybe_unserialize($session_data);
423
+				} catch (Exception $e) {
424 424
 					$msg = esc_html__(
425 425
 						'An error occurred while attempting to unserialize the session data.',
426 426
 						'event_espresso'
427 427
 					);
428
-					$msg .= WP_DEBUG ? '<br>' . $this->find_serialize_error( $session_data ) : '';
429
-					throw new InvalidSessionDataException( $msg, 0, $e );
428
+					$msg .= WP_DEBUG ? '<br>'.$this->find_serialize_error($session_data) : '';
429
+					throw new InvalidSessionDataException($msg, 0, $e);
430 430
 				}
431 431
 			}
432 432
 			// just a check to make sure the session array is indeed an array
433
-			if ( ! is_array( $session_data ) ) {
433
+			if ( ! is_array($session_data)) {
434 434
 				// no?!?! then something is wrong
435 435
 				$msg = esc_html__(
436 436
 					'The session data is missing, invalid, or corrupted.',
437 437
 					'event_espresso'
438 438
 				);
439
-				$msg .= WP_DEBUG ? '<br>' . $this->find_serialize_error( $session_data ) : '';
440
-				throw new InvalidSessionDataException( $msg );
439
+				$msg .= WP_DEBUG ? '<br>'.$this->find_serialize_error($session_data) : '';
440
+				throw new InvalidSessionDataException($msg);
441 441
 			}
442 442
 			// get the current time in UTC
443
-			$this->_time = isset( $this->_time ) ? $this->_time : time();
443
+			$this->_time = isset($this->_time) ? $this->_time : time();
444 444
 			// and reset the session expiration
445
-			$this->_expiration = isset( $session_data['expiration'] )
445
+			$this->_expiration = isset($session_data['expiration'])
446 446
 				? $session_data['expiration']
447 447
 				: $this->_time + $this->_lifespan;
448 448
 
@@ -450,24 +450,24 @@  discard block
 block discarded – undo
450 450
 			// set initial site access time and the session expiration
451 451
 			$this->_set_init_access_and_expiration();
452 452
 			// set referer
453
-			$this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] )
454
-				? esc_attr( $_SERVER['HTTP_REFERER'] )
453
+			$this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER'])
454
+				? esc_attr($_SERVER['HTTP_REFERER'])
455 455
 				: '';
456 456
 			// no previous session = go back and create one (on top of the data above)
457 457
 			return FALSE;
458 458
 		}
459 459
 		// now the user agent
460
-		if ( $session_data['user_agent'] !== $this->_user_agent ) {
460
+		if ($session_data['user_agent'] !== $this->_user_agent) {
461 461
 			return FALSE;
462 462
 		}
463 463
 		// wait a minute... how old are you?
464
-		if ( $this->_time > $this->_expiration ) {
464
+		if ($this->_time > $this->_expiration) {
465 465
 			// yer too old fer me!
466 466
 			// wipe out everything that isn't a default session datum
467
-			$this->clear_session( __CLASS__, __FUNCTION__ );
467
+			$this->clear_session(__CLASS__, __FUNCTION__);
468 468
 		}
469 469
 		// make event espresso session data available to plugin
470
-		$this->_session_data = array_merge( $this->_session_data, $session_data );
470
+		$this->_session_data = array_merge($this->_session_data, $session_data);
471 471
 		return TRUE;
472 472
 
473 473
 	}
@@ -485,12 +485,12 @@  discard block
 block discarded – undo
485 485
 	  */
486 486
 	protected function _generate_session_id() {
487 487
 		// check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length
488
-		if ( isset( $_REQUEST[ 'EESID' ] ) ) {
489
-			$session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] );
488
+		if (isset($_REQUEST['EESID'])) {
489
+			$session_id = sanitize_text_field($_REQUEST['EESID']);
490 490
 		} else {
491
-			$session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() );
491
+			$session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt());
492 492
 		}
493
-		return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id );
493
+		return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
494 494
 	}
495 495
 
496 496
 
@@ -502,20 +502,20 @@  discard block
 block discarded – undo
502 502
 	  */
503 503
 	protected function _get_sid_salt() {
504 504
 		// was session id salt already saved to db ?
505
-		if ( empty( $this->_sid_salt ) ) {
505
+		if (empty($this->_sid_salt)) {
506 506
 			// no?  then maybe use WP defined constant
507
-			if ( defined( 'AUTH_SALT' ) ) {
507
+			if (defined('AUTH_SALT')) {
508 508
 				$this->_sid_salt = AUTH_SALT;
509 509
 			}
510 510
 			// if salt doesn't exist or is too short
511
-			if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) {
511
+			if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) {
512 512
 				// create a new one
513
-				$this->_sid_salt = wp_generate_password( 64 );
513
+				$this->_sid_salt = wp_generate_password(64);
514 514
 			}
515 515
 			// and save it as a permanent session setting
516
-			$session_settings = get_option( 'ee_session_settings' );
517
-			$session_settings[ 'sid_salt' ] = $this->_sid_salt;
518
-			update_option( 'ee_session_settings', $session_settings );
516
+			$session_settings = get_option('ee_session_settings');
517
+			$session_settings['sid_salt'] = $this->_sid_salt;
518
+			update_option('ee_session_settings', $session_settings);
519 519
 		}
520 520
 		return $this->_sid_salt;
521 521
 	}
@@ -543,19 +543,19 @@  discard block
 block discarded – undo
543 543
 	  * @param bool $new_session
544 544
 	  * @return TRUE on success, FALSE on fail
545 545
 	  */
546
-	public function update( $new_session = FALSE ) {
547
-		$this->_session_data = isset( $this->_session_data )
548
-			&& is_array( $this->_session_data )
549
-			&& isset( $this->_session_data['id'])
546
+	public function update($new_session = FALSE) {
547
+		$this->_session_data = isset($this->_session_data)
548
+			&& is_array($this->_session_data)
549
+			&& isset($this->_session_data['id'])
550 550
 			? $this->_session_data
551 551
 			: NULL;
552
-		if ( empty( $this->_session_data )) {
552
+		if (empty($this->_session_data)) {
553 553
 			$this->_set_defaults();
554 554
 		}
555 555
 		$session_data = array();
556
-		foreach ( $this->_session_data as $key => $value ) {
556
+		foreach ($this->_session_data as $key => $value) {
557 557
 
558
-			switch( $key ) {
558
+			switch ($key) {
559 559
 
560 560
 				case 'id' :
561 561
 					// session ID
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 				break;
574 574
 
575 575
 				case 'init_access' :
576
-					$session_data['init_access'] = absint( $value );
576
+					$session_data['init_access'] = absint($value);
577 577
 				break;
578 578
 
579 579
 				case 'last_access' :
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 
584 584
 				case 'expiration' :
585 585
 					// when the session expires
586
-					$session_data['expiration'] = ! empty( $this->_expiration )
586
+					$session_data['expiration'] = ! empty($this->_expiration)
587 587
 						? $this->_expiration
588 588
 						: $session_data['init_access'] + $this->_lifespan;
589 589
 				break;
@@ -595,11 +595,11 @@  discard block
 block discarded – undo
595 595
 
596 596
 				case 'pages_visited' :
597 597
 					$page_visit = $this->_get_page_visit();
598
-					if ( $page_visit ) {
598
+					if ($page_visit) {
599 599
 						// set pages visited where the first will be the http referrer
600
-						$this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit;
600
+						$this->_session_data['pages_visited'][$this->_time] = $page_visit;
601 601
 						// we'll only save the last 10 page visits.
602
-						$session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 );
602
+						$session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
603 603
 					}
604 604
 				break;
605 605
 
@@ -613,9 +613,9 @@  discard block
 block discarded – undo
613 613
 
614 614
 		$this->_session_data = $session_data;
615 615
 		// creating a new session does not require saving to the db just yet
616
-		if ( ! $new_session ) {
616
+		if ( ! $new_session) {
617 617
 			// ready? let's save
618
-			if ( $this->_save_session_to_db() ) {
618
+			if ($this->_save_session_to_db()) {
619 619
 				return TRUE;
620 620
 			} else {
621 621
 				return FALSE;
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 	  * @param string $location
638 638
 	  * @return mixed
639 639
 	  */
640
-	 public function update_on_redirect( $location ) {
640
+	 public function update_on_redirect($location) {
641 641
 		 $this->update();
642 642
 		 return $location;
643 643
 	}
@@ -649,9 +649,9 @@  discard block
 block discarded – undo
649 649
 	 * 	@return bool
650 650
 	 */
651 651
 	private function _create_espresso_session( ) {
652
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' );
652
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
653 653
 		// use the update function for now with $new_session arg set to TRUE
654
-		return  $this->update( TRUE ) ? TRUE : FALSE;
654
+		return  $this->update(TRUE) ? TRUE : FALSE;
655 655
 	}
656 656
 
657 657
 
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 				// OR an admin request that is NOT AJAX
679 679
 				|| (
680 680
 					is_admin()
681
-					&& ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
681
+					&& ! (defined('DOING_AJAX') && DOING_AJAX)
682 682
 				)
683 683
 			)
684 684
 		) {
@@ -691,13 +691,13 @@  discard block
 block discarded – undo
691 691
             $session_data = base64_encode($session_data);
692 692
         }
693 693
 		// encrypt it if we are using encryption
694
-		$session_data = $this->_use_encryption ? $this->encryption->encrypt( $session_data ) : $session_data;
694
+		$session_data = $this->_use_encryption ? $this->encryption->encrypt($session_data) : $session_data;
695 695
 		// maybe save hash check
696
-		if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
697
-			set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan );
696
+		if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
697
+			set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan);
698 698
 		}
699 699
 		// we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient(  transient ID, data, expiry )
700
-		return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan );
700
+		return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan);
701 701
 	}
702 702
 
703 703
 
@@ -723,10 +723,10 @@  discard block
 block discarded – undo
723 723
 			'HTTP_FORWARDED',
724 724
 			'REMOTE_ADDR'
725 725
 		);
726
-		foreach ( $server_keys as $key ){
727
-			if ( isset( $_SERVER[ $key ] )) {
728
-				foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) {
729
-					if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) {
726
+		foreach ($server_keys as $key) {
727
+			if (isset($_SERVER[$key])) {
728
+				foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
729
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) {
730 730
 						$visitor_ip = $ip;
731 731
 					}
732 732
 				}
@@ -745,32 +745,32 @@  discard block
 block discarded – undo
745 745
 	 *			@return string
746 746
 	 */
747 747
 	public function _get_page_visit() {
748
-		$page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
748
+		$page_visit = home_url('/').'wp-admin/admin-ajax.php';
749 749
 		// check for request url
750
-		if ( isset( $_SERVER['REQUEST_URI'] )) {
750
+		if (isset($_SERVER['REQUEST_URI'])) {
751 751
 			$http_host = '';
752 752
 			$page_id = '?';
753 753
 			$e_reg = '';
754
-			$request_uri = esc_url( $_SERVER['REQUEST_URI'] );
755
-			$ru_bits = explode( '?', $request_uri );
754
+			$request_uri = esc_url($_SERVER['REQUEST_URI']);
755
+			$ru_bits = explode('?', $request_uri);
756 756
 			$request_uri = $ru_bits[0];
757 757
 			// check for and grab host as well
758
-			if ( isset( $_SERVER['HTTP_HOST'] )) {
759
-				$http_host = esc_url( $_SERVER['HTTP_HOST'] );
758
+			if (isset($_SERVER['HTTP_HOST'])) {
759
+				$http_host = esc_url($_SERVER['HTTP_HOST']);
760 760
 			}
761 761
 			// check for page_id in SERVER REQUEST
762
-			if ( isset( $_REQUEST['page_id'] )) {
762
+			if (isset($_REQUEST['page_id'])) {
763 763
 				// rebuild $e_reg without any of the extra parameters
764
-				$page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&amp;';
764
+				$page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&amp;';
765 765
 			}
766 766
 			// check for $e_reg in SERVER REQUEST
767
-			if ( isset( $_REQUEST['ee'] )) {
767
+			if (isset($_REQUEST['ee'])) {
768 768
 				// rebuild $e_reg without any of the extra parameters
769
-				$e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] );
769
+				$e_reg = 'ee='.esc_attr($_REQUEST['ee']);
770 770
 			}
771
-			$page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' );
771
+			$page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?');
772 772
 		}
773
-		return $page_visit !== home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : '';
773
+		return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
774 774
 
775 775
 	}
776 776
 
@@ -799,14 +799,14 @@  discard block
 block discarded – undo
799 799
 	  * @param string $function
800 800
 	  * @return void
801 801
 	  */
802
-	public function clear_session( $class = '', $function = '' ) {
802
+	public function clear_session($class = '', $function = '') {
803 803
 		//echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span>    <b style="font-size:10px;">  ' . __LINE__ . ' </b></h3>';
804
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
804
+		do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()');
805 805
 		$this->reset_cart();
806 806
 		$this->reset_checkout();
807 807
 		$this->reset_transaction();
808 808
 		// wipe out everything that isn't a default session datum
809
-		$this->reset_data( array_keys( $this->_session_data ));
809
+		$this->reset_data(array_keys($this->_session_data));
810 810
 		// reset initial site access time and the session expiration
811 811
 		$this->_set_init_access_and_expiration();
812 812
 		$this->_save_session_to_db();
@@ -821,42 +821,42 @@  discard block
 block discarded – undo
821 821
 	  * @param bool  $show_all_notices
822 822
 	  * @return TRUE on success, FALSE on fail
823 823
 	  */
824
-	public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) {
824
+	public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) {
825 825
 		// if $data_to_reset is not in an array, then put it in one
826
-		if ( ! is_array( $data_to_reset ) ) {
827
-			$data_to_reset = array ( $data_to_reset );
826
+		if ( ! is_array($data_to_reset)) {
827
+			$data_to_reset = array($data_to_reset);
828 828
 		}
829 829
 		// nothing ??? go home!
830
-		if ( empty( $data_to_reset )) {
831
-			EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
830
+		if (empty($data_to_reset)) {
831
+			EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
832 832
 			return FALSE;
833 833
 		}
834 834
 		$return_value = TRUE;
835 835
 		// since $data_to_reset is an array, cycle through the values
836
-		foreach ( $data_to_reset as $reset ) {
836
+		foreach ($data_to_reset as $reset) {
837 837
 
838 838
 			// first check to make sure it is a valid session var
839
-			if ( isset( $this->_session_data[ $reset ] )) {
839
+			if (isset($this->_session_data[$reset])) {
840 840
 				// then check to make sure it is not a default var
841
-				if ( ! array_key_exists( $reset, $this->_default_session_vars )) {
841
+				if ( ! array_key_exists($reset, $this->_default_session_vars)) {
842 842
 					// remove session var
843
-					unset( $this->_session_data[ $reset ] );
844
-					if ( $show_all_notices ) {
845
-						EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
843
+					unset($this->_session_data[$reset]);
844
+					if ($show_all_notices) {
845
+						EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
846 846
 					}
847
-					$return_value = !isset($return_value) ? TRUE : $return_value;
847
+					$return_value = ! isset($return_value) ? TRUE : $return_value;
848 848
 
849 849
 				} else {
850 850
 					// yeeeeeeeeerrrrrrrrrrr OUT !!!!
851
-					if ( $show_all_notices ) {
852
-						EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
851
+					if ($show_all_notices) {
852
+						EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
853 853
 					}
854 854
 					$return_value = FALSE;
855 855
 				}
856 856
 
857
-			} else if ( $show_all_notices ) {
857
+			} else if ($show_all_notices) {
858 858
 				// oops! that session var does not exist!
859
-				EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
859
+				EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
860 860
 				$return_value = FALSE;
861 861
 			}
862 862
 
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 	 *   @access public
877 877
 	 */
878 878
 	public function wp_loaded() {
879
-		if ( isset(  EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) {
880
-			$this->clear_session( __CLASS__, __FUNCTION__ );
879
+		if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) {
880
+			$this->clear_session(__CLASS__, __FUNCTION__);
881 881
 		}
882 882
 	}
883 883
 
@@ -902,24 +902,24 @@  discard block
 block discarded – undo
902 902
 	  */
903 903
 	 public function garbage_collection() {
904 904
 		 // only perform during regular requests
905
-		 if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) {
905
+		 if ( ! defined('DOING_AJAX') || ! DOING_AJAX) {
906 906
 			 /** @type WPDB $wpdb */
907 907
 			 global $wpdb;
908 908
 			 // since transient expiration timestamps are set in the future, we can compare against NOW
909 909
 			 $expiration = time();
910
-			 $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 );
910
+			 $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2);
911 911
 			 // filter the query limit. Set to 0 to turn off garbage collection
912
-			 $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 ));
912
+			 $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50));
913 913
 			 // non-zero LIMIT means take out the trash
914
-			 if ( $expired_session_transient_delete_query_limit ) {
914
+			 if ($expired_session_transient_delete_query_limit) {
915 915
 				 //array of transient keys that require garbage collection
916 916
 				 $session_keys = array(
917 917
 					 EE_Session::session_id_prefix,
918 918
 					 EE_Session::hash_check_prefix,
919 919
 				 );
920
-				 foreach ( $session_keys as $session_key ) {
921
-					 $session_key = str_replace( '_', '\_', $session_key );
922
-					 $session_key = '\_transient\_timeout\_' . $session_key . '%';
920
+				 foreach ($session_keys as $session_key) {
921
+					 $session_key = str_replace('_', '\_', $session_key);
922
+					 $session_key = '\_transient\_timeout\_'.$session_key.'%';
923 923
 					 $SQL = "
924 924
 					SELECT option_name
925 925
 					FROM {$wpdb->options}
@@ -929,25 +929,25 @@  discard block
 block discarded – undo
929 929
 					OR option_value > {$too_far_in_the_the_future} )
930 930
 					LIMIT {$expired_session_transient_delete_query_limit}
931 931
 				";
932
-					 $expired_sessions = $wpdb->get_col( $SQL );
932
+					 $expired_sessions = $wpdb->get_col($SQL);
933 933
 					 // valid results?
934
-					 if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) {
934
+					 if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
935 935
 						 // format array of results into something usable within the actual DELETE query's IN clause
936 936
 						 $expired = array();
937
-						 foreach ( $expired_sessions as $expired_session ) {
938
-							 $expired[ ] = "'" . $expired_session . "'";
939
-							 $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'";
937
+						 foreach ($expired_sessions as $expired_session) {
938
+							 $expired[] = "'".$expired_session."'";
939
+							 $expired[] = "'".str_replace('timeout_', '', $expired_session)."'";
940 940
 						 }
941
-						 $expired = implode( ', ', $expired );
941
+						 $expired = implode(', ', $expired);
942 942
 						 $SQL = "
943 943
 						DELETE FROM {$wpdb->options}
944 944
 						WHERE option_name
945 945
 						IN ( $expired );
946 946
 					 ";
947
-						 $results = $wpdb->query( $SQL );
947
+						 $results = $wpdb->query($SQL);
948 948
 						 // if something went wrong, then notify the admin
949
-						 if ( $results instanceof WP_Error && is_admin() ) {
950
-							 EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ );
949
+						 if ($results instanceof WP_Error && is_admin()) {
950
+							 EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
951 951
 						 }
952 952
 					 }
953 953
 				 }
@@ -968,22 +968,22 @@  discard block
 block discarded – undo
968 968
 	  * @param $string
969 969
 	  * @return bool
970 970
 	  */
971
-	 private function valid_base_64( $string ) {
971
+	 private function valid_base_64($string) {
972 972
          // ensure data is a string
973 973
          if ( ! is_string($string)) {
974 974
              return false;
975 975
          }
976
-		 $decoded = base64_decode( $string, true );
976
+		 $decoded = base64_decode($string, true);
977 977
 		 // Check if there is no invalid character in string
978
-		 if ( ! preg_match( '/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string ) ) {
978
+		 if ( ! preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) {
979 979
 			 return false;
980 980
 		 }
981 981
 		 // Decode the string in strict mode and send the response
982
-		 if ( ! base64_decode( $string, true ) ) {
982
+		 if ( ! base64_decode($string, true)) {
983 983
 			 return false;
984 984
 		 }
985 985
 		 // Encode and compare it to original one
986
-		 return base64_encode( $decoded ) === $string;
986
+		 return base64_encode($decoded) === $string;
987 987
 	 }
988 988
 
989 989
 
@@ -993,34 +993,34 @@  discard block
 block discarded – undo
993 993
 	  * @param $data1
994 994
 	  * @return string
995 995
 	  */
996
-	 private function find_serialize_error( $data1 ) {
996
+	 private function find_serialize_error($data1) {
997 997
 		$error = "<pre>";
998 998
 		 $data2 = preg_replace_callback(
999 999
 			 '!s:(\d+):"(.*?)";!',
1000
-			 function ( $match ) {
1001
-				 return ( $match[1] === strlen( $match[2] ) )
1000
+			 function($match) {
1001
+				 return ($match[1] === strlen($match[2]))
1002 1002
 					 ? $match[0]
1003 1003
 					 : 's:'
1004
-					   . strlen( $match[2] )
1004
+					   . strlen($match[2])
1005 1005
 					   . ':"'
1006 1006
 					   . $match[2]
1007 1007
 					   . '";';
1008 1008
 			 },
1009 1009
 			 $data1
1010 1010
 		 );
1011
-		$max = ( strlen( $data1 ) > strlen( $data2 ) ) ? strlen( $data1 ) : strlen( $data2 );
1012
-		$error .= $data1 . PHP_EOL;
1013
-		$error .= $data2 . PHP_EOL;
1014
-		for ( $i = 0; $i < $max; $i++ ) {
1015
-			if ( @$data1[ $i ] !== @$data2[ $i ] ) {
1016
-				$error .= "Difference " . @$data1[ $i ] . " != " . @$data2[ $i ] . PHP_EOL;
1017
-				$error .= "\t-> ORD number " . ord( @$data1[ $i ] ) . " != " . ord( @$data2[ $i ] ) . PHP_EOL;
1018
-				$error .= "\t-> Line Number = $i" . PHP_EOL;
1019
-				$start = ( $i - 20 );
1020
-				$start = ( $start < 0 ) ? 0 : $start;
1011
+		$max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2);
1012
+		$error .= $data1.PHP_EOL;
1013
+		$error .= $data2.PHP_EOL;
1014
+		for ($i = 0; $i < $max; $i++) {
1015
+			if (@$data1[$i] !== @$data2[$i]) {
1016
+				$error .= "Difference ".@$data1[$i]." != ".@$data2[$i].PHP_EOL;
1017
+				$error .= "\t-> ORD number ".ord(@$data1[$i])." != ".ord(@$data2[$i]).PHP_EOL;
1018
+				$error .= "\t-> Line Number = $i".PHP_EOL;
1019
+				$start = ($i - 20);
1020
+				$start = ($start < 0) ? 0 : $start;
1021 1021
 				$length = 40;
1022 1022
 				$point = $max - $i;
1023
-				if ( $point < 20 ) {
1023
+				if ($point < 20) {
1024 1024
 					$rlength = 1;
1025 1025
 					$rpoint = -$point;
1026 1026
 				} else {
@@ -1029,16 +1029,16 @@  discard block
 block discarded – undo
1029 1029
 				}
1030 1030
 				$error .= "\t-> Section Data1  = ";
1031 1031
 				$error .= substr_replace(
1032
-					substr( $data1, $start, $length ),
1033
-					"<b style=\"color:green\">{$data1[ $i ]}</b>",
1032
+					substr($data1, $start, $length),
1033
+					"<b style=\"color:green\">{$data1[$i]}</b>",
1034 1034
 					$rpoint,
1035 1035
 					$rlength
1036 1036
 				);
1037 1037
 				$error .= PHP_EOL;
1038 1038
 				$error .= "\t-> Section Data2  = ";
1039 1039
 				$error .= substr_replace(
1040
-					substr( $data2, $start, $length ),
1041
-					"<b style=\"color:red\">{$data2[ $i ]}</b>",
1040
+					substr($data2, $start, $length),
1041
+					"<b style=\"color:red\">{$data2[$i]}</b>",
1042 1042
 					$rpoint,
1043 1043
 					$rlength
1044 1044
 				);
Please login to merge, or discard this patch.
core/exceptions/InvalidSessionDataException.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\exceptions;
3 3
 
4
-defined( 'ABSPATH' ) || exit;
4
+defined('ABSPATH') || exit;
5 5
 
6 6
 
7 7
 
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
 	 * @param int        $code
23 23
 	 * @param \Exception $previous
24 24
 	 */
25
-	public function __construct( $message = '', $code = 0, \Exception $previous = null ) {
26
-		if ( empty( $message ) ) {
27
-			$message = esc_html__( 'The session data is either missing or invalid.', 'event_espresso' );
25
+	public function __construct($message = '', $code = 0, \Exception $previous = null) {
26
+		if (empty($message)) {
27
+			$message = esc_html__('The session data is either missing or invalid.', 'event_espresso');
28 28
 		}
29
-		parent::__construct( $message, $code, $previous );
29
+		parent::__construct($message, $code, $previous);
30 30
 	}
31 31
 
32 32
 
Please login to merge, or discard this patch.
support/templates/support_admin_details_additional_information.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,3 @@
 block discarded – undo
1 1
 <div class="padding">
2
-	<p><?php printf( esc_html__( 'Check out the %1$sroadmap for Event Espresso%2$s.', 'event_espresso' ), '<a href="https://trello.com/b/zg9DCIpe/event-espresso-public-roadmap" target="_blank">','</a>' ); ?></p>
2
+	<p><?php printf(esc_html__('Check out the %1$sroadmap for Event Espresso%2$s.', 'event_espresso'), '<a href="https://trello.com/b/zg9DCIpe/event-espresso-public-roadmap" target="_blank">', '</a>'); ?></p>
3 3
 </div>
4 4
\ No newline at end of file
Please login to merge, or discard this patch.