Passed
Pull Request — master (#191)
by
unknown
04:15
created
includes/gateways/paypal.php 1 patch
Spacing   +283 added lines, -283 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_action( 'wpinv_paypal_cc_form', '__return_false' );
6
-add_filter( 'wpinv_paypal_support_subscription', '__return_true' );
5
+add_action('wpinv_paypal_cc_form', '__return_false');
6
+add_filter('wpinv_paypal_support_subscription', '__return_true');
7 7
 
8
-function wpinv_process_paypal_payment( $purchase_data ) {
9
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
10
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
8
+function wpinv_process_paypal_payment($purchase_data) {
9
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
10
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
11 11
     }
12 12
 
13 13
     // Collect payment data
@@ -25,30 +25,30 @@  discard block
 block discarded – undo
25 25
     );
26 26
 
27 27
     // Record the pending payment
28
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
28
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
29 29
 
30 30
     // Check payment
31
-    if ( ! $invoice ) {
31
+    if (!$invoice) {
32 32
         // Record the error
33
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
33
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
34 34
         // Problems? send back
35
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
35
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
36 36
     } else {
37 37
         // Only send to PayPal if the pending payment is created successfully
38
-        $listener_url = wpinv_get_ipn_url( 'paypal' );
38
+        $listener_url = wpinv_get_ipn_url('paypal');
39 39
 
40 40
         // Get the success url
41
-        $return_url = add_query_arg( array(
41
+        $return_url = add_query_arg(array(
42 42
                 'payment-confirm' => 'paypal',
43 43
                 'invoice-id' => $invoice->ID
44
-            ), get_permalink( wpinv_get_option( 'success_page', false ) ) );
44
+            ), get_permalink(wpinv_get_option('success_page', false)));
45 45
 
46 46
         // Get the PayPal redirect uri
47
-        $paypal_redirect = trailingslashit( wpinv_get_paypal_redirect() ) . '?';
47
+        $paypal_redirect = trailingslashit(wpinv_get_paypal_redirect()) . '?';
48 48
 
49 49
         // Setup PayPal arguments
50 50
         $paypal_args = array(
51
-            'business'      => wpinv_get_option( 'paypal_email', false ),
51
+            'business'      => wpinv_get_option('paypal_email', false),
52 52
             'email'         => $invoice->get_email(),
53 53
             'first_name'    => $invoice->get_first_name(),
54 54
             'last_name'     => $invoice->get_last_name(),
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
             'shipping'      => '0',
58 58
             'no_note'       => '1',
59 59
             'currency_code' => wpinv_get_currency(),
60
-            'charset'       => get_bloginfo( 'charset' ),
60
+            'charset'       => get_bloginfo('charset'),
61 61
             'custom'        => $invoice->ID,
62 62
             'rm'            => '2',
63 63
             'return'        => $return_url,
64
-            'cancel_return' => wpinv_get_failed_transaction_uri( '?invoice-id=' . $invoice->ID ),
64
+            'cancel_return' => wpinv_get_failed_transaction_uri('?invoice-id=' . $invoice->ID),
65 65
             'notify_url'    => $listener_url,
66
-            'cbt'           => get_bloginfo( 'name' ),
66
+            'cbt'           => get_bloginfo('name'),
67 67
             'bn'            => 'WPInvoicing_SP',
68 68
             'lc'            => 'US', // this will force paypal site to english
69
-            'landing_page'  => apply_filters( 'wpinv_paypal_standard_landing_page', 'billing', $invoice ), // 'login' or 'billing'. login - PayPal account login, billing - Non-PayPal account.
69
+            'landing_page'  => apply_filters('wpinv_paypal_standard_landing_page', 'billing', $invoice), // 'login' or 'billing'. login - PayPal account login, billing - Non-PayPal account.
70 70
         );
71 71
 
72 72
         $paypal_args['address1'] = $invoice->get_address();
@@ -80,57 +80,57 @@  discard block
 block discarded – undo
80 80
             'upload' => '1'
81 81
         );
82 82
 
83
-        $paypal_args = array_merge( $paypal_extra_args, $paypal_args );
83
+        $paypal_args = array_merge($paypal_extra_args, $paypal_args);
84 84
 
85 85
         // Add cart items
86 86
         $i = 1;
87
-        if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) {
88
-            foreach ( $purchase_data['cart_details'] as $item ) {
87
+        if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) {
88
+            foreach ($purchase_data['cart_details'] as $item) {
89 89
                 $item['quantity'] = $item['quantity'] > 0 ? $item['quantity'] : 1;
90
-                $item_amount = wpinv_sanitize_amount( $item['subtotal'] / $item['quantity'], 2 );
90
+                $item_amount = wpinv_sanitize_amount($item['subtotal'] / $item['quantity'], 2);
91 91
 
92
-                if ( $item_amount <= 0 ) {
92
+                if ($item_amount <= 0) {
93 93
                     $item_amount = 0;
94 94
                 }
95 95
 
96
-                $paypal_args['item_number_' . $i ]      = $item['id'];
97
-                $paypal_args['item_name_' . $i ]        = stripslashes_deep( html_entity_decode( wpinv_get_cart_item_name( $item ), ENT_COMPAT, 'UTF-8' ) );
98
-                $paypal_args['quantity_' . $i ]         = $item['quantity'];
99
-                $paypal_args['amount_' . $i ]           = $item_amount;
100
-                $paypal_args['discount_amount_' . $i ]  = wpinv_sanitize_amount( $item['discount'], 2 );
96
+                $paypal_args['item_number_' . $i]      = $item['id'];
97
+                $paypal_args['item_name_' . $i]        = stripslashes_deep(html_entity_decode(wpinv_get_cart_item_name($item), ENT_COMPAT, 'UTF-8'));
98
+                $paypal_args['quantity_' . $i]         = $item['quantity'];
99
+                $paypal_args['amount_' . $i]           = $item_amount;
100
+                $paypal_args['discount_amount_' . $i]  = wpinv_sanitize_amount($item['discount'], 2);
101 101
 
102 102
                 $i++;
103 103
             }
104 104
         }
105 105
 
106 106
         // Add taxes to the cart
107
-        if ( wpinv_use_taxes() ) {
108
-            $paypal_args['tax_cart'] = wpinv_sanitize_amount( (float)$invoice->get_tax(), 2 );
107
+        if (wpinv_use_taxes()) {
108
+            $paypal_args['tax_cart'] = wpinv_sanitize_amount((float)$invoice->get_tax(), 2);
109 109
         }
110 110
 
111
-        $paypal_args = apply_filters( 'wpinv_paypal_args', $paypal_args, $purchase_data, $invoice );
111
+        $paypal_args = apply_filters('wpinv_paypal_args', $paypal_args, $purchase_data, $invoice);
112 112
 
113 113
         // Build query
114
-        $paypal_redirect .= http_build_query( $paypal_args );
114
+        $paypal_redirect .= http_build_query($paypal_args);
115 115
 
116 116
         // Fix for some sites that encode the entities
117
-        $paypal_redirect = str_replace( '&amp;', '&', $paypal_redirect );
117
+        $paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
118 118
 
119 119
         // Get rid of cart contents
120 120
         wpinv_empty_cart();
121 121
         
122 122
         // Redirect to PayPal
123
-        wp_redirect( $paypal_redirect );
123
+        wp_redirect($paypal_redirect);
124 124
         exit;
125 125
     }
126 126
 }
127
-add_action( 'wpinv_gateway_paypal', 'wpinv_process_paypal_payment' );
127
+add_action('wpinv_gateway_paypal', 'wpinv_process_paypal_payment');
128 128
 
129
-function wpinv_get_paypal_recurring_args( $paypal_args, $purchase_data, $invoice ) {
130
-    if ( $invoice->is_recurring() && $item_id = $invoice->get_recurring() ) {
131
-        $item   = new WPInv_Item( $item_id );
129
+function wpinv_get_paypal_recurring_args($paypal_args, $purchase_data, $invoice) {
130
+    if ($invoice->is_recurring() && $item_id = $invoice->get_recurring()) {
131
+        $item = new WPInv_Item($item_id);
132 132
         
133
-        if ( empty( $item ) ) {
133
+        if (empty($item)) {
134 134
             return $paypal_args;
135 135
         }
136 136
 
@@ -138,25 +138,25 @@  discard block
 block discarded – undo
138 138
         $interval           = $item->get_recurring_interval();
139 139
         $bill_times         = (int)$item->get_recurring_limit();
140 140
         
141
-        $initial_amount     = wpinv_sanitize_amount( $invoice->get_total(), 2 );
142
-        $recurring_amount   = wpinv_sanitize_amount( $invoice->get_recurring_details( 'total' ), 2 );
141
+        $initial_amount     = wpinv_sanitize_amount($invoice->get_total(), 2);
142
+        $recurring_amount   = wpinv_sanitize_amount($invoice->get_recurring_details('total'), 2);
143 143
         
144 144
         $paypal_args['cmd'] = '_xclick-subscriptions';
145 145
         $paypal_args['sra'] = '1';
146 146
         $paypal_args['src'] = '1';
147 147
         
148 148
         // Set item description
149
-        $item_name                  = sprintf( '[%s] %s', $invoice->get_number(), wpinv_get_cart_item_name( array( 'id' => $item->ID ) ) );
150
-        $paypal_args['item_name']   = stripslashes_deep( html_entity_decode( $item_name, ENT_COMPAT, 'UTF-8' ) );
149
+        $item_name                  = sprintf('[%s] %s', $invoice->get_number(), wpinv_get_cart_item_name(array('id' => $item->ID)));
150
+        $paypal_args['item_name']   = stripslashes_deep(html_entity_decode($item_name, ENT_COMPAT, 'UTF-8'));
151 151
         
152
-        if ( $invoice->is_free_trial() && $item->has_free_trial() ) {
152
+        if ($invoice->is_free_trial() && $item->has_free_trial()) {
153 153
             $paypal_args['a1']  = $initial_amount;
154 154
             $paypal_args['p1']  = $item->get_trial_interval();
155 155
             $paypal_args['t1']  = $item->get_trial_period();
156 156
             
157 157
             // Set the recurring amount
158 158
             $paypal_args['a3']  = $recurring_amount;
159
-        } else if ( $initial_amount != $recurring_amount && $bill_times != 1 ) {
159
+        } else if ($initial_amount != $recurring_amount && $bill_times != 1) {
160 160
             $paypal_args['a1']  = $initial_amount;
161 161
             $paypal_args['p1']  = $interval;
162 162
             $paypal_args['t1']  = $period;
@@ -164,63 +164,63 @@  discard block
 block discarded – undo
164 164
             // Set the recurring amount
165 165
             $paypal_args['a3']  = $recurring_amount;
166 166
             
167
-            if ( $bill_times > 1 ) {
167
+            if ($bill_times > 1) {
168 168
                 $bill_times--;
169 169
             }
170 170
         } else {
171
-            $paypal_args['a3']  = $initial_amount;
171
+            $paypal_args['a3'] = $initial_amount;
172 172
         }
173 173
         
174 174
         $paypal_args['p3']  = $interval;
175 175
         $paypal_args['t3']  = $period;
176 176
         
177
-        if ( $bill_times > 1 ) {
177
+        if ($bill_times > 1) {
178 178
             // Make sure it's not over the max of 52
179
-            $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
179
+            $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
180 180
         }
181 181
                 
182 182
         // Remove cart items
183 183
         $i = 1;
184
-        if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) {
185
-            foreach ( $purchase_data['cart_details'] as $item ) {                
186
-                if ( isset( $paypal_args['item_number_' . $i] ) ) {
187
-                    unset( $paypal_args['item_number_' . $i] );
184
+        if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) {
185
+            foreach ($purchase_data['cart_details'] as $item) {                
186
+                if (isset($paypal_args['item_number_' . $i])) {
187
+                    unset($paypal_args['item_number_' . $i]);
188 188
                 }
189
-                if ( isset( $paypal_args['item_name_' . $i] ) ) {
190
-                    unset( $paypal_args['item_name_' . $i] );
189
+                if (isset($paypal_args['item_name_' . $i])) {
190
+                    unset($paypal_args['item_name_' . $i]);
191 191
                 }
192
-                if ( isset( $paypal_args['quantity_' . $i] ) ) {
193
-                    unset( $paypal_args['quantity_' . $i] );
192
+                if (isset($paypal_args['quantity_' . $i])) {
193
+                    unset($paypal_args['quantity_' . $i]);
194 194
                 }
195
-                if ( isset( $paypal_args['amount_' . $i] ) ) {
196
-                    unset( $paypal_args['amount_' . $i] );
195
+                if (isset($paypal_args['amount_' . $i])) {
196
+                    unset($paypal_args['amount_' . $i]);
197 197
                 }
198
-                if ( isset( $paypal_args['discount_amount_' . $i] ) ) {
199
-                    unset( $paypal_args['discount_amount_' . $i] );
198
+                if (isset($paypal_args['discount_amount_' . $i])) {
199
+                    unset($paypal_args['discount_amount_' . $i]);
200 200
                 }
201 201
 
202 202
                 $i++;
203 203
             }
204 204
         }
205 205
         
206
-        if ( isset( $paypal_args['tax_cart'] ) ) {
207
-            unset( $paypal_args['tax_cart'] );
206
+        if (isset($paypal_args['tax_cart'])) {
207
+            unset($paypal_args['tax_cart']);
208 208
         }
209 209
                 
210
-        if ( isset( $paypal_args['upload'] ) ) {
211
-            unset( $paypal_args['upload'] );
210
+        if (isset($paypal_args['upload'])) {
211
+            unset($paypal_args['upload']);
212 212
         }
213 213
         
214
-        $paypal_args = apply_filters( 'wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice );
214
+        $paypal_args = apply_filters('wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice);
215 215
     }
216 216
     
217 217
     return $paypal_args;
218 218
 }
219
-add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 );
219
+add_filter('wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3);
220 220
 
221 221
 function wpinv_process_paypal_ipn() {
222 222
 	// Check the request method is POST
223
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
223
+	if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
224 224
 		return;
225 225
 	}
226 226
 
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 	$post_data = '';
229 229
 
230 230
 	// Fallback just in case post_max_size is lower than needed
231
-	if ( ini_get( 'allow_url_fopen' ) ) {
232
-		$post_data = file_get_contents( 'php://input' );
231
+	if (ini_get('allow_url_fopen')) {
232
+		$post_data = file_get_contents('php://input');
233 233
 	} else {
234 234
 		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
235
-		ini_set( 'post_max_size', '12M' );
235
+		ini_set('post_max_size', '12M');
236 236
 	}
237 237
 	// Start the encoded data collection with notification command
238 238
 	$encoded_data = 'cmd=_notify-validate';
@@ -241,43 +241,43 @@  discard block
 block discarded – undo
241 241
 	$arg_separator = wpinv_get_php_arg_separator_output();
242 242
 
243 243
 	// Verify there is a post_data
244
-	if ( $post_data || strlen( $post_data ) > 0 ) {
244
+	if ($post_data || strlen($post_data) > 0) {
245 245
 		// Append the data
246
-		$encoded_data .= $arg_separator.$post_data;
246
+		$encoded_data .= $arg_separator . $post_data;
247 247
 	} else {
248 248
 		// Check if POST is empty
249
-		if ( empty( $_POST ) ) {
249
+		if (empty($_POST)) {
250 250
 			// Nothing to do
251 251
 			return;
252 252
 		} else {
253 253
 			// Loop through each POST
254
-			foreach ( $_POST as $key => $value ) {
254
+			foreach ($_POST as $key => $value) {
255 255
 				// Encode the value and append the data
256
-				$encoded_data .= $arg_separator."$key=" . urlencode( $value );
256
+				$encoded_data .= $arg_separator . "$key=" . urlencode($value);
257 257
 			}
258 258
 		}
259 259
 	}
260 260
 
261 261
 	// Convert collected post data to an array
262
-	parse_str( $encoded_data, $encoded_data_array );
262
+	parse_str($encoded_data, $encoded_data_array);
263 263
 
264
-	foreach ( $encoded_data_array as $key => $value ) {
265
-		if ( false !== strpos( $key, 'amp;' ) ) {
266
-			$new_key = str_replace( '&amp;', '&', $key );
267
-			$new_key = str_replace( 'amp;', '&' , $new_key );
264
+	foreach ($encoded_data_array as $key => $value) {
265
+		if (false !== strpos($key, 'amp;')) {
266
+			$new_key = str_replace('&amp;', '&', $key);
267
+			$new_key = str_replace('amp;', '&', $new_key);
268 268
 
269
-			unset( $encoded_data_array[ $key ] );
270
-			$encoded_data_array[ $new_key ] = $value;
269
+			unset($encoded_data_array[$key]);
270
+			$encoded_data_array[$new_key] = $value;
271 271
 		}
272 272
 	}
273 273
 
274 274
 	// Get the PayPal redirect uri
275
-	$paypal_redirect = wpinv_get_paypal_redirect( true );
275
+	$paypal_redirect = wpinv_get_paypal_redirect(true);
276 276
 
277
-	if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) {
277
+	if (!wpinv_get_option('disable_paypal_verification', false)) {
278 278
 		// Validate the IPN
279 279
 
280
-		$remote_post_vars      = array(
280
+		$remote_post_vars = array(
281 281
 			'method'           => 'POST',
282 282
 			'timeout'          => 45,
283 283
 			'redirection'      => 5,
@@ -295,21 +295,21 @@  discard block
 block discarded – undo
295 295
 		);
296 296
 
297 297
 		// Get response
298
-		$api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars );
298
+		$api_response = wp_remote_post(wpinv_get_paypal_redirect(), $remote_post_vars);
299 299
 
300
-		if ( is_wp_error( $api_response ) ) {
301
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
300
+		if (is_wp_error($api_response)) {
301
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response)));
302 302
 			return; // Something went wrong
303 303
 		}
304 304
 
305
-		if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) {
306
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
305
+		if ($api_response['body'] !== 'VERIFIED' && wpinv_get_option('disable_paypal_verification', false)) {
306
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response)));
307 307
 			return; // Response not okay
308 308
 		}
309 309
 	}
310 310
 
311 311
 	// Check if $post_data_array has been populated
312
-	if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) )
312
+	if (!is_array($encoded_data_array) && !empty($encoded_data_array))
313 313
 		return;
314 314
 
315 315
 	$defaults = array(
@@ -317,265 +317,265 @@  discard block
 block discarded – undo
317 317
 		'payment_status' => ''
318 318
 	);
319 319
 
320
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
320
+	$encoded_data_array = wp_parse_args($encoded_data_array, $defaults);
321 321
 
322
-	$invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
322
+	$invoice_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0;
323 323
     
324
-	wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ );
325
-	wpinv_error_log( $encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__ );
324
+	wpinv_error_log($encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__);
325
+	wpinv_error_log($encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__);
326 326
 
327
-	if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) {
327
+	if (has_action('wpinv_paypal_' . $encoded_data_array['txn_type'])) {
328 328
 		// Allow PayPal IPN types to be processed separately
329
-		do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id );
329
+		do_action('wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id);
330 330
 	} else {
331 331
 		// Fallback to web accept just in case the txn_type isn't present
332
-		do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id );
332
+		do_action('wpinv_paypal_web_accept', $encoded_data_array, $invoice_id);
333 333
 	}
334 334
 	exit;
335 335
 }
336
-add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' );
336
+add_action('wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn');
337 337
 
338
-function wpinv_process_paypal_web_accept_and_cart( $data, $invoice_id ) {
339
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
338
+function wpinv_process_paypal_web_accept_and_cart($data, $invoice_id) {
339
+	if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') {
340 340
 		return;
341 341
 	}
342 342
 
343
-	if( empty( $invoice_id ) ) {
343
+	if (empty($invoice_id)) {
344 344
 		return;
345 345
 	}
346 346
 
347 347
 	// Collect payment details
348
-	$purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
348
+	$purchase_key   = isset($data['invoice']) ? $data['invoice'] : $data['item_number'];
349 349
 	$paypal_amount  = $data['mc_gross'];
350
-	$payment_status = strtolower( $data['payment_status'] );
351
-	$currency_code  = strtolower( $data['mc_currency'] );
352
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
353
-	$payment_meta   = wpinv_get_invoice_meta( $invoice_id );
350
+	$payment_status = strtolower($data['payment_status']);
351
+	$currency_code  = strtolower($data['mc_currency']);
352
+	$business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
353
+	$payment_meta   = wpinv_get_invoice_meta($invoice_id);
354 354
 
355
-	if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) {
355
+	if (wpinv_get_payment_gateway($invoice_id) != 'paypal') {
356 356
 		return; // this isn't a PayPal standard IPN
357 357
 	}
358 358
 
359 359
 	// Verify payment recipient
360
-	if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) {
361
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
362
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
363
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ), '', '', true );
360
+	if (strcasecmp($business_email, trim(wpinv_get_option('paypal_email', false))) != 0) {
361
+		wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
362
+		wpinv_update_payment_status($invoice_id, 'wpi-failed');
363
+		wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid PayPal business email.', 'invoicing'), '', '', true);
364 364
 		return;
365 365
 	}
366 366
 
367 367
 	// Verify payment currency
368
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
369
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
370
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
371
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ), '', '', true );
368
+	if ($currency_code != strtolower($payment_meta['currency'])) {
369
+		wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
370
+		wpinv_update_payment_status($invoice_id, 'wpi-failed');
371
+		wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid currency in PayPal IPN.', 'invoicing'), '', '', true);
372 372
 		return;
373 373
 	}
374 374
 
375
-	if ( !wpinv_get_payment_user_email( $invoice_id ) ) {
375
+	if (!wpinv_get_payment_user_email($invoice_id)) {
376 376
 		// This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
377 377
 		// No email associated with purchase, so store from PayPal
378
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] );
378
+		wpinv_update_invoice_meta($invoice_id, '_wpinv_email', $data['payer_email']);
379 379
 
380 380
 		// Setup and store the customer's details
381 381
 		$user_info = array(
382 382
 			'user_id'    => '-1',
383
-			'email'      => sanitize_text_field( $data['payer_email'] ),
384
-			'first_name' => sanitize_text_field( $data['first_name'] ),
385
-			'last_name'  => sanitize_text_field( $data['last_name'] ),
383
+			'email'      => sanitize_text_field($data['payer_email']),
384
+			'first_name' => sanitize_text_field($data['first_name']),
385
+			'last_name'  => sanitize_text_field($data['last_name']),
386 386
 			'discount'   => '',
387 387
 		);
388
-		$user_info['address'] = ! empty( $data['address_street']       ) ? sanitize_text_field( $data['address_street'] )       : false;
389
-		$user_info['city']    = ! empty( $data['address_city']         ) ? sanitize_text_field( $data['address_city'] )         : false;
390
-		$user_info['state']   = ! empty( $data['address_state']        ) ? sanitize_text_field( $data['address_state'] )        : false;
391
-		$user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
392
-		$user_info['zip']     = ! empty( $data['address_zip']          ) ? sanitize_text_field( $data['address_zip'] )          : false;
388
+		$user_info['address'] = !empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false;
389
+		$user_info['city']    = !empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false;
390
+		$user_info['state']   = !empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false;
391
+		$user_info['country'] = !empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false;
392
+		$user_info['zip']     = !empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false;
393 393
 
394 394
 		$payment_meta['user_info'] = $user_info;
395
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta );
395
+		wpinv_update_invoice_meta($invoice_id, '_wpinv_payment_meta', $payment_meta);
396 396
 	}
397 397
 
398
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
398
+	if ($payment_status == 'refunded' || $payment_status == 'reversed') {
399 399
 		// Process a refund
400
-		wpinv_process_paypal_refund( $data, $invoice_id );
400
+		wpinv_process_paypal_refund($data, $invoice_id);
401 401
 	} else {
402
-		if ( get_post_status( $invoice_id ) == 'publish' ) {
402
+		if (get_post_status($invoice_id) == 'publish') {
403 403
 			return; // Only paid payments once
404 404
 		}
405 405
 
406 406
 		// Retrieve the total purchase amount (before PayPal)
407
-		$payment_amount = wpinv_payment_total( $invoice_id );
407
+		$payment_amount = wpinv_payment_total($invoice_id);
408 408
 
409
-		if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
409
+		if (number_format((float)$paypal_amount, 2) < number_format((float)$payment_amount, 2)) {
410 410
 			// The prices don't match
411
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
412
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
413
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ), '', '', true );
411
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
412
+			wpinv_update_payment_status($invoice_id, 'wpi-failed');
413
+			wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid amount in PayPal IPN.', 'invoicing'), '', '', true);
414 414
 			return;
415 415
 		}
416
-		if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) {
416
+		if ($purchase_key != wpinv_get_payment_key($invoice_id)) {
417 417
 			// Purchase keys don't match
418
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
419
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
420
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ), '', '', true );
418
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
419
+			wpinv_update_payment_status($invoice_id, 'wpi-failed');
420
+			wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing'), '', '', true);
421 421
 			return;
422 422
 		}
423 423
 
424
-		if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) {
425
-			wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ), '', '', true );
426
-			wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] );
427
-			wpinv_update_payment_status( $invoice_id, 'publish' );
428
-		} else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
424
+		if ('complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode('paypal')) {
425
+			wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $data['txn_id']), '', '', true);
426
+			wpinv_set_payment_transaction_id($invoice_id, $data['txn_id']);
427
+			wpinv_update_payment_status($invoice_id, 'publish');
428
+		} else if ('pending' == $payment_status && isset($data['pending_reason'])) {
429 429
 			// Look for possible pending reasons, such as an echeck
430 430
 			$note = '';
431 431
 
432
-			switch( strtolower( $data['pending_reason'] ) ) {
432
+			switch (strtolower($data['pending_reason'])) {
433 433
 				case 'echeck' :
434
-					$note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' );
434
+					$note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing');
435 435
 					break;
436 436
 				
437 437
                 case 'address' :
438
-					$note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' );
438
+					$note = __('Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing');
439 439
 					break;
440 440
 				
441 441
                 case 'intl' :
442
-					$note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' );
442
+					$note = __('Payment must be accepted manually through PayPal due to international account regulations', 'invoicing');
443 443
 					break;
444 444
 				
445 445
                 case 'multi-currency' :
446
-					$note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' );
446
+					$note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing');
447 447
 					break;
448 448
 				
449 449
                 case 'paymentreview' :
450 450
                 case 'regulatory_review' :
451
-					$note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' );
451
+					$note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing');
452 452
 					break;
453 453
 				
454 454
                 case 'unilateral' :
455
-					$note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' );
455
+					$note = __('Payment was sent to non-confirmed or non-registered email address.', 'invoicing');
456 456
 					break;
457 457
 				
458 458
                 case 'upgrade' :
459
-					$note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' );
459
+					$note = __('PayPal account must be upgraded before this payment can be accepted', 'invoicing');
460 460
 					break;
461 461
 				
462 462
                 case 'verify' :
463
-					$note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' );
463
+					$note = __('PayPal account is not verified. Verify account in order to accept this payment', 'invoicing');
464 464
 					break;
465 465
 
466 466
 				case 'other' :
467
-					$note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' );
467
+					$note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing');
468 468
 					break;
469 469
 			}
470 470
 
471
-			if ( ! empty( $note ) ) {
472
-				wpinv_insert_payment_note( $invoice_id, $note, '', '', true );
471
+			if (!empty($note)) {
472
+				wpinv_insert_payment_note($invoice_id, $note, '', '', true);
473 473
 			}
474 474
 		} else {
475
-			wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ), '', '', true );
475
+			wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal IPN has been received with invalid payment status: %s', 'invoicing'), $payment_status), '', '', true);
476 476
 		}
