Completed
Push — master ( fe691d...813aaf )
by Boro
01:54
created
includes/payment-methods/class-wc-gateway-stripe-sepa.php 1 patch
Spacing   +97 added lines, -97 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
 
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 	public function __construct() {
73 73
 		$this->retry_interval       = 1;
74 74
 		$this->id                   = 'stripe_sepa';
75
-		$this->method_title         = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' );
75
+		$this->method_title         = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe');
76 76
 		/* translators: link */
77
-		$this->method_description   = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
77
+		$this->method_description   = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe'));
78 78
 		$this->has_fields           = true;
79 79
 		$this->supports             = array(
80 80
 			'products',
@@ -100,28 +100,28 @@  discard block
 block discarded – undo
100 100
 		// Load the settings.
101 101
 		$this->init_settings();
102 102
 
103
-		$main_settings              = get_option( 'woocommerce_stripe_settings' );
104
-		$this->title                = $this->get_option( 'title' );
105
-		$this->description          = $this->get_option( 'description' );
106
-		$this->enabled              = $this->get_option( 'enabled' );
107
-		$this->testmode             = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false;
108
-		$this->saved_cards          = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false;
109
-		$this->publishable_key      = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : '';
110
-		$this->secret_key           = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : '';
111
-		$this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : '';
112
-
113
-		if ( $this->testmode ) {
114
-			$this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : '';
115
-			$this->secret_key      = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : '';
103
+		$main_settings              = get_option('woocommerce_stripe_settings');
104
+		$this->title                = $this->get_option('title');
105
+		$this->description          = $this->get_option('description');
106
+		$this->enabled              = $this->get_option('enabled');
107
+		$this->testmode             = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false;
108
+		$this->saved_cards          = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false;
109
+		$this->publishable_key      = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : '';
110
+		$this->secret_key           = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : '';
111
+		$this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : '';
112
+
113
+		if ($this->testmode) {
114
+			$this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : '';
115
+			$this->secret_key      = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : '';
116 116
 		}
117 117
 
118
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
119
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
118
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
119
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
120 120
 
121
-		if ( WC_Stripe_Helper::is_pre_orders_exists() ) {
121
+		if (WC_Stripe_Helper::is_pre_orders_exists()) {
122 122
 			$this->pre_orders = new WC_Stripe_Pre_Orders_Compat();
123 123
 
124
-			add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this->pre_orders, 'process_pre_order_release_payment' ) );
124
+			add_action('wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array($this->pre_orders, 'process_pre_order_release_payment'));
125 125
 		}
126 126
 	}
127 127
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 	 * @return array
134 134
 	 */
135 135
 	public function get_supported_currency() {
136
-		return apply_filters( 'wc_stripe_sepa_supported_currencies', array(
136
+		return apply_filters('wc_stripe_sepa_supported_currencies', array(
137 137
 			'EUR',
138
-		) );
138
+		));
139 139
 	}
140 140
 
141 141
 	/**
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
 	 * @return bool
147 147
 	 */
148 148
 	public function is_available() {
149
-		if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
149
+		if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
150 150
 			return false;
151 151
 		}
152 152
 
153
-		if ( is_add_payment_method_page() && ! $this->saved_cards ) {
153
+		if (is_add_payment_method_page() && ! $this->saved_cards) {
154 154
 			return false;
155 155
 		}
156 156
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 		$icons_str .= $icons['sepa'];
173 173
 
174
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
174
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
175 175
 	}
176 176
 
177 177
 	/**
@@ -182,19 +182,19 @@  discard block
 block discarded – undo
182 182
 	 * @access public
183 183
 	 */
184 184
 	public function payment_scripts() {
185
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) {
185
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) {
186 186
 			return;
187 187
 		}
188 188
 
189
-		wp_enqueue_style( 'stripe_styles' );
190
-		wp_enqueue_script( 'woocommerce_stripe' );
189
+		wp_enqueue_style('stripe_styles');
190
+		wp_enqueue_script('woocommerce_stripe');
191 191
 	}
192 192
 
193 193
 	/**
194 194
 	 * Initialize Gateway Settings Form Fields.
195 195
 	 */
196 196
 	public function init_form_fields() {
197
-		$this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-sepa-settings.php' );
197
+		$this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-sepa-settings.php');
198 198
 	}
199 199
 
200 200
 	/**
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function mandate_display() {
208 208
 		/* translators: statement descriptor */
209
-		printf( __( 'By providing your IBAN and confirming this payment, you are authorizing %s and Stripe, our payment service provider, to send instructions to your bank to debit your account and your bank to debit your account in accordance with those instructions. You are entitled to a refund from your bank under the terms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited.', 'woocommerce-gateway-stripe' ), WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor ) );
209
+		printf(__('By providing your IBAN and confirming this payment, you are authorizing %s and Stripe, our payment service provider, to send instructions to your bank to debit your account and your bank to debit your account in accordance with those instructions. You are entitled to a refund from your bank under the terms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited.', 'woocommerce-gateway-stripe'), WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor));
210 210
 	}
