Completed
Pull Request — master (#653)
by Gabor
03:10
created
includes/class-wc-stripe-helper.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 	 * @param object $order
23 23
 	 * @return string $currency
24 24
 	 */
25
-	public static function get_stripe_currency( $order = null ) {
26
-		if ( is_null( $order ) ) {
25
+	public static function get_stripe_currency($order = null) {
26
+		if (is_null($order)) {
27 27
 			return false;
28 28
 		}
29 29
 
30 30
 		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
31 31
 
32
-		return WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, self::META_NAME_STRIPE_CURRENCY, true ) : $order->get_meta( self::META_NAME_STRIPE_CURRENCY, true );
32
+		return WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, self::META_NAME_STRIPE_CURRENCY, true) : $order->get_meta(self::META_NAME_STRIPE_CURRENCY, true);
33 33
 	}
34 34
 
35 35
 	/**
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 	 * @param object $order
40 40
 	 * @param string $currency
41 41
 	 */
42
-	public static function update_stripe_currency( $order = null, $currency ) {
43
-		if ( is_null( $order ) ) {
42
+	public static function update_stripe_currency($order = null, $currency) {
43
+		if (is_null($order)) {
44 44
 			return false;
45 45
 		}
46 46
 
47 47
 		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
48 48
 
49
-		WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, self::META_NAME_STRIPE_CURRENCY, $currency ) : $order->update_meta_data( self::META_NAME_STRIPE_CURRENCY, $currency );
49
+		WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_STRIPE_CURRENCY, $currency) : $order->update_meta_data(self::META_NAME_STRIPE_CURRENCY, $currency);
50 50
 	}
51 51
 
52 52
 	/**
@@ -56,22 +56,22 @@  discard block
 block discarded – undo
56 56
 	 * @param object $order
57 57
 	 * @return string $amount
58 58
 	 */
59
-	public static function get_stripe_fee( $order = null ) {
60
-		if ( is_null( $order ) ) {
59
+	public static function get_stripe_fee($order = null) {
60
+		if (is_null($order)) {
61 61
 			return false;
62 62
 		}
63 63
 
64 64
 		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
65 65
 
66
-		$amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, self::META_NAME_FEE, true ) : $order->get_meta( self::META_NAME_FEE, true );
66
+		$amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, self::META_NAME_FEE, true) : $order->get_meta(self::META_NAME_FEE, true);
67 67
 
68 68
 		// If not found let's check for legacy name.
69
-		if ( empty( $amount ) ) {
70
-			$amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, self::LEGACY_META_NAME_FEE, true ) : $order->get_meta( self::LEGACY_META_NAME_FEE, true );
69
+		if (empty($amount)) {
70
+			$amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, self::LEGACY_META_NAME_FEE, true) : $order->get_meta(self::LEGACY_META_NAME_FEE, true);
71 71
 
72 72
 			// If found update to new name.
73
-			if ( $amount ) {
74
-				self::update_stripe_fee( $order, $amount );
73
+			if ($amount) {
74
+				self::update_stripe_fee($order, $amount);
75 75
 			}
76 76
 		}
77 77
 
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 	 * @param object $order
86 86
 	 * @param float $amount
87 87
 	 */
88
-	public static function update_stripe_fee( $order = null, $amount = 0.0 ) {
89
-		if ( is_null( $order ) ) {
88
+	public static function update_stripe_fee($order = null, $amount = 0.0) {
89
+		if (is_null($order)) {
90 90
 			return false;
91 91
 		}
92 92
 
93 93
 		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
94 94
 
95
-		WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, self::META_NAME_FEE, $amount ) : $order->update_meta_data( self::META_NAME_FEE, $amount );
95
+		WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_FEE, $amount) : $order->update_meta_data(self::META_NAME_FEE, $amount);
96 96
 	}
97 97
 
98 98
 	/**
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 	 * @since 4.1.0
102 102
 	 * @param object $order
103 103
 	 */
104
-	public static function delete_stripe_fee( $order = null ) {
105
-		if ( is_null( $order ) ) {
104
+	public static function delete_stripe_fee($order = null) {
105
+		if (is_null($order)) {
106 106
 			return false;
107 107
 		}
108 108
 
109 109
 		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
110 110
 
111
-		delete_post_meta( $order_id, self::META_NAME_FEE );
112
-		delete_post_meta( $order_id, self::LEGACY_META_NAME_FEE );
111
+		delete_post_meta($order_id, self::META_NAME_FEE);
112
+		delete_post_meta($order_id, self::LEGACY_META_NAME_FEE);
113 113
 	}
114 114
 
115 115
 	/**
@@ -119,22 +119,22 @@  discard block
 block discarded – undo
119 119
 	 * @param object $order
120 120
 	 * @return string $amount
121 121
 	 */
122
-	public static function get_stripe_net( $order = null ) {
123
-		if ( is_null( $order ) ) {
122
+	public static function get_stripe_net($order = null) {
123
+		if (is_null($order)) {
124 124
 			return false;
125 125
 		}
126 126
 
127 127
 		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
128 128
 
129
-		$amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, self::META_NAME_NET, true ) : $order->get_meta( self::META_NAME_NET, true );
129
+		$amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, self::META_NAME_NET, true) : $order->get_meta(self::META_NAME_NET, true);
130 130
 
131 131
 		// If not found let's check for legacy name.
132
-		if ( empty( $amount ) ) {
133
-			$amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, self::LEGACY_META_NAME_NET, true ) : $order->get_meta( self::LEGACY_META_NAME_NET, true );
132
+		if (empty($amount)) {
133
+			$amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, self::LEGACY_META_NAME_NET, true) : $order->get_meta(self::LEGACY_META_NAME_NET, true);
134 134
 
135 135
 			// If found update to new name.
136
-			if ( $amount ) {
137
-				self::update_stripe_net( $order, $amount );
136
+			if ($amount) {
137
+				self::update_stripe_net($order, $amount);
138 138
 			}
139 139
 		}
140 140
 
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 	 * @param object $order
149 149
 	 * @param float $amount
150 150
 	 */
151
-	public static function update_stripe_net( $order = null, $amount = 0.0 ) {
152
-		if ( is_null( $order ) ) {
151
+	public static function update_stripe_net($order = null, $amount = 0.0) {
152
+		if (is_null($order)) {
153 153
 			return false;
154 154
 		}
155 155
 
156 156
 		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
157 157
 
158
-		WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, self::META_NAME_NET, $amount ) : $order->update_meta_data( self::META_NAME_NET, $amount );
158
+		WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_NET, $amount) : $order->update_meta_data(self::META_NAME_NET, $amount);
159 159
 	}
160 160
 
161 161
 	/**
@@ -164,15 +164,15 @@  discard block
 block discarded – undo
164 164
 	 * @since 4.1.0
165 165
 	 * @param object $order
166 166
 	 */
167
-	public static function delete_stripe_net( $order = null ) {
168
-		if ( is_null( $order ) ) {
167
+	public static function delete_stripe_net($order = null) {
168
+		if (is_null($order)) {
169 169
 			return false;
170 170
 		}
171 171
 
172 172
 		$order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
173 173
 
174
-		delete_post_meta( $order_id, self::META_NAME_NET );
175
-		delete_post_meta( $order_id, self::LEGACY_META_NAME_NET );
174
+		delete_post_meta($order_id, self::META_NAME_NET);
175
+		delete_post_meta($order_id, self::LEGACY_META_NAME_NET);
176 176
 	}
177 177
 
178 178
 	/**
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @return float|int
185 185
 	 */
186
-	public static function get_stripe_amount( $total, $currency = '' ) {
187
-		if ( ! $currency ) {
186
+	public static function get_stripe_amount($total, $currency = '') {
187
+		if ( ! $currency) {
188 188
 			$currency = get_woocommerce_currency();
189 189
 		}
190 190
 
191
-		if ( in_array( strtolower( $currency ), self::no_decimal_currencies() ) ) {
192
-			return absint( $total );
191
+		if (in_array(strtolower($currency), self::no_decimal_currencies())) {
192
+			return absint($total);
193 193
 		} else {
194
-			return absint( wc_format_decimal( ( (float) $total * 100 ), wc_get_price_decimals() ) ); // In cents.
194
+			return absint(wc_format_decimal(((float) $total * 100), wc_get_price_decimals())); // In cents.
195 195
 		}
196 196
 	}
197 197
 
@@ -203,25 +203,25 @@  discard block
 block discarded – undo
203 203
 	 * @return array
204 204
 	 */
205 205
 	public static function get_localized_messages() {
206
-		return apply_filters( 'wc_stripe_localized_messages', array(
207
-			'invalid_number'           => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ),
208
-			'invalid_expiry_month'     => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ),
209
-			'invalid_expiry_year'      => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ),
210
-			'invalid_cvc'              => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ),
211
-			'incorrect_number'         => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ),
212
-			'incomplete_number'        => __( 'The card number is incomplete.', 'woocommerce-gateway-stripe' ),
213
-			'incomplete_cvc'           => __( 'The card\'s security code is incomplete.', 'woocommerce-gateway-stripe' ),
214
-			'incomplete_expiry'        => __( 'The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe' ),
215
-			'expired_card'             => __( 'The card has expired.', 'woocommerce-gateway-stripe' ),
216
-			'incorrect_cvc'            => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ),
217
-			'incorrect_zip'            => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ),
218
-			'invalid_expiry_year_past' => __( 'The card\'s expiration year is in the past', 'woocommerce-gateway-stripe' ),
219
-			'card_declined'            => __( 'The card was declined.', 'woocommerce-gateway-stripe' ),
220
-			'missing'                  => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ),
221
-			'processing_error'         => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ),
222
-			'invalid_request_error'    => __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ),
223
-			'invalid_sofort_country'   => __( 'The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe' ),
224
-		) );
206
+		return apply_filters('wc_stripe_localized_messages', array(
207
+			'invalid_number'           => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'),
208
+			'invalid_expiry_month'     => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'),
209
+			'invalid_expiry_year'      => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'),
210
+			'invalid_cvc'              => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'),
211
+			'incorrect_number'         => __('The card number is incorrect.', 'woocommerce-gateway-stripe'),
212
+			'incomplete_number'        => __('The card number is incomplete.', 'woocommerce-gateway-stripe'),
213
+			'incomplete_cvc'           => __('The card\'s security code is incomplete.', 'woocommerce-gateway-stripe'),
214
+			'incomplete_expiry'        => __('The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe'),
215
+			'expired_card'             => __('The card has expired.', 'woocommerce-gateway-stripe'),
216
+			'incorrect_cvc'            => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'),
217
+			'incorrect_zip'            => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'),
218
+			'invalid_expiry_year_past' => __('The card\'s expiration year is in the past', 'woocommerce-gateway-stripe'),
219
+			'card_declined'            => __('The card was declined.', 'woocommerce-gateway-stripe'),
220
+			'missing'                  => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'),
221
+			'processing_error'         => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'),
222
+			'invalid_request_error'    => __('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe'),
223
+			'invalid_sofort_country'   => __('The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe'),
224
+		));
225 225
 	}