477 477
 	}
478 478
 }
479
-add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 );
479
+add_action('wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2);
480 480
 
481 481
 // Process PayPal subscription sign ups
482
-add_action( 'wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup' );
482
+add_action('wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup');
483 483
 
484 484
 // Process PayPal subscription payments
485
-add_action( 'wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment' );
485
+add_action('wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment');
486 486
 
487 487
 // Process PayPal subscription cancellations
488
-add_action( 'wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel' );
488
+add_action('wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel');
489 489
 
490 490
 // Process PayPal subscription end of term notices
491
-add_action( 'wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot' );
491
+add_action('wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot');
492 492
 
493 493
 // Process PayPal payment failed
494
-add_action( 'wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed' );
494
+add_action('wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed');
495 495
 
496 496
 
497 497
 /**
498 498
  * Process the subscription started IPN.
499 499
  */
500
-function wpinv_process_paypal_subscr_signup( $ipn_data ) {
501
-    $parent_invoice_id = absint( $ipn_data['custom'] );
502
-    if( empty( $parent_invoice_id ) ) {
500
+function wpinv_process_paypal_subscr_signup($ipn_data) {
501
+    $parent_invoice_id = absint($ipn_data['custom']);
502
+    if (empty($parent_invoice_id)) {
503 503
         return;
504 504
     }
505 505
 
506
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
507
-    if ( empty( $invoice ) ) {
506
+    $invoice = wpinv_get_invoice($parent_invoice_id);
507
+    if (empty($invoice)) {
508 508
         return;
509 509
     }
510 510
 
511
-    if ( $invoice->is_free_trial() && !empty( $ipn_data['invoice'] ) ) {
512
-        wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Invoice ID: %s', 'invoicing' ) , $ipn_data['invoice'] ), '', '', true);
513
-        if ( !empty( $ipn_data['txn_id'] ) ) {
514
-            wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] );
511
+    if ($invoice->is_free_trial() && !empty($ipn_data['invoice'])) {
512
+        wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Invoice ID: %s', 'invoicing'), $ipn_data['invoice']), '', '', true);
513
+        if (!empty($ipn_data['txn_id'])) {
514
+            wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']);
515 515
         }
516 516
     }
517 517
 
518
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
519
-    if ( false === $subscription ) {
518
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
519
+    if (false === $subscription) {
520 520
         return;
521 521
     }
522 522
     
523
-    wpinv_update_payment_status( $parent_invoice_id, 'publish' );
523
+    wpinv_update_payment_status($parent_invoice_id, 'publish');
524 524
     sleep(1);
525
-    wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ), '', '', true );
526
-    update_post_meta($parent_invoice_id,'_wpinv_subscr_profile_id', $ipn_data['subscr_id']);
525
+    wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id']), '', '', true);
526
+    update_post_meta($parent_invoice_id, '_wpinv_subscr_profile_id', $ipn_data['subscr_id']);
527 527
 
528 528
     $status     = 'trialling' == $subscription->status ? 'trialling' : 'active';
529
-    $diff_days  = absint( ( ( strtotime( $subscription->expiration ) - strtotime( $subscription->created ) ) / DAY_IN_SECONDS ) );
530
-    $created    = date_i18n( 'Y-m-d H:i:s' );
531
-    $expiration = date_i18n( 'Y-m-d 23:59:59', ( strtotime( $created ) + ( $diff_days * DAY_IN_SECONDS ) ) );
529
+    $diff_days  = absint(((strtotime($subscription->expiration) - strtotime($subscription->created)) / DAY_IN_SECONDS));
530
+    $created    = date_i18n('Y-m-d H:i:s');
531
+    $expiration = date_i18n('Y-m-d 23:59:59', (strtotime($created) + ($diff_days * DAY_IN_SECONDS)));
532 532
 
533 533
     // Retrieve pending subscription from database and update it's status to active and set proper profile ID
534
-    $subscription->update( array( 'profile_id' => $ipn_data['subscr_id'], 'status' => $status, 'created' => $created, 'expiration' => $expiration ) );
534
+    $subscription->update(array('profile_id' => $ipn_data['subscr_id'], 'status' => $status, 'created' => $created, 'expiration' => $expiration));
535 535
 }
536 536
 
537 537
 /**
538 538
  * Process the subscription payment received IPN.
539 539
  */
540
-function wpinv_process_paypal_subscr_payment( $ipn_data ) {
541
-    $parent_invoice_id = absint( $ipn_data['custom'] );
540
+function wpinv_process_paypal_subscr_payment($ipn_data) {
541
+    $parent_invoice_id = absint($ipn_data['custom']);
542 542
 
543
-    $parent_invoice = wpinv_get_invoice( $parent_invoice_id );
544
-    if ( empty( $parent_invoice ) ) {
543
+    $parent_invoice = wpinv_get_invoice($parent_invoice_id);
544
+    if (empty($parent_invoice)) {
545 545
         return;
546 546
     }
547 547
 
548
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
549
-    if ( false === $subscription ) {
548
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
549
+    if (false === $subscription) {
550 550
         return;
551 551
     }
552 552
 
553
-    $transaction_id = wpinv_get_payment_transaction_id( $parent_invoice_id );
553
+    $transaction_id = wpinv_get_payment_transaction_id($parent_invoice_id);
554 554
     $times_billed   = $subscription->get_times_billed();
555
-    $signup_date    = strtotime( $subscription->created );
556
-    $today          = date( 'Ynd', $signup_date ) == date( 'Ynd', strtotime( $ipn_data['payment_date'] ) );
555
+    $signup_date    = strtotime($subscription->created);
556
+    $today          = date('Ynd', $signup_date) == date('Ynd', strtotime($ipn_data['payment_date']));
557 557
 
558 558
     // Look to see if payment is same day as signup and we have set the transaction ID on the parent payment yet.
559
-    if ( (empty($times_billed) || $today) && ( !$transaction_id || $transaction_id == $parent_invoice_id ) ) {
560
-        wpinv_update_payment_status( $parent_invoice_id, 'publish' );
559
+    if ((empty($times_billed) || $today) && (!$transaction_id || $transaction_id == $parent_invoice_id)) {
560
+        wpinv_update_payment_status($parent_invoice_id, 'publish');
561 561
         sleep(1);
562 562
         
563 563
         // This is the very first payment
564
-        wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] );
565
-        wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ), '', '', true );
564
+        wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']);
565
+        wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id']), '', '', true);
566 566
         return;
567 567
     }
568 568
 
569
-    if ( wpinv_get_id_by_transaction_id( $ipn_data['txn_id'] ) ) {
569
+    if (wpinv_get_id_by_transaction_id($ipn_data['txn_id'])) {
570 570
         return; // Payment already recorded
571 571
     }
572 572
 
573
-    $currency_code = strtolower( $ipn_data['mc_currency'] );
573
+    $currency_code = strtolower($ipn_data['mc_currency']);
574 574
 
575 575
     // verify details
576
-    if ( $currency_code != strtolower( wpinv_get_currency() ) ) {
576
+    if ($currency_code != strtolower(wpinv_get_currency())) {
577 577
         // the currency code is invalid
578
-        wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: ', 'invoicing' ), json_encode( $ipn_data ) ) );
578
+        wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: ', 'invoicing'), json_encode($ipn_data)));
579 579
         return;
580 580
     }
581 581
 
@@ -585,11 +585,11 @@  discard block
 block discarded – undo
585 585
         'gateway'        => 'paypal'
586 586
     );
587 587
     
588
-    $invoice_id = $subscription->add_payment( $args );
588
+    $invoice_id = $subscription->add_payment($args);
589 589
 
590
-    if ( $invoice_id > 0 ) {
591
-        wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ), '', '', true );
592
-        wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ), '', '', true );
590
+    if ($invoice_id > 0) {
591
+        wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id']), '', '', true);
592
+        wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id']), '', '', true);
593 593
 
594 594
         $subscription->renew();
595 595
     }
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
 /**
599 599
  * Process the subscription canceled IPN.
600 600
  */
601
-function wpinv_process_paypal_subscr_cancel( $ipn_data ) {
602
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
601
+function wpinv_process_paypal_subscr_cancel($ipn_data) {
602
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
603 603
 
604
-    if( false === $subscription ) {
604
+    if (false === $subscription) {
605 605
         return;
606 606
     }
607 607
 
@@ -611,10 +611,10 @@  discard block
 block discarded – undo
611 611
 /**
612 612
  * Process the subscription expired IPN.
613 613
  */
614
-function wpinv_process_paypal_subscr_eot( $ipn_data ) {
615
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
614
+function wpinv_process_paypal_subscr_eot($ipn_data) {
615
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
616 616
 
617
-    if( false === $subscription ) {
617
+    if (false === $subscription) {
618 618
         return;
619 619
     }
620 620
 
@@ -624,40 +624,40 @@  discard block
 block discarded – undo
624 624
 /**
625 625
  * Process the subscription payment failed IPN.
626 626
  */
627
-function wpinv_process_paypal_subscr_failed( $ipn_data ) {
628
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
627
+function wpinv_process_paypal_subscr_failed($ipn_data) {
628
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
629 629
 
630
-    if( false === $subscription ) {
630
+    if (false === $subscription) {
631 631
         return;
632 632
     }
633 633
 
634 634
     $subscription->failing();
635 635
 
636
-    do_action( 'wpinv_recurring_payment_failed', $subscription );
636
+    do_action('wpinv_recurring_payment_failed', $subscription);
637 637
 }
638 638
 
639 639
 /**
640 640
  * Retrieve the subscription this IPN notice is for.
641 641
  */
642
-function wpinv_get_paypal_subscription( $ipn_data = array() ) {
643
-    $parent_invoice_id = absint( $ipn_data['custom'] );
642
+function wpinv_get_paypal_subscription($ipn_data = array()) {
643
+    $parent_invoice_id = absint($ipn_data['custom']);
644 644
 
645
-    if( empty( $parent_invoice_id ) ) {
645
+    if (empty($parent_invoice_id)) {
646 646
         return false;
647 647
     }
648 648
 
649
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
650
-    if ( empty( $invoice ) ) {
649
+    $invoice = wpinv_get_invoice($parent_invoice_id);
650
+    if (empty($invoice)) {
651 651
         return false;
652 652
     }
653 653
 
654
-    $subscription = new WPInv_Subscription( $ipn_data['subscr_id'], true );
654
+    $subscription = new WPInv_Subscription($ipn_data['subscr_id'], true);
655 655
 
656
-    if ( ! ( ! empty( $subscription ) && $subscription->id > 0 ) ) {
657
-        $subscription = wpinv_get_subscription( $parent_invoice_id );
656
+    if (!(!empty($subscription) && $subscription->id > 0)) {
657
+        $subscription = wpinv_get_subscription($parent_invoice_id);
658 658
 
659
-        if ( ! empty( $subscription ) && $subscription->id > 0 ) {
660
-            $subscription->update( array( 'profile_id' => sanitize_text_field( $ipn_data['subscr_id'] ) ) );
659
+        if (!empty($subscription) && $subscription->id > 0) {
660
+            $subscription->update(array('profile_id' => sanitize_text_field($ipn_data['subscr_id'])));
661 661
         } else {
662 662
             return false;
663 663
         }
@@ -667,46 +667,46 @@  discard block
 block discarded – undo
667 667
 
668 668
 }
669 669
 
670
-function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) {
670
+function wpinv_process_paypal_refund($data, $invoice_id = 0) {
671 671
 	// Collect payment details
672 672
 
673
-	if( empty( $invoice_id ) ) {
673
+	if (empty($invoice_id)) {
674 674
 		return;
675 675
 	}
676 676
 
677
-	if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) {
677
+	if (get_post_status($invoice_id) == 'wpi-refunded') {
678 678
 		return; // Only refund payments once
679 679
 	}
680 680
 
681
-	$payment_amount = wpinv_payment_total( $invoice_id );
681
+	$payment_amount = wpinv_payment_total($invoice_id);
682 682
 	$refund_amount  = $data['mc_gross'] * -1;
683 683
 
684
-	do_action( 'wpinv_paypal_refund_request', $data, $invoice_id );
684
+	do_action('wpinv_paypal_refund_request', $data, $invoice_id);
685 685
 
686
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
687
-		wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing' ), (float)$refund_amount . ' '. $data['mc_currency'], $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
686
+	if (number_format((float)$refund_amount, 2) < number_format((float)$payment_amount, 2)) {
687
+		wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing'), (float)$refund_amount . ' ' . $data['mc_currency'], $data['parent_txn_id'], $data['reason_code']), '', '', true);
688 688
 
689
-		do_action( 'wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount );
689
+		do_action('wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount);
690 690
 
691 691
 		return; // This is a partial refund
692 692
 	}
693 693
 
694
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
695
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ), '', '', true );
696
-	wpinv_update_payment_status( $invoice_id, 'wpi-refunded' );
694
+	wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'invoicing'), $data['parent_txn_id'], $data['reason_code']), '', '', true);
695
+	wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Refund Transaction ID: %s', 'invoicing'), $data['txn_id']), '', '', true);
696
+	wpinv_update_payment_status($invoice_id, 'wpi-refunded');
697 697
 
698
-	do_action( 'wpinv_paypal_invoice_fully_refunded', $data, $invoice_id );
698
+	do_action('wpinv_paypal_invoice_fully_refunded', $data, $invoice_id);
699 699
 }
700 700
 
701
-function wpinv_get_paypal_redirect( $ssl_check = false ) {
702
-    if ( is_ssl() || ! $ssl_check ) {
701
+function wpinv_get_paypal_redirect($ssl_check = false) {
702
+    if (is_ssl() || !$ssl_check) {
703 703
         $protocol = 'https://';
704 704
     } else {
705 705
         $protocol = 'http://';
706 706
     }
707 707
 
708 708
     // Check the current payment mode
709
-    if ( wpinv_is_test_mode( 'paypal' ) ) {
709
+    if (wpinv_is_test_mode('paypal')) {
710 710
         // Test mode
711 711
         $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr';
712 712
     } else {
@@ -714,120 +714,120 @@  discard block
 block discarded – undo
714 714
         $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr';
715 715
     }
716 716
 
717
-    return apply_filters( 'wpinv_paypal_uri', $paypal_uri );
717
+    return apply_filters('wpinv_paypal_uri', $paypal_uri);
718 718
 }
719 719
 
720
-function wpinv_paypal_success_page_content( $content ) {
720
+function wpinv_paypal_success_page_content($content) {
721 721
     global $wpi_invoice;
722 722
     
723 723
     $session = wpinv_get_checkout_session();
724 724
 
725
-    if ( empty( $_GET['invoice-id'] ) && empty( $session['invoice_key'] )  ) {
725
+    if (empty($_GET['invoice-id']) && empty($session['invoice_key'])) {
726 726
         return $content;
727 727
     }
728 728
 
729
-    $invoice_id = !empty( $_GET['invoice-id'] ) ? absint( $_GET['invoice-id'] ) : wpinv_get_invoice_id_by_key( $session['invoice_key'] );
729
+    $invoice_id = !empty($_GET['invoice-id']) ? absint($_GET['invoice-id']) : wpinv_get_invoice_id_by_key($session['invoice_key']);
730 730
 
731
-    if ( empty(  $invoice_id ) ) {
731
+    if (empty($invoice_id)) {
732 732
         return $content;
733 733
     }
734 734
 
735
-    $wpi_invoice = wpinv_get_invoice( $invoice_id );
735
+    $wpi_invoice = wpinv_get_invoice($invoice_id);
736 736
     
737
-    if ( !empty( $wpi_invoice ) && 'wpi-pending' == $wpi_invoice->status ) {
737
+    if (!empty($wpi_invoice) && 'wpi-pending' == $wpi_invoice->status) {
738 738
         // Payment is still pending so show processing indicator to fix the Race Condition, issue #
739 739
         ob_start();
740
-        wpinv_get_template_part( 'wpinv-payment-processing' );
740
+        wpinv_get_template_part('wpinv-payment-processing');
741 741
         $content = ob_get_clean();
742 742
     }
743 743
 
744 744
     return $content;
745 745
 }
746
-add_filter( 'wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content' );
746
+add_filter('wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content');
747 747
 
748
-function wpinv_paypal_get_transaction_id( $invoice_id ) {
748
+function wpinv_paypal_get_transaction_id($invoice_id) {
749 749
     $transaction_id = '';
750
-    $notes = wpinv_get_invoice_notes( $invoice_id );
750
+    $notes = wpinv_get_invoice_notes($invoice_id);
751 751
 
752
-    foreach ( $notes as $note ) {
753
-        if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) {
752
+    foreach ($notes as $note) {
753
+        if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) {
754 754
             $transaction_id = $match[1];
755 755
             continue;
756 756
         }
757 757
     }
758 758
 
759
-    return apply_filters( 'wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id );
759
+    return apply_filters('wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id);
760 760
 }
761
-add_filter( 'wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1 );
761
+add_filter('wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1);
762 762
 
763
-function wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice ) {
764
-    if ( $transaction_id == $invoice_id ) {
763
+function wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice) {
764
+    if ($transaction_id == $invoice_id) {
765 765
         $transaction_link = $transaction_id;
766 766
     } else {
767
-        if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) {
767
+        if (!empty($invoice) && !empty($invoice->mode)) {
768 768
             $mode = $invoice->mode;
769 769
         } else {
770
-            $mode = wpinv_is_test_mode( 'paypal' ) ? 'test' : 'live';
770
+            $mode = wpinv_is_test_mode('paypal') ? 'test' : 'live';
771 771
         }
772 772
 
773 773
         $sandbox = $mode == 'test' ? '.sandbox' : '';
774 774
         $transaction_url = 'https://www' . $sandbox . '.paypal.com/webscr?cmd=_history-details-from-hub&id=' . $transaction_id;
775 775
 
776
-        $transaction_link = '<a href="' . esc_url( $transaction_url ) . '" target="_blank">' . $transaction_id . '</a>';
776
+        $transaction_link = '<a href="' . esc_url($transaction_url) . '" target="_blank">' . $transaction_id . '</a>';
777 777
     }
778 778
 
779
-    return apply_filters( 'wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $transaction_id, $invoice );
779
+    return apply_filters('wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $transaction_id, $invoice);
780 780
 }
781
-add_filter( 'wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3 );
781
+add_filter('wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3);
782 782
 
783
-function wpinv_paypal_profile_id_link( $profile_id, $subscription ) {
783
+function wpinv_paypal_profile_id_link($profile_id, $subscription) {
784 784
     $link = $profile_id;
785 785
 
786
-    if ( ! empty( $profile_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) {
787
-        $invoice = wpinv_get_invoice( $invoice_id );
786
+    if (!empty($profile_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) {
787
+        $invoice = wpinv_get_invoice($invoice_id);
788 788
 
789
-        if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) {
789
+        if (!empty($invoice) && !empty($invoice->mode)) {
790 790
             $mode = $invoice->mode;
791 791
         } else {
792
-            $mode = wpinv_is_test_mode( 'paypal' ) ? 'test' : 'live';
792
+            $mode = wpinv_is_test_mode('paypal') ? 'test' : 'live';
793 793
         }
794 794
 
795 795
         $sandbox = $mode == 'test' ? '.sandbox' : '';
796 796
         $url = 'https://www' . $sandbox . '.paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=' . $profile_id;
797 797
 
798
-        $link = '<a href="' . esc_url( $url ) . '" target="_blank">' . $profile_id . '</a>';
798
+        $link = '<a href="' . esc_url($url) . '" target="_blank">' . $profile_id . '</a>';
799 799
     }
800 800
     
801
-    return apply_filters( 'wpinv_paypal_profile_id_link', $link, $profile_id, $subscription );
801
+    return apply_filters('wpinv_paypal_profile_id_link', $link, $profile_id, $subscription);
802 802
 }
803
-add_filter( 'wpinv_subscription_profile_link_paypal', 'wpinv_paypal_profile_id_link', 10, 2 );
803
+add_filter('wpinv_subscription_profile_link_paypal', 'wpinv_paypal_profile_id_link', 10, 2);
804 804
 
805
-function wpinv_paypal_transaction_id_link( $transaction_id, $subscription ) {
806
-    if ( ! empty( $transaction_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) {
807
-        $invoice = wpinv_get_invoice( $invoice_id );
805
+function wpinv_paypal_transaction_id_link($transaction_id, $subscription) {
806
+    if (!empty($transaction_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) {
807
+        $invoice = wpinv_get_invoice($invoice_id);
808 808
 
809
-        if ( ! empty( $invoice ) ) {
810
-            return wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice );
809
+        if (!empty($invoice)) {
810
+            return wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice);
811 811
         }        
812 812
     }
813 813
     
814 814
     return $transaction_id;
815 815
 }
816
-add_filter( 'wpinv_subscription_transaction_link_paypal', 'wpinv_paypal_transaction_id_link', 10, 2 );
816
+add_filter('wpinv_subscription_transaction_link_paypal', 'wpinv_paypal_transaction_id_link', 10, 2);
817 817
 
818 818
 function wpinv_is_paypal_valid_for_use() {
819
-    return in_array( wpinv_get_currency(), apply_filters( 'wpinv_paypal_supported_currencies', array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ) ) );
819
+    return in_array(wpinv_get_currency(), apply_filters('wpinv_paypal_supported_currencies', array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR')));
820 820
 }
821 821
 
822
-function wpinv_check_paypal_currency_support( $gateway_list ) {
823
-    if ( isset( $gateway_list['paypal'] ) && ! wpinv_is_paypal_valid_for_use() ) {
824
-        unset( $gateway_list['paypal'] );
822
+function wpinv_check_paypal_currency_support($gateway_list) {
823
+    if (isset($gateway_list['paypal']) && !wpinv_is_paypal_valid_for_use()) {
824
+        unset($gateway_list['paypal']);
825 825
     }
826 826
     return $gateway_list;
827 827
 }
828
-add_filter( 'wpinv_enabled_payment_gateways', 'wpinv_check_paypal_currency_support', 10, 1 );
828
+add_filter('wpinv_enabled_payment_gateways', 'wpinv_check_paypal_currency_support', 10, 1);
829 829
 
830
-function wpinv_gateway_paypal_button_label( $label ) {
831
-    return __( 'Proceed to PayPal', 'invoicing' );
830
+function wpinv_gateway_paypal_button_label($label) {
831
+    return __('Proceed to PayPal', 'invoicing');
832 832
 }
833
-add_filter( 'wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1 );
834 833
\ No newline at end of file
834
+add_filter('wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1);
835 835
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/composer/autoload_static.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,31 +6,31 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5
8 8
 {
9
-    public static $files = array (
9
+    public static $files = array(
10 10
         '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php',
11 11
     );
12 12
 
13
-    public static $prefixLengthsPsr4 = array (
13
+    public static $prefixLengthsPsr4 = array(
14 14
         'C' => 
15
-        array (
15
+        array(
16 16
             'Composer\\Installers\\' => 20,
17 17
         ),
18 18
     );
19 19
 
20
-    public static $prefixDirsPsr4 = array (
20
+    public static $prefixDirsPsr4 = array(
21 21
         'Composer\\Installers\\' => 
22
-        array (
22
+        array(
23 23
             0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers',
24 24
         ),
25 25
     );
26 26
 
27
-    public static $classMap = array (
27
+    public static $classMap = array(
28 28
         'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php',
29 29
     );
30 30
 
31 31
     public static function getInitializer(ClassLoader $loader)
32 32
     {
33
-        return \Closure::bind(function () use ($loader) {
33
+        return \Closure::bind(function() use ($loader) {
34 34
             $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4;
35 35
             $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4;
36 36
             $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap;
Please login to merge, or discard this patch.
vendor/composer/ClassLoader.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
         if (!$prefix) {
112 112
             if ($prepend) {
113 113
                 $this->fallbackDirsPsr0 = array_merge(
114
-                    (array) $paths,
114
+                    (array)$paths,
115 115
                     $this->fallbackDirsPsr0
116 116
                 );
117 117
             } else {
118 118
                 $this->fallbackDirsPsr0 = array_merge(
119 119
                     $this->fallbackDirsPsr0,
120
-                    (array) $paths
120
+                    (array)$paths
121 121
                 );
122 122
             }
123 123
 
@@ -126,19 +126,19 @@  discard block
 block discarded – undo
126 126
 
127 127
         $first = $prefix[0];
128 128
         if (!isset($this->prefixesPsr0[$first][$prefix])) {
129
-            $this->prefixesPsr0[$first][$prefix] = (array) $paths;
129
+            $this->prefixesPsr0[$first][$prefix] = (array)$paths;
130 130
 
131 131
             return;
132 132
         }
133 133
         if ($prepend) {
134 134
             $this->prefixesPsr0[$first][$prefix] = array_merge(
135
-                (array) $paths,
135
+                (array)$paths,
136 136
                 $this->prefixesPsr0[$first][$prefix]
137 137
             );
138 138
         } else {
139 139
             $this->prefixesPsr0[$first][$prefix] = array_merge(
140 140
                 $this->prefixesPsr0[$first][$prefix],
141
-                (array) $paths
141
+                (array)$paths
142 142
             );
143 143
         }
144 144
     }
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
             // Register directories for the root namespace.
160 160
             if ($prepend) {
161 161
                 $this->fallbackDirsPsr4 = array_merge(
162
-                    (array) $paths,
162
+                    (array)$paths,
163 163
                     $this->fallbackDirsPsr4
164 164
                 );
165 165
             } else {
166 166
                 $this->fallbackDirsPsr4 = array_merge(
167 167
                     $this->fallbackDirsPsr4,
168
-                    (array) $paths
168
+                    (array)$paths
169 169
                 );
170 170
             }
171 171
         } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
                 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176 176
             }
177 177
             $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178
-            $this->prefixDirsPsr4[$prefix] = (array) $paths;
178
+            $this->prefixDirsPsr4[$prefix] = (array)$paths;
179 179
         } elseif ($prepend) {
180 180
             // Prepend directories for an already registered namespace.
181 181
             $this->prefixDirsPsr4[$prefix] = array_merge(
182
-                (array) $paths,
182
+                (array)$paths,
183 183
                 $this->prefixDirsPsr4[$prefix]
184 184
             );
185 185
         } else {
186 186
             // Append directories for an already registered namespace.
187 187
             $this->prefixDirsPsr4[$prefix] = array_merge(
188 188
                 $this->prefixDirsPsr4[$prefix],
189
-                (array) $paths
189
+                (array)$paths
190 190
             );
191 191
         }
192 192
     }
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
     public function set($prefix, $paths)
202 202
     {
203 203
         if (!$prefix) {
204
-            $this->fallbackDirsPsr0 = (array) $paths;
204
+            $this->fallbackDirsPsr0 = (array)$paths;
205 205
         } else {
206
-            $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
206
+            $this->prefixesPsr0[$prefix[0]][$prefix] = (array)$paths;
207 207
         }
208 208
     }
209 209
 
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
     public function setPsr4($prefix, $paths)
220 220
     {
221 221
         if (!$prefix) {
222
-            $this->fallbackDirsPsr4 = (array) $paths;
222
+            $this->fallbackDirsPsr4 = (array)$paths;
223 223
         } else {
224 224
             $length = strlen($prefix);
225 225
             if ('\\' !== $prefix[$length - 1]) {
226 226
                 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227 227
             }
228 228
             $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229
-            $this->prefixDirsPsr4[$prefix] = (array) $paths;
229
+            $this->prefixDirsPsr4[$prefix] = (array)$paths;
230 230
         }
231 231
     }
232 232
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             return false;
343 343
         }
344 344
         if (null !== $this->apcuPrefix) {
345
-            $file = apcu_fetch($this->apcuPrefix.$class, $hit);
345
+            $file = apcu_fetch($this->apcuPrefix . $class, $hit);
346 346
             if ($hit) {
347 347
                 return $file;
348 348
             }
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
         }
357 357
 
358 358
         if (null !== $this->apcuPrefix) {
359
-            apcu_add($this->apcuPrefix.$class, $file);
359
+            apcu_add($this->apcuPrefix . $class, $file);
360 360
         }
361 361
 
362 362
         if (false === $file) {
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
     public function getLocations()
36 36
     {
37 37
         if ($this->matchesCakeVersion('>=', '3.0.0')) {
38
-            $this->locations['plugin'] =  $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
38
+            $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
39 39
         }
40 40
         return $this->locations;
41 41
     }
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/GravInstaller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
         $restrictedWords = implode('|', array_keys($this->locations));
21 21
 
22 22
         $vars['name'] = strtolower($vars['name']);
23
-        $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui',
23
+        $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:' . $restrictedWords . ')-)?(.*?)(?:-(?:' . $restrictedWords . '))?$/ui',
24 24
             '$1',
25 25
             $vars['name']
26 26
         );
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/MauticInstaller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     public function inflectPackageVars($vars)
15 15
     {
16 16
         if ($vars['type'] == 'mautic-plugin') {
17
-            $vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) {
17
+            $vars['name'] = preg_replace_callback('/(-[a-z])/', function($matches) {
18 18
                 return strtoupper($matches[0][1]);
19 19
             }, ucfirst($vars['name']));
20 20
         }
Please login to merge, or discard this patch.
composer/installers/src/Composer/Installers/PlentymarketsInstaller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
                 unset($vars['name'][$key]);
23 23
             }
24 24
         }
25
-        $vars['name'] = implode("",$vars['name']);
25
+        $vars['name'] = implode("", $vars['name']);
26 26
 
27 27
         return $vars;
28 28
     }
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/MajimaInstaller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
      */
29 29
     private function correctPluginName($vars)
30 30
     {
31
-        $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
31
+        $camelCasedName = preg_replace_callback('/(-[a-z])/', function($matches) {
32 32
             return strtoupper($matches[0][1]);
33 33
         }, $vars['name']);
34 34
         $vars['name'] = ucfirst($camelCasedName);
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/AglInstaller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
      */
13 13
     public function inflectPackageVars($vars)
14 14
     {
15
-        $vars['name'] = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) {
15
+        $vars['name'] = preg_replace_callback('/(?:^|_|-)(.?)/', function($matches) {
16 16
             return strtoupper($matches[1]);
17 17
         }, $vars['name']);
18 18
 
Please login to merge, or discard this patch.