211 211
 
212 212
 	/**
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
 	 */
218 218
 	public function form() {
219 219
 		?>
220
-		<fieldset id="wc-<?php echo esc_attr( $this->id ); ?>-form" class="wc-payment-form">
221
-			<?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?>
220
+		<fieldset id="wc-<?php echo esc_attr($this->id); ?>-form" class="wc-payment-form">
221
+			<?php do_action('woocommerce_credit_card_form_start', $this->id); ?>
222 222
 			<p class="wc-stripe-sepa-mandate" style="margin-bottom:40px;"><?php $this->mandate_display(); ?></p>
223 223
 			<p class="form-row form-row-wide">
224 224
 				<label for="stripe-iban-element">
225
-					<?php esc_html_e( 'IBAN.', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span>
225
+					<?php esc_html_e('IBAN.', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span>
226 226
 				</label>
227 227
 				<div id="stripe-iban-element" class="wc-stripe-iban-element-field">
228 228
 					<!-- A Stripe Element will be inserted here. -->
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			<!-- Used to display form errors -->
233 233
 			<div class="stripe-source-errors" role="alert"></div>
234 234
 			<br />
235
-			<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
235
+			<?php do_action('woocommerce_credit_card_form_end', $this->id); ?>
236 236
 			<div class="clear"></div>
237 237
 		</fieldset>
238 238
 		<?php
@@ -243,45 +243,45 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	public function payment_fields() {
245 245
 		$total                = WC()->cart->total;
246
-		$display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards;
246
+		$display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards;
247 247
 		$description          = $this->get_description();
248
-		$description          = ! empty( $description ) ? $description : '';
248
+		$description          = ! empty($description) ? $description : '';
249 249
 
250 250
 		// If paying from order, we need to get total from order not cart.
251
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
252
-			$order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) );
251
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
252
+			$order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key'])));
253 253
 			$total = $order->get_total();
254 254
 		}
255 255
 
256
-		if ( is_add_payment_method_page() ) {
256
+		if (is_add_payment_method_page()) {
257 257
 			$total = '';
258 258
 		}
259 259
 
260 260
 		echo '<div
261 261
 			id="stripe-sepa_debit-payment-data"
262
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
263
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">';
262
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
263
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">';
264 264
 
265
-		if ( $this->testmode ) {
266
-			$description .= ' ' . __( 'TEST MODE ENABLED. In test mode, you can use IBAN number DE89370400440532013000.', 'woocommerce-gateway-stripe' );
265
+		if ($this->testmode) {
266
+			$description .= ' ' . __('TEST MODE ENABLED. In test mode, you can use IBAN number DE89370400440532013000.', 'woocommerce-gateway-stripe');
267 267
 		}
268 268
 
269
-		$description = trim( $description );
269
+		$description = trim($description);
270 270
 
271
-		echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id );
271
+		echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id);
272 272
 
273
-		if ( $display_tokenization ) {
273
+		if ($display_tokenization) {
274 274
 			$this->tokenization_script();
275 275
 			$this->saved_payment_methods();
276 276
 		}
277 277
 
278 278
 		$this->form();
279 279
 
280
-		if ( apply_filters( 'wc_stripe_display_save_payment_method_checkbox', $display_tokenization ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) {
280
+		if (apply_filters('wc_stripe_display_save_payment_method_checkbox', $display_tokenization) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) {
281 281
 			$this->save_payment_method_checkbox();
282 282
 		}
283 283
 
284
-		do_action( 'wc_stripe_sepa_payment_fields', $this->id );
284
+		do_action('wc_stripe_sepa_payment_fields', $this->id);
285 285
 
286 286
 		echo '</div>';
287 287
 	}
@@ -297,99 +297,99 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return array|void
299 299
 	 */
300
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
300
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
301 301
 		try {
302
-			$order = wc_get_order( $order_id );
302
+			$order = wc_get_order($order_id);
303 303
 
304
-			if ( $this->maybe_process_pre_orders( $order_id ) ) {
305
-				return $this->pre_orders->process_pre_order( $order_id );
304
+			if ($this->maybe_process_pre_orders($order_id)) {
305
+				return $this->pre_orders->process_pre_order($order_id);
306 306
 			}
307 307
 
308 308
 			// This comes from the create account checkbox in the checkout page.
309
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
309
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
310 310
 
311
-			if ( $create_account ) {
312
-				$new_customer_id     = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id();
313
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
311
+			if ($create_account) {
312
+				$new_customer_id     = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id();
313
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
314 314
 				$new_stripe_customer->create_customer();
315 315
 			}
316 316
 
317
-			$prepared_source = $this->prepare_source( get_current_user_id(), $force_save_source );
317
+			$prepared_source = $this->prepare_source(get_current_user_id(), $force_save_source);
318 318
 
319
-			$this->save_source_to_order( $order, $prepared_source );
319
+			$this->save_source_to_order($order, $prepared_source);
320 320
 
321 321
 			// Result from Stripe API request.
322 322
 			$response = null;
323 323
 
324
-			if ( $order->get_total() > 0 ) {
324
+			if ($order->get_total() > 0) {
325 325
 				// This will throw exception if not valid.
326
-				$this->validate_minimum_order_amount( $order );
326
+				$this->validate_minimum_order_amount($order);
327 327
 
328
-				WC_Stripe_Logger::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
328
+				WC_Stripe_Logger::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}");
329 329
 
330 330
 				// Make the request.
331
-				$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $prepared_source ) );
331
+				$response = WC_Stripe_API::request($this->generate_payment_request($order, $prepared_source));
332 332
 
333
-				if ( ! empty( $response->error ) ) {
333
+				if ( ! empty($response->error)) {
334 334
 					// Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without.
335
-					if ( $this->is_no_such_customer_error( $response->error ) ) {
336
-						if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
337
-							delete_user_meta( $order->customer_user, '_stripe_customer_id' );
338
-							delete_post_meta( $order_id, '_stripe_customer_id' );
335
+					if ($this->is_no_such_customer_error($response->error)) {
336
+						if (WC_Stripe_Helper::is_wc_lt('3.0')) {
337
+							delete_user_meta($order->customer_user, '_stripe_customer_id');
338
+							delete_post_meta($order_id, '_stripe_customer_id');
339 339
 						} else {
340
-							delete_user_meta( $order->get_customer_id(), '_stripe_customer_id' );
341
-							$order->delete_meta_data( '_stripe_customer_id' );
340
+							delete_user_meta($order->get_customer_id(), '_stripe_customer_id');
341
+							$order->delete_meta_data('_stripe_customer_id');
342 342
 							$order->save();
343 343
 						}
344 344
 					}
345 345
 
346
-					if ( $this->is_no_such_token_error( $response->error ) && $prepared_source->token_id ) {
346
+					if ($this->is_no_such_token_error($response->error) && $prepared_source->token_id) {
347 347
 						// Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message.
348
-						$wc_token = WC_Payment_Tokens::get( $prepared_source->token_id );
348
+						$wc_token = WC_Payment_Tokens::get($prepared_source->token_id);
349 349
 						$wc_token->delete();
350
-						$localized_message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' );
351
-						$order->add_order_note( $localized_message );
352
-						throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
350
+						$localized_message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe');
351
+						$order->add_order_note($localized_message);
352
+						throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
353 353
 					}
354 354
 
355 355
 					// We want to retry.
356
-					if ( $this->is_retryable_error( $response->error ) ) {
357
-						if ( $retry ) {
356
+					if ($this->is_retryable_error($response->error)) {
357
+						if ($retry) {
358 358
 							// Don't do anymore retries after this.
359
-							if ( 5 <= $this->retry_interval ) {
359
+							if (5 <= $this->retry_interval) {
360 360
 
361
-								return $this->process_payment( $order_id, false, $force_save_source );
361
+								return $this->process_payment($order_id, false, $force_save_source);
362 362
 							}
363 363
 
364
-							sleep( $this->retry_interval );
364
+							sleep($this->retry_interval);
365 365
 
366 366
 							$this->retry_interval++;
367 367
 
368
-							return $this->process_payment( $order_id, true, $force_save_source );
368
+							return $this->process_payment($order_id, true, $force_save_source);
369 369
 						} else {
370
-							$localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' );
371
-							$order->add_order_note( $localized_message );
372
-							throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
370
+							$localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe');
371
+							$order->add_order_note($localized_message);
372
+							throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
373 373
 						}
374 374
 					}
375 375
 
376 376
 					$localized_messages = WC_Stripe_Helper::get_localized_messages();
377 377
 
378
-					if ( 'card_error' === $response->error->type ) {
379
-						$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
378
+					if ('card_error' === $response->error->type) {
379
+						$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
380 380
 					} else {
381
-						$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
381
+						$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
382 382
 					}
383 383
 
384
-					$order->add_order_note( $localized_message );
384
+					$order->add_order_note($localized_message);
385 385
 
386
-					throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
386
+					throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
387 387
 				}
388 388
 
389
-				do_action( 'wc_gateway_stripe_process_payment', $response, $order );
389
+				do_action('wc_gateway_stripe_process_payment', $response, $order);
390 390
 
391 391
 				// Process valid response.
392
-				$this->process_response( $response, $order );
392
+				$this->process_response($response, $order);
393 393
 			} else {
394 394
 				$order->payment_complete();
395 395
 			}
@@ -400,17 +400,17 @@  discard block
 block discarded – undo
400 400
 			// Return thank you page redirect.
401 401
 			return array(
402 402
 				'result'   => 'success',
403
-				'redirect' => $this->get_return_url( $order ),
403
+				'redirect' => $this->get_return_url($order),
404 404
 			);
405 405
 
406
-		} catch ( WC_Stripe_Exception $e ) {
407
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
408
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
406
+		} catch (WC_Stripe_Exception $e) {
407
+			wc_add_notice($e->getLocalizedMessage(), 'error');
408
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
409 409
 
410
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
410
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
411 411
 
412
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
413
-				$this->send_failed_order_email( $order_id );
412
+			if ($order->has_status(array('pending', 'failed'))) {
413
+				$this->send_failed_order_email($order_id);
414 414
 			}
415 415
 
416 416
 			return array(
Please login to merge, or discard this patch.
woocommerce-gateway-stripe.php 1 patch
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  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
 
@@ -29,29 +29,29 @@  discard block
 block discarded – undo
29 29
  */
30 30
 function woocommerce_stripe_missing_wc_notice() {
31 31
 	/* translators: 1. URL link. */
32
-	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
+	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>';
33 33
 }
34 34
 
35
-add_action( 'plugins_loaded', 'woocommerce_gateway_stripe_init' );
35
+add_action('plugins_loaded', 'woocommerce_gateway_stripe_init');
36 36
 
37 37
 function woocommerce_gateway_stripe_init() {
38
-	load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
38
+	load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages');
39 39
 
40
-	if ( ! class_exists( 'WooCommerce' ) ) {
41
-		add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' );
40
+	if ( ! class_exists('WooCommerce')) {
41
+		add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice');
42 42
 		return;
43 43
 	}
44 44
 
45
-	if ( ! class_exists( 'WC_Stripe' ) ) :
45
+	if ( ! class_exists('WC_Stripe')) :
46 46
 		/**
47 47
 		 * Required minimums and constants
48 48
 		 */
49
-		define( 'WC_STRIPE_VERSION', '4.1.10' );
50
-		define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
51
-		define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' );
52
-		define( 'WC_STRIPE_MAIN_FILE', __FILE__ );
53
-		define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
54
-		define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
49
+		define('WC_STRIPE_VERSION', '4.1.10');
50
+		define('WC_STRIPE_MIN_PHP_VER', '5.6.0');
51
+		define('WC_STRIPE_MIN_WC_VER', '2.6.0');
52
+		define('WC_STRIPE_MAIN_FILE', __FILE__);
53
+		define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__))));
54
+		define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__)));
55 55
 
56 56
 		class WC_Stripe {
57 57
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			 * @return Singleton The *Singleton* instance.
72 72
 			 */
73 73
 			public static function get_instance() {
74
-				if ( null === self::$instance ) {
74
+				if (null === self::$instance) {
75 75
 					self::$instance = new self();
76 76
 				}
77 77
 				return self::$instance;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 			 * *Singleton* via the `new` operator from outside of this class.
99 99
 			 */
100 100
 			private function __construct() {
101
-				add_action( 'admin_init', array( $this, 'install' ) );
101
+				add_action('admin_init', array($this, 'install'));
102 102
 				$this->init();
103 103
 			}
104 104
 
@@ -109,48 +109,48 @@  discard block
 block discarded – undo
109 109
 			 * @version 4.0.0
110 110
 			 */
111 111
 			public function init() {
112
-				if ( is_admin() ) {
113
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php';
112
+				if (is_admin()) {
113
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php';
114 114
 				}
115 115
 
116
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php';
117
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php';
118
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php';
119
-				include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php';
120
-				require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
121
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php';
122
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php';
123
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php';
124
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
125
-				require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php';
126
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
127
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
128
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
129
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
130
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
131
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
132
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
133
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
134
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
135
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
136
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php';
137
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
138
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php';
139
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php';
140
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php';
141
-
142
-				if ( is_admin() ) {
143
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php';
116
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-exception.php';
117
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-logger.php';
118
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-helper.php';
119
+				include_once dirname(__FILE__) . '/includes/class-wc-stripe-api.php';
120
+				require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
121
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php';
122
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php';
123
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php';
124
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
125
+				require_once dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php';
126
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
127
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
128
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
129
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
130
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
131
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
132
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
133
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
134
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
135
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
136
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php';
137
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
138
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php';
139
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php';
140
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-customer.php';
141
+
142
+				if (is_admin()) {
143
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php';
144 144
 				}
145 145
 
146 146
 				// REMOVE IN THE FUTURE.
147
-				require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
147
+				require_once dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
148 148
 
149
-				add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) );
150
-				add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
149
+				add_filter('woocommerce_payment_gateways', array($this, 'add_gateways'));
150
+				add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
151 151
 
152
-				if ( version_compare( WC_VERSION, '3.4', '<' ) ) {
153
-					add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) );
152
+				if (version_compare(WC_VERSION, '3.4', '<')) {
153
+					add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin'));
154 154
 				}
155 155
 			}
156 156
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 			 * @version 4.0.0
162 162
 			 */
163 163
 			public function update_plugin_version() {
164
-				delete_option( 'wc_stripe_version' );
165
-				update_option( 'wc_stripe_version', WC_STRIPE_VERSION );
164
+				delete_option('wc_stripe_version');
165
+				update_option('wc_stripe_version', WC_STRIPE_VERSION);
166 166
 			}
167 167
 
168 168
 			/**
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
 			 * @version 3.1.0
173 173
 			 */
174 174
 			public function install() {
175
-				if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) {
175
+				if ( ! is_plugin_active(plugin_basename(__FILE__))) {
176 176
 					return;
177 177
 				}
178 178
 
179
-				if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) {
180
-					do_action( 'woocommerce_stripe_updated' );
179
+				if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) {
180
+					do_action('woocommerce_stripe_updated');
181 181
 
182
-					if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) {
183
-						define( 'WC_STRIPE_INSTALLING', true );
182
+					if ( ! defined('WC_STRIPE_INSTALLING')) {
183
+						define('WC_STRIPE_INSTALLING', true);
184 184
 					}
185 185
 
186 186
 					$this->update_plugin_version();
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 			 * @since 1.0.0
194 194
 			 * @version 4.0.0
195 195
 			 */
196
-			public function plugin_action_links( $links ) {
196
+			public function plugin_action_links($links) {
197 197
 				$plugin_links = array(
198
-					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
199
-					'<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>',
200
-					'<a href="https://woocommerce.com/contact-us/">' . esc_html__( 'Support', 'woocommerce-gateway-stripe' ) . '</a>',
198
+					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>',
199
+					'<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__('Docs', 'woocommerce-gateway-stripe') . '</a>',
200
+					'<a href="https://woocommerce.com/contact-us/">' . esc_html__('Support', 'woocommerce-gateway-stripe') . '</a>',
201 201
 				);
202
-				return array_merge( $plugin_links, $links );
202
+				return array_merge($plugin_links, $links);
203 203
 			}
204 204
 
205 205
 			/**
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 			 * @since 1.0.0
209 209
 			 * @version 4.0.0
210 210
 			 */
211
-			public function add_gateways( $methods ) {
212
-				if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) {
211
+			public function add_gateways($methods) {
212
+				if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) {
213 213
 					$methods[] = 'WC_Stripe_Subs_Compat';
214 214
 					$methods[] = 'WC_Stripe_Sepa_Subs_Compat';
215 215
 				} else {
@@ -235,28 +235,28 @@  discard block
 block discarded – undo
235 235
 			 * @since 4.0.0
236 236
 			 * @version 4.0.0
237 237
 			 */
238
-			public function filter_gateway_order_admin( $sections ) {
239
-				unset( $sections['stripe'] );
240
-				unset( $sections['stripe_bancontact'] );
241
-				unset( $sections['stripe_sofort'] );
242
-				unset( $sections['stripe_giropay'] );
243
-				unset( $sections['stripe_eps'] );
244
-				unset( $sections['stripe_ideal'] );
245
-				unset( $sections['stripe_p24'] );
246
-				unset( $sections['stripe_alipay'] );
247
-				unset( $sections['stripe_sepa'] );
248
-				unset( $sections['stripe_multibanco'] );
238
+			public function filter_gateway_order_admin($sections) {
239
+				unset($sections['stripe']);
240
+				unset($sections['stripe_bancontact']);
241
+				unset($sections['stripe_sofort']);
242
+				unset($sections['stripe_giropay']);
243
+				unset($sections['stripe_eps']);
244
+				unset($sections['stripe_ideal']);
245
+				unset($sections['stripe_p24']);
246
+				unset($sections['stripe_alipay']);
247
+				unset($sections['stripe_sepa']);
248
+				unset($sections['stripe_multibanco']);
249 249
 
250 250
 				$sections['stripe']            = 'Stripe';
251
-				$sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' );
252
-				$sections['stripe_sofort']     = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' );
253
-				$sections['stripe_giropay']    = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' );
254
-				$sections['stripe_eps']        = __( 'Stripe EPS', 'woocommerce-gateway-stripe' );
255
-				$sections['stripe_ideal']      = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' );
256
-				$sections['stripe_p24']        = __( 'Stripe P24', 'woocommerce-gateway-stripe' );
257
-				$sections['stripe_alipay']     = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' );
258
-				$sections['stripe_sepa']       = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' );
259
-				$sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' );
251
+				$sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe');
252
+				$sections['stripe_sofort']     = __('Stripe SOFORT', 'woocommerce-gateway-stripe');
253
+				$sections['stripe_giropay']    = __('Stripe Giropay', 'woocommerce-gateway-stripe');
254
+				$sections['stripe_eps']        = __('Stripe EPS', 'woocommerce-gateway-stripe');
255
+				$sections['stripe_ideal']      = __('Stripe iDeal', 'woocommerce-gateway-stripe');
256
+				$sections['stripe_p24']        = __('Stripe P24', 'woocommerce-gateway-stripe');
257
+				$sections['stripe_alipay']     = __('Stripe Alipay', 'woocommerce-gateway-stripe');
258
+				$sections['stripe_sepa']       = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe');
259
+				$sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe');
260 260
 
261 261
 				return $sections;
262 262
 			}
Please login to merge, or discard this patch.