226 226
 
227 227
 	/**
@@ -258,24 +258,24 @@  discard block
 block discarded – undo
258 258
 	 * @param string $type Type of number to format
259 259
 	 * @return string
260 260
 	 */
261
-	public static function format_balance_fee( $balance_transaction, $type = 'fee' ) {
262
-		if ( ! is_object( $balance_transaction ) ) {
261
+	public static function format_balance_fee($balance_transaction, $type = 'fee') {
262
+		if ( ! is_object($balance_transaction)) {
263 263
 			return;
264 264
 		}
265 265
 
266
-		if ( in_array( strtolower( $balance_transaction->currency ), self::no_decimal_currencies() ) ) {
267
-			if ( 'fee' === $type ) {
266
+		if (in_array(strtolower($balance_transaction->currency), self::no_decimal_currencies())) {
267
+			if ('fee' === $type) {
268 268
 				return $balance_transaction->fee;
269 269
 			}
270 270
 
271 271
 			return $balance_transaction->net;
272 272
 		}
273 273
 
274
-		if ( 'fee' === $type ) {
275
-			return number_format( $balance_transaction->fee / 100, 2, '.', '' );
274
+		if ('fee' === $type) {
275
+			return number_format($balance_transaction->fee / 100, 2, '.', '');
276 276
 		}
277 277
 
278
-		return number_format( $balance_transaction->net / 100, 2, '.', '' );
278
+		return number_format($balance_transaction->net / 100, 2, '.', '');
279 279
 	}
280 280
 
281 281
 	/**
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 */
284 284
 	public static function get_minimum_amount() {
285 285
 		// Check order amount
286
-		switch ( get_woocommerce_currency() ) {
286
+		switch (get_woocommerce_currency()) {
287 287
 			case 'USD':
288 288
 			case 'CAD':
289 289
 			case 'EUR':
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
 	 * @param string $method The payment method to get the settings from.
329 329
 	 * @param string $setting The name of the setting to get.
330 330
 	 */
331
-	public static function get_settings( $method = null, $setting = null ) {
332
-		$all_settings = null === $method ? get_option( 'woocommerce_stripe_settings', array() ) : get_option( 'woocommerce_stripe_' . $method . '_settings', array() );
331
+	public static function get_settings($method = null, $setting = null) {
332
+		$all_settings = null === $method ? get_option('woocommerce_stripe_settings', array()) : get_option('woocommerce_stripe_' . $method . '_settings', array());
333 333
 
334
-		if ( null === $setting ) {
334
+		if (null === $setting) {
335 335
 			return $all_settings;
336 336
 		}
337 337
 
338
-		return isset( $all_settings[ $setting ] ) ? $all_settings[ $setting ] : '';
338
+		return isset($all_settings[$setting]) ? $all_settings[$setting] : '';
339 339
 	}
340 340
 
341 341
 	/**
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 * @return bool
346 346
 	 */
347 347
 	public static function is_pre_orders_exists() {
348
-		return class_exists( 'WC_Pre_Orders_Order' );
348
+		return class_exists('WC_Pre_Orders_Order');
349 349
 	}
350 350
 
351 351
 	/**
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	 * @return bool
357 357
 	 */
358 358
 	public static function is_pre_30() {
359
-		return version_compare( WC_VERSION, '3.0.0', '<' );
359
+		return version_compare(WC_VERSION, '3.0.0', '<');
360 360
 	}
361 361
 
362 362
 	/**
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 * @return string
370 370
 	 */
371 371
 	public static function get_webhook_url() {
372
-		return add_query_arg( 'wc-api', 'wc_stripe', trailingslashit( get_home_url() ) );
372
+		return add_query_arg('wc-api', 'wc_stripe', trailingslashit(get_home_url()));
373 373
 	}
374 374
 
375 375
 	/**
@@ -379,13 +379,13 @@  discard block
 block discarded – undo
379 379
 	 * @version 4.0.0
380 380
 	 * @param string $source_id
381 381
 	 */
382
-	public static function get_order_by_source_id( $source_id ) {
382
+	public static function get_order_by_source_id($source_id) {
383 383
 		global $wpdb;
384 384
 
385
-		$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $source_id, '_stripe_source_id' ) );
385
+		$order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $source_id, '_stripe_source_id'));
386 386
 
387
-		if ( ! empty( $order_id ) ) {
388
-			return wc_get_order( $order_id );
387
+		if ( ! empty($order_id)) {
388
+			return wc_get_order($order_id);
389 389
 		}
390 390
 
391 391
 		return false;
@@ -398,13 +398,13 @@  discard block
 block discarded – undo
398 398
 	 * @version 4.0.0
399 399
 	 * @param string $charge_id
400 400
 	 */
401
-	public static function get_order_by_charge_id( $charge_id ) {
401
+	public static function get_order_by_charge_id($charge_id) {
402 402
 		global $wpdb;
403 403
 
404
-		$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $charge_id, '_transaction_id' ) );
404
+		$order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $charge_id, '_transaction_id'));
405 405
 
406
-		if ( ! empty( $order_id ) ) {
407
-			return wc_get_order( $order_id );
406
+		if ( ! empty($order_id)) {
407
+			return wc_get_order($order_id);
408 408
 		}
409 409
 
410 410
 		return false;
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
 	 * @param string $statement_descriptor
421 421
 	 * @return string $statement_descriptor Sanitized statement descriptor
422 422
 	 */
423
-	public static function clean_statement_descriptor( $statement_descriptor = '' ) {
424
-		$disallowed_characters = array( '<', '>', '"', "'" );
423
+	public static function clean_statement_descriptor($statement_descriptor = '') {
424
+		$disallowed_characters = array('<', '>', '"', "'");
425 425
 
426 426
 		// Remove special characters.
427
-		$statement_descriptor = str_replace( $disallowed_characters, '', $statement_descriptor );
427
+		$statement_descriptor = str_replace($disallowed_characters, '', $statement_descriptor);
428 428
 
429
-		$statement_descriptor = substr( trim( $statement_descriptor ), 0, 22 );
429
+		$statement_descriptor = substr(trim($statement_descriptor), 0, 22);
430 430
 
431 431
 		return $statement_descriptor;
432 432
 	}
Please login to merge, or discard this patch.
woocommerce-gateway-stripe.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
  *
16 16
  */
17 17
 
18
-if ( ! defined( 'ABSPATH' ) ) {
18
+if ( ! defined('ABSPATH')) {
19 19
 	exit;
20 20
 }
21 21
 
22
-require_once( dirname( __FILE__ ) . '/woo-includes/woo-functions.php' );
22
+require_once(dirname(__FILE__) . '/woo-includes/woo-functions.php');
23 23
 
24 24
 /**
25 25
  * WooCommerce fallback notice.
@@ -28,24 +28,24 @@  discard block
 block discarded – undo
28 28
  * @return string
29 29
  */
30 30
 function woocommerce_stripe_missing_wc_notice() {
31
-	echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'Stripe requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-gateway-stripe' ), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>' ) . '</strong></p></div>';
31
+	echo '<div class="error"><p><strong>' . sprintf(esc_html__('Stripe requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-gateway-stripe'), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>') . '</strong></p></div>';
32 32
 }
33 33
 
34
-if ( ! wc_stripe_is_wc_active() ) {
35
-	add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' );
34
+if ( ! wc_stripe_is_wc_active()) {
35
+	add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice');
36 36
 	return;
37 37
 }
38 38
 
39
-if ( ! class_exists( 'WC_Stripe' ) ) :
39
+if ( ! class_exists('WC_Stripe')) :
40 40
 	/**
41 41
 	 * Required minimums and constants
42 42
 	 */
43
-	define( 'WC_STRIPE_VERSION', '4.1.4' );
44
-	define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
45
-	define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' );
46
-	define( 'WC_STRIPE_MAIN_FILE', __FILE__ );
47
-	define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
48
-	define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
43
+	define('WC_STRIPE_VERSION', '4.1.4');
44
+	define('WC_STRIPE_MIN_PHP_VER', '5.6.0');
45
+	define('WC_STRIPE_MIN_WC_VER', '2.6.0');
46
+	define('WC_STRIPE_MAIN_FILE', __FILE__);
47
+	define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__))));
48
+	define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__)));
49 49
 
50 50
 	class WC_Stripe {
51 51
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		 * @return Singleton The *Singleton* instance.
66 66
 		 */
67 67
 		public static function get_instance() {
68
-			if ( null === self::$instance ) {
68
+			if (null === self::$instance) {
69 69
 				self::$instance = new self();
70 70
 			}
71 71
 			return self::$instance;
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 		 * *Singleton* via the `new` operator from outside of this class.
93 93
 		 */
94 94
 		private function __construct() {
95
-			add_action( 'admin_init', array( $this, 'install' ) );
96
-			add_action( 'plugins_loaded', array( $this, 'init' ) );
95
+			add_action('admin_init', array($this, 'install'));
96
+			add_action('plugins_loaded', array($this, 'init'));
97 97
 		}
98 98
 
99 99
 		/**
@@ -103,51 +103,51 @@  discard block
 block discarded – undo
103 103
 		 * @version 4.0.0
104 104
 		 */
105 105
 		public function init() {
106
-			if ( is_admin() ) {
107
-				require_once( dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php' );
106
+			if (is_admin()) {
107
+				require_once(dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php');
108 108
 			}
109 109
 
110
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php' );
111
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php' );
112
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php' );
113
-			include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php' );
114
-
115
-			load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
116
-
117
-			require_once( dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php' );
118
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php' );
119
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php' );
120
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php' );
121
-			require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php' );
122
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php' );
123
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php' );
124
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php' );
125
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php' );
126
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php' );
127
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php' );
128
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php' );
129
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php' );
130
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php' );
131
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php' );
132
-			require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php' );
133
-			require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php' );
134
-			require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php' );
135
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php' );
136
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php' );
137
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php' );
138
-
139
-			if ( is_admin() ) {
140
-				require_once( dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php' );
110
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-exception.php');
111
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-logger.php');
112
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-helper.php');
113
+			include_once(dirname(__FILE__) . '/includes/class-wc-stripe-api.php');
114
+
115
+			load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages');
116
+
117
+			require_once(dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php');
118
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php');
119
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php');
120
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php');
121
+			require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php');
122
+			require_once(dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php');
123
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php');
124
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php');
125
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php');
126
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php');
127
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php');
128
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php');
129
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php');
130
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php');
131
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php');
132
+			require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php');
133
+			require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php');
134
+			require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php');
135
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php');
136
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php');
137
+			require_once(dirname(__FILE__) . '/includes/class-wc-stripe-customer.php');
138
+
139
+			if (is_admin()) {
140
+				require_once(dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php');
141 141
 			}
142 142
 
143 143
 			// REMOVE IN THE FUTURE.
144
-			require_once( dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php' );
144
+			require_once(dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php');
145 145
 
146
-			add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) );
147
-			add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
146
+			add_filter('woocommerce_payment_gateways', array($this, 'add_gateways'));
147
+			add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
148 148
 
149
-			if ( version_compare( WC_VERSION, '3.4', '<' ) ) {
150
-				add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) );
149
+			if (version_compare(WC_VERSION, '3.4', '<')) {
150
+				add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin'));
151 151
 			}
152 152
 		}
153 153
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 		 * @version 4.0.0
159 159
 		 */
160 160
 		public function update_plugin_version() {
161
-			delete_option( 'wc_stripe_version' );
162
-			update_option( 'wc_stripe_version', WC_STRIPE_VERSION );
161
+			delete_option('wc_stripe_version');
162
+			update_option('wc_stripe_version', WC_STRIPE_VERSION);
163 163
 		}
164 164
 
165 165
 		/**
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
 		 * @version 3.1.0
170 170
 		 */
171 171
 		public function install() {
172
-			if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) {
172
+			if ( ! is_plugin_active(plugin_basename(__FILE__))) {
173 173
 				return;
174 174
 			}
175 175
 
176
-			if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) {
177
-				do_action( 'woocommerce_stripe_updated' );
176
+			if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) {
177
+				do_action('woocommerce_stripe_updated');
178 178
 
179
-				if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) {
180
-					define( 'WC_STRIPE_INSTALLING', true );
179
+				if ( ! defined('WC_STRIPE_INSTALLING')) {
180
+					define('WC_STRIPE_INSTALLING', true);
181 181
 				}
182 182
 
183 183
 				$this->update_plugin_version();
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
 		 * @since 1.0.0
191 191
 		 * @version 4.0.0
192 192
 		 */
193
-		public function plugin_action_links( $links ) {
193
+		public function plugin_action_links($links) {
194 194
 			$plugin_links = array(
195
-				'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
196
-				'<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>',
197
-				'<a href="https://woocommerce.com/contact-us/">' . esc_html__( 'Support', 'woocommerce-gateway-stripe' ) . '</a>',
195
+				'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>',
196
+				'<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__('Docs', 'woocommerce-gateway-stripe') . '</a>',
197
+				'<a href="https://woocommerce.com/contact-us/">' . esc_html__('Support', 'woocommerce-gateway-stripe') . '</a>',
198 198
 			);
199
-			return array_merge( $plugin_links, $links );
199
+			return array_merge($plugin_links, $links);
200 200
 		}
201 201
 
202 202
 		/**
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 		 * @since 1.0.0
206 206
 		 * @version 4.0.0
207 207
 		 */
208
-		public function add_gateways( $methods ) {
209
-			if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) {
208
+		public function add_gateways($methods) {
209
+			if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) {
210 210
 				$methods[] = 'WC_Stripe_Subs_Compat';
211 211
 				$methods[] = 'WC_Stripe_Sepa_Subs_Compat';
212 212
 			} else {
@@ -232,28 +232,28 @@  discard block
 block discarded – undo
232 232
 		 * @since 4.0.0
233 233
 		 * @version 4.0.0
234 234
 		 */
235
-		public function filter_gateway_order_admin( $sections ) {
236
-			unset( $sections['stripe'] );
237
-			unset( $sections['stripe_bancontact'] );
238
-			unset( $sections['stripe_sofort'] );
239
-			unset( $sections['stripe_giropay'] );
240
-			unset( $sections['stripe_eps'] );
241
-			unset( $sections['stripe_ideal'] );
242
-			unset( $sections['stripe_p24'] );
243
-			unset( $sections['stripe_alipay'] );
244
-			unset( $sections['stripe_sepa'] );
245
-			unset( $sections['stripe_multibanco'] );
235
+		public function filter_gateway_order_admin($sections) {
236
+			unset($sections['stripe']);
237
+			unset($sections['stripe_bancontact']);
238
+			unset($sections['stripe_sofort']);
239
+			unset($sections['stripe_giropay']);
240
+			unset($sections['stripe_eps']);
241
+			unset($sections['stripe_ideal']);
242
+			unset($sections['stripe_p24']);
243
+			unset($sections['stripe_alipay']);
244
+			unset($sections['stripe_sepa']);
245
+			unset($sections['stripe_multibanco']);
246 246
 
247 247
 			$sections['stripe']            = 'Stripe';
248
-			$sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' );
249
-			$sections['stripe_sofort']     = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' );
250
-			$sections['stripe_giropay']    = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' );
251
-			$sections['stripe_eps']        = __( 'Stripe EPS', 'woocommerce-gateway-stripe' );
252
-			$sections['stripe_ideal']      = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' );
253
-			$sections['stripe_p24']        = __( 'Stripe P24', 'woocommerce-gateway-stripe' );
254
-			$sections['stripe_alipay']     = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' );
255
-			$sections['stripe_sepa']       = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' );
256
-			$sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' );
248
+			$sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe');
249
+			$sections['stripe_sofort']     = __('Stripe SOFORT', 'woocommerce-gateway-stripe');
250
+			$sections['stripe_giropay']    = __('Stripe Giropay', 'woocommerce-gateway-stripe');
251
+			$sections['stripe_eps']        = __('Stripe EPS', 'woocommerce-gateway-stripe');
252
+			$sections['stripe_ideal']      = __('Stripe iDeal', 'woocommerce-gateway-stripe');
253
+			$sections['stripe_p24']        = __('Stripe P24', 'woocommerce-gateway-stripe');
254
+			$sections['stripe_alipay']     = __('Stripe Alipay', 'woocommerce-gateway-stripe');
255
+			$sections['stripe_sepa']       = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe');
256
+			$sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe');
257 257
 
258 258
 			return $sections;
259 259
 		}
Please login to merge, or discard this patch.
includes/admin/class-wc-stripe-privacy.php 1 patch
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! class_exists( 'WC_Abstract_Privacy' ) ) {
2
+if ( ! class_exists('WC_Abstract_Privacy')) {
3 3
 	return;
4 4
 }
5 5
 
@@ -9,18 +9,18 @@  discard block
 block discarded – undo
9 9
 	 *
10 10
 	 */
11 11
 	public function __construct() {
12
-		parent::__construct( __( 'Stripe', 'woocommerce-gateway-stripe' ) );
12
+		parent::__construct(__('Stripe', 'woocommerce-gateway-stripe'));
13 13
 
14
-		$this->add_exporter( 'woocommerce-gateway-stripe-order-data', __( 'WooCommerce Stripe Order Data', 'woocommerce-gateway-stripe' ), array( $this, 'order_data_exporter' ) );
14
+		$this->add_exporter('woocommerce-gateway-stripe-order-data', __('WooCommerce Stripe Order Data', 'woocommerce-gateway-stripe'), array($this, 'order_data_exporter'));
15 15
 
16
-		if ( function_exists( 'wcs_get_subscriptions' ) ) {
17
-			$this->add_exporter( 'woocommerce-gateway-stripe-subscriptions-data', __( 'WooCommerce Stripe Subscriptions Data', 'woocommerce-gateway-stripe' ), array( $this, 'subscriptions_data_exporter' ) );
16
+		if (function_exists('wcs_get_subscriptions')) {
17
+			$this->add_exporter('woocommerce-gateway-stripe-subscriptions-data', __('WooCommerce Stripe Subscriptions Data', 'woocommerce-gateway-stripe'), array($this, 'subscriptions_data_exporter'));
18 18
 		}
19 19
 
20
-		$this->add_exporter( 'woocommerce-gateway-stripe-customer-data', __( 'WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe' ), array( $this, 'customer_data_exporter' ) );
20
+		$this->add_exporter('woocommerce-gateway-stripe-customer-data', __('WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe'), array($this, 'customer_data_exporter'));
21 21
 
22
-		$this->add_eraser( 'woocommerce-gateway-stripe-customer-data', __( 'WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe' ), array( $this, 'customer_data_eraser' ) );
23
-		$this->add_eraser( 'woocommerce-gateway-stripe-order-data', __( 'WooCommerce Stripe Data', 'woocommerce-gateway-stripe' ), array( $this, 'order_data_eraser' ) );
22
+		$this->add_eraser('woocommerce-gateway-stripe-customer-data', __('WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe'), array($this, 'customer_data_eraser'));
23
+		$this->add_eraser('woocommerce-gateway-stripe-order-data', __('WooCommerce Stripe Data', 'woocommerce-gateway-stripe'), array($this, 'order_data_eraser'));
24 24
 	}
25 25
 
26 26
 	/**
@@ -31,22 +31,22 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @return array WP_Post
33 33
 	 */
34
-	protected function get_stripe_orders( $email_address, $page ) {
35
-		$user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
34
+	protected function get_stripe_orders($email_address, $page) {
35
+		$user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data.
36 36
 
37
-		$order_query    = array(
38
-			'payment_method' => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ),
37
+		$order_query = array(
38
+			'payment_method' => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'),
39 39
 			'limit'          => 10,
40 40
 			'page'           => $page,
41 41
 		);
42 42
 
43
-		if ( $user instanceof WP_User ) {
43
+		if ($user instanceof WP_User) {
44 44
 			$order_query['customer_id'] = (int) $user->ID;
45 45
 		} else {
46 46
 			$order_query['billing_email'] = $email_address;
47 47
 		}
48 48
 
49
-		return wc_get_orders( $order_query );
49
+		return wc_get_orders($order_query);
50 50
 	}
51 51
 
52 52
 	/**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	public function get_privacy_message() {
57
-		return wpautop( sprintf( __( 'By using this extension, you may be storing personal data or sharing data with an external service. <a href="%s" target="_blank">Learn more about how this works, including what you may want to include in your privacy policy.</a>', 'woocommerce-gateway-stripe' ), 'https://docs.woocommerce.com/document/privacy-payments/#woocommerce-gateway-stripe' ) );
57
+		return wpautop(sprintf(__('By using this extension, you may be storing personal data or sharing data with an external service. <a href="%s" target="_blank">Learn more about how this works, including what you may want to include in your privacy policy.</a>', 'woocommerce-gateway-stripe'), 'https://docs.woocommerce.com/document/privacy-payments/#woocommerce-gateway-stripe'));
58 58
 	}
59 59
 
60 60
 	/**
@@ -65,34 +65,34 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @return array
67 67
 	 */
68
-	public function order_data_exporter( $email_address, $page = 1 ) {
68
+	public function order_data_exporter($email_address, $page = 1) {
69 69
 		$done           = false;
70 70
 		$data_to_export = array();
71 71
 
72
-		$orders = $this->get_stripe_orders( $email_address, (int) $page );
72
+		$orders = $this->get_stripe_orders($email_address, (int) $page);
73 73
 
74 74
 		$done = true;
75 75
 
76
-		if ( 0 < count( $orders ) ) {
77
-			foreach ( $orders as $order ) {
76
+		if (0 < count($orders)) {
77
+			foreach ($orders as $order) {
78 78
 				$data_to_export[] = array(
79 79
 					'group_id'    => 'woocommerce_orders',
80
-					'group_label' => __( 'Orders', 'woocommerce-gateway-stripe' ),
80
+					'group_label' => __('Orders', 'woocommerce-gateway-stripe'),
81 81
 					'item_id'     => 'order-' . $order->get_id(),
82 82
 					'data'        => array(
83 83
 						array(
84
-							'name'  => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ),
85
-							'value' => get_post_meta( $order->get_id(), '_stripe_source_id', true ),
84
+							'name'  => __('Stripe payment id', 'woocommerce-gateway-stripe'),
85
+							'value' => get_post_meta($order->get_id(), '_stripe_source_id', true),
86 86
 						),
87 87
 						array(
88
-							'name'  => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ),
89
-							'value' => get_post_meta( $order->get_id(), '_stripe_customer_id', true ),
88
+							'name'  => __('Stripe customer id', 'woocommerce-gateway-stripe'),
89
+							'value' => get_post_meta($order->get_id(), '_stripe_customer_id', true),
90 90
 						),
91 91
 					),
92 92
 				);
93 93
 			}
94 94
 
95
-			$done = 10 > count( $orders );
95
+			$done = 10 > count($orders);
96 96
 		}
97 97
 
98 98
 		return array(
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return array
111 111
 	 */
112
-	public function subscriptions_data_exporter( $email_address, $page = 1 ) {
112
+	public function subscriptions_data_exporter($email_address, $page = 1) {
113 113
 		$done           = false;
114 114
 		$page           = (int) $page;
115 115
 		$data_to_export = array();
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			'relation'    => 'AND',
119 119
 			array(
120 120
 				'key'     => '_payment_method',
121
-				'value'   => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ),
121
+				'value'   => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'),
122 122
 				'compare' => 'IN',
123 123
 			),
124 124
 			array(
@@ -128,36 +128,36 @@  discard block
 block discarded – undo
128 128
 			),
129 129
 		);
130 130
 
131
-		$subscription_query    = array(
131
+		$subscription_query = array(
132 132
 			'posts_per_page'  => 10,
133 133
 			'page'            => $page,
134 134
 			'meta_query'      => $meta_query,
135 135
 		);
136 136
 
137
-		$subscriptions = wcs_get_subscriptions( $subscription_query );
137
+		$subscriptions = wcs_get_subscriptions($subscription_query);
138 138
 
139 139
 		$done = true;
140 140
 
141
-		if ( 0 < count( $subscriptions ) ) {
142
-			foreach ( $subscriptions as $subscription ) {
141
+		if (0 < count($subscriptions)) {
142
+			foreach ($subscriptions as $subscription) {
143 143
 				$data_to_export[] = array(
144 144
 					'group_id'    => 'woocommerce_subscriptions',
145
-					'group_label' => __( 'Subscriptions', 'woocommerce-gateway-stripe' ),
145
+					'group_label' => __('Subscriptions', 'woocommerce-gateway-stripe'),
146 146
 					'item_id'     => 'subscription-' . $subscription->get_id(),
147 147
 					'data'        => array(
148 148
 						array(
149
-							'name'  => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ),
150
-							'value' => get_post_meta( $subscription->get_id(), '_stripe_source_id', true ),
149
+							'name'  => __('Stripe payment id', 'woocommerce-gateway-stripe'),
150
+							'value' => get_post_meta($subscription->get_id(), '_stripe_source_id', true),
151 151
 						),
152 152
 						array(
153
-							'name'  => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ),
154
-							'value' => get_post_meta( $subscription->get_id(), '_stripe_customer_id', true ),
153
+							'name'  => __('Stripe customer id', 'woocommerce-gateway-stripe'),
154
+							'value' => get_post_meta($subscription->get_id(), '_stripe_customer_id', true),
155 155
 						),
156 156
 					),
157 157
 				);
158 158
 			}
159 159
 
160
-			$done = 10 > count( $subscriptions );
160
+			$done = 10 > count($subscriptions);
161 161
 		}
162 162
 
163 163
 		return array(
@@ -173,24 +173,24 @@  discard block
 block discarded – undo
173 173
 	 * @param int    $page  Page.
174 174
 	 * @return array An array of personal data in name value pairs
175 175
 	 */
176
-	public function customer_data_exporter( $email_address, $page ) {
177
-		$user           = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
176
+	public function customer_data_exporter($email_address, $page) {
177
+		$user           = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data.
178 178
 		$data_to_export = array();
179 179
 
180
-		if ( $user instanceof WP_User ) {
181
-			$stripe_user = new WC_Stripe_Customer( $user->ID );
180
+		if ($user instanceof WP_User) {
181
+			$stripe_user = new WC_Stripe_Customer($user->ID);
182 182
 
183 183
 			$data_to_export[] = array(
184 184
 				'group_id'    => 'woocommerce_customer',
185
-				'group_label' => __( 'Customer Data', 'woocommerce-gateway-stripe' ),
185
+				'group_label' => __('Customer Data', 'woocommerce-gateway-stripe'),
186 186
 				'item_id'     => 'user',
187 187
 				'data'        => array(
188 188
 					array(
189
-						'name'  => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ),
190
-						'value' => get_user_meta( $user->ID, '_stripe_source_id', true ),
189
+						'name'  => __('Stripe payment id', 'woocommerce-gateway-stripe'),
190
+						'value' => get_user_meta($user->ID, '_stripe_source_id', true),
191 191
 					),
192 192
 					array(
193
-						'name'  => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ),
193
+						'name'  => __('Stripe customer id', 'woocommerce-gateway-stripe'),
194 194
 						'value' => $stripe_user->get_id(),
195 195
 					),
196 196
 				),
@@ -210,21 +210,21 @@  discard block
 block discarded – undo
210 210
 	 * @param int    $page  Page.
211 211
 	 * @return array An array of personal data in name value pairs
212 212
 	 */
213
-	public function customer_data_eraser( $email_address, $page ) {
213
+	public function customer_data_eraser($email_address, $page) {
214 214
 		$page = (int) $page;
215
-		$user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
215
+		$user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data.
216 216
 
217
-		$stripe_customer_id = get_user_meta( $user->ID, '_stripe_customer_id', true );
218
-		$stripe_source_id   = get_user_meta( $user->ID, '_stripe_source_id', true );
217
+		$stripe_customer_id = get_user_meta($user->ID, '_stripe_customer_id', true);
218
+		$stripe_source_id   = get_user_meta($user->ID, '_stripe_source_id', true);
219 219
 
220 220
 		$items_removed  = false;
221 221
 		$messages       = array();
222 222
 
223
-		if ( ! empty( $stripe_customer_id ) || ! empty( $stripe_source_id ) ) {
223
+		if ( ! empty($stripe_customer_id) || ! empty($stripe_source_id)) {
224 224
 			$items_removed = true;
225
-			delete_user_meta( $user->ID, '_stripe_customer_id' );
226
-			delete_user_meta( $user->ID, '_stripe_source_id' );
227
-			$messages[] = __( 'Stripe User Data Erased.', 'woocommerce-gateway-stripe' );
225
+			delete_user_meta($user->ID, '_stripe_customer_id');
226
+			delete_user_meta($user->ID, '_stripe_source_id');
227
+			$messages[] = __('Stripe User Data Erased.', 'woocommerce-gateway-stripe');
228 228
 		}
229 229
 
230 230
 		return array(
@@ -242,29 +242,29 @@  discard block
 block discarded – undo
242 242
 	 * @param int    $page  Page.
243 243
 	 * @return array An array of personal data in name value pairs
244 244
 	 */
245
-	public function order_data_eraser( $email_address, $page ) {
246
-		$orders = $this->get_stripe_orders( $email_address, (int) $page );
245
+	public function order_data_eraser($email_address, $page) {
246
+		$orders = $this->get_stripe_orders($email_address, (int) $page);
247 247
 
248 248
 		$items_removed  = false;
249 249
 		$items_retained = false;
250 250
 		$messages       = array();
251 251
 
252
-		foreach ( (array) $orders as $order ) {
253
-			$order = wc_get_order( $order->get_id() );
252
+		foreach ((array) $orders as $order) {
253
+			$order = wc_get_order($order->get_id());
254 254
 
255
-			list( $removed, $retained, $msgs ) = $this->maybe_handle_order( $order );
255
+			list($removed, $retained, $msgs) = $this->maybe_handle_order($order);
256 256
 			$items_removed  |= $removed;
257 257
 			$items_retained |= $retained;
258
-			$messages        = array_merge( $messages, $msgs );
258
+			$messages        = array_merge($messages, $msgs);
259 259
 
260
-			list( $removed, $retained, $msgs ) = $this->maybe_handle_subscription( $order );
260
+			list($removed, $retained, $msgs) = $this->maybe_handle_subscription($order);
261 261
 			$items_removed  |= $removed;
262 262
 			$items_retained |= $retained;
263
-			$messages        = array_merge( $messages, $msgs );
263
+			$messages        = array_merge($messages, $msgs);
264 264
 		}
265 265
 
266 266
 		// Tell core if we have more orders to work on still
267
-		$done = count( $orders ) < 10;
267
+		$done = count($orders) < 10;
268 268
 
269 269
 		return array(
270 270
 			'items_removed'  => $items_removed,
@@ -280,49 +280,49 @@  discard block
 block discarded – undo
280 280
 	 * @param WC_Order $order
281 281
 	 * @return array
282 282
 	 */
283
-	protected function maybe_handle_subscription( $order ) {
284
-		if ( ! class_exists( 'WC_Subscriptions' ) ) {
285
-			return array( false, false, array() );
283
+	protected function maybe_handle_subscription($order) {
284
+		if ( ! class_exists('WC_Subscriptions')) {
285
+			return array(false, false, array());
286 286
 		}
287 287
 
288
-		if ( ! wcs_order_contains_subscription( $order ) ) {
289
-			return array( false, false, array() );
288
+		if ( ! wcs_order_contains_subscription($order)) {
289
+			return array(false, false, array());
290 290
 		}
291 291
 
292
-		$subscription    = current( wcs_get_subscriptions_for_order( $order->get_id() ) );
292
+		$subscription    = current(wcs_get_subscriptions_for_order($order->get_id()));
293 293
 		$subscription_id = $subscription->get_id();
294 294
 
295
-		$stripe_source_id = get_post_meta( $subscription_id, '_stripe_source_id', true );
295
+		$stripe_source_id = get_post_meta($subscription_id, '_stripe_source_id', true);
296 296
 
297
-		if ( empty( $stripe_source_id ) ) {
298
-			return array( false, false, array() );
297
+		if (empty($stripe_source_id)) {
298
+			return array(false, false, array());
299 299
 		}
300 300
 
301
-		$order_age = strtotime( 'now' ) - $order->get_date_created()->getTimestamp();
301
+		$order_age = strtotime('now') - $order->get_date_created()->getTimestamp();
302 302
 
303 303
 		// If order age is longer than specified days, don't do anything to it
304 304
 		// TODO: Figure out if 180 is the real number
305
-		if ( $order_age < DAY_IN_SECONDS * 180 ) {
306
-			return array( false, true, array( sprintf( __( 'Order ID %d is less than 180 days (Stripe)' ), $order->get_id() ) ) );
305
+		if ($order_age < DAY_IN_SECONDS * 180) {
306
+			return array(false, true, array(sprintf(__('Order ID %d is less than 180 days (Stripe)'), $order->get_id())));
307 307
 		}
308 308
 
309
-		if ( $subscription->has_status( apply_filters( 'wc_stripe_privacy_eraser_subs_statuses', array( 'on-hold', 'active' ) ) ) ) {
310
-			return array( false, true, array( sprintf( __( 'Order ID %d contains an active Subscription' ), $order->get_id() ) ) );
309
+		if ($subscription->has_status(apply_filters('wc_stripe_privacy_eraser_subs_statuses', array('on-hold', 'active')))) {
310
+			return array(false, true, array(sprintf(__('Order ID %d contains an active Subscription'), $order->get_id())));
311 311
 		}
312 312
 
313
-		$renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders( $order->get_id() );
313
+		$renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders($order->get_id());
314 314
 
315
-		foreach ( $renewal_orders as $renewal_order_id ) {
316
-			delete_post_meta( $renewal_order_id, '_stripe_source_id' );
317
-			delete_post_meta( $renewal_order_id, '_stripe_refund_id' );
318
-			delete_post_meta( $renewal_order_id, '_stripe_customer_id' );
315
+		foreach ($renewal_orders as $renewal_order_id) {
316
+			delete_post_meta($renewal_order_id, '_stripe_source_id');
317
+			delete_post_meta($renewal_order_id, '_stripe_refund_id');
318
+			delete_post_meta($renewal_order_id, '_stripe_customer_id');
319 319
 		}
320 320
 
321
-		delete_post_meta( $subscription_id, '_stripe_source_id' );
322
-		delete_post_meta( $subscription_id, '_stripe_refund_id' );
323
-		delete_post_meta( $subscription_id, '_stripe_customer_id' );
321
+		delete_post_meta($subscription_id, '_stripe_source_id');
322
+		delete_post_meta($subscription_id, '_stripe_refund_id');
323
+		delete_post_meta($subscription_id, '_stripe_customer_id');
324 324
 
325
-		return array( true, false, array( __( 'Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe' ) ) );
325
+		return array(true, false, array(__('Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe')));
326 326
 	}
327 327
 
328 328
 	/**
@@ -331,21 +331,21 @@  discard block
 block discarded – undo
331 331
 	 * @param WC_Order $order
332 332
 	 * @return array
333 333
 	 */
334
-	protected function maybe_handle_order( $order ) {
334
+	protected function maybe_handle_order($order) {
335 335
 		$order_id           = $order->get_id();
336
-		$stripe_source_id   = get_post_meta( $order_id, '_stripe_source_id', true );
337
-		$stripe_refund_id   = get_post_meta( $order_id, '_stripe_refund_id', true );
338
-		$stripe_customer_id = get_post_meta( $order_id, '_stripe_customer_id', true );
336
+		$stripe_source_id   = get_post_meta($order_id, '_stripe_source_id', true);
337
+		$stripe_refund_id   = get_post_meta($order_id, '_stripe_refund_id', true);
338
+		$stripe_customer_id = get_post_meta($order_id, '_stripe_customer_id', true);
339 339
 
340
-		if ( empty( $stripe_source_id ) && empty( $stripe_refund_id ) && empty( $stripe_customer_id ) ) {
341
-			return array( false, false, array() );
340
+		if (empty($stripe_source_id) && empty($stripe_refund_id) && empty($stripe_customer_id)) {
341
+			return array(false, false, array());
342 342
 		}
343 343
 
344
-		delete_post_meta( $order_id, '_stripe_source_id' );
345
-		delete_post_meta( $order_id, '_stripe_refund_id' );
346
-		delete_post_meta( $order_id, '_stripe_customer_id' );
344
+		delete_post_meta($order_id, '_stripe_source_id');
345
+		delete_post_meta($order_id, '_stripe_refund_id');
346
+		delete_post_meta($order_id, '_stripe_customer_id');
347 347
 
348
-		return array( true, false, array( __( 'Stripe personal data erased.', 'woocommerce-gateway-stripe' ) ) );
348
+		return array(true, false, array(__('Stripe personal data erased.', 'woocommerce-gateway-stripe')));
349 349
 	}
350 350
 }
351 351
 
Please login to merge, or discard this patch.
includes/class-wc-stripe-api.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * Set secret API Key.
27 27
 	 * @param string $key
28 28
 	 */
29
-	public static function set_secret_key( $secret_key ) {
29
+	public static function set_secret_key($secret_key) {
30 30
 		self::$secret_key = $secret_key;
31 31
 	}
32 32
 
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 	 * @return string
36 36
 	 */
37 37
 	public static function get_secret_key() {
38
-		if ( ! self::$secret_key ) {
39
-			$options = get_option( 'woocommerce_stripe_settings' );
38
+		if ( ! self::$secret_key) {
39
+			$options = get_option('woocommerce_stripe_settings');
40 40
 
41
-			if ( isset( $options['testmode'], $options['secret_key'], $options['test_secret_key'] ) ) {
42
-				self::set_secret_key( 'yes' === $options['testmode'] ? $options['test_secret_key'] : $options['secret_key'] );
41
+			if (isset($options['testmode'], $options['secret_key'], $options['test_secret_key'])) {
42
+				self::set_secret_key('yes' === $options['testmode'] ? $options['test_secret_key'] : $options['secret_key']);
43 43
 			}
44 44
 		}
45 45
 		return self::$secret_key;
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
 		$user_agent = self::get_user_agent();
79 79
 		$app_info   = $user_agent['application'];
80 80
 
81
-		return apply_filters( 'woocommerce_stripe_request_headers', array(
82
-			'Authorization'              => 'Basic ' . base64_encode( self::get_secret_key() . ':' ),
81
+		return apply_filters('woocommerce_stripe_request_headers', array(
82
+			'Authorization'              => 'Basic ' . base64_encode(self::get_secret_key() . ':'),
83 83
 			'Stripe-Version'             => self::STRIPE_API_VERSION,
84 84
 			'User-Agent'                 => $app_info['name'] . '/' . $app_info['version'] . ' (' . $app_info['url'] . ')',
85
-			'X-Stripe-Client-User-Agent' => json_encode( $user_agent ),
86
-		) );
85
+			'X-Stripe-Client-User-Agent' => json_encode($user_agent),
86
+		));
87 87
 	}
88 88
 
89 89
 	/**
@@ -96,16 +96,16 @@  discard block
 block discarded – undo
96 96
 	 * @param bool $with_headers To get the response with headers.
97 97
 	 * @return array|WP_Error
98 98
 	 */
99
-	public static function request( $request, $api = 'charges', $method = 'POST', $with_headers = false ) {
100
-		WC_Stripe_Logger::log( "{$api} request: " . print_r( $request, true ) );
99
+	public static function request($request, $api = 'charges', $method = 'POST', $with_headers = false) {
100
+		WC_Stripe_Logger::log("{$api} request: " . print_r($request, true));
101 101
 
102 102
 		$headers = self::get_headers();
103 103
 
104
-		if ( 'charges' === $api && 'POST' === $method ) {
105
-			$customer = ! empty( $request['customer'] ) ? $request['customer'] : '';
106
-			$source   = ! empty( $request['source'] ) ? $request['source'] : $customer;
104
+		if ('charges' === $api && 'POST' === $method) {
105
+			$customer = ! empty($request['customer']) ? $request['customer'] : '';
106
+			$source   = ! empty($request['source']) ? $request['source'] : $customer;
107 107
 
108
-			$headers['Idempotency-Key'] = apply_filters( 'wc_stripe_idempotency_key', $request['metadata']['order_id'] . '-' . $source, $request );
108
+			$headers['Idempotency-Key'] = apply_filters('wc_stripe_idempotency_key', $request['metadata']['order_id'] . '-' . $source, $request);
109 109
 		}
110 110
 
111 111
 		$response = wp_safe_remote_post(
@@ -113,24 +113,24 @@  discard block
 block discarded – undo
113 113
 			array(
114 114
 				'method'  => $method,
115 115
 				'headers' => $headers,
116
-				'body'    => apply_filters( 'woocommerce_stripe_request_body', $request, $api ),
116
+				'body'    => apply_filters('woocommerce_stripe_request_body', $request, $api),
117 117
 				'timeout' => 70,
118 118
 			)
119 119
 		);
120 120
 
121
-		if ( is_wp_error( $response ) || empty( $response['body'] ) ) {
122
-			WC_Stripe_Logger::log( 'Error Response: ' . print_r( $response, true ) . PHP_EOL . PHP_EOL . 'Failed request: ' . print_r( array(
121
+		if (is_wp_error($response) || empty($response['body'])) {
122
+			WC_Stripe_Logger::log('Error Response: ' . print_r($response, true) . PHP_EOL . PHP_EOL . 'Failed request: ' . print_r(array(
123 123
 				'api'     => $api,
124 124
 				'request' => $request,
125
-			), true ) );
126
-			throw new WC_Stripe_Exception( print_r( $response, true ), __( 'There was a problem connecting to the Stripe API endpoint.', 'woocommerce-gateway-stripe' ) );
125
+			), true));
126
+			throw new WC_Stripe_Exception(print_r($response, true), __('There was a problem connecting to the Stripe API endpoint.', 'woocommerce-gateway-stripe'));
127 127
 		}
128 128
 
129
-		if ( $with_headers ) {
130
-			return array( 'headers' => wp_remote_retrieve_headers( $response ), 'body' => json_decode( $response['body'] ) );
129
+		if ($with_headers) {
130
+			return array('headers' => wp_remote_retrieve_headers($response), 'body' => json_decode($response['body']));
131 131
 		}
132 132
 
133
-		return json_decode( $response['body'] );
133
+		return json_decode($response['body']);
134 134
 	}
135 135
 
136 136
 	/**
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	 * @version 4.0.0
141 141
 	 * @param string $api
142 142
 	 */
143
-	public static function retrieve( $api ) {
144
-		WC_Stripe_Logger::log( "{$api}" );
143
+	public static function retrieve($api) {
144
+		WC_Stripe_Logger::log("{$api}");
145 145
 
146 146
 		$response = wp_safe_remote_get(
147 147
 			self::ENDPOINT . $api,
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 			)
153 153
 		);
154 154
 
155
-		if ( is_wp_error( $response ) || empty( $response['body'] ) ) {
156
-			WC_Stripe_Logger::log( 'Error Response: ' . print_r( $response, true ) );
157
-			return new WP_Error( 'stripe_error', __( 'There was a problem connecting to the Stripe API endpoint.', 'woocommerce-gateway-stripe' ) );
155
+		if (is_wp_error($response) || empty($response['body'])) {
156
+			WC_Stripe_Logger::log('Error Response: ' . print_r($response, true));
157
+			return new WP_Error('stripe_error', __('There was a problem connecting to the Stripe API endpoint.', 'woocommerce-gateway-stripe'));
158 158
 		}
159 159
 
160
-		return json_decode( $response['body'] );
160
+		return json_decode($response['body']);
161 161
 	}
162 162
 }
Please login to merge, or discard this patch.