Completed
Pull Request — master (#1166)
by Dwain
01:44
created
includes/abstracts/abstract-wc-stripe-payment-gateway.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@
 block discarded – undo
163 163
 				&& preg_match( '/^[rs]k_test_/', $this->secret_key );
164 164
 		} else {
165 165
 			return preg_match( '/^pk_live_/', $this->publishable_key )
166
-			    && preg_match( '/^[rs]k_live_/', $this->secret_key );
166
+				&& preg_match( '/^[rs]k_live_/', $this->secret_key );
167 167
 		}
168 168
 	}
169 169
 
Please login to merge, or discard this patch.
Spacing   +375 added lines, -376 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
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function display_admin_settings_webhook_description() {
23 23
 		/* translators: 1) webhook url */
24
-		return sprintf( __( 'You must add the following webhook endpoint <strong style="background-color:#ddd;">&nbsp;%s&nbsp;</strong> to your <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Stripe account settings</a>. This will enable you to receive notifications on the charge statuses.', 'woocommerce-gateway-stripe' ), WC_Stripe_Helper::get_webhook_url() );
24
+		return sprintf(__('You must add the following webhook endpoint <strong style="background-color:#ddd;">&nbsp;%s&nbsp;</strong> to your <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Stripe account settings</a>. This will enable you to receive notifications on the charge statuses.', 'woocommerce-gateway-stripe'), WC_Stripe_Helper::get_webhook_url());
25 25
 	}
26 26
 
27 27
 	/**
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 				<input id="wc-%1$s-new-payment-method" name="wc-%1$s-new-payment-method" type="checkbox" value="true" style="width:auto;" />
36 36
 				<label for="wc-%1$s-new-payment-method" style="display:inline;">%2$s</label>
37 37
 			</p>',
38
-			esc_attr( $this->id ),
39
-			esc_html( apply_filters( 'wc_stripe_save_to_account_text', __( 'Save payment information to my account for future purchases.', 'woocommerce-gateway-stripe' ) ) )
38
+			esc_attr($this->id),
39
+			esc_html(apply_filters('wc_stripe_save_to_account_text', __('Save payment information to my account for future purchases.', 'woocommerce-gateway-stripe')))
40 40
 		);
41 41
 	}
42 42
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @since 4.0.5
48 48
 	 * @param array $error
49 49
 	 */
50
-	public function is_retryable_error( $error ) {
50
+	public function is_retryable_error($error) {
51 51
 		return (
52 52
 			'invalid_request_error' === $error->type ||
53 53
 			'idempotency_error' === $error->type ||
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 	 * @since 4.1.0
65 65
 	 * @param array $error
66 66
 	 */
67
-	public function is_same_idempotency_error( $error ) {
67
+	public function is_same_idempotency_error($error) {
68 68
 		return (
69 69
 			$error &&
70 70
 			'idempotency_error' === $error->type &&
71
-			preg_match( '/Keys for idempotent requests can only be used with the same parameters they were first used with./i', $error->message )
71
+			preg_match('/Keys for idempotent requests can only be used with the same parameters they were first used with./i', $error->message)
72 72
 		);
73 73
 	}
74 74
 
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
 	 * @since 4.1.0
80 80
 	 * @param array $error
81 81
 	 */
82
-	public function is_no_such_customer_error( $error ) {
82
+	public function is_no_such_customer_error($error) {
83 83
 		return (
84 84
 			$error &&
85 85
 			'invalid_request_error' === $error->type &&
86
-			preg_match( '/No such customer/i', $error->message )
86
+			preg_match('/No such customer/i', $error->message)
87 87
 		);
88 88
 	}
89 89
 
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 	 * @since 4.1.0
95 95
 	 * @param array $error
96 96
 	 */
97
-	public function is_no_such_token_error( $error ) {
97
+	public function is_no_such_token_error($error) {
98 98
 		return (
99 99
 			$error &&
100 100
 			'invalid_request_error' === $error->type &&
101
-			preg_match( '/No such token/i', $error->message )
101
+			preg_match('/No such token/i', $error->message)
102 102
 		);
103 103
 	}
104 104
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 	 * @since 4.1.0
110 110
 	 * @param array $error
111 111
 	 */
112
-	public function is_no_such_source_error( $error ) {
112
+	public function is_no_such_source_error($error) {
113 113
 		return (
114 114
 			$error &&
115 115
 			'invalid_request_error' === $error->type &&
116
-			preg_match( '/No such source/i', $error->message )
116
+			preg_match('/No such source/i', $error->message)
117 117
 		);
118 118
 	}
119 119
 
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 	 * @since 4.1.0
125 125
 	 * @param array $error
126 126
 	 */
127
-	public function is_no_linked_source_error( $error ) {
127
+	public function is_no_linked_source_error($error) {
128 128
 		return (
129 129
 			$error &&
130 130
 			'invalid_request_error' === $error->type &&
131
-			preg_match( '/does not have a linked source with ID/i', $error->message )
131
+			preg_match('/does not have a linked source with ID/i', $error->message)
132 132
 		);
133 133
 	}
134 134
 
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
 	 * @param object $error
142 142
 	 * @return bool
143 143
 	 */
144
-	public function need_update_idempotency_key( $source_object, $error ) {
144
+	public function need_update_idempotency_key($source_object, $error) {
145 145
 		return (
146 146
 			$error &&
147 147
 			1 < $this->retry_interval &&
148
-			! empty( $source_object ) &&
148
+			! empty($source_object) &&
149 149
 			'chargeable' === $source_object->status &&
150
-			self::is_same_idempotency_error( $error )
150
+			self::is_same_idempotency_error($error)
151 151
 		);
152 152
 	}
153 153
 
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
 		// NOTE: updates to this function should be added to are_keys_set()
162 162
 		// in includes/payment-methods/class-wc-stripe-payment-request.php
163 163
 
164
-		if ( $this->testmode ) {
165
-			return preg_match( '/^pk_test_/', $this->publishable_key )
166
-				&& preg_match( '/^[rs]k_test_/', $this->secret_key );
164
+		if ($this->testmode) {
165
+			return preg_match('/^pk_test_/', $this->publishable_key)
166
+				&& preg_match('/^[rs]k_test_/', $this->secret_key);
167 167
 		} else {
168
-			return preg_match( '/^pk_live_/', $this->publishable_key )
169
-			    && preg_match( '/^[rs]k_live_/', $this->secret_key );
168
+			return preg_match('/^pk_live_/', $this->publishable_key)
169
+			    && preg_match('/^[rs]k_live_/', $this->secret_key);
170 170
 		}
171 171
 	}
172 172
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 * @since 4.1.3
177 177
 	 */
178 178
 	public function is_available() {
179
-		if ( 'yes' === $this->enabled ) {
179
+		if ('yes' === $this->enabled) {
180 180
 			return $this->are_keys_set();
181 181
 		}
182 182
 
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
 	 * @param int $order_id
192 192
 	 * @return bool
193 193
 	 */
194
-	public function maybe_process_pre_orders( $order_id ) {
194
+	public function maybe_process_pre_orders($order_id) {
195 195
 		return (
196 196
 			WC_Stripe_Helper::is_pre_orders_exists() &&
197
-			$this->pre_orders->is_pre_order( $order_id ) &&
198
-			WC_Pre_Orders_Order::order_requires_payment_tokenization( $order_id ) &&
199
-			! is_wc_endpoint_url( 'order-pay' )
197
+			$this->pre_orders->is_pre_order($order_id) &&
198
+			WC_Pre_Orders_Order::order_requires_payment_tokenization($order_id) &&
199
+			! is_wc_endpoint_url('order-pay')
200 200
 		);
201 201
 	}
202 202
 
@@ -240,10 +240,10 @@  discard block
 block discarded – undo
240 240
 	 * @version 4.0.0
241 241
 	 * @param object $order
242 242
 	 */
243
-	public function validate_minimum_order_amount( $order ) {
244
-		if ( $order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount() ) {
243
+	public function validate_minimum_order_amount($order) {
244
+		if ($order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount()) {
245 245
 			/* translators: 1) dollar amount */
246
-			throw new WC_Stripe_Exception( 'Did not meet minimum amount', sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe_Helper::get_minimum_amount() / 100 ) ) );
246
+			throw new WC_Stripe_Exception('Did not meet minimum amount', sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe_Helper::get_minimum_amount() / 100)));
247 247
 		}
248 248
 	}
249 249
 
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
 	 * @since 4.0.0
254 254
 	 * @version 4.0.0
255 255
 	 */
256
-	public function get_transaction_url( $order ) {
257
-		if ( $this->testmode ) {
256
+	public function get_transaction_url($order) {
257
+		if ($this->testmode) {
258 258
 			$this->view_transaction_url = 'https://dashboard.stripe.com/test/payments/%s';
259 259
 		} else {
260 260
 			$this->view_transaction_url = 'https://dashboard.stripe.com/payments/%s';
261 261
 		}
262 262
 
263
-		return parent::get_transaction_url( $order );
263
+		return parent::get_transaction_url($order);
264 264
 	}
265 265
 
266 266
 	/**
@@ -269,15 +269,15 @@  discard block
 block discarded – undo
269 269
 	 * @since 4.0.0
270 270
 	 * @version 4.0.0
271 271
 	 */
272
-	public function get_stripe_customer_id( $order ) {
273
-		$customer = get_user_option( '_stripe_customer_id', WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id() );
272
+	public function get_stripe_customer_id($order) {
273
+		$customer = get_user_option('_stripe_customer_id', WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id());
274 274
 
275
-		if ( empty( $customer ) ) {
275
+		if (empty($customer)) {
276 276
 			// Try to get it via the order.
277
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
278
-				return get_post_meta( $order->id, '_stripe_customer_id', true );
277
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
278
+				return get_post_meta($order->id, '_stripe_customer_id', true);
279 279
 			} else {
280
-				return $order->get_meta( '_stripe_customer_id', true );
280
+				return $order->get_meta('_stripe_customer_id', true);
281 281
 			}
282 282
 		} else {
283 283
 			return $customer;
@@ -294,23 +294,23 @@  discard block
 block discarded – undo
294 294
 	 * @param object $order
295 295
 	 * @param int $id Stripe session id.
296 296
 	 */
297
-	public function get_stripe_return_url( $order = null, $id = null ) {
298
-		if ( is_object( $order ) ) {
299
-			if ( empty( $id ) ) {
297
+	public function get_stripe_return_url($order = null, $id = null) {
298
+		if (is_object($order)) {
299
+			if (empty($id)) {
300 300
 				$id = uniqid();
301 301
 			}
302 302
 
303
-			$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
303
+			$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
304 304
 
305 305
 			$args = array(
306 306
 				'utm_nooverride' => '1',
307 307
 				'order_id'       => $order_id,
308 308
 			);
309 309
 
310
-			return wp_sanitize_redirect( esc_url_raw( add_query_arg( $args, $this->get_return_url( $order ) ) ) );
310
+			return wp_sanitize_redirect(esc_url_raw(add_query_arg($args, $this->get_return_url($order))));
311 311
 		}
312 312
 
313
-		return wp_sanitize_redirect( esc_url_raw( add_query_arg( array( 'utm_nooverride' => '1' ), $this->get_return_url() ) ) );
313
+		return wp_sanitize_redirect(esc_url_raw(add_query_arg(array('utm_nooverride' => '1'), $this->get_return_url())));
314 314
 	}
315 315
 
316 316
 	/**
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 	 * @param  int  $order_id
319 319
 	 * @return boolean
320 320
 	 */
321
-	public function has_subscription( $order_id ) {
322
-		return ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_is_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ) );
321
+	public function has_subscription($order_id) {
322
+		return (function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order_id) || wcs_is_subscription($order_id) || wcs_order_contains_renewal($order_id)));
323 323
 	}
324 324
 
325 325
 	/**
@@ -331,34 +331,33 @@  discard block
 block discarded – undo
331 331
 	 * @param  object $prepared_source
332 332
 	 * @return array()
333 333
 	 */
334
-	public function generate_payment_request( $order, $prepared_source ) {
335
-		$settings              = get_option( 'woocommerce_stripe_settings', array() );
336
-		$statement_descriptor  = ! empty( $settings['statement_descriptor'] ) ? str_replace( "'", '', $settings['statement_descriptor'] ) : '';
337
-		$capture               = ! empty( $settings['capture'] ) && 'yes' === $settings['capture'] ? true : false;
334
+	public function generate_payment_request($order, $prepared_source) {
335
+		$settings              = get_option('woocommerce_stripe_settings', array());
336
+		$statement_descriptor  = ! empty($settings['statement_descriptor']) ? str_replace("'", '', $settings['statement_descriptor']) : '';
337
+		$capture               = ! empty($settings['capture']) && 'yes' === $settings['capture'] ? true : false;
338 338
 		$post_data             = array();
339
-		$post_data['currency'] = strtolower( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency() );
340
-		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $post_data['currency'] );
339
+		$post_data['currency'] = strtolower(WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency());
340
+		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $post_data['currency']);
341 341
 		/* translators: 1) blog name 2) order number */
342
-		$post_data['description'] = sprintf( __( '%1$s - Order %2$s', 'woocommerce-gateway-stripe' ), wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $order->get_order_number() );
343
-		$billing_email            = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_email : $order->get_billing_email();
344
-		$billing_first_name       = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_first_name : $order->get_billing_first_name();
345
-		$billing_last_name        = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_last_name : $order->get_billing_last_name();
342
+		$post_data['description'] = sprintf(__('%1$s - Order %2$s', 'woocommerce-gateway-stripe'), wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES), $order->get_order_number());
343
+		$billing_email            = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_email : $order->get_billing_email();
344
+		$billing_first_name       = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_first_name : $order->get_billing_first_name();
345
+		$billing_last_name        = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_last_name : $order->get_billing_last_name();
346 346
 
347
-		if ( ! empty( $billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) {
347
+		if ( ! empty($billing_email) && apply_filters('wc_stripe_send_stripe_receipt', false)) {
348 348
 			$post_data['receipt_email'] = $billing_email;
349 349
 		}
350 350
 
351
-		switch ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method() ) {
352
-			case 'stripe':
353
-				if ( ! empty( $statement_descriptor ) ) {
354
-					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor );
351
+		switch (WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method()) {
352
+			case 'stripe' : if ( ! empty($statement_descriptor)) {
353
+					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor);
355 354
 				}
356 355
 
357 356
 				$post_data['capture'] = $capture ? 'true' : 'false';
358 357
 				break;
359 358
 			case 'stripe_sepa':
360
-				if ( ! empty( $statement_descriptor ) ) {
361
-					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor );
359
+				if ( ! empty($statement_descriptor)) {
360
+					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor);
362 361
 				}
363 362
 				break;
364 363
 		}
@@ -366,25 +365,25 @@  discard block
 block discarded – undo
366 365
 		$post_data['expand[]'] = 'balance_transaction';
367 366
 
368 367
 		$metadata = array(
369
-			__( 'customer_name', 'woocommerce-gateway-stripe' ) => sanitize_text_field( $billing_first_name ) . ' ' . sanitize_text_field( $billing_last_name ),
370
-			__( 'customer_email', 'woocommerce-gateway-stripe' ) => sanitize_email( $billing_email ),
368
+			__('customer_name', 'woocommerce-gateway-stripe') => sanitize_text_field($billing_first_name) . ' ' . sanitize_text_field($billing_last_name),
369
+			__('customer_email', 'woocommerce-gateway-stripe') => sanitize_email($billing_email),
371 370
 			'order_id' => $order->get_order_number(),
372 371
 		);
373 372
 
374
-		if ( $this->has_subscription( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id() ) ) {
373
+		if ($this->has_subscription(WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id())) {
375 374
 			$metadata += array(
376 375
 				'payment_type' => 'recurring',
377
-				'site_url'     => esc_url( get_site_url() ),
376
+				'site_url'     => esc_url(get_site_url()),
378 377
 			);
379 378
 		}
380 379
 
381
-		$post_data['metadata'] = apply_filters( 'wc_stripe_payment_metadata', $metadata, $order, $prepared_source );
380
+		$post_data['metadata'] = apply_filters('wc_stripe_payment_metadata', $metadata, $order, $prepared_source);
382 381
 
383
-		if ( $prepared_source->customer ) {
382
+		if ($prepared_source->customer) {
384 383
 			$post_data['customer'] = $prepared_source->customer;
385 384
 		}
386 385
 
387
-		if ( $prepared_source->source ) {
386
+		if ($prepared_source->source) {
388 387
 			$post_data['source'] = $prepared_source->source;
389 388
 		}
390 389
 
@@ -396,72 +395,72 @@  discard block
 block discarded – undo
396 395
 		 * @param WC_Order $order
397 396
 		 * @param object $source
398 397
 		 */
399
-		return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order, $prepared_source );
398
+		return apply_filters('wc_stripe_generate_payment_request', $post_data, $order, $prepared_source);
400 399
 	}
401 400
 
402 401
 	/**
403 402
 	 * Store extra meta data for an order from a Stripe Response.
404 403
 	 */
405
-	public function process_response( $response, $order ) {
406
-		WC_Stripe_Logger::log( 'Processing response: ' . print_r( $response, true ) );
404
+	public function process_response($response, $order) {
405
+		WC_Stripe_Logger::log('Processing response: ' . print_r($response, true));
407 406
 
408
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
409
-		$captured = ( isset( $response->captured ) && $response->captured ) ? 'yes' : 'no';
407
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
408
+		$captured = (isset($response->captured) && $response->captured) ? 'yes' : 'no';
410 409
 
411 410
 		// Store charge data.
412
-		WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_stripe_charge_captured', $captured ) : $order->update_meta_data( '_stripe_charge_captured', $captured );
411
+		WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_stripe_charge_captured', $captured) : $order->update_meta_data('_stripe_charge_captured', $captured);
413 412
 
414
-		if ( isset( $response->balance_transaction ) ) {
415
-			$this->update_fees( $order, is_string( $response->balance_transaction ) ? $response->balance_transaction : $response->balance_transaction->id );
413
+		if (isset($response->balance_transaction)) {
414
+			$this->update_fees($order, is_string($response->balance_transaction) ? $response->balance_transaction : $response->balance_transaction->id);
416 415
 		}
417 416
 
418
-		if ( 'yes' === $captured ) {
417
+		if ('yes' === $captured) {
419 418
 			/**
420 419
 			 * Charge can be captured but in a pending state. Payment methods
421 420
 			 * that are asynchronous may take couple days to clear. Webhook will
422 421
 			 * take care of the status changes.
423 422
 			 */
424
-			if ( 'pending' === $response->status ) {
425
-				$order_stock_reduced = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_order_stock_reduced', true ) : $order->get_meta( '_order_stock_reduced', true );
423
+			if ('pending' === $response->status) {
424
+				$order_stock_reduced = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_order_stock_reduced', true) : $order->get_meta('_order_stock_reduced', true);
426 425
 
427
-				if ( ! $order_stock_reduced ) {
428
-					WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->reduce_order_stock() : wc_reduce_stock_levels( $order_id );
426
+				if ( ! $order_stock_reduced) {
427
+					WC_Stripe_Helper::is_wc_lt('3.0') ? $order->reduce_order_stock() : wc_reduce_stock_levels($order_id);
429 428
 				}
430 429
 
431
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_transaction_id', $response->id ) : $order->set_transaction_id( $response->id );
430
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_transaction_id', $response->id) : $order->set_transaction_id($response->id);
432 431
 				/* translators: transaction id */
433
-				$order->update_status( 'on-hold', sprintf( __( 'Stripe charge awaiting payment: %s.', 'woocommerce-gateway-stripe' ), $response->id ) );
432
+				$order->update_status('on-hold', sprintf(__('Stripe charge awaiting payment: %s.', 'woocommerce-gateway-stripe'), $response->id));
434 433
 			}
435 434
 
436
-			if ( 'succeeded' === $response->status ) {
437
-				$order->payment_complete( $response->id );
435
+			if ('succeeded' === $response->status) {
436
+				$order->payment_complete($response->id);
438 437
 
439 438
 				/* translators: transaction id */
440
-				$message = sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $response->id );
441
-				$order->add_order_note( $message );
439
+				$message = sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $response->id);
440
+				$order->add_order_note($message);
442 441
 			}
443 442
 
444
-			if ( 'failed' === $response->status ) {
445
-				$localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
446
-				$order->add_order_note( $localized_message );
447
-				throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
443
+			if ('failed' === $response->status) {
444
+				$localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
445
+				$order->add_order_note($localized_message);
446
+				throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
448 447
 			}
449 448
 		} else {
450
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_transaction_id', $response->id ) : $order->set_transaction_id( $response->id );
449
+			WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_transaction_id', $response->id) : $order->set_transaction_id($response->id);
451 450
 
452
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
453
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->reduce_order_stock() : wc_reduce_stock_levels( $order_id );
451
+			if ($order->has_status(array('pending', 'failed'))) {
452
+				WC_Stripe_Helper::is_wc_lt('3.0') ? $order->reduce_order_stock() : wc_reduce_stock_levels($order_id);
454 453
 			}
455 454
 
456 455
 			/* translators: transaction id */
457
-			$order->update_status( 'on-hold', sprintf( __( 'Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe' ), $response->id ) );
456
+			$order->update_status('on-hold', sprintf(__('Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe'), $response->id));
458 457
 		}
459 458
 
460
-		if ( is_callable( array( $order, 'save' ) ) ) {
459
+		if (is_callable(array($order, 'save'))) {
461 460
 			$order->save();
462 461
 		}
463 462
 
464
-		do_action( 'wc_gateway_stripe_process_response', $response, $order );
463
+		do_action('wc_gateway_stripe_process_response', $response, $order);
465 464
 
466 465
 		return $response;
467 466
 	}
@@ -474,10 +473,10 @@  discard block
 block discarded – undo
474 473
 	 * @param int $order_id
475 474
 	 * @return null
476 475
 	 */
477
-	public function send_failed_order_email( $order_id ) {
476
+	public function send_failed_order_email($order_id) {
478 477
 		$emails = WC()->mailer()->get_emails();
479
-		if ( ! empty( $emails ) && ! empty( $order_id ) ) {
480
-			$emails['WC_Email_Failed_Order']->trigger( $order_id );
478
+		if ( ! empty($emails) && ! empty($order_id)) {
479
+			$emails['WC_Email_Failed_Order']->trigger($order_id);
481 480
 		}
482 481
 	}
483 482
 
@@ -489,36 +488,36 @@  discard block
 block discarded – undo
489 488
 	 * @param object $order
490 489
 	 * @return object $details
491 490
 	 */
492
-	public function get_owner_details( $order ) {
493
-		$billing_first_name = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_first_name : $order->get_billing_first_name();
494
-		$billing_last_name  = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_last_name : $order->get_billing_last_name();
491
+	public function get_owner_details($order) {
492
+		$billing_first_name = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_first_name : $order->get_billing_first_name();
493
+		$billing_last_name  = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_last_name : $order->get_billing_last_name();
495 494
 
496 495
 		$details = array();
497 496
 
498 497
 		$name  = $billing_first_name . ' ' . $billing_last_name;
499
-		$email = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_email : $order->get_billing_email();
500
-		$phone = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_phone : $order->get_billing_phone();
498
+		$email = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_email : $order->get_billing_email();
499
+		$phone = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_phone : $order->get_billing_phone();
501 500
 
502
-		if ( ! empty( $phone ) ) {
501
+		if ( ! empty($phone)) {
503 502
 			$details['phone'] = $phone;
504 503
 		}
505 504
 
506
-		if ( ! empty( $name ) ) {
505
+		if ( ! empty($name)) {
507 506
 			$details['name'] = $name;
508 507
 		}
509 508
 
510
-		if ( ! empty( $email ) ) {
509
+		if ( ! empty($email)) {
511 510
 			$details['email'] = $email;
512 511
 		}
513 512
 
514
-		$details['address']['line1']       = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_address_1 : $order->get_billing_address_1();
515
-		$details['address']['line2']       = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_address_2 : $order->get_billing_address_2();
516
-		$details['address']['state']       = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_state : $order->get_billing_state();
517
-		$details['address']['city']        = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_city : $order->get_billing_city();
518
-		$details['address']['postal_code'] = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_postcode : $order->get_billing_postcode();
519
-		$details['address']['country']     = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_country : $order->get_billing_country();
513
+		$details['address']['line1']       = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_address_1 : $order->get_billing_address_1();
514
+		$details['address']['line2']       = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_address_2 : $order->get_billing_address_2();
515
+		$details['address']['state']       = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_state : $order->get_billing_state();
516
+		$details['address']['city']        = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_city : $order->get_billing_city();
517
+		$details['address']['postal_code'] = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_postcode : $order->get_billing_postcode();
518
+		$details['address']['country']     = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_country : $order->get_billing_country();
520 519
 
521
-		return (object) apply_filters( 'wc_stripe_owner_details', $details, $order );
520
+		return (object) apply_filters('wc_stripe_owner_details', $details, $order);
522 521
 	}
523 522
 
524 523
 	/**
@@ -527,15 +526,15 @@  discard block
 block discarded – undo
527 526
 	 * @since 4.0.3
528 527
 	 * @param string $source_id The source ID to get source object for.
529 528
 	 */
530
-	public function get_source_object( $source_id = '' ) {
531
-		if ( empty( $source_id ) ) {
529
+	public function get_source_object($source_id = '') {
530
+		if (empty($source_id)) {
532 531
 			return '';
533 532
 		}
534 533
 
535
-		$source_object = WC_Stripe_API::retrieve( 'sources/' . $source_id );
534
+		$source_object = WC_Stripe_API::retrieve('sources/' . $source_id);
536 535
 
537
-		if ( ! empty( $source_object->error ) ) {
538
-			throw new WC_Stripe_Exception( print_r( $source_object, true ), $source_object->error->message );
536
+		if ( ! empty($source_object->error)) {
537
+			throw new WC_Stripe_Exception(print_r($source_object, true), $source_object->error->message);
539 538
 		}
540 539
 
541 540
 		return $source_object;
@@ -548,10 +547,10 @@  discard block
 block discarded – undo
548 547
 	 * @param object $source_object
549 548
 	 * @return bool
550 549
 	 */
551
-	public function is_prepaid_card( $source_object ) {
550
+	public function is_prepaid_card($source_object) {
552 551
 		return (
553 552
 			$source_object
554
-			&& ( 'token' === $source_object->object || 'source' === $source_object->object )
553
+			&& ('token' === $source_object->object || 'source' === $source_object->object)
555 554
 			&& 'prepaid' === $source_object->card->funding
556 555
 		);
557 556
 	}
@@ -563,8 +562,8 @@  discard block
 block discarded – undo
563 562
 	 * @param string $source_id
564 563
 	 * @return bool
565 564
 	 */
566
-	public function is_type_legacy_card( $source_id ) {
567
-		return ( preg_match( '/^card_/', $source_id ) );
565
+	public function is_type_legacy_card($source_id) {
566
+		return (preg_match('/^card_/', $source_id));
568 567
 	}
569 568
 
570 569
 	/**
@@ -574,9 +573,9 @@  discard block
 block discarded – undo
574 573
 	 * @return bool
575 574
 	 */
576 575
 	public function is_using_saved_payment_method() {
577
-		$payment_method = isset( $_POST['payment_method'] ) ? wc_clean( $_POST['payment_method'] ) : 'stripe';
576
+		$payment_method = isset($_POST['payment_method']) ? wc_clean($_POST['payment_method']) : 'stripe';
578 577
 
579
-		return ( isset( $_POST[ 'wc-' . $payment_method . '-payment-token' ] ) && 'new' !== $_POST[ 'wc-' . $payment_method . '-payment-token' ] );
578
+		return (isset($_POST['wc-' . $payment_method . '-payment-token']) && 'new' !== $_POST['wc-' . $payment_method . '-payment-token']);
580 579
 	}
581 580
 
582 581
 	/**
@@ -592,64 +591,64 @@  discard block
 block discarded – undo
592 591
 	 * @throws Exception When card was not added or for and invalid card.
593 592
 	 * @return object
594 593
 	 */
595
-	public function prepare_source( $user_id, $force_save_source = false, $existing_customer_id = null ) {
596
-		$customer = new WC_Stripe_Customer( $user_id );
597
-		if ( ! empty( $existing_customer_id ) ) {
598
-			$customer->set_id( $existing_customer_id );
594
+	public function prepare_source($user_id, $force_save_source = false, $existing_customer_id = null) {
595
+		$customer = new WC_Stripe_Customer($user_id);
596
+		if ( ! empty($existing_customer_id)) {
597
+			$customer->set_id($existing_customer_id);
599 598
 		}
600 599
 
601
-		$force_save_source = apply_filters( 'wc_stripe_force_save_source', $force_save_source, $customer );
600
+		$force_save_source = apply_filters('wc_stripe_force_save_source', $force_save_source, $customer);
602 601
 		$source_object     = '';
603 602
 		$source_id         = '';
604 603
 		$wc_token_id       = false;
605
-		$payment_method    = isset( $_POST['payment_method'] ) ? wc_clean( $_POST['payment_method'] ) : 'stripe';
604
+		$payment_method    = isset($_POST['payment_method']) ? wc_clean($_POST['payment_method']) : 'stripe';
606 605
 		$is_token          = false;
607 606
 
608 607
 		// New CC info was entered and we have a new source to process.
609
-		if ( ! empty( $_POST['stripe_source'] ) ) {
610
-			$source_object = self::get_source_object( wc_clean( $_POST['stripe_source'] ) );
608
+		if ( ! empty($_POST['stripe_source'])) {
609
+			$source_object = self::get_source_object(wc_clean($_POST['stripe_source']));
611 610
 			$source_id     = $source_object->id;
612 611
 
613 612
 			// This checks to see if customer opted to save the payment method to file.
614
-			$maybe_saved_card = isset( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] ) && ! empty( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] );
613
+			$maybe_saved_card = isset($_POST['wc-' . $payment_method . '-new-payment-method']) && ! empty($_POST['wc-' . $payment_method . '-new-payment-method']);
615 614
 
616 615
 			/**
617 616
 			 * This is true if the user wants to store the card to their account.
618 617
 			 * Criteria to save to file is they are logged in, they opted to save or product requirements and the source is
619 618
 			 * actually reusable. Either that or force_save_source is true.
620 619
 			 */
621
-			if ( ( $user_id && $this->saved_cards && $maybe_saved_card && 'reusable' === $source_object->usage ) || $force_save_source ) {
622
-				$response = $customer->add_source( $source_object->id );
620
+			if (($user_id && $this->saved_cards && $maybe_saved_card && 'reusable' === $source_object->usage) || $force_save_source) {
621
+				$response = $customer->add_source($source_object->id);
623 622
 
624
-				if ( ! empty( $response->error ) ) {
625
-					throw new WC_Stripe_Exception( print_r( $response, true ), $this->get_localized_error_message_from_response( $response ) );
623
+				if ( ! empty($response->error)) {
624
+					throw new WC_Stripe_Exception(print_r($response, true), $this->get_localized_error_message_from_response($response));
626 625
 				}
627 626
 			}
628
-		} elseif ( $this->is_using_saved_payment_method() ) {
627
+		} elseif ($this->is_using_saved_payment_method()) {
629 628
 			// Use an existing token, and then process the payment.
630
-			$wc_token_id = wc_clean( $_POST[ 'wc-' . $payment_method . '-payment-token' ] );
631
-			$wc_token    = WC_Payment_Tokens::get( $wc_token_id );
629
+			$wc_token_id = wc_clean($_POST['wc-' . $payment_method . '-payment-token']);
630
+			$wc_token    = WC_Payment_Tokens::get($wc_token_id);
632 631
 
633
-			if ( ! $wc_token || $wc_token->get_user_id() !== get_current_user_id() ) {
634
-				WC()->session->set( 'refresh_totals', true );
635
-				throw new WC_Stripe_Exception( 'Invalid payment method', __( 'Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe' ) );
632
+			if ( ! $wc_token || $wc_token->get_user_id() !== get_current_user_id()) {
633
+				WC()->session->set('refresh_totals', true);
634
+				throw new WC_Stripe_Exception('Invalid payment method', __('Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe'));
636 635
 			}
637 636
 
638 637
 			$source_id = $wc_token->get_token();
639 638
 
640
-			if ( $this->is_type_legacy_card( $source_id ) ) {
639
+			if ($this->is_type_legacy_card($source_id)) {
641 640
 				$is_token = true;
642 641
 			}
643
-		} elseif ( isset( $_POST['stripe_token'] ) && 'new' !== $_POST['stripe_token'] ) {
644
-			$stripe_token     = wc_clean( $_POST['stripe_token'] );
645
-			$maybe_saved_card = isset( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] ) && ! empty( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] );
642
+		} elseif (isset($_POST['stripe_token']) && 'new' !== $_POST['stripe_token']) {
643
+			$stripe_token     = wc_clean($_POST['stripe_token']);
644
+			$maybe_saved_card = isset($_POST['wc-' . $payment_method . '-new-payment-method']) && ! empty($_POST['wc-' . $payment_method . '-new-payment-method']);
646 645
 
647 646
 			// This is true if the user wants to store the card to their account.
648
-			if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_save_source ) {
649
-				$response = $customer->add_source( $stripe_token );
647
+			if (($user_id && $this->saved_cards && $maybe_saved_card) || $force_save_source) {
648
+				$response = $customer->add_source($stripe_token);
650 649
 
651
-				if ( ! empty( $response->error ) ) {
652
-					throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
650
+				if ( ! empty($response->error)) {
651
+					throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
653 652
 				}
654 653
 			} else {
655 654
 				$source_id    = $stripe_token;
@@ -658,15 +657,15 @@  discard block
 block discarded – undo
658 657
 		}
659 658
 
660 659
 		$customer_id = $customer->get_id();
661
-		if ( ! $customer_id ) {
662
-			$customer->set_id( $customer->create_customer() );
660
+		if ( ! $customer_id) {
661
+			$customer->set_id($customer->create_customer());
663 662
 			$customer_id = $customer->get_id();
664 663
 		} else {
665 664
 			$customer_id = $customer->update_customer();
666 665
 		}
667 666
 
668
-		if ( empty( $source_object ) && ! $is_token ) {
669
-			$source_object = self::get_source_object( $source_id );
667
+		if (empty($source_object) && ! $is_token) {
668
+			$source_object = self::get_source_object($source_id);
670 669
 		}
671 670
 
672 671
 		return (object) array(
@@ -690,39 +689,39 @@  discard block
 block discarded – undo
690 689
 	 * @param object $order
691 690
 	 * @return object
692 691
 	 */
693
-	public function prepare_order_source( $order = null ) {
692
+	public function prepare_order_source($order = null) {
694 693
 		$stripe_customer = new WC_Stripe_Customer();
695 694
 		$stripe_source   = false;
696 695
 		$token_id        = false;
697 696
 		$source_object   = false;
698 697
 
699
-		if ( $order ) {
700
-			$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
698
+		if ($order) {
699
+			$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
701 700
 
702
-			$stripe_customer_id = get_post_meta( $order_id, '_stripe_customer_id', true );
701
+			$stripe_customer_id = get_post_meta($order_id, '_stripe_customer_id', true);
703 702
 
704
-			if ( $stripe_customer_id ) {
705
-				$stripe_customer->set_id( $stripe_customer_id );
703
+			if ($stripe_customer_id) {
704
+				$stripe_customer->set_id($stripe_customer_id);
706 705
 			}
707 706
 
708
-			$source_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_stripe_source_id', true ) : $order->get_meta( '_stripe_source_id', true );
707
+			$source_id = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_stripe_source_id', true) : $order->get_meta('_stripe_source_id', true);
709 708
 
710 709
 			// Since 4.0.0, we changed card to source so we need to account for that.
711
-			if ( empty( $source_id ) ) {
712
-				$source_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_stripe_card_id', true ) : $order->get_meta( '_stripe_card_id', true );
710
+			if (empty($source_id)) {
711
+				$source_id = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_stripe_card_id', true) : $order->get_meta('_stripe_card_id', true);
713 712
 
714 713
 				// Take this opportunity to update the key name.
715
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_stripe_source_id', $source_id ) : $order->update_meta_data( '_stripe_source_id', $source_id );
714
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_stripe_source_id', $source_id) : $order->update_meta_data('_stripe_source_id', $source_id);
716 715
 
717
-				if ( is_callable( array( $order, 'save' ) ) ) {
716
+				if (is_callable(array($order, 'save'))) {
718 717
 					$order->save();
719 718
 				}
720 719
 			}
721 720
 
722
-			if ( $source_id ) {
721
+			if ($source_id) {
723 722
 				$stripe_source = $source_id;
724
-				$source_object = WC_Stripe_API::retrieve( 'sources/' . $source_id );
725
-			} elseif ( apply_filters( 'wc_stripe_use_default_customer_source', true ) ) {
723
+				$source_object = WC_Stripe_API::retrieve('sources/' . $source_id);
724
+			} elseif (apply_filters('wc_stripe_use_default_customer_source', true)) {
726 725
 				/*
727 726
 				 * We can attempt to charge the customer's default source
728 727
 				 * by sending empty source id.
@@ -747,27 +746,27 @@  discard block
 block discarded – undo
747 746
 	 * @param WC_Order $order For to which the source applies.
748 747
 	 * @param stdClass $source Source information.
749 748
 	 */
750
-	public function save_source_to_order( $order, $source ) {
751
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
749
+	public function save_source_to_order($order, $source) {
750
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
752 751
 
753 752
 		// Store source in the order.
754
-		if ( $source->customer ) {
755
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
756
-				update_post_meta( $order_id, '_stripe_customer_id', $source->customer );
753
+		if ($source->customer) {
754
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
755
+				update_post_meta($order_id, '_stripe_customer_id', $source->customer);
757 756
 			} else {
758
-				$order->update_meta_data( '_stripe_customer_id', $source->customer );
757
+				$order->update_meta_data('_stripe_customer_id', $source->customer);
759 758
 			}
760 759
 		}
761 760
 
762
-		if ( $source->source ) {
763
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
764
-				update_post_meta( $order_id, '_stripe_source_id', $source->source );
761
+		if ($source->source) {
762
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
763
+				update_post_meta($order_id, '_stripe_source_id', $source->source);
765 764
 			} else {
766
-				$order->update_meta_data( '_stripe_source_id', $source->source );
765
+				$order->update_meta_data('_stripe_source_id', $source->source);
767 766
 			}
768 767
 		}
769 768
 
770
-		if ( is_callable( array( $order, 'save' ) ) ) {
769
+		if (is_callable(array($order, 'save'))) {
771 770
 			$order->save();
772 771
 		}
773 772
 	}
@@ -781,38 +780,38 @@  discard block
 block discarded – undo
781 780
 	 * @param object $order The order object
782 781
 	 * @param int $balance_transaction_id
783 782
 	 */
784
-	public function update_fees( $order, $balance_transaction_id ) {
785
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
783
+	public function update_fees($order, $balance_transaction_id) {
784
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
786 785
 
787
-		$balance_transaction = WC_Stripe_API::retrieve( 'balance/history/' . $balance_transaction_id );
786
+		$balance_transaction = WC_Stripe_API::retrieve('balance/history/' . $balance_transaction_id);
788 787
 
789
-		if ( empty( $balance_transaction->error ) ) {
790
-			if ( isset( $balance_transaction ) && isset( $balance_transaction->fee ) ) {
788
+		if (empty($balance_transaction->error)) {
789
+			if (isset($balance_transaction) && isset($balance_transaction->fee)) {
791 790
 				// Fees and Net needs to both come from Stripe to be accurate as the returned
792 791
 				// values are in the local currency of the Stripe account, not from WC.
793
-				$fee_refund = ! empty( $balance_transaction->fee ) ? WC_Stripe_Helper::format_balance_fee( $balance_transaction, 'fee' ) : 0;
794
-				$net_refund = ! empty( $balance_transaction->net ) ? WC_Stripe_Helper::format_balance_fee( $balance_transaction, 'net' ) : 0;
792
+				$fee_refund = ! empty($balance_transaction->fee) ? WC_Stripe_Helper::format_balance_fee($balance_transaction, 'fee') : 0;
793
+				$net_refund = ! empty($balance_transaction->net) ? WC_Stripe_Helper::format_balance_fee($balance_transaction, 'net') : 0;
795 794
 
796 795
 				// Current data fee & net.
797
-				$fee_current = WC_Stripe_Helper::get_stripe_fee( $order );
798
-				$net_current = WC_Stripe_Helper::get_stripe_net( $order );
796
+				$fee_current = WC_Stripe_Helper::get_stripe_fee($order);
797
+				$net_current = WC_Stripe_Helper::get_stripe_net($order);
799 798
 
800 799
 				// Calculation.
801 800
 				$fee = (float) $fee_current + (float) $fee_refund;
802 801
 				$net = (float) $net_current + (float) $net_refund;
803 802
 
804
-				WC_Stripe_Helper::update_stripe_fee( $order, $fee );
805
-				WC_Stripe_Helper::update_stripe_net( $order, $net );
803
+				WC_Stripe_Helper::update_stripe_fee($order, $fee);
804
+				WC_Stripe_Helper::update_stripe_net($order, $net);
806 805
 
807
-				$currency = ! empty( $balance_transaction->currency ) ? strtoupper( $balance_transaction->currency ) : null;
808
-				WC_Stripe_Helper::update_stripe_currency( $order, $currency );
806
+				$currency = ! empty($balance_transaction->currency) ? strtoupper($balance_transaction->currency) : null;
807
+				WC_Stripe_Helper::update_stripe_currency($order, $currency);
809 808
 
810
-				if ( is_callable( array( $order, 'save' ) ) ) {
809
+				if (is_callable(array($order, 'save'))) {
811 810
 					$order->save();
812 811
 				}
813 812
 			}
814 813
 		} else {
815
-			WC_Stripe_Logger::log( "Unable to update fees/net meta for order: {$order_id}" );
814
+			WC_Stripe_Logger::log("Unable to update fees/net meta for order: {$order_id}");
816 815
 		}
817 816
 	}
818 817
 
@@ -825,99 +824,99 @@  discard block
 block discarded – undo
825 824
 	 * @param  float $amount
826 825
 	 * @return bool
827 826
 	 */
828
-	public function process_refund( $order_id, $amount = null, $reason = '' ) {
829
-		$order = wc_get_order( $order_id );
827
+	public function process_refund($order_id, $amount = null, $reason = '') {
828
+		$order = wc_get_order($order_id);
830 829
 
831
-		if ( ! $order ) {
830
+		if ( ! $order) {
832 831
 			return false;
833 832
 		}
834 833
 
835 834
 		$request = array();
836 835
 
837
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
838
-			$order_currency = get_post_meta( $order_id, '_order_currency', true );
839
-			$captured       = get_post_meta( $order_id, '_stripe_charge_captured', true );
840
-			$charge_id      = get_post_meta( $order_id, '_transaction_id', true );
836
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
837
+			$order_currency = get_post_meta($order_id, '_order_currency', true);
838
+			$captured       = get_post_meta($order_id, '_stripe_charge_captured', true);
839
+			$charge_id      = get_post_meta($order_id, '_transaction_id', true);
841 840
 		} else {
842 841
 			$order_currency = $order->get_currency();
843
-			$captured       = $order->get_meta( '_stripe_charge_captured', true );
842
+			$captured       = $order->get_meta('_stripe_charge_captured', true);
844 843
 			$charge_id      = $order->get_transaction_id();
845 844
 		}
846 845
 
847
-		if ( ! $charge_id ) {
846
+		if ( ! $charge_id) {
848 847
 			return false;
849 848
 		}
850 849
 
851
-		if ( ! is_null( $amount ) ) {
852
-			$request['amount'] = WC_Stripe_Helper::get_stripe_amount( $amount, $order_currency );
850
+		if ( ! is_null($amount)) {
851
+			$request['amount'] = WC_Stripe_Helper::get_stripe_amount($amount, $order_currency);
853 852
 		}
854 853
 
855 854
 		// If order is only authorized, don't pass amount.
856
-		if ( 'yes' !== $captured ) {
857
-			unset( $request['amount'] );
855
+		if ('yes' !== $captured) {
856
+			unset($request['amount']);
858 857
 		}
859 858
 
860
-		if ( $reason ) {
859
+		if ($reason) {
861 860
 			$request['metadata'] = array(
862 861
 				'reason' => $reason,
863 862
 			);
864 863
 		}
865 864
 
866 865
 		$request['charge'] = $charge_id;
867
-		WC_Stripe_Logger::log( "Info: Beginning refund for order {$charge_id} for the amount of {$amount}" );
866
+		WC_Stripe_Logger::log("Info: Beginning refund for order {$charge_id} for the amount of {$amount}");
868 867
 
869
-		$request = apply_filters( 'wc_stripe_refund_request', $request, $order );
868
+		$request = apply_filters('wc_stripe_refund_request', $request, $order);
870 869
 
871
-		$intent = $this->get_intent_from_order( $order );
870
+		$intent = $this->get_intent_from_order($order);
872 871
 		$intent_cancelled = false;
873
-		if ( $intent ) {
872
+		if ($intent) {
874 873
 			// If the order has a Payment Intent pending capture, then the Intent itself must be refunded (cancelled), not the Charge
875
-			if ( ! empty( $intent->error ) ) {
874
+			if ( ! empty($intent->error)) {
876 875
 				$response = $intent;
877 876
 				$intent_cancelled = true;
878
-			} elseif ( 'requires_capture' === $intent->status ) {
877
+			} elseif ('requires_capture' === $intent->status) {
879 878
 				$result = WC_Stripe_API::request(
880 879
 					array(),
881 880
 					'payment_intents/' . $intent->id . '/cancel'
882 881
 				);
883 882
 				$intent_cancelled = true;
884 883
 
885
-				if ( ! empty( $result->error ) ) {
884
+				if ( ! empty($result->error)) {
886 885
 					$response = $result;
887 886
 				} else {
888
-					$charge = end( $result->charges->data );
889
-					$response = end( $charge->refunds->data );
887
+					$charge = end($result->charges->data);
888
+					$response = end($charge->refunds->data);
890 889
 				}
891 890
 			}
892 891
 		}
893 892
 
894
-		if ( ! $intent_cancelled ) {
895
-			$response = WC_Stripe_API::request( $request, 'refunds' );
893
+		if ( ! $intent_cancelled) {
894
+			$response = WC_Stripe_API::request($request, 'refunds');
896 895
 		}
897 896
 
898
-		if ( ! empty( $response->error ) ) {
899
-			WC_Stripe_Logger::log( 'Error: ' . $response->error->message );
897
+		if ( ! empty($response->error)) {
898
+			WC_Stripe_Logger::log('Error: ' . $response->error->message);
900 899
 
901 900
 			return $response;
902 901
 
903
-		} elseif ( ! empty( $response->id ) ) {
904
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_stripe_refund_id', $response->id ) : $order->update_meta_data( '_stripe_refund_id', $response->id );
902
+		} elseif ( ! empty($response->id)) {
903
+			WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_stripe_refund_id', $response->id) : $order->update_meta_data('_stripe_refund_id', $response->id);
905 904
 
906
-			$amount = wc_price( $response->amount / 100 );
905
+			$amount = wc_price($response->amount / 100);
907 906
 
908
-			if ( in_array( strtolower( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency() ), WC_Stripe_Helper::no_decimal_currencies() ) ) {
909
-				$amount = wc_price( $response->amount );
907
+			if (in_array(strtolower(WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency()), WC_Stripe_Helper::no_decimal_currencies())) {
908
+				$amount = wc_price($response->amount);
910 909
 			}
911 910
 
912
-			if ( isset( $response->balance_transaction ) ) {
913
-				$this->update_fees( $order, $response->balance_transaction );
911
+			if (isset($response->balance_transaction)) {
912
+				$this->update_fees($order, $response->balance_transaction);
914 913
 			}
915 914
 
916 915
 			/* translators: 1) dollar amount 2) transaction id 3) refund message */
917
-			$refund_message = ( isset( $captured ) && 'yes' === $captured ) ? sprintf( __( 'Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe' ), $amount, $response->id, $reason ) : __( 'Pre-Authorization Released', 'woocommerce-gateway-stripe' );
916
+			$refund_message = (isset($captured) && 'yes' === $captured) ? sprintf(__('Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe'), $amount, $response->id, $reason) : __('Pre-Authorization Released', 'woocommerce-gateway-stripe');
918 917
 
919
-			$order->add_order_note( $refund_message );
920
-			WC_Stripe_Logger::log( 'Success: ' . html_entity_decode( wp_strip_all_tags( $refund_message ) ) );
918
+			$order->add_order_note($refund_message);
919
+			WC_Stripe_Logger::log('Success: ' . html_entity_decode(wp_strip_all_tags($refund_message)));
921 920
 
922 921
 			return true;
923 922
 		}
@@ -932,46 +931,46 @@  discard block
 block discarded – undo
932 931
 	 */
933 932
 	public function add_payment_method() {
934 933
 		$error     = false;
935
-		$error_msg = __( 'There was a problem adding the payment method.', 'woocommerce-gateway-stripe' );
934
+		$error_msg = __('There was a problem adding the payment method.', 'woocommerce-gateway-stripe');
936 935
 		$source_id = '';
937 936
 
938
-		if ( empty( $_POST['stripe_source'] ) && empty( $_POST['stripe_token'] ) || ! is_user_logged_in() ) {
937
+		if (empty($_POST['stripe_source']) && empty($_POST['stripe_token']) || ! is_user_logged_in()) {
939 938
 			$error = true;
940 939
 		}
941 940
 
942
-		$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
941
+		$stripe_customer = new WC_Stripe_Customer(get_current_user_id());
943 942
 
944
-		$source = ! empty( $_POST['stripe_source'] ) ? wc_clean( $_POST['stripe_source'] ) : '';
943
+		$source = ! empty($_POST['stripe_source']) ? wc_clean($_POST['stripe_source']) : '';
945 944
 
946
-		$source_object = WC_Stripe_API::retrieve( 'sources/' . $source );
945
+		$source_object = WC_Stripe_API::retrieve('sources/' . $source);
947 946
 
948
-		if ( isset( $source_object ) ) {
949
-			if ( ! empty( $source_object->error ) ) {
947
+		if (isset($source_object)) {
948
+			if ( ! empty($source_object->error)) {
950 949
 				$error = true;
951 950
 			}
952 951
 
953 952
 			$source_id = $source_object->id;
954
-		} elseif ( isset( $_POST['stripe_token'] ) ) {
955
-			$source_id = wc_clean( $_POST['stripe_token'] );
953
+		} elseif (isset($_POST['stripe_token'])) {
954
+			$source_id = wc_clean($_POST['stripe_token']);
956 955
 		}
957 956
 
958
-		$response = $stripe_customer->add_source( $source_id );
957
+		$response = $stripe_customer->add_source($source_id);
959 958
 
960
-		if ( ! $response || is_wp_error( $response ) || ! empty( $response->error ) ) {
959
+		if ( ! $response || is_wp_error($response) || ! empty($response->error)) {
961 960
 			$error = true;
962 961
 		}
963 962
 
964
-		if ( $error ) {
965
-			wc_add_notice( $error_msg, 'error' );
966
-			WC_Stripe_Logger::log( 'Add payment method Error: ' . $error_msg );
963
+		if ($error) {
964
+			wc_add_notice($error_msg, 'error');
965
+			WC_Stripe_Logger::log('Add payment method Error: ' . $error_msg);
967 966
 			return;
968 967
 		}
969 968
 
970
-		do_action( 'wc_stripe_add_payment_method_' . $_POST['payment_method'] . '_success', $source_id, $source_object );
969
+		do_action('wc_stripe_add_payment_method_' . $_POST['payment_method'] . '_success', $source_id, $source_object);
971 970
 
972 971
 		return array(
973 972
 			'result'   => 'success',
974
-			'redirect' => wc_get_endpoint_url( 'payment-methods' ),
973
+			'redirect' => wc_get_endpoint_url('payment-methods'),
975 974
 		);
976 975
 	}
977 976
 
@@ -988,10 +987,10 @@  discard block
 block discarded – undo
988 987
 		 * Stripe expects Norwegian to only be passed NO.
989 988
 		 * But WP has different dialects.
990 989
 		 */
991
-		if ( 'NO' === substr( $locale, 3, 2 ) ) {
990
+		if ('NO' === substr($locale, 3, 2)) {
992 991
 			$locale = 'no';
993 992
 		} else {
994
-			$locale = substr( get_locale(), 0, 2 );
993
+			$locale = substr(get_locale(), 0, 2);
995 994
 		}
996 995
 
997 996
 		return $locale;
@@ -1005,9 +1004,9 @@  discard block
 block discarded – undo
1005 1004
 	 * @param string $idempotency_key
1006 1005
 	 * @param array $request
1007 1006
 	 */
1008
-	public function change_idempotency_key( $idempotency_key, $request ) {
1009
-		$customer = ! empty( $request['customer'] ) ? $request['customer'] : '';
1010
-		$source   = ! empty( $request['source'] ) ? $request['source'] : $customer;
1007
+	public function change_idempotency_key($idempotency_key, $request) {
1008
+		$customer = ! empty($request['customer']) ? $request['customer'] : '';
1009
+		$source   = ! empty($request['source']) ? $request['source'] : $customer;
1011 1010
 		$count    = $this->retry_interval;
1012 1011
 
1013 1012
 		return $request['metadata']['order_id'] . '-' . $count . '-' . $source;
@@ -1021,8 +1020,8 @@  discard block
 block discarded – undo
1021 1020
 	 * @since 4.0.6
1022 1021
 	 * @param array $headers
1023 1022
 	 */
1024
-	public function is_original_request( $headers ) {
1025
-		if ( $headers['original-request'] === $headers['request-id'] ) {
1023
+	public function is_original_request($headers) {
1024
+		if ($headers['original-request'] === $headers['request-id']) {
1026 1025
 			return true;
1027 1026
 		}
1028 1027
 
@@ -1036,27 +1035,27 @@  discard block
 block discarded – undo
1036 1035
 	 * @param object   $prepared_source The source that is used for the payment.
1037 1036
 	 * @return array                    The arguments for the request.
1038 1037
 	 */
1039
-	public function generate_create_intent_request( $order, $prepared_source ) {
1038
+	public function generate_create_intent_request($order, $prepared_source) {
1040 1039
 		// The request for a charge contains metadata for the intent.
1041
-		$full_request = $this->generate_payment_request( $order, $prepared_source );
1040
+		$full_request = $this->generate_payment_request($order, $prepared_source);
1042 1041
 
1043 1042
 		$request = array(
1044 1043
 			'source'               => $prepared_source->source,
1045
-			'amount'               => WC_Stripe_Helper::get_stripe_amount( $order->get_total() ),
1046
-			'currency'             => strtolower( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency() ),
1044
+			'amount'               => WC_Stripe_Helper::get_stripe_amount($order->get_total()),
1045
+			'currency'             => strtolower(WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency()),
1047 1046
 			'description'          => $full_request['description'],
1048 1047
 			'metadata'             => $full_request['metadata'],
1049
-			'capture_method'       => ( 'true' === $full_request['capture'] ) ? 'automatic' : 'manual',
1048
+			'capture_method'       => ('true' === $full_request['capture']) ? 'automatic' : 'manual',
1050 1049
 			'payment_method_types' => array(
1051 1050
 				'card',
1052 1051
 			),
1053 1052
 		);
1054 1053
 
1055
-		if ( $prepared_source->customer ) {
1054
+		if ($prepared_source->customer) {
1056 1055
 			$request['customer'] = $prepared_source->customer;
1057 1056
 		}
1058 1057
 
1059
-		if ( isset( $full_request['statement_descriptor'] ) ) {
1058
+		if (isset($full_request['statement_descriptor'])) {
1060 1059
 			$request['statement_descriptor'] = $full_request['statement_descriptor'];
1061 1060
 		}
1062 1061
 
@@ -1068,7 +1067,7 @@  discard block
 block discarded – undo
1068 1067
 		 * @param WC_Order $order
1069 1068
 		 * @param object $source
1070 1069
 		 */
1071
-		return apply_filters( 'wc_stripe_generate_create_intent_request', $request, $order, $prepared_source );
1070
+		return apply_filters('wc_stripe_generate_create_intent_request', $request, $order, $prepared_source);
1072 1071
 	}
1073 1072
 
1074 1073
 	/**
@@ -1077,27 +1076,27 @@  discard block
 block discarded – undo
1077 1076
 	 * @param WC_Order $order The order that is being paid for.
1078 1077
 	 * @return array          The level 3 data to send to Stripe.
1079 1078
 	 */
1080
-	public function get_level3_data_from_order( $order ) {
1079
+	public function get_level3_data_from_order($order) {
1081 1080
 		// WC Versions before 3.0 don't support postcodes and are
1082 1081
 		// incompatible with level3 data.
1083
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
1082
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
1084 1083
 			return array();
1085 1084
 		}
1086 1085
 
1087 1086
 		// Get the order items. Don't need their keys, only their values.
1088 1087
 		// Order item IDs are used as keys in the original order items array.
1089
-		$order_items = array_values( $order->get_items() );
1088
+		$order_items = array_values($order->get_items());
1090 1089
 		$currency    = $order->get_currency();
1091 1090
 
1092
-		$stripe_line_items = array_map(function( $item ) use ( $currency ) {
1091
+		$stripe_line_items = array_map(function($item) use ($currency) {
1093 1092
 			$product_id          = $item->get_variation_id()
1094 1093
 				? $item->get_variation_id()
1095 1094
 				: $item->get_product_id();
1096
-			$product_description = substr( $item->get_name(), 0, 26 );
1095
+			$product_description = substr($item->get_name(), 0, 26);
1097 1096
 			$quantity            = $item->get_quantity();
1098
-			$unit_cost           = WC_Stripe_Helper::get_stripe_amount( ( $item->get_subtotal() / $quantity ), $currency );
1099
-			$tax_amount          = WC_Stripe_Helper::get_stripe_amount( $item->get_total_tax(), $currency );
1100
-			$discount_amount     = WC_Stripe_Helper::get_stripe_amount( $item->get_subtotal() - $item->get_total(), $currency );
1097
+			$unit_cost           = WC_Stripe_Helper::get_stripe_amount(($item->get_subtotal() / $quantity), $currency);
1098
+			$tax_amount          = WC_Stripe_Helper::get_stripe_amount($item->get_total_tax(), $currency);
1099
+			$discount_amount     = WC_Stripe_Helper::get_stripe_amount($item->get_subtotal() - $item->get_total(), $currency);
1101 1100
 
1102 1101
 			return (object) array(
1103 1102
 				'product_code'        => (string) $product_id, // Up to 12 characters that uniquely identify the product.
@@ -1112,19 +1111,19 @@  discard block
 block discarded – undo
1112 1111
 		$level3_data = array(
1113 1112
 			'merchant_reference'   => $order->get_id(), // An alphanumeric string of up to  characters in length. This unique value is assigned by the merchant to identify the order. Also known as an “Order ID”.
1114 1113
 
1115
-			'shipping_amount'      => WC_Stripe_Helper::get_stripe_amount( $order->get_shipping_total() + $order->get_shipping_tax(), $currency), // The shipping cost, in cents, as a non-negative integer.
1114
+			'shipping_amount'      => WC_Stripe_Helper::get_stripe_amount($order->get_shipping_total() + $order->get_shipping_tax(), $currency), // The shipping cost, in cents, as a non-negative integer.
1116 1115
 			'line_items'           => $stripe_line_items,
1117 1116
 		);
1118 1117
 
1119 1118
 		// The customer’s U.S. shipping ZIP code.
1120 1119
 		$shipping_address_zip = $order->get_shipping_postcode();
1121
-		if ( $this->is_valid_us_zip_code( $shipping_address_zip ) ) {
1120
+		if ($this->is_valid_us_zip_code($shipping_address_zip)) {
1122 1121
 			$level3_data['shipping_address_zip'] = $shipping_address_zip;
1123 1122
 		}
1124 1123
 
1125 1124
 		// The merchant’s U.S. shipping ZIP code.
1126
-		$store_postcode = get_option( 'woocommerce_store_postcode' );
1127
-		if ( $this->is_valid_us_zip_code( $store_postcode ) ) {
1125
+		$store_postcode = get_option('woocommerce_store_postcode');
1126
+		if ($this->is_valid_us_zip_code($store_postcode)) {
1128 1127
 			$level3_data['shipping_from_zip'] = $store_postcode;
1129 1128
 		}
1130 1129
 
@@ -1138,20 +1137,20 @@  discard block
 block discarded – undo
1138 1137
 	 * @param object   $prepared_source The source that is used for the payment.
1139 1138
 	 * @return object                   An intent or an error.
1140 1139
 	 */
1141
-	public function create_intent( $order, $prepared_source ) {
1142
-		$request = $this->generate_create_intent_request( $order, $prepared_source );
1140
+	public function create_intent($order, $prepared_source) {
1141
+		$request = $this->generate_create_intent_request($order, $prepared_source);
1143 1142
 
1144 1143
 		// Create an intent that awaits an action.
1145
-		$intent = WC_Stripe_API::request( $request, 'payment_intents' );
1146
-		if ( ! empty( $intent->error ) ) {
1144
+		$intent = WC_Stripe_API::request($request, 'payment_intents');
1145
+		if ( ! empty($intent->error)) {
1147 1146
 			return $intent;
1148 1147
 		}
1149 1148
 
1150
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
1151
-		WC_Stripe_Logger::log( "Stripe PaymentIntent $intent->id initiated for order $order_id" );
1149
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
1150
+		WC_Stripe_Logger::log("Stripe PaymentIntent $intent->id initiated for order $order_id");
1152 1151
 
1153 1152
 		// Save the intent ID to the order.
1154
-		$this->save_intent_to_order( $order, $intent );
1153
+		$this->save_intent_to_order($order, $intent);
1155 1154
 
1156 1155
 		return $intent;
1157 1156
 	}
@@ -1164,27 +1163,27 @@  discard block
 block discarded – undo
1164 1163
 	 * @param object   $prepared_source Currently selected source.
1165 1164
 	 * @return object                   An updated intent.
1166 1165
 	 */
1167
-	public function update_existing_intent( $intent, $order, $prepared_source ) {
1166
+	public function update_existing_intent($intent, $order, $prepared_source) {
1168 1167
 		$request = array();
1169 1168
 
1170
-		if ( $prepared_source->source !== $intent->source ) {
1169
+		if ($prepared_source->source !== $intent->source) {
1171 1170
 			$request['source'] = $prepared_source->source;
1172 1171
 		}
1173 1172
 
1174
-		$new_amount = WC_Stripe_Helper::get_stripe_amount( $order->get_total() );
1175
-		if ( $intent->amount !== $new_amount ) {
1173
+		$new_amount = WC_Stripe_Helper::get_stripe_amount($order->get_total());
1174
+		if ($intent->amount !== $new_amount) {
1176 1175
 			$request['amount'] = $new_amount;
1177 1176
 		}
1178 1177
 
1179
-		if ( $prepared_source->customer && $intent->customer !== $prepared_source->customer ) {
1178
+		if ($prepared_source->customer && $intent->customer !== $prepared_source->customer) {
1180 1179
 			$request['customer'] = $prepared_source->customer;
1181 1180
 		}
1182 1181
 
1183
-		if ( empty( $request ) ) {
1182
+		if (empty($request)) {
1184 1183
 			return $intent;
1185 1184
 		}
1186 1185
 
1187
-		$level3_data = $this->get_level3_data_from_order( $order );
1186
+		$level3_data = $this->get_level3_data_from_order($order);
1188 1187
 		return WC_Stripe_API::request_with_level3_data(
1189 1188
 			$request,
1190 1189
 			"payment_intents/$intent->id",
@@ -1202,8 +1201,8 @@  discard block
 block discarded – undo
1202 1201
 	 * @param object   $prepared_source The source that is being charged.
1203 1202
 	 * @return object                   Either an error or the updated intent.
1204 1203
 	 */
1205
-	public function confirm_intent( $intent, $order, $prepared_source ) {
1206
-		if ( 'requires_confirmation' !== $intent->status ) {
1204
+	public function confirm_intent($intent, $order, $prepared_source) {
1205
+		if ('requires_confirmation' !== $intent->status) {
1207 1206
 			return $intent;
1208 1207
 		}
1209 1208
 
@@ -1212,7 +1211,7 @@  discard block
 block discarded – undo
1212 1211
 			'source' => $prepared_source->source,
1213 1212
 		);
1214 1213
 
1215
-		$level3_data = $this->get_level3_data_from_order( $order );
1214
+		$level3_data = $this->get_level3_data_from_order($order);
1216 1215
 		$confirmed_intent = WC_Stripe_API::request_with_level3_data(
1217 1216
 			$confirm_request,
1218 1217
 			"payment_intents/$intent->id/confirm",
@@ -1220,16 +1219,16 @@  discard block
 block discarded – undo
1220 1219
 			$order
1221 1220
 		);
1222 1221
 
1223
-		if ( ! empty( $confirmed_intent->error ) ) {
1222
+		if ( ! empty($confirmed_intent->error)) {
1224 1223
 			return $confirmed_intent;
1225 1224
 		}
1226 1225
 
1227 1226
 		// Save a note about the status of the intent.
1228
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
1229
-		if ( 'succeeded' === $confirmed_intent->status ) {
1230
-			WC_Stripe_Logger::log( "Stripe PaymentIntent $intent->id succeeded for order $order_id" );
1231
-		} elseif ( 'requires_action' === $confirmed_intent->status ) {
1232
-			WC_Stripe_Logger::log( "Stripe PaymentIntent $intent->id requires authentication for order $order_id" );
1227
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
1228
+		if ('succeeded' === $confirmed_intent->status) {
1229
+			WC_Stripe_Logger::log("Stripe PaymentIntent $intent->id succeeded for order $order_id");
1230
+		} elseif ('requires_action' === $confirmed_intent->status) {
1231
+			WC_Stripe_Logger::log("Stripe PaymentIntent $intent->id requires authentication for order $order_id");
1233 1232
 		}
1234 1233
 
1235 1234
 		return $confirmed_intent;
@@ -1242,16 +1241,16 @@  discard block
 block discarded – undo
1242 1241
 	 * @param WC_Order $order For to which the source applies.
1243 1242
 	 * @param stdClass $intent Payment intent information.
1244 1243
 	 */
1245
-	public function save_intent_to_order( $order, $intent ) {
1246
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
1244
+	public function save_intent_to_order($order, $intent) {
1245
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
1247 1246
 
1248
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
1249
-			update_post_meta( $order_id, '_stripe_intent_id', $intent->id );
1247
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
1248
+			update_post_meta($order_id, '_stripe_intent_id', $intent->id);
1250 1249
 		} else {
1251
-			$order->update_meta_data( '_stripe_intent_id', $intent->id );
1250
+			$order->update_meta_data('_stripe_intent_id', $intent->id);
1252 1251
 		}
1253 1252
 
1254
-		if ( is_callable( array( $order, 'save' ) ) ) {
1253
+		if (is_callable(array($order, 'save'))) {
1255 1254
 			$order->save();
1256 1255
 		}
1257 1256
 	}
@@ -1263,23 +1262,23 @@  discard block
 block discarded – undo
1263 1262
 	 * @param WC_Order $order The order to retrieve an intent for.
1264 1263
 	 * @return obect|bool     Either the intent object or `false`.
1265 1264
 	 */
1266
-	public function get_intent_from_order( $order ) {
1267
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
1268
-			return $this->pre_3_0_get_intent_from_order( $order );
1265
+	public function get_intent_from_order($order) {
1266
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
1267
+			return $this->pre_3_0_get_intent_from_order($order);
1269 1268
 		}
1270 1269
 
1271 1270
 		$order_id  = $order->get_id();
1272
-		$intent_id = $order->get_meta( '_stripe_intent_id' );
1271
+		$intent_id = $order->get_meta('_stripe_intent_id');
1273 1272
 
1274
-		if ( $intent_id ) {
1275
-			return $this->get_intent( 'payment_intents', $intent_id );
1273
+		if ($intent_id) {
1274
+			return $this->get_intent('payment_intents', $intent_id);
1276 1275
 		}
1277 1276
 
1278 1277
 		// The order doesn't have a payment intent, but it may have a setup intent.
1279
-		$intent_id = $order->get_meta( '_stripe_setup_intent' );
1278
+		$intent_id = $order->get_meta('_stripe_setup_intent');
1280 1279
 
1281
-		if ( $intent_id ) {
1282
-			return $this->get_intent( 'setup_intents', $intent_id );
1280
+		if ($intent_id) {
1281
+			return $this->get_intent('setup_intents', $intent_id);
1283 1282
 		}
1284 1283
 
1285 1284
 		return false;
@@ -1291,19 +1290,19 @@  discard block
 block discarded – undo
1291 1290
 	 * @param WC_Order $order The order to retrieve an intent for.
1292 1291
 	 * @return obect|bool     Either the intent object or `false`.
1293 1292
 	 */
1294
-	private function pre_3_0_get_intent_from_order( $order ) {
1293
+	private function pre_3_0_get_intent_from_order($order) {
1295 1294
 		$order_id  = $order->id;
1296
-		$intent_id = get_post_meta( $order_id, '_stripe_intent_id', true );
1295
+		$intent_id = get_post_meta($order_id, '_stripe_intent_id', true);
1297 1296
 
1298
-		if ( $intent_id ) {
1299
-			return $this->get_intent( 'payment_intents', $intent_id );
1297
+		if ($intent_id) {
1298
+			return $this->get_intent('payment_intents', $intent_id);
1300 1299
 		}
1301 1300
 
1302 1301
 		// The order doesn't have a payment intent, but it may have a setup intent.
1303
-		$intent_id = get_post_meta( $order_id, '_stripe_setup_intent', true );
1302
+		$intent_id = get_post_meta($order_id, '_stripe_setup_intent', true);
1304 1303
 
1305
-		if ( $intent_id ) {
1306
-			return $this->get_intent( 'setup_intents', $intent_id );
1304
+		if ($intent_id) {
1305
+			return $this->get_intent('setup_intents', $intent_id);
1307 1306
 		}
1308 1307
 
1309 1308
 		return false;
@@ -1317,15 +1316,15 @@  discard block
 block discarded – undo
1317 1316
 	 * @return object|bool 			Either the intent object or `false`.
1318 1317
 	 * @throws Exception 			Throws exception for unknown $intent_type.
1319 1318
 	 */
1320
-	private function get_intent( $intent_type, $intent_id ) {
1321
-		if ( ! in_array( $intent_type, [ 'payment_intents', 'setup_intents' ] ) ) {
1322
-			throw new Exception( "Failed to get intent of type $intent_type. Type is not allowed" );
1319
+	private function get_intent($intent_type, $intent_id) {
1320
+		if ( ! in_array($intent_type, ['payment_intents', 'setup_intents'])) {
1321
+			throw new Exception("Failed to get intent of type $intent_type. Type is not allowed");
1323 1322
 		}
1324 1323
 
1325
-		$response = WC_Stripe_API::request( array(), "$intent_type/$intent_id", 'GET' );
1324
+		$response = WC_Stripe_API::request(array(), "$intent_type/$intent_id", 'GET');
1326 1325
 
1327
-		if ( $response && isset( $response->{ 'error' } ) ) {
1328
-			$error_response_message = print_r( $response, true );
1326
+		if ($response && isset($response->{ 'error' } )) {
1327
+			$error_response_message = print_r($response, true);
1329 1328
 			WC_Stripe_Logger::log("Failed to get Stripe intent $intent_type/$intent_id.");
1330 1329
 			WC_Stripe_Logger::log("Response: $error_response_message");
1331 1330
 			return false;
@@ -1342,18 +1341,18 @@  discard block
 block discarded – undo
1342 1341
 	 * @param stdClass $intent The intent that is being processed.
1343 1342
 	 * @return bool            A flag that indicates whether the order is already locked.
1344 1343
 	 */
1345
-	public function lock_order_payment( $order, $intent = null ) {
1346
-		$order_id       = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
1344
+	public function lock_order_payment($order, $intent = null) {
1345
+		$order_id       = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
1347 1346
 		$transient_name = 'wc_stripe_processing_intent_' . $order_id;
1348
-		$processing     = get_transient( $transient_name );
1347
+		$processing     = get_transient($transient_name);
1349 1348
 
1350 1349
 		// Block the process if the same intent is already being handled.
1351
-		if ( "-1" === $processing || ( isset( $intent->id ) && $processing === $intent->id ) ) {
1350
+		if ("-1" === $processing || (isset($intent->id) && $processing === $intent->id)) {
1352 1351
 			return true;
1353 1352
 		}
1354 1353
 
1355 1354
 		// Save the new intent as a transient, eventually overwriting another one.
1356
-		set_transient( $transient_name, empty( $intent ) ? '-1' : $intent->id, 5 * MINUTE_IN_SECONDS );
1355
+		set_transient($transient_name, empty($intent) ? '-1' : $intent->id, 5 * MINUTE_IN_SECONDS);
1357 1356
 
1358 1357
 		return false;
1359 1358
 	}
@@ -1364,9 +1363,9 @@  discard block
 block discarded – undo
1364 1363
 	 * @since 4.2
1365 1364
 	 * @param WC_Order $order The order that is being unlocked.
1366 1365
 	 */
1367
-	public function unlock_order_payment( $order ) {
1368
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
1369
-		delete_transient( 'wc_stripe_processing_intent_' . $order_id );
1366
+	public function unlock_order_payment($order) {
1367
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
1368
+		delete_transient('wc_stripe_processing_intent_' . $order_id);
1370 1369
 	}
1371 1370
 
1372 1371
 	/**
@@ -1376,9 +1375,9 @@  discard block
 block discarded – undo
1376 1375
 	 * @param object $response The response from Stripe.
1377 1376
 	 * @return boolean Whether or not it's a 'authentication_required' error
1378 1377
 	 */
1379
-	public function is_authentication_required_for_payment( $response ) {
1380
-		return ( ! empty( $response->error ) && 'authentication_required' === $response->error->code )
1381
-			|| ( ! empty( $response->last_payment_error ) && 'authentication_required' === $response->last_payment_error->code );
1378
+	public function is_authentication_required_for_payment($response) {
1379
+		return ( ! empty($response->error) && 'authentication_required' === $response->error->code)
1380
+			|| ( ! empty($response->last_payment_error) && 'authentication_required' === $response->last_payment_error->code);
1382 1381
 	}
1383 1382
 
1384 1383
 	/**
@@ -1388,21 +1387,21 @@  discard block
 block discarded – undo
1388 1387
 	 * @param object   $prepared_source The source, entered/chosen by the customer.
1389 1388
 	 * @return string                   The client secret of the intent, used for confirmation in JS.
1390 1389
 	 */
1391
-	public function setup_intent( $order, $prepared_source ) {
1392
-		$order_id     = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
1393
-		$setup_intent = WC_Stripe_API::request( array(
1390
+	public function setup_intent($order, $prepared_source) {
1391
+		$order_id     = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
1392
+		$setup_intent = WC_Stripe_API::request(array(
1394 1393
 			'payment_method' => $prepared_source->source,
1395 1394
 			'customer'       => $prepared_source->customer,
1396 1395
 			'confirm'        => 'true',
1397
-		), 'setup_intents' );
1396
+		), 'setup_intents');
1398 1397
 
1399
-		if ( is_wp_error( $setup_intent ) ) {
1400
-			WC_Stripe_Logger::log( "Unable to create SetupIntent for Order #$order_id: " . print_r( $setup_intent, true ) );
1401
-		} elseif ( 'requires_action' === $setup_intent->status ) {
1402
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
1403
-				update_post_meta( $order_id, '_stripe_setup_intent', $setup_intent->id );
1398
+		if (is_wp_error($setup_intent)) {
1399
+			WC_Stripe_Logger::log("Unable to create SetupIntent for Order #$order_id: " . print_r($setup_intent, true));
1400
+		} elseif ('requires_action' === $setup_intent->status) {
1401
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
1402
+				update_post_meta($order_id, '_stripe_setup_intent', $setup_intent->id);
1404 1403
 			} else {
1405
-				$order->update_meta_data( '_stripe_setup_intent', $setup_intent->id );
1404
+				$order->update_meta_data('_stripe_setup_intent', $setup_intent->id);
1406 1405
 				$order->save();
1407 1406
 			}
1408 1407
 
@@ -1418,12 +1417,12 @@  discard block
 block discarded – undo
1418 1417
 	 * @param float    $amount          The amount to charge. If not specified, it will be read from the order.
1419 1418
 	 * @return object                   An intent or an error.
1420 1419
 	 */
1421
-	public function create_and_confirm_intent_for_off_session( $order, $prepared_source, $amount = NULL ) {
1420
+	public function create_and_confirm_intent_for_off_session($order, $prepared_source, $amount = NULL) {
1422 1421
 		// The request for a charge contains metadata for the intent.
1423
-		$full_request = $this->generate_payment_request( $order, $prepared_source );
1422
+		$full_request = $this->generate_payment_request($order, $prepared_source);
1424 1423
 
1425 1424
 		$request = array(
1426
-			'amount'               => $amount ? WC_Stripe_Helper::get_stripe_amount( $amount, $full_request['currency'] ) : $full_request['amount'],
1425
+			'amount'               => $amount ? WC_Stripe_Helper::get_stripe_amount($amount, $full_request['currency']) : $full_request['amount'],
1427 1426
 			'currency'             => $full_request['currency'],
1428 1427
 			'description'          => $full_request['description'],
1429 1428
 			'metadata'             => $full_request['metadata'],
@@ -1435,44 +1434,44 @@  discard block
 block discarded – undo
1435 1434
 			'confirmation_method'  => 'automatic',
1436 1435
 		);
1437 1436
 
1438
-		if ( isset( $full_request['statement_descriptor'] ) ) {
1437
+		if (isset($full_request['statement_descriptor'])) {
1439 1438
 			$request['statement_descriptor'] = $full_request['statement_descriptor'];
1440 1439
 		}
1441 1440
 
1442
-		if ( isset( $full_request['customer'] ) ) {
1441
+		if (isset($full_request['customer'])) {
1443 1442
 			$request['customer'] = $full_request['customer'];
1444 1443
 		}
1445 1444
 
1446
-		if ( isset( $full_request['source'] ) ) {
1445
+		if (isset($full_request['source'])) {
1447 1446
 			$request['source'] = $full_request['source'];
1448 1447
 		}
1449 1448
 
1450
-		$level3_data = $this->get_level3_data_from_order( $order );
1449
+		$level3_data = $this->get_level3_data_from_order($order);
1451 1450
 		$intent = WC_Stripe_API::request_with_level3_data(
1452 1451
 			$request,
1453 1452
 			'payment_intents',
1454 1453
 			$level3_data,
1455 1454
 			$order
1456 1455
 		);
1457
-		$is_authentication_required = $this->is_authentication_required_for_payment( $intent );
1456
+		$is_authentication_required = $this->is_authentication_required_for_payment($intent);
1458 1457
 
1459
-		if ( ! empty( $intent->error ) && ! $is_authentication_required ) {
1458
+		if ( ! empty($intent->error) && ! $is_authentication_required) {
1460 1459
 			return $intent;
1461 1460
 		}
1462 1461
 
1463
-		$intent_id      = ( ! empty( $intent->error )
1462
+		$intent_id = ( ! empty($intent->error)
1464 1463
 			? $intent->error->payment_intent->id
1465 1464
 			: $intent->id
1466 1465
 		);
1467
-		$payment_intent = ( ! empty( $intent->error )
1466
+		$payment_intent = ( ! empty($intent->error)
1468 1467
 			? $intent->error->payment_intent
1469 1468
 			: $intent
1470 1469
 		);
1471
-		$order_id       = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
1472
-		WC_Stripe_Logger::log( "Stripe PaymentIntent $intent_id initiated for order $order_id" );
1470
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
1471
+		WC_Stripe_Logger::log("Stripe PaymentIntent $intent_id initiated for order $order_id");
1473 1472
 
1474 1473
 		// Save the intent ID to the order.
1475
-		$this->save_intent_to_order( $order, $payment_intent );
1474
+		$this->save_intent_to_order($order, $payment_intent);
1476 1475
 
1477 1476
 		return $intent;
1478 1477
 	}
@@ -1483,13 +1482,13 @@  discard block
 block discarded – undo
1483 1482
 	 * Fix renewal for existing subscriptions affected by https://github.com/woocommerce/woocommerce-gateway-stripe/issues/1072.
1484 1483
 	 * @param int $order_id subscription renewal order id.
1485 1484
 	 */
1486
-	public function ensure_subscription_has_customer_id( $order_id ) {
1487
-		$subscriptions_ids = wcs_get_subscriptions_for_order( $order_id, array( 'order_type' => 'any' ) );
1488
-		foreach( $subscriptions_ids as $subscription_id => $subscription ) {
1489
-			if ( ! metadata_exists( 'post', $subscription_id, '_stripe_customer_id' ) ) {
1490
-				$stripe_customer = new WC_Stripe_Customer( $subscription->get_user_id() );
1491
-				update_post_meta( $subscription_id, '_stripe_customer_id', $stripe_customer->get_id() );
1492
-				update_post_meta( $order_id, '_stripe_customer_id', $stripe_customer->get_id() );
1485
+	public function ensure_subscription_has_customer_id($order_id) {
1486
+		$subscriptions_ids = wcs_get_subscriptions_for_order($order_id, array('order_type' => 'any'));
1487
+		foreach ($subscriptions_ids as $subscription_id => $subscription) {
1488
+			if ( ! metadata_exists('post', $subscription_id, '_stripe_customer_id')) {
1489
+				$stripe_customer = new WC_Stripe_Customer($subscription->get_user_id());
1490
+				update_post_meta($subscription_id, '_stripe_customer_id', $stripe_customer->get_id());
1491
+				update_post_meta($order_id, '_stripe_customer_id', $stripe_customer->get_id());
1493 1492
 			}
1494 1493
 		}
1495 1494
 	}
@@ -1499,7 +1498,7 @@  discard block
 block discarded – undo
1499 1498
 	 * @param string $zip The ZIP code to verify.
1500 1499
 	 * @return boolean
1501 1500
 	 */
1502
-	public function is_valid_us_zip_code( $zip ) {
1503
-		return ! empty( $zip ) && preg_match( '/^\d{5,5}(-\d{4,4})?$/', $zip );
1501
+	public function is_valid_us_zip_code($zip) {
1502
+		return ! empty($zip) && preg_match('/^\d{5,5}(-\d{4,4})?$/', $zip);
1504 1503
 	}
1505 1504
 }
Please login to merge, or discard this patch.
includes/admin/class-wc-stripe-admin-notices.php 1 patch
Spacing   +105 added lines, -105 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
 
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 * @since 4.1.0
22 22
 	 */
23 23
 	public function __construct() {
24
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
25
-		add_action( 'wp_loaded', array( $this, 'hide_notices' ) );
26
-		add_action( 'woocommerce_stripe_updated', array( $this, 'stripe_updated' ) );
24
+		add_action('admin_notices', array($this, 'admin_notices'));
25
+		add_action('wp_loaded', array($this, 'hide_notices'));
26
+		add_action('woocommerce_stripe_updated', array($this, 'stripe_updated'));
27 27
 	}
28 28
 
29 29
 	/**
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 * @since 1.0.0
33 33
 	 * @version 4.0.0
34 34
 	 */
35
-	public function add_admin_notice( $slug, $class, $message, $dismissible = false ) {
36
-		$this->notices[ $slug ] = array(
35
+	public function add_admin_notice($slug, $class, $message, $dismissible = false) {
36
+		$this->notices[$slug] = array(
37 37
 			'class'       => $class,
38 38
 			'message'     => $message,
39 39
 			'dismissible' => $dismissible,
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @version 4.0.0
48 48
 	 */
49 49
 	public function admin_notices() {
50
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
50
+		if ( ! current_user_can('manage_woocommerce')) {
51 51
 			return;
52 52
 		}
53 53
 
@@ -57,17 +57,17 @@  discard block
 block discarded – undo
57 57
 		// All other payment methods.
58 58
 		$this->payment_methods_check_environment();
59 59
 
60
-		foreach ( (array) $this->notices as $notice_key => $notice ) {
61
-			echo '<div class="' . esc_attr( $notice['class'] ) . '" style="position:relative;">';
60
+		foreach ((array) $this->notices as $notice_key => $notice) {
61
+			echo '<div class="' . esc_attr($notice['class']) . '" style="position:relative;">';
62 62
 
63
-			if ( $notice['dismissible'] ) {
63
+			if ($notice['dismissible']) {
64 64
 				?>
65
-				<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-stripe-hide-notice', $notice_key ), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce' ) ); ?>" class="woocommerce-message-close notice-dismiss" style="position:relative;float:right;padding:9px 0px 9px 9px 9px;text-decoration:none;"></a>
65
+				<a href="<?php echo esc_url(wp_nonce_url(add_query_arg('wc-stripe-hide-notice', $notice_key), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce')); ?>" class="woocommerce-message-close notice-dismiss" style="position:relative;float:right;padding:9px 0px 9px 9px 9px;text-decoration:none;"></a>
66 66
 				<?php
67 67
 			}
68 68
 
69 69
 			echo '<p>';
70
-			echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array(), 'target' => array() ) ) );
70
+			echo wp_kses($notice['message'], array('a' => array('href' => array(), 'target' => array())));
71 71
 			echo '</p></div>';
72 72
 		}
73 73
 	}
@@ -100,118 +100,118 @@  discard block
 block discarded – undo
100 100
 	 * @version 4.0.0
101 101
 	 */
102 102
 	public function stripe_check_environment() {
103
-		$show_style_notice   = get_option( 'wc_stripe_show_style_notice' );
104
-		$show_ssl_notice     = get_option( 'wc_stripe_show_ssl_notice' );
105
-		$show_keys_notice    = get_option( 'wc_stripe_show_keys_notice' );
106
-		$show_3ds_notice     = get_option( 'wc_stripe_show_3ds_notice' );
107
-		$show_phpver_notice  = get_option( 'wc_stripe_show_phpver_notice' );
108
-		$show_wcver_notice   = get_option( 'wc_stripe_show_wcver_notice' );
109
-		$show_curl_notice    = get_option( 'wc_stripe_show_curl_notice' );
110
-		$show_sca_notice     = get_option( 'wc_stripe_show_sca_notice' );
111
-		$changed_keys_notice = get_option( 'wc_stripe_show_changed_keys_notice' );
112
-		$options             = get_option( 'woocommerce_stripe_settings' );
113
-		$testmode            = ( isset( $options['testmode'] ) && 'yes' === $options['testmode'] ) ? true : false;
114
-		$test_pub_key        = isset( $options['test_publishable_key'] ) ? $options['test_publishable_key'] : '';
115
-		$test_secret_key     = isset( $options['test_secret_key'] ) ? $options['test_secret_key'] : '';
116
-		$live_pub_key        = isset( $options['publishable_key'] ) ? $options['publishable_key'] : '';
117
-		$live_secret_key     = isset( $options['secret_key'] ) ? $options['secret_key'] : '';
118
-		$three_d_secure      = isset( $options['three_d_secure'] ) && 'yes' === $options['three_d_secure'];
119
-
120
-		if ( isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) {
121
-			if ( empty( $show_3ds_notice ) && $three_d_secure ) {
103
+		$show_style_notice   = get_option('wc_stripe_show_style_notice');
104
+		$show_ssl_notice     = get_option('wc_stripe_show_ssl_notice');
105
+		$show_keys_notice    = get_option('wc_stripe_show_keys_notice');
106
+		$show_3ds_notice     = get_option('wc_stripe_show_3ds_notice');
107
+		$show_phpver_notice  = get_option('wc_stripe_show_phpver_notice');
108
+		$show_wcver_notice   = get_option('wc_stripe_show_wcver_notice');
109
+		$show_curl_notice    = get_option('wc_stripe_show_curl_notice');
110
+		$show_sca_notice     = get_option('wc_stripe_show_sca_notice');
111
+		$changed_keys_notice = get_option('wc_stripe_show_changed_keys_notice');
112
+		$options             = get_option('woocommerce_stripe_settings');
113
+		$testmode            = (isset($options['testmode']) && 'yes' === $options['testmode']) ? true : false;
114
+		$test_pub_key        = isset($options['test_publishable_key']) ? $options['test_publishable_key'] : '';
115
+		$test_secret_key     = isset($options['test_secret_key']) ? $options['test_secret_key'] : '';
116
+		$live_pub_key        = isset($options['publishable_key']) ? $options['publishable_key'] : '';
117
+		$live_secret_key     = isset($options['secret_key']) ? $options['secret_key'] : '';
118
+		$three_d_secure      = isset($options['three_d_secure']) && 'yes' === $options['three_d_secure'];
119
+
120
+		if (isset($options['enabled']) && 'yes' === $options['enabled']) {
121
+			if (empty($show_3ds_notice) && $three_d_secure) {
122 122
 				$url = 'https://stripe.com/docs/payments/3d-secure#three-ds-radar';
123 123
 
124 124
 				/* translators: 1) A URL that explains Stripe Radar. */
125
-				$message = __( 'WooCommerce Stripe - We see that you had the "Require 3D secure when applicable" setting turned on. This setting is not available here anymore, because it is now replaced by Stripe Radar. You can learn more about it <a href="%s" target="_blank">here</a>.', 'woocommerce-gateway-stripe' );
125
+				$message = __('WooCommerce Stripe - We see that you had the "Require 3D secure when applicable" setting turned on. This setting is not available here anymore, because it is now replaced by Stripe Radar. You can learn more about it <a href="%s" target="_blank">here</a>.', 'woocommerce-gateway-stripe');
126 126
 
127
-				$this->add_admin_notice( '3ds', 'notice notice-warning', sprintf( $message, $url ), true );
127
+				$this->add_admin_notice('3ds', 'notice notice-warning', sprintf($message, $url), true);
128 128
 			}
129 129
 
130
-			if ( empty( $show_style_notice ) ) {
130
+			if (empty($show_style_notice)) {
131 131
 				/* translators: 1) int version 2) int version */
132
-				$message = __( 'WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://docs.woocommerce.com/document/stripe/#styling" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe' );
132
+				$message = __('WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://docs.woocommerce.com/document/stripe/#styling" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe');
133 133
 
134
-				$this->add_admin_notice( 'style', 'notice notice-warning', $message, true );
134
+				$this->add_admin_notice('style', 'notice notice-warning', $message, true);
135 135
 
136 136
 				return;
137 137
 			}
138 138
 
139
-			if ( empty( $show_phpver_notice ) ) {
140
-				if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) {
139
+			if (empty($show_phpver_notice)) {
140
+				if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) {
141 141
 					/* translators: 1) int version 2) int version */
142
-					$message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' );
142
+					$message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe');
143 143
 
144
-					$this->add_admin_notice( 'phpver', 'error', sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() ), true );
144
+					$this->add_admin_notice('phpver', 'error', sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion()), true);
145 145
 
146 146
 					return;
147 147
 				}
148 148
 			}
149 149
 
150
-			if ( empty( $show_wcver_notice ) ) {
151
-				if ( WC_Stripe_Helper::is_wc_lt( WC_STRIPE_MIN_WC_VER ) ) {
150
+			if (empty($show_wcver_notice)) {
151
+				if (WC_Stripe_Helper::is_wc_lt(WC_STRIPE_MIN_WC_VER)) {
152 152
 					/* translators: 1) int version 2) int version */
153
-					$message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' );
153
+					$message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe');
154 154
 
155
-					$this->add_admin_notice( 'wcver', 'notice notice-warning', sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION ), true );
155
+					$this->add_admin_notice('wcver', 'notice notice-warning', sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION), true);
156 156
 
157 157
 					return;
158
-				} elseif ( WC_Stripe_Helper::is_wc_lt( WC_STRIPE_FUTURE_MIN_WC_VER ) ) {
158
+				} elseif (WC_Stripe_Helper::is_wc_lt(WC_STRIPE_FUTURE_MIN_WC_VER)) {
159 159
 					/* translators: 1) int version 2) int version */
160
-					$message = __( 'WooCommerce Stripe - This is the last version of the plugin compatible with WooCommerce %1$s. All furture versions of the plugin will require WooCommerce %2$s or greater.', 'woocommerce-gateway-stripe' );
161
-					$this->add_admin_notice( 'wcver', 'notice notice-warning', sprintf( $message, WC_VERSION, WC_STRIPE_FUTURE_MIN_WC_VER ), true );
160
+					$message = __('WooCommerce Stripe - This is the last version of the plugin compatible with WooCommerce %1$s. All furture versions of the plugin will require WooCommerce %2$s or greater.', 'woocommerce-gateway-stripe');
161
+					$this->add_admin_notice('wcver', 'notice notice-warning', sprintf($message, WC_VERSION, WC_STRIPE_FUTURE_MIN_WC_VER), true);
162 162
 				}
163 163
 			}
164 164
 
165
-			if ( empty( $show_curl_notice ) ) {
166
-				if ( ! function_exists( 'curl_init' ) ) {
167
-					$this->add_admin_notice( 'curl', 'notice notice-warning', __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' ), true );
165
+			if (empty($show_curl_notice)) {
166
+				if ( ! function_exists('curl_init')) {
167
+					$this->add_admin_notice('curl', 'notice notice-warning', __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe'), true);
168 168
 				}
169 169
 			}
170 170
 
171
-			if ( empty( $show_keys_notice ) ) {
171
+			if (empty($show_keys_notice)) {
172 172
 				$secret = WC_Stripe_API::get_secret_key();
173 173
 
174
-				if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) {
174
+				if (empty($secret) && ! (isset($_GET['page'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'])) {
175 175
 					$setting_link = $this->get_setting_link();
176 176
 					/* translators: 1) link */
177
-					$this->add_admin_notice( 'keys', 'notice notice-warning', sprintf( __( 'Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
177
+					$this->add_admin_notice('keys', 'notice notice-warning', sprintf(__('Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
178 178
 				}
179 179
 
180 180
 				// Check if keys are entered properly per live/test mode.
181
-				if ( $testmode ) {
181
+				if ($testmode) {
182 182
 					if (
183
-						! empty( $test_pub_key ) && ! preg_match( '/^pk_test_/', $test_pub_key )
184
-						|| ! empty( $test_secret_key ) && ! preg_match( '/^[rs]k_test_/', $test_secret_key ) ) {
183
+						! empty($test_pub_key) && ! preg_match('/^pk_test_/', $test_pub_key)
184
+						|| ! empty($test_secret_key) && ! preg_match('/^[rs]k_test_/', $test_secret_key) ) {
185 185
 						$setting_link = $this->get_setting_link();
186 186
 						/* translators: 1) link */
187
-						$this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
187
+						$this->add_admin_notice('keys', 'notice notice-error', sprintf(__('Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
188 188
 					}
189 189
 				} else {
190 190
 					if (
191
-						! empty( $live_pub_key ) && ! preg_match( '/^pk_live_/', $live_pub_key )
192
-						|| ! empty( $live_secret_key ) && ! preg_match( '/^[rs]k_live_/', $live_secret_key ) ) {
191
+						! empty($live_pub_key) && ! preg_match('/^pk_live_/', $live_pub_key)
192
+						|| ! empty($live_secret_key) && ! preg_match('/^[rs]k_live_/', $live_secret_key) ) {
193 193
 						$setting_link = $this->get_setting_link();
194 194
 						/* translators: 1) link */
195
-						$this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in live mode however your live keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
195
+						$this->add_admin_notice('keys', 'notice notice-error', sprintf(__('Stripe is in live mode however your live keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
196 196
 					}
197 197
 				}
198 198
 			}
199 199
 
200
-			if ( empty( $show_ssl_notice ) ) {
200
+			if (empty($show_ssl_notice)) {
201 201
 				// Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected.
202
-				if ( ! wc_checkout_is_https() ) {
202
+				if ( ! wc_checkout_is_https()) {
203 203
 					/* translators: 1) link */
204
-					$this->add_admin_notice( 'ssl', 'notice notice-warning', sprintf( __( 'Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe' ), 'https://en.wikipedia.org/wiki/Transport_Layer_Security' ), true );
204
+					$this->add_admin_notice('ssl', 'notice notice-warning', sprintf(__('Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe'), 'https://en.wikipedia.org/wiki/Transport_Layer_Security'), true);
205 205
 				}
206 206
 			}
207 207
 
208
-			if ( empty( $show_sca_notice ) ) {
209
-				$this->add_admin_notice( 'sca', 'notice notice-success', sprintf( __( 'Stripe is now ready for Strong Customer Authentication (SCA) and 3D Secure 2! <a href="%1$s" target="_blank">Read about SCA</a>', 'woocommerce-gateway-stripe' ), 'https://woocommerce.com/posts/introducing-strong-customer-authentication-sca/' ), true );
208
+			if (empty($show_sca_notice)) {
209
+				$this->add_admin_notice('sca', 'notice notice-success', sprintf(__('Stripe is now ready for Strong Customer Authentication (SCA) and 3D Secure 2! <a href="%1$s" target="_blank">Read about SCA</a>', 'woocommerce-gateway-stripe'), 'https://woocommerce.com/posts/introducing-strong-customer-authentication-sca/'), true);
210 210
 			}
211 211
 
212
-			if ( 'yes' === $changed_keys_notice ) {
212
+			if ('yes' === $changed_keys_notice) {
213 213
 				// translators: %s is a the URL for the link.
214
-				$this->add_admin_notice( 'changed_keys', 'notice notice-warning', sprintf( __( 'The public and/or secret keys for the Stripe gateway have been changed. This might cause errors for existing customers and saved payment methods. <a href="%s" target="_blank">Click here to learn more</a>.', 'woocommerce-gateway-stripe' ), 'https://docs.woocommerce.com/document/stripe-fixing-customer-errors/' ), true );
214
+				$this->add_admin_notice('changed_keys', 'notice notice-warning', sprintf(__('The public and/or secret keys for the Stripe gateway have been changed. This might cause errors for existing customers and saved payment methods. <a href="%s" target="_blank">Click here to learn more</a>.', 'woocommerce-gateway-stripe'), 'https://docs.woocommerce.com/document/stripe-fixing-customer-errors/'), true);
215 215
 			}
216 216
 		}
217 217
 	}
@@ -224,17 +224,17 @@  discard block
 block discarded – undo
224 224
 	public function payment_methods_check_environment() {
225 225
 		$payment_methods = $this->get_payment_methods();
226 226
 
227
-		foreach ( $payment_methods as $method => $class ) {
228
-			$show_notice = get_option( 'wc_stripe_show_' . strtolower( $method ) . '_notice' );
227
+		foreach ($payment_methods as $method => $class) {
228
+			$show_notice = get_option('wc_stripe_show_' . strtolower($method) . '_notice');
229 229
 			$gateway     = new $class();
230 230
 
231
-			if ( 'yes' !== $gateway->enabled || 'no' === $show_notice ) {
231
+			if ('yes' !== $gateway->enabled || 'no' === $show_notice) {
232 232
 				continue;
233 233
 			}
234 234
 
235
-			if ( ! in_array( get_woocommerce_currency(), $gateway->get_supported_currency() ) ) {
235
+			if ( ! in_array(get_woocommerce_currency(), $gateway->get_supported_currency())) {
236 236
 				/* translators: %1$s Payment method, %2$s List of supported currencies */
237
-				$this->add_admin_notice( $method, 'notice notice-error', sprintf( __( '%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe' ), $method, implode( ', ', $gateway->get_supported_currency() ) ), true );
237
+				$this->add_admin_notice($method, 'notice notice-error', sprintf(__('%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe'), $method, implode(', ', $gateway->get_supported_currency())), true);
238 238
 			}
239 239
 		}
240 240
 	}
@@ -246,71 +246,71 @@  discard block
 block discarded – undo
246 246
 	 * @version 4.0.0
247 247
 	 */
248 248
 	public function hide_notices() {
249
-		if ( isset( $_GET['wc-stripe-hide-notice'] ) && isset( $_GET['_wc_stripe_notice_nonce'] ) ) {
250
-			if ( ! wp_verify_nonce( $_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce' ) ) {
251
-				wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe' ) );
249
+		if (isset($_GET['wc-stripe-hide-notice']) && isset($_GET['_wc_stripe_notice_nonce'])) {
250
+			if ( ! wp_verify_nonce($_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce')) {
251
+				wp_die(__('Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe'));
252 252
 			}
253 253
 
254
-			if ( ! current_user_can( 'manage_woocommerce' ) ) {
255
-				wp_die( __( 'Cheatin&#8217; huh?', 'woocommerce-gateway-stripe' ) );
254
+			if ( ! current_user_can('manage_woocommerce')) {
255
+				wp_die(__('Cheatin&#8217; huh?', 'woocommerce-gateway-stripe'));
256 256
 			}
257 257
 
258
-			$notice = wc_clean( $_GET['wc-stripe-hide-notice'] );
258
+			$notice = wc_clean($_GET['wc-stripe-hide-notice']);
259 259
 
260
-			switch ( $notice ) {
260
+			switch ($notice) {
261 261
 				case 'style':
262
-					update_option( 'wc_stripe_show_style_notice', 'no' );
262
+					update_option('wc_stripe_show_style_notice', 'no');
263 263
 					break;
264 264
 				case 'phpver':
265
-					update_option( 'wc_stripe_show_phpver_notice', 'no' );
265
+					update_option('wc_stripe_show_phpver_notice', 'no');
266 266
 					break;
267 267
 				case 'wcver':
268
-					update_option( 'wc_stripe_show_wcver_notice', 'no' );
268
+					update_option('wc_stripe_show_wcver_notice', 'no');
269 269
 					break;
270 270
 				case 'curl':
271
-					update_option( 'wc_stripe_show_curl_notice', 'no' );
271
+					update_option('wc_stripe_show_curl_notice', 'no');
272 272
 					break;
273 273
 				case 'ssl':
274
-					update_option( 'wc_stripe_show_ssl_notice', 'no' );
274
+					update_option('wc_stripe_show_ssl_notice', 'no');
275 275
 					break;
276 276
 				case 'keys':
277
-					update_option( 'wc_stripe_show_keys_notice', 'no' );
277
+					update_option('wc_stripe_show_keys_notice', 'no');
278 278
 					break;
279 279
 				case '3ds':
280
-					update_option( 'wc_stripe_show_3ds_notice', 'no' );
280
+					update_option('wc_stripe_show_3ds_notice', 'no');
281 281
 					break;
282 282
 				case 'Alipay':
283
-					update_option( 'wc_stripe_show_alipay_notice', 'no' );
283
+					update_option('wc_stripe_show_alipay_notice', 'no');
284 284
 					break;
285 285
 				case 'Bancontact':
286
-					update_option( 'wc_stripe_show_bancontact_notice', 'no' );
286
+					update_option('wc_stripe_show_bancontact_notice', 'no');
287 287
 					break;
288 288
 				case 'EPS':
289
-					update_option( 'wc_stripe_show_eps_notice', 'no' );
289
+					update_option('wc_stripe_show_eps_notice', 'no');
290 290
 					break;
291 291
 				case 'Giropay':
292
-					update_option( 'wc_stripe_show_giropay_notice', 'no' );
292
+					update_option('wc_stripe_show_giropay_notice', 'no');
293 293
 					break;
294 294
 				case 'iDeal':
295
-					update_option( 'wc_stripe_show_ideal_notice', 'no' );
295
+					update_option('wc_stripe_show_ideal_notice', 'no');
296 296
 					break;
297 297
 				case 'Multibanco':
298
-					update_option( 'wc_stripe_show_multibanco_notice', 'no' );
298
+					update_option('wc_stripe_show_multibanco_notice', 'no');
299 299
 					break;
300 300
 				case 'P24':
301
-					update_option( 'wc_stripe_show_p24_notice', 'no' );
301
+					update_option('wc_stripe_show_p24_notice', 'no');
302 302
 					break;
303 303
 				case 'SEPA':
304
-					update_option( 'wc_stripe_show_sepa_notice', 'no' );
304
+					update_option('wc_stripe_show_sepa_notice', 'no');
305 305
 					break;
306 306
 				case 'SOFORT':
307
-					update_option( 'wc_stripe_show_sofort_notice', 'no' );
307
+					update_option('wc_stripe_show_sofort_notice', 'no');
308 308
 					break;
309 309
 				case 'sca':
310
-					update_option( 'wc_stripe_show_sca_notice', 'no' );
310
+					update_option('wc_stripe_show_sca_notice', 'no');
311 311
 					break;
312 312
 				case 'changed_keys':
313
-					update_option( 'wc_stripe_show_changed_keys_notice', 'no' );
313
+					update_option('wc_stripe_show_changed_keys_notice', 'no');
314 314
 			}
315 315
 		}
316 316
 	}
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
 	 * @return string Setting link
324 324
 	 */
325 325
 	public function get_setting_link() {
326
-		$use_id_as_section = function_exists( 'WC' ) ? version_compare( WC()->version, '2.6', '>=' ) : false;
326
+		$use_id_as_section = function_exists('WC') ? version_compare(WC()->version, '2.6', '>=') : false;
327 327
 
328
-		$section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' );
328
+		$section_slug = $use_id_as_section ? 'stripe' : strtolower('WC_Gateway_Stripe');
329 329
 
330
-		return admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . $section_slug );
330
+		return admin_url('admin.php?page=wc-settings&tab=checkout&section=' . $section_slug);
331 331
 	}
332 332
 
333 333
 	/**
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
 	 * @since 4.3.0
337 337
 	 */
338 338
 	public function stripe_updated() {
339
-		$previous_version = get_option( 'wc_stripe_version' );
339
+		$previous_version = get_option('wc_stripe_version');
340 340
 
341 341
 		// Only show the style notice if the plugin was installed and older than 4.1.4.
342
-		if ( empty( $previous_version ) || version_compare( $previous_version, '4.1.4', 'ge' ) ) {
343
-			update_option( 'wc_stripe_show_style_notice', 'no' );
342
+		if (empty($previous_version) || version_compare($previous_version, '4.1.4', 'ge')) {
343
+			update_option('wc_stripe_show_style_notice', 'no');
344 344
 		}
345 345
 
346 346
 		// Only show the SCA notice on pre-4.3.0 installs.
347
-		if ( empty( $previous_version ) || version_compare( $previous_version, '4.3.0', 'ge' ) ) {
348
-			update_option( 'wc_stripe_show_sca_notice', 'no' );
347
+		if (empty($previous_version) || version_compare($previous_version, '4.3.0', 'ge')) {
348
+			update_option('wc_stripe_show_sca_notice', 'no');
349 349
 		}
350 350
 	}
351 351
 }
Please login to merge, or discard this patch.
includes/admin/stripe-settings.php 1 patch
Spacing   +56 added lines, -56 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
 
@@ -7,160 +7,160 @@  discard block
 block discarded – undo
7 7
 	'wc_stripe_settings',
8 8
 	array(
9 9
 		'enabled'                       => array(
10
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
11
-			'label'       => __( 'Enable Stripe', 'woocommerce-gateway-stripe' ),
10
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
11
+			'label'       => __('Enable Stripe', 'woocommerce-gateway-stripe'),
12 12
 			'type'        => 'checkbox',
13 13
 			'description' => '',
14 14
 			'default'     => 'no',
15 15
 		),
16 16
 		'title'                         => array(
17
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
17
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
18 18
 			'type'        => 'text',
19
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
20
-			'default'     => __( 'Credit Card (Stripe)', 'woocommerce-gateway-stripe' ),
19
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
20
+			'default'     => __('Credit Card (Stripe)', 'woocommerce-gateway-stripe'),
21 21
 			'desc_tip'    => true,
22 22
 		),
23 23
 		'description'                   => array(
24
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
24
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
25 25
 			'type'        => 'text',
26
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
27
-			'default'     => __( 'Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe' ),
26
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
27
+			'default'     => __('Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe'),
28 28
 			'desc_tip'    => true,
29 29
 		),
30 30
 		'webhook'                       => array(
31
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
31
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
32 32
 			'type'        => 'title',
33 33
 			/* translators: webhook URL */
34 34
 			'description' => $this->display_admin_settings_webhook_description(),
35 35
 		),
36 36
 		'testmode'                      => array(
37
-			'title'       => __( 'Test mode', 'woocommerce-gateway-stripe' ),
38
-			'label'       => __( 'Enable Test Mode', 'woocommerce-gateway-stripe' ),
37
+			'title'       => __('Test mode', 'woocommerce-gateway-stripe'),
38
+			'label'       => __('Enable Test Mode', 'woocommerce-gateway-stripe'),
39 39
 			'type'        => 'checkbox',
40
-			'description' => __( 'Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe' ),
40
+			'description' => __('Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe'),
41 41
 			'default'     => 'yes',
42 42
 			'desc_tip'    => true,
43 43
 		),
44 44
 		'test_publishable_key'          => array(
45
-			'title'       => __( 'Test Publishable Key', 'woocommerce-gateway-stripe' ),
45
+			'title'       => __('Test Publishable Key', 'woocommerce-gateway-stripe'),
46 46
 			'type'        => 'text',
47
-			'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with `pk_` will be saved.', 'woocommerce-gateway-stripe' ),
47
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with `pk_` will be saved.', 'woocommerce-gateway-stripe'),
48 48
 			'default'     => '',
49 49
 			'desc_tip'    => true,
50 50
 		),
51 51
 		'test_secret_key'               => array(
52
-			'title'       => __( 'Test Secret Key', 'woocommerce-gateway-stripe' ),
52
+			'title'       => __('Test Secret Key', 'woocommerce-gateway-stripe'),
53 53
 			'type'        => 'password',
54
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
54
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
55 55
 			'default'     => '',
56 56
 			'desc_tip'    => true,
57 57
 		),
58 58
 		'test_webhook_secret'           => array(
59
-			'title'       => __( 'Test Webhook Secret', 'woocommerce-gateway-stripe' ),
59
+			'title'       => __('Test Webhook Secret', 'woocommerce-gateway-stripe'),
60 60
 			'type'        => 'password',
61
-			'description' => __( 'Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe' ),
61
+			'description' => __('Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe'),
62 62
 			'default'     => '',
63 63
 			'desc_tip'    => true,
64 64
 		),
65 65
 		'publishable_key'               => array(
66
-			'title'       => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ),
66
+			'title'       => __('Live Publishable Key', 'woocommerce-gateway-stripe'),
67 67
 			'type'        => 'text',
68
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
68
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
69 69
 			'default'     => '',
70 70
 			'desc_tip'    => true,
71 71
 		),
72 72
 		'secret_key'                    => array(
73
-			'title'       => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ),
73
+			'title'       => __('Live Secret Key', 'woocommerce-gateway-stripe'),
74 74
 			'type'        => 'password',
75
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
75
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
76 76
 			'default'     => '',
77 77
 			'desc_tip'    => true,
78 78
 		),
79 79
 		'webhook_secret'               => array(
80
-			'title'       => __( 'Webhook Secret', 'woocommerce-gateway-stripe' ),
80
+			'title'       => __('Webhook Secret', 'woocommerce-gateway-stripe'),
81 81
 			'type'        => 'password',
82
-			'description' => __( 'Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe' ),
82
+			'description' => __('Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe'),
83 83
 			'default'     => '',
84 84
 			'desc_tip'    => true,
85 85
 		),
86 86
 		'inline_cc_form'                => array(
87
-			'title'       => __( 'Inline Credit Card Form', 'woocommerce-gateway-stripe' ),
87
+			'title'       => __('Inline Credit Card Form', 'woocommerce-gateway-stripe'),
88 88
 			'type'        => 'checkbox',
89
-			'description' => __( 'Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe' ),
89
+			'description' => __('Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe'),
90 90
 			'default'     => 'no',
91 91
 			'desc_tip'    => true,
92 92
 		),
93 93
 		'statement_descriptor'          => array(
94
-			'title'       => __( 'Statement Descriptor', 'woocommerce-gateway-stripe' ),
94
+			'title'       => __('Statement Descriptor', 'woocommerce-gateway-stripe'),
95 95
 			'type'        => 'text',
96
-			'description' => __( 'Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe' ),
96
+			'description' => __('Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe'),
97 97
 			'default'     => '',
98 98
 			'desc_tip'    => true,
99 99
 		),
100 100
 		'capture'                       => array(
101
-			'title'       => __( 'Capture', 'woocommerce-gateway-stripe' ),
102
-			'label'       => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ),
101
+			'title'       => __('Capture', 'woocommerce-gateway-stripe'),
102
+			'label'       => __('Capture charge immediately', 'woocommerce-gateway-stripe'),
103 103
 			'type'        => 'checkbox',
104
-			'description' => __( 'Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe' ),
104
+			'description' => __('Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe'),
105 105
 			'default'     => 'yes',
106 106
 			'desc_tip'    => true,
107 107
 		),
108 108
 		'payment_request'               => array(
109
-			'title'       => __( 'Payment Request Buttons', 'woocommerce-gateway-stripe' ),
109
+			'title'       => __('Payment Request Buttons', 'woocommerce-gateway-stripe'),
110 110
 			/* translators: 1) br tag 2) opening anchor tag 3) closing anchor tag */
111
-			'label'       => sprintf( __( 'Enable Payment Request Buttons. (Apple Pay/Chrome Payment Request API) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe' ), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>' ),
111
+			'label'       => sprintf(__('Enable Payment Request Buttons. (Apple Pay/Chrome Payment Request API) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe'), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>'),
112 112
 			'type'        => 'checkbox',
113
-			'description' => __( 'If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe' ),
113
+			'description' => __('If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe'),
114 114
 			'default'     => 'yes',
115 115
 			'desc_tip'    => true,
116 116
 		),
117 117
 		'payment_request_button_type'   => array(
118
-			'title'       => __( 'Payment Request Button Type', 'woocommerce-gateway-stripe' ),
119
-			'label'       => __( 'Button Type', 'woocommerce-gateway-stripe' ),
118
+			'title'       => __('Payment Request Button Type', 'woocommerce-gateway-stripe'),
119
+			'label'       => __('Button Type', 'woocommerce-gateway-stripe'),
120 120
 			'type'        => 'select',
121
-			'description' => __( 'Select the button type you would like to show.', 'woocommerce-gateway-stripe' ),
121
+			'description' => __('Select the button type you would like to show.', 'woocommerce-gateway-stripe'),
122 122
 			'default'     => 'buy',
123 123
 			'desc_tip'    => true,
124 124
 			'options'     => array(
125
-				'default' => __( 'Default', 'woocommerce-gateway-stripe' ),
126
-				'buy'     => __( 'Buy', 'woocommerce-gateway-stripe' ),
127
-				'donate'  => __( 'Donate', 'woocommerce-gateway-stripe' ),
125
+				'default' => __('Default', 'woocommerce-gateway-stripe'),
126
+				'buy'     => __('Buy', 'woocommerce-gateway-stripe'),
127
+				'donate'  => __('Donate', 'woocommerce-gateway-stripe'),
128 128
 			),
129 129
 		),
130 130
 		'payment_request_button_theme'  => array(
131
-			'title'       => __( 'Payment Request Button Theme', 'woocommerce-gateway-stripe' ),
132
-			'label'       => __( 'Button Theme', 'woocommerce-gateway-stripe' ),
131
+			'title'       => __('Payment Request Button Theme', 'woocommerce-gateway-stripe'),
132
+			'label'       => __('Button Theme', 'woocommerce-gateway-stripe'),
133 133
 			'type'        => 'select',
134
-			'description' => __( 'Select the button theme you would like to show.', 'woocommerce-gateway-stripe' ),
134
+			'description' => __('Select the button theme you would like to show.', 'woocommerce-gateway-stripe'),
135 135
 			'default'     => 'dark',
136 136
 			'desc_tip'    => true,
137 137
 			'options'     => array(
138
-				'dark'          => __( 'Dark', 'woocommerce-gateway-stripe' ),
139
-				'light'         => __( 'Light', 'woocommerce-gateway-stripe' ),
140
-				'light-outline' => __( 'Light-Outline', 'woocommerce-gateway-stripe' ),
138
+				'dark'          => __('Dark', 'woocommerce-gateway-stripe'),
139
+				'light'         => __('Light', 'woocommerce-gateway-stripe'),
140
+				'light-outline' => __('Light-Outline', 'woocommerce-gateway-stripe'),
141 141
 			),
142 142
 		),
143 143
 		'payment_request_button_height' => array(
144
-			'title'       => __( 'Payment Request Button Height', 'woocommerce-gateway-stripe' ),
145
-			'label'       => __( 'Button Height', 'woocommerce-gateway-stripe' ),
144
+			'title'       => __('Payment Request Button Height', 'woocommerce-gateway-stripe'),
145
+			'label'       => __('Button Height', 'woocommerce-gateway-stripe'),
146 146
 			'type'        => 'text',
147
-			'description' => __( 'Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe' ),
147
+			'description' => __('Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe'),
148 148
 			'default'     => '44',
149 149
 			'desc_tip'    => true,
150 150
 		),
151 151
 		'saved_cards'                   => array(
152
-			'title'       => __( 'Saved Cards', 'woocommerce-gateway-stripe' ),
153
-			'label'       => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ),
152
+			'title'       => __('Saved Cards', 'woocommerce-gateway-stripe'),
153
+			'label'       => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'),
154 154
 			'type'        => 'checkbox',
155
-			'description' => __( 'If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe' ),
155
+			'description' => __('If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe'),
156 156
 			'default'     => 'yes',
157 157
 			'desc_tip'    => true,
158 158
 		),
159 159
 		'logging'                       => array(
160
-			'title'       => __( 'Logging', 'woocommerce-gateway-stripe' ),
161
-			'label'       => __( 'Log debug messages', 'woocommerce-gateway-stripe' ),
160
+			'title'       => __('Logging', 'woocommerce-gateway-stripe'),
161
+			'label'       => __('Log debug messages', 'woocommerce-gateway-stripe'),
162 162
 			'type'        => 'checkbox',
163
-			'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ),
163
+			'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'),
164 164
 			'default'     => 'no',
165 165
 			'desc_tip'    => true,
166 166
 		),
Please login to merge, or discard this patch.
includes/payment-methods/class-wc-stripe-payment-request.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -123,10 +123,10 @@
 block discarded – undo
123 123
 		// in includes/abstracts/abstract-wc-stripe-payment-gateway.php
124 124
 		if ( $this->testmode ) {
125 125
 			return preg_match( '/^pk_test_/', $this->publishable_key )
126
-			       && preg_match( '/^[rs]k_test_/', $this->secret_key );
126
+				   && preg_match( '/^[rs]k_test_/', $this->secret_key );
127 127
 		} else {
128 128
 			return preg_match( '/^pk_live_/', $this->publishable_key )
129
-			       && preg_match( '/^[rs]k_live_/', $this->secret_key );
129
+				   && preg_match( '/^[rs]k_live_/', $this->secret_key );
130 130
 		}
131 131
 	}
132 132
 
Please login to merge, or discard this patch.
Spacing   +306 added lines, -306 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   4.0.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
@@ -64,41 +64,41 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function __construct() {
66 66
 		self::$_this            = $this;
67
-		$this->stripe_settings  = get_option( 'woocommerce_stripe_settings', array() );
68
-		$this->testmode         = ( ! empty( $this->stripe_settings['testmode'] ) && 'yes' === $this->stripe_settings['testmode'] ) ? true : false;
69
-		$this->publishable_key  = ! empty( $this->stripe_settings['publishable_key'] ) ? $this->stripe_settings['publishable_key'] : '';
70
-		$this->secret_key       = ! empty( $this->stripe_settings['secret_key'] ) ? $this->stripe_settings['secret_key'] : '';
71
-		$this->total_label      = ! empty( $this->stripe_settings['statement_descriptor'] ) ? WC_Stripe_Helper::clean_statement_descriptor( $this->stripe_settings['statement_descriptor'] ) : '';
67
+		$this->stripe_settings  = get_option('woocommerce_stripe_settings', array());
68
+		$this->testmode         = ( ! empty($this->stripe_settings['testmode']) && 'yes' === $this->stripe_settings['testmode']) ? true : false;
69
+		$this->publishable_key  = ! empty($this->stripe_settings['publishable_key']) ? $this->stripe_settings['publishable_key'] : '';
70
+		$this->secret_key       = ! empty($this->stripe_settings['secret_key']) ? $this->stripe_settings['secret_key'] : '';
71
+		$this->total_label      = ! empty($this->stripe_settings['statement_descriptor']) ? WC_Stripe_Helper::clean_statement_descriptor($this->stripe_settings['statement_descriptor']) : '';
72 72
 
73
-		if ( $this->testmode ) {
74
-			$this->publishable_key = ! empty( $this->stripe_settings['test_publishable_key'] ) ? $this->stripe_settings['test_publishable_key'] : '';
75
-			$this->secret_key      = ! empty( $this->stripe_settings['test_secret_key'] ) ? $this->stripe_settings['test_secret_key'] : '';
73
+		if ($this->testmode) {
74
+			$this->publishable_key = ! empty($this->stripe_settings['test_publishable_key']) ? $this->stripe_settings['test_publishable_key'] : '';
75
+			$this->secret_key      = ! empty($this->stripe_settings['test_secret_key']) ? $this->stripe_settings['test_secret_key'] : '';
76 76
 		}
77 77
 
78
-		$this->total_label = str_replace( "'", '', $this->total_label ) . apply_filters( 'wc_stripe_payment_request_total_label_suffix', ' (via WooCommerce)' );
78
+		$this->total_label = str_replace("'", '', $this->total_label) . apply_filters('wc_stripe_payment_request_total_label_suffix', ' (via WooCommerce)');
79 79
 
80 80
 		// Checks if Stripe Gateway is enabled.
81
-		if ( empty( $this->stripe_settings ) || ( isset( $this->stripe_settings['enabled'] ) && 'yes' !== $this->stripe_settings['enabled'] ) ) {
81
+		if (empty($this->stripe_settings) || (isset($this->stripe_settings['enabled']) && 'yes' !== $this->stripe_settings['enabled'])) {
82 82
 			return;
83 83
 		}
84 84
 
85 85
 		// Checks if Payment Request is enabled.
86
-		if ( ! isset( $this->stripe_settings['payment_request'] ) || 'yes' !== $this->stripe_settings['payment_request'] ) {
86
+		if ( ! isset($this->stripe_settings['payment_request']) || 'yes' !== $this->stripe_settings['payment_request']) {
87 87
 			return;
88 88
 		}
89 89
 
90 90
 		// Don't load for change payment method page.
91
-		if ( isset( $_GET['change_payment_method'] ) ) {
91
+		if (isset($_GET['change_payment_method'])) {
92 92
 			return;
93 93
 		}
94 94
 
95
-		$wc_default_country = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
95
+		$wc_default_country = substr(get_option('woocommerce_default_country'), 0, 2);
96 96
 
97
-		if ( ! in_array( $wc_default_country, $this->get_stripe_supported_countries() ) ) {
97
+		if ( ! in_array($wc_default_country, $this->get_stripe_supported_countries())) {
98 98
 			return;
99 99
 		}
100 100
 
101
-		add_action( 'template_redirect', array( $this, 'set_session' ) );
101
+		add_action('template_redirect', array($this, 'set_session'));
102 102
 		$this->init();
103 103
 	}
104 104
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @return array The list of countries.
110 110
 	 */
111 111
 	public function get_stripe_supported_countries() {
112
-		return apply_filters( 'wc_stripe_supported_countries', array( 'AT', 'AU', 'BE', 'BR', 'CA', 'CH', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'HK', 'IE', 'IN', 'IT', 'JP', 'LT', 'LU', 'LV', 'MX', 'NL', 'NZ', 'NO', 'PH', 'PL', 'PR', 'PT', 'RO', 'SE', 'SG', 'SK', 'US' ) );
112
+		return apply_filters('wc_stripe_supported_countries', array('AT', 'AU', 'BE', 'BR', 'CA', 'CH', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'HK', 'IE', 'IN', 'IT', 'JP', 'LT', 'LU', 'LV', 'MX', 'NL', 'NZ', 'NO', 'PH', 'PL', 'PR', 'PT', 'RO', 'SE', 'SG', 'SK', 'US'));
113 113
 	}
114 114
 
115 115
 	/**
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 	public function are_keys_set() {
122 122
 		// NOTE: updates to this function should be added to are_keys_set()
123 123
 		// in includes/abstracts/abstract-wc-stripe-payment-gateway.php
124
-		if ( $this->testmode ) {
125
-			return preg_match( '/^pk_test_/', $this->publishable_key )
126
-			       && preg_match( '/^[rs]k_test_/', $this->secret_key );
124
+		if ($this->testmode) {
125
+			return preg_match('/^pk_test_/', $this->publishable_key)
126
+			       && preg_match('/^[rs]k_test_/', $this->secret_key);
127 127
 		} else {
128
-			return preg_match( '/^pk_live_/', $this->publishable_key )
129
-			       && preg_match( '/^[rs]k_live_/', $this->secret_key );
128
+			return preg_match('/^pk_live_/', $this->publishable_key)
129
+			       && preg_match('/^[rs]k_live_/', $this->secret_key);
130 130
 		}
131 131
 	}
132 132
 
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 	 * @since 4.0.0
148 148
 	 */
149 149
 	public function set_session() {
150
-		if ( ! is_product() || ( isset( WC()->session ) && WC()->session->has_session() ) ) {
150
+		if ( ! is_product() || (isset(WC()->session) && WC()->session->has_session())) {
151 151
 			return;
152 152
 		}
153 153
 
154
-		WC()->session->set_customer_session_cookie( true );
154
+		WC()->session->set_customer_session_cookie(true);
155 155
 	}
156 156
 
157 157
 	/**
@@ -161,40 +161,40 @@  discard block
 block discarded – undo
161 161
 	 * @version 4.0.0
162 162
 	 */
163 163
 	public function init() {
164
-		add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ) );
164
+		add_action('wp_enqueue_scripts', array($this, 'scripts'));
165 165
 
166 166
 		/*
167 167
 		 * In order to display the Payment Request button in the correct position,
168 168
 		 * a new hook was added to WooCommerce 3.0. In older versions of WooCommerce,
169 169
 		 * CSS is used to position the button.
170 170
 		 */
171
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
172
-			add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_payment_request_button_html' ), 1 );
173
-			add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_payment_request_button_separator_html' ), 2 );
171
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
172
+			add_action('woocommerce_after_add_to_cart_button', array($this, 'display_payment_request_button_html'), 1);
173
+			add_action('woocommerce_after_add_to_cart_button', array($this, 'display_payment_request_button_separator_html'), 2);
174 174
 		} else {
175
-			add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_html' ), 1 );
176
-			add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_separator_html' ), 2 );
175
+			add_action('woocommerce_after_add_to_cart_quantity', array($this, 'display_payment_request_button_html'), 1);
176
+			add_action('woocommerce_after_add_to_cart_quantity', array($this, 'display_payment_request_button_separator_html'), 2);
177 177
 		}
178 178
 
179
-		add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_payment_request_button_html' ), 1 );
180
-		add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_payment_request_button_separator_html' ), 2 );
179
+		add_action('woocommerce_proceed_to_checkout', array($this, 'display_payment_request_button_html'), 1);
180
+		add_action('woocommerce_proceed_to_checkout', array($this, 'display_payment_request_button_separator_html'), 2);
181 181
 
182
-		add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_payment_request_button_html' ), 1 );
183
-		add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_payment_request_button_separator_html' ), 2 );
182
+		add_action('woocommerce_checkout_before_customer_details', array($this, 'display_payment_request_button_html'), 1);
183
+		add_action('woocommerce_checkout_before_customer_details', array($this, 'display_payment_request_button_separator_html'), 2);
184 184
 
185
-		add_action( 'wc_ajax_wc_stripe_get_cart_details', array( $this, 'ajax_get_cart_details' ) );
186
-		add_action( 'wc_ajax_wc_stripe_get_shipping_options', array( $this, 'ajax_get_shipping_options' ) );
187
-		add_action( 'wc_ajax_wc_stripe_update_shipping_method', array( $this, 'ajax_update_shipping_method' ) );
188
-		add_action( 'wc_ajax_wc_stripe_create_order', array( $this, 'ajax_create_order' ) );
189
-		add_action( 'wc_ajax_wc_stripe_add_to_cart', array( $this, 'ajax_add_to_cart' ) );
190
-		add_action( 'wc_ajax_wc_stripe_get_selected_product_data', array( $this, 'ajax_get_selected_product_data' ) );
191
-		add_action( 'wc_ajax_wc_stripe_clear_cart', array( $this, 'ajax_clear_cart' ) );
192
-		add_action( 'wc_ajax_wc_stripe_log_errors', array( $this, 'ajax_log_errors' ) );
185
+		add_action('wc_ajax_wc_stripe_get_cart_details', array($this, 'ajax_get_cart_details'));
186
+		add_action('wc_ajax_wc_stripe_get_shipping_options', array($this, 'ajax_get_shipping_options'));
187
+		add_action('wc_ajax_wc_stripe_update_shipping_method', array($this, 'ajax_update_shipping_method'));
188
+		add_action('wc_ajax_wc_stripe_create_order', array($this, 'ajax_create_order'));
189
+		add_action('wc_ajax_wc_stripe_add_to_cart', array($this, 'ajax_add_to_cart'));
190
+		add_action('wc_ajax_wc_stripe_get_selected_product_data', array($this, 'ajax_get_selected_product_data'));
191
+		add_action('wc_ajax_wc_stripe_clear_cart', array($this, 'ajax_clear_cart'));
192
+		add_action('wc_ajax_wc_stripe_log_errors', array($this, 'ajax_log_errors'));
193 193
 
194
-		add_filter( 'woocommerce_gateway_title', array( $this, 'filter_gateway_title' ), 10, 2 );
195
-		add_filter( 'woocommerce_validate_postcode', array( $this, 'postal_code_validation' ), 10, 3 );
194
+		add_filter('woocommerce_gateway_title', array($this, 'filter_gateway_title'), 10, 2);
195
+		add_filter('woocommerce_validate_postcode', array($this, 'postal_code_validation'), 10, 3);
196 196
 
197
-		add_action( 'woocommerce_checkout_order_processed', array( $this, 'add_order_meta' ), 10, 2 );
197
+		add_action('woocommerce_checkout_order_processed', array($this, 'add_order_meta'), 10, 2);
198 198
 	}
199 199
 
200 200
 	/**
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * @return string
206 206
 	 */
207 207
 	public function get_button_type() {
208
-		return isset( $this->stripe_settings['payment_request_button_type'] ) ? $this->stripe_settings['payment_request_button_type'] : 'default';
208
+		return isset($this->stripe_settings['payment_request_button_type']) ? $this->stripe_settings['payment_request_button_type'] : 'default';
209 209
 	}
210 210
 
211 211
 	/**
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @return string
217 217
 	 */
218 218
 	public function get_button_theme() {
219
-		return isset( $this->stripe_settings['payment_request_button_theme'] ) ? $this->stripe_settings['payment_request_button_theme'] : 'dark';
219
+		return isset($this->stripe_settings['payment_request_button_theme']) ? $this->stripe_settings['payment_request_button_theme'] : 'dark';
220 220
 	}
221 221
 
222 222
 	/**
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 * @return string
228 228
 	 */
229 229
 	public function get_button_height() {
230
-		return isset( $this->stripe_settings['payment_request_button_height'] ) ? str_replace( 'px', '', $this->stripe_settings['payment_request_button_height'] ) : '64';
230
+		return isset($this->stripe_settings['payment_request_button_height']) ? str_replace('px', '', $this->stripe_settings['payment_request_button_height']) : '64';
231 231
 	}
232 232
 
233 233
 	/**
@@ -237,26 +237,26 @@  discard block
 block discarded – undo
237 237
 	 * @version 4.0.0
238 238
 	 */
239 239
 	public function get_product_data() {
240
-		if ( ! is_product() ) {
240
+		if ( ! is_product()) {
241 241
 			return false;
242 242
 		}
243 243
 
244 244
 		global $post;
245 245
 
246
-		$product = wc_get_product( $post->ID );
246
+		$product = wc_get_product($post->ID);
247 247
 
248
-		if ( 'variable' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ) ) {
249
-			$attributes = wc_clean( wp_unslash( $_GET ) );
248
+		if ('variable' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type())) {
249
+			$attributes = wc_clean(wp_unslash($_GET));
250 250
 
251
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
252
-				$variation_id = $product->get_matching_variation( $attributes );
251
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
252
+				$variation_id = $product->get_matching_variation($attributes);
253 253
 			} else {
254
-				$data_store   = WC_Data_Store::load( 'product' );
255
-				$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
254
+				$data_store   = WC_Data_Store::load('product');
255
+				$variation_id = $data_store->find_matching_product_variation($product, $attributes);
256 256
 			}
257 257
 
258
-			if ( ! empty( $variation_id ) ) {
259
-				$product = wc_get_product( $variation_id );
258
+			if ( ! empty($variation_id)) {
259
+				$product = wc_get_product($variation_id);
260 260
 			}
261 261
 		}
262 262
 
@@ -264,28 +264,28 @@  discard block
 block discarded – undo
264 264
 		$items = array();
265 265
 
266 266
 		$items[] = array(
267
-			'label'  => WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->name : $product->get_name(),
268
-			'amount' => WC_Stripe_Helper::get_stripe_amount( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->price : $product->get_price() ),
267
+			'label'  => WC_Stripe_Helper::is_wc_lt('3.0') ? $product->name : $product->get_name(),
268
+			'amount' => WC_Stripe_Helper::get_stripe_amount(WC_Stripe_Helper::is_wc_lt('3.0') ? $product->price : $product->get_price()),
269 269
 		);
270 270
 
271
-		if ( wc_tax_enabled() ) {
271
+		if (wc_tax_enabled()) {
272 272
 			$items[] = array(
273
-				'label'   => __( 'Tax', 'woocommerce-gateway-stripe' ),
273
+				'label'   => __('Tax', 'woocommerce-gateway-stripe'),
274 274
 				'amount'  => 0,
275 275
 				'pending' => true,
276 276
 			);
277 277
 		}
278 278
 
279
-		if ( wc_shipping_enabled() && $product->needs_shipping() ) {
279
+		if (wc_shipping_enabled() && $product->needs_shipping()) {
280 280
 			$items[] = array(
281
-				'label'   => __( 'Shipping', 'woocommerce-gateway-stripe' ),
281
+				'label'   => __('Shipping', 'woocommerce-gateway-stripe'),
282 282
 				'amount'  => 0,
283 283
 				'pending' => true,
284 284
 			);
285 285
 
286 286
 			$data['shippingOptions'] = array(
287 287
 				'id'     => 'pending',
288
-				'label'  => __( 'Pending', 'woocommerce-gateway-stripe' ),
288
+				'label'  => __('Pending', 'woocommerce-gateway-stripe'),
289 289
 				'detail' => '',
290 290
 				'amount' => 0,
291 291
 			);
@@ -293,41 +293,41 @@  discard block
 block discarded – undo
293 293
 
294 294
 		$data['displayItems'] = $items;
295 295
 		$data['total']        = array(
296
-			'label'   => apply_filters( 'wc_stripe_payment_request_total_label', $this->total_label ),
297
-			'amount'  => WC_Stripe_Helper::get_stripe_amount( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->price : $product->get_price() ),
296
+			'label'   => apply_filters('wc_stripe_payment_request_total_label', $this->total_label),
297
+			'amount'  => WC_Stripe_Helper::get_stripe_amount(WC_Stripe_Helper::is_wc_lt('3.0') ? $product->price : $product->get_price()),
298 298
 			'pending' => true,
299 299
 		);
300 300
 
301
-		$data['requestShipping'] = ( wc_shipping_enabled() && $product->needs_shipping() );
302
-		$data['currency']        = strtolower( get_woocommerce_currency() );
303
-		$data['country_code']    = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
301
+		$data['requestShipping'] = (wc_shipping_enabled() && $product->needs_shipping());
302
+		$data['currency']        = strtolower(get_woocommerce_currency());
303
+		$data['country_code']    = substr(get_option('woocommerce_default_country'), 0, 2);
304 304
 
305
-		return apply_filters( 'wc_stripe_payment_request_product_data', $data, $product );
305
+		return apply_filters('wc_stripe_payment_request_product_data', $data, $product);
306 306
 	}
307 307
 
308 308
 	/**
309 309
 	 * Filters the gateway title to reflect Payment Request type
310 310
 	 *
311 311
 	 */
312
-	public function filter_gateway_title( $title, $id ) {
312
+	public function filter_gateway_title($title, $id) {
313 313
 		global $post;
314 314
 
315
-		if ( ! is_object( $post ) ) {
315
+		if ( ! is_object($post)) {
316 316
 			return $title;
317 317
 		}
318 318
 
319
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
320
-			$method_title = get_post_meta( $post->ID, '_payment_method_title', true );
319
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
320
+			$method_title = get_post_meta($post->ID, '_payment_method_title', true);
321 321
 		} else {
322
-			$order        = wc_get_order( $post->ID );
323
-			$method_title = is_object( $order ) ? $order->get_payment_method_title() : '';
322
+			$order        = wc_get_order($post->ID);
323
+			$method_title = is_object($order) ? $order->get_payment_method_title() : '';
324 324
 		}
325 325
 
326
-		if ( 'stripe' === $id && ! empty( $method_title ) && 'Apple Pay (Stripe)' === $method_title ) {
326
+		if ('stripe' === $id && ! empty($method_title) && 'Apple Pay (Stripe)' === $method_title) {
327 327
 			return $method_title;
328 328
 		}
329 329
 
330
-		if ( 'stripe' === $id && ! empty( $method_title ) && 'Chrome Payment Request (Stripe)' === $method_title ) {
330
+		if ('stripe' === $id && ! empty($method_title) && 'Chrome Payment Request (Stripe)' === $method_title) {
331 331
 			return $method_title;
332 332
 		}
333 333
 
@@ -340,16 +340,16 @@  discard block
 block discarded – undo
340 340
 	 * @since 3.1.4
341 341
 	 * @version 4.0.0
342 342
 	 */
343
-	public function postal_code_validation( $valid, $postcode, $country ) {
343
+	public function postal_code_validation($valid, $postcode, $country) {
344 344
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
345 345
 
346
-		if ( ! isset( $gateways['stripe'] ) ) {
346
+		if ( ! isset($gateways['stripe'])) {
347 347
 			return $valid;
348 348
 		}
349 349
 
350
-		$payment_request_type = isset( $_POST['payment_request_type'] ) ? wc_clean( $_POST['payment_request_type'] ) : '';
350
+		$payment_request_type = isset($_POST['payment_request_type']) ? wc_clean($_POST['payment_request_type']) : '';
351 351
 
352
-		if ( 'apple_pay' !== $payment_request_type ) {
352
+		if ('apple_pay' !== $payment_request_type) {
353 353
 			return $valid;
354 354
 		}
355 355
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 		 * the order and not let it go through. The remedy for now is just to remove this validation.
360 360
 		 * Note that this only works with shipping providers that don't validate full postal codes.
361 361
 		 */
362
-		if ( 'GB' === $country || 'CA' === $country ) {
362
+		if ('GB' === $country || 'CA' === $country) {
363 363
 			return true;
364 364
 		}
365 365
 
@@ -374,29 +374,29 @@  discard block
 block discarded – undo
374 374
 	 * @param int $order_id
375 375
 	 * @param array $posted_data The posted data from checkout form.
376 376
 	 */
377
-	public function add_order_meta( $order_id, $posted_data ) {
378
-		if ( empty( $_POST['payment_request_type'] ) ) {
377
+	public function add_order_meta($order_id, $posted_data) {
378
+		if (empty($_POST['payment_request_type'])) {
379 379
 			return;
380 380
 		}
381 381
 
382
-		$order = wc_get_order( $order_id );
382
+		$order = wc_get_order($order_id);
383 383
 
384
-		$payment_request_type = wc_clean( $_POST['payment_request_type'] );
384
+		$payment_request_type = wc_clean($_POST['payment_request_type']);
385 385
 
386
-		if ( 'apple_pay' === $payment_request_type ) {
387
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
388
-				update_post_meta( $order_id, '_payment_method_title', 'Apple Pay (Stripe)' );
386
+		if ('apple_pay' === $payment_request_type) {
387
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
388
+				update_post_meta($order_id, '_payment_method_title', 'Apple Pay (Stripe)');
389 389
 			} else {
390
-				$order->set_payment_method_title( 'Apple Pay (Stripe)' );
390
+				$order->set_payment_method_title('Apple Pay (Stripe)');
391 391
 				$order->save();
392 392
 			}
393 393
 		}
394 394
 
395
-		if ( 'payment_request_api' === $payment_request_type ) {
396
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
397
-				update_post_meta( $order_id, '_payment_method_title', 'Chrome Payment Request (Stripe)' );
395
+		if ('payment_request_api' === $payment_request_type) {
396
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
397
+				update_post_meta($order_id, '_payment_method_title', 'Chrome Payment Request (Stripe)');
398 398
 			} else {
399
-				$order->set_payment_method_title( 'Chrome Payment Request (Stripe)' );
399
+				$order->set_payment_method_title('Chrome Payment Request (Stripe)');
400 400
 				$order->save();
401 401
 			}
402 402
 		}
@@ -435,20 +435,20 @@  discard block
 block discarded – undo
435 435
 	 * @return bool
436 436
 	 */
437 437
 	public function allowed_items_in_cart() {
438
-		foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
439
-			$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
438
+		foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
439
+			$_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);
440 440
 
441
-			if ( ! in_array( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $_product->product_type : $_product->get_type() ), $this->supported_product_types() ) ) {
441
+			if ( ! in_array((WC_Stripe_Helper::is_wc_lt('3.0') ? $_product->product_type : $_product->get_type()), $this->supported_product_types())) {
442 442
 				return false;
443 443
 			}
444 444
 
445 445
 			// Trial subscriptions with shipping are not supported
446
-			if ( class_exists( 'WC_Subscriptions_Order' ) && WC_Subscriptions_Cart::cart_contains_subscription() && $_product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $_product ) > 0 ) {
446
+			if (class_exists('WC_Subscriptions_Order') && WC_Subscriptions_Cart::cart_contains_subscription() && $_product->needs_shipping() && WC_Subscriptions_Product::get_trial_length($_product) > 0) {
447 447
 				return false;
448 448
 			}
449 449
 
450 450
 			// Pre Orders compatbility where we don't support charge upon release.
451
-			if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Cart::cart_contains_pre_order() && WC_Pre_Orders_Product::product_is_charged_upon_release( WC_Pre_Orders_Cart::get_pre_order_product() ) ) {
451
+			if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Cart::cart_contains_pre_order() && WC_Pre_Orders_Product::product_is_charged_upon_release(WC_Pre_Orders_Cart::get_pre_order_product())) {
452 452
 				return false;
453 453
 			}
454 454
 		}
@@ -464,73 +464,73 @@  discard block
 block discarded – undo
464 464
 	 */
465 465
 	public function scripts() {
466 466
 		// If keys are not set bail.
467
-		if ( ! $this->are_keys_set() ) {
468
-			WC_Stripe_Logger::log( 'Keys are not set correctly.' );
467
+		if ( ! $this->are_keys_set()) {
468
+			WC_Stripe_Logger::log('Keys are not set correctly.');
469 469
 			return;
470 470
 		}
471 471
 
472 472
 		// If no SSL bail.
473
-		if ( ! $this->testmode && ! is_ssl() ) {
474
-			WC_Stripe_Logger::log( 'Stripe Payment Request live mode requires SSL.' );
473
+		if ( ! $this->testmode && ! is_ssl()) {
474
+			WC_Stripe_Logger::log('Stripe Payment Request live mode requires SSL.');
475 475
 			return;
476 476
 		}
477 477
 
478
-		if ( ! is_product() && ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) ) {
478
+		if ( ! is_product() && ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order'])) {
479 479
 			return;
480 480
 		}
481 481
 
482
-		if ( is_product() && ! $this->should_show_payment_button_on_product_page() ) {
482
+		if (is_product() && ! $this->should_show_payment_button_on_product_page()) {
483 483
 			return;
484 484
 		}
485 485
 
486
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
486
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
487 487
 
488 488
 		$stripe_params = array(
489
-			'ajax_url'        => WC_AJAX::get_endpoint( '%%endpoint%%' ),
489
+			'ajax_url'        => WC_AJAX::get_endpoint('%%endpoint%%'),
490 490
 			'stripe'          => array(
491 491
 				'key'                => $this->publishable_key,
492
-				'allow_prepaid_card' => apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no',
492
+				'allow_prepaid_card' => apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no',
493 493
 			),
494 494
 			'nonce'           => array(
495
-				'payment'                   => wp_create_nonce( 'wc-stripe-payment-request' ),
496
-				'shipping'                  => wp_create_nonce( 'wc-stripe-payment-request-shipping' ),
497
-				'update_shipping'           => wp_create_nonce( 'wc-stripe-update-shipping-method' ),
498
-				'checkout'                  => wp_create_nonce( 'woocommerce-process_checkout' ),
499
-				'add_to_cart'               => wp_create_nonce( 'wc-stripe-add-to-cart' ),
500
-				'get_selected_product_data' => wp_create_nonce( 'wc-stripe-get-selected-product-data' ),
501
-				'log_errors'                => wp_create_nonce( 'wc-stripe-log-errors' ),
502
-				'clear_cart'                => wp_create_nonce( 'wc-stripe-clear-cart' ),
495
+				'payment'                   => wp_create_nonce('wc-stripe-payment-request'),
496
+				'shipping'                  => wp_create_nonce('wc-stripe-payment-request-shipping'),
497
+				'update_shipping'           => wp_create_nonce('wc-stripe-update-shipping-method'),
498
+				'checkout'                  => wp_create_nonce('woocommerce-process_checkout'),
499
+				'add_to_cart'               => wp_create_nonce('wc-stripe-add-to-cart'),
500
+				'get_selected_product_data' => wp_create_nonce('wc-stripe-get-selected-product-data'),
501
+				'log_errors'                => wp_create_nonce('wc-stripe-log-errors'),
502
+				'clear_cart'                => wp_create_nonce('wc-stripe-clear-cart'),
503 503
 			),
504 504
 			'i18n'            => array(
505
-				'no_prepaid_card'  => __( 'Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe' ),
505
+				'no_prepaid_card'  => __('Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe'),
506 506
 				/* translators: Do not translate the [option] placeholder */
507
-				'unknown_shipping' => __( 'Unknown shipping option "[option]".', 'woocommerce-gateway-stripe' ),
507
+				'unknown_shipping' => __('Unknown shipping option "[option]".', 'woocommerce-gateway-stripe'),
508 508
 			),
509 509
 			'checkout'        => array(
510 510
 				'url'            => wc_get_checkout_url(),
511
-				'currency_code'  => strtolower( get_woocommerce_currency() ),
512
-				'country_code'   => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
511
+				'currency_code'  => strtolower(get_woocommerce_currency()),
512
+				'country_code'   => substr(get_option('woocommerce_default_country'), 0, 2),
513 513
 				'needs_shipping' => WC()->cart->needs_shipping() ? 'yes' : 'no',
514 514
 			),
515 515
 			'button'          => array(
516 516
 				'type'   => $this->get_button_type(),
517 517
 				'theme'  => $this->get_button_theme(),
518 518
 				'height' => $this->get_button_height(),
519
-				'locale' => apply_filters( 'wc_stripe_payment_request_button_locale', substr( get_locale(), 0, 2 ) ), // Default format is en_US.
519
+				'locale' => apply_filters('wc_stripe_payment_request_button_locale', substr(get_locale(), 0, 2)), // Default format is en_US.
520 520
 			),
521 521
 			'is_product_page' => is_product(),
522 522
 			'product'         => $this->get_product_data(),
523 523
 		);
524 524
 
525
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
526
-		wp_register_script( 'wc_stripe_payment_request', plugins_url( 'assets/js/stripe-payment-request' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery', 'stripe' ), WC_STRIPE_VERSION, true );
525
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
526
+		wp_register_script('wc_stripe_payment_request', plugins_url('assets/js/stripe-payment-request' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery', 'stripe'), WC_STRIPE_VERSION, true);
527 527
 
528
-		wp_localize_script( 'wc_stripe_payment_request', 'wc_stripe_payment_request_params', apply_filters( 'wc_stripe_payment_request_params', $stripe_params ) );
528
+		wp_localize_script('wc_stripe_payment_request', 'wc_stripe_payment_request_params', apply_filters('wc_stripe_payment_request_params', $stripe_params));
529 529
 
530
-		wp_enqueue_script( 'wc_stripe_payment_request' );
530
+		wp_enqueue_script('wc_stripe_payment_request');
531 531
 
532 532
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
533
-		if ( isset( $gateways['stripe'] ) ) {
533
+		if (isset($gateways['stripe'])) {
534 534
 			$gateways['stripe']->payment_scripts();
535 535
 		}
536 536
 	}
@@ -546,23 +546,23 @@  discard block
 block discarded – undo
546 546
 
547 547
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
548 548
 
549
-		if ( ! isset( $gateways['stripe'] ) ) {
549
+		if ( ! isset($gateways['stripe'])) {
550 550
 			return;
551 551
 		}
552 552
 
553
-		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) {
553
+		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset($_GET['pay_for_order'])) {
554 554
 			return;
555 555
 		}
556 556
 
557
-		if ( is_checkout() && ! apply_filters( 'wc_stripe_show_payment_request_on_checkout', false, $post ) ) {
557
+		if (is_checkout() && ! apply_filters('wc_stripe_show_payment_request_on_checkout', false, $post)) {
558 558
 			return;
559 559
 		}
560 560
 
561
-		if ( is_product() && ! $this->should_show_payment_button_on_product_page() ) {
561
+		if (is_product() && ! $this->should_show_payment_button_on_product_page()) {
562 562
 			return;
563 563
 		} else {
564
-			if ( ! $this->allowed_items_in_cart() ) {
565
-				WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' );
564
+			if ( ! $this->allowed_items_in_cart()) {
565
+				WC_Stripe_Logger::log('Items in the cart has unsupported product type ( Payment Request button disabled )');
566 566
 				return;
567 567
 			}
568 568
 		}
@@ -586,28 +586,28 @@  discard block
 block discarded – undo
586 586
 
587 587
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
588 588
 
589
-		if ( ! isset( $gateways['stripe'] ) ) {
589
+		if ( ! isset($gateways['stripe'])) {
590 590
 			return;
591 591
 		}
592 592
 
593
-		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) {
593
+		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset($_GET['pay_for_order'])) {
594 594
 			return;
595 595
 		}
596 596
 
597
-		if ( is_checkout() && ! apply_filters( 'wc_stripe_show_payment_request_on_checkout', false, $post ) ) {
597
+		if (is_checkout() && ! apply_filters('wc_stripe_show_payment_request_on_checkout', false, $post)) {
598 598
 			return;
599 599
 		}
600 600
 
601
-		if ( is_product() && ! $this->should_show_payment_button_on_product_page() ) {
601
+		if (is_product() && ! $this->should_show_payment_button_on_product_page()) {
602 602
 			return;
603 603
 		} else {
604
-			if ( ! $this->allowed_items_in_cart() ) {
605
-				WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' );
604
+			if ( ! $this->allowed_items_in_cart()) {
605
+				WC_Stripe_Logger::log('Items in the cart has unsupported product type ( Payment Request button disabled )');
606 606
 				return;
607 607
 			}
608 608
 		}
609 609
 		?>
610
-		<p id="wc-stripe-payment-request-button-separator" style="margin-top:1.5em;text-align:center;display:none;">&mdash; <?php esc_html_e( 'OR', 'woocommerce-gateway-stripe' ); ?> &mdash;</p>
610
+		<p id="wc-stripe-payment-request-button-separator" style="margin-top:1.5em;text-align:center;display:none;">&mdash; <?php esc_html_e('OR', 'woocommerce-gateway-stripe'); ?> &mdash;</p>
611 611
 		<?php
612 612
 	}
613 613
 
@@ -623,32 +623,32 @@  discard block
 block discarded – undo
623 623
 	private function should_show_payment_button_on_product_page() {
624 624
 		global $post;
625 625
 
626
-		$product = wc_get_product( $post->ID );
626
+		$product = wc_get_product($post->ID);
627 627
 
628
-		if ( apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false, $post ) ) {
628
+		if (apply_filters('wc_stripe_hide_payment_request_on_product_page', false, $post)) {
629 629
 			return false;
630 630
 		}
631 631
 
632
-		if ( ! is_object( $product ) || ! in_array( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) {
632
+		if ( ! is_object($product) || ! in_array((WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type()), $this->supported_product_types())) {
633 633
 			return false;
634 634
 		}
635 635
 
636 636
 		// Trial subscriptions with shipping are not supported
637
-		if ( class_exists( 'WC_Subscriptions_Order' ) && $product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $product ) > 0 ) {
637
+		if (class_exists('WC_Subscriptions_Order') && $product->needs_shipping() && WC_Subscriptions_Product::get_trial_length($product) > 0) {
638 638
 			return false;
639 639
 		}
640 640
 
641 641
 		// Pre Orders charge upon release not supported.
642
-		if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Product::product_is_charged_upon_release( $product ) ) {
643
-			WC_Stripe_Logger::log( 'Pre Order charge upon release is not supported. ( Payment Request button disabled )' );
642
+		if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Product::product_is_charged_upon_release($product)) {
643
+			WC_Stripe_Logger::log('Pre Order charge upon release is not supported. ( Payment Request button disabled )');
644 644
 			return false;
645 645
 		}
646 646
 
647 647
 		// File upload addon not supported
648
-		if ( class_exists( 'WC_Product_Addons_Helper' ) ) {
649
-			$product_addons = WC_Product_Addons_Helper::get_product_addons( $product->get_id() );
650
-			foreach ( $product_addons as $addon ) {
651
-				if ( 'file_upload' === $addon['type'] ) {
648
+		if (class_exists('WC_Product_Addons_Helper')) {
649
+			$product_addons = WC_Product_Addons_Helper::get_product_addons($product->get_id());
650
+			foreach ($product_addons as $addon) {
651
+				if ('file_upload' === $addon['type']) {
652 652
 					return false;
653 653
 				}
654 654
 			}
@@ -664,11 +664,11 @@  discard block
 block discarded – undo
664 664
 	 * @version 4.0.0
665 665
 	 */
666 666
 	public function ajax_log_errors() {
667
-		check_ajax_referer( 'wc-stripe-log-errors', 'security' );
667
+		check_ajax_referer('wc-stripe-log-errors', 'security');
668 668
 
669
-		$errors = wc_clean( stripslashes( $_POST['errors'] ) );
669
+		$errors = wc_clean(stripslashes($_POST['errors']));
670 670
 
671
-		WC_Stripe_Logger::log( $errors );
671
+		WC_Stripe_Logger::log($errors);
672 672
 
673 673
 		exit;
674 674
 	}
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 	 * @version 4.0.0
681 681
 	 */
682 682
 	public function ajax_clear_cart() {
683
-		check_ajax_referer( 'wc-stripe-clear-cart', 'security' );
683
+		check_ajax_referer('wc-stripe-clear-cart', 'security');
684 684
 
685 685
 		WC()->cart->empty_cart();
686 686
 		exit;
@@ -690,10 +690,10 @@  discard block
 block discarded – undo
690 690
 	 * Get cart details.
691 691
 	 */
692 692
 	public function ajax_get_cart_details() {
693
-		check_ajax_referer( 'wc-stripe-payment-request', 'security' );
693
+		check_ajax_referer('wc-stripe-payment-request', 'security');
694 694
 
695
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
696
-			define( 'WOOCOMMERCE_CART', true );
695
+		if ( ! defined('WOOCOMMERCE_CART')) {
696
+			define('WOOCOMMERCE_CART', true);
697 697
 		}
698 698
 
699 699
 		WC()->cart->calculate_totals();
@@ -704,14 +704,14 @@  discard block
 block discarded – undo
704 704
 		$data = array(
705 705
 			'shipping_required' => WC()->cart->needs_shipping(),
706 706
 			'order_data'        => array(
707
-				'currency'     => strtolower( $currency ),
708
-				'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
707
+				'currency'     => strtolower($currency),
708
+				'country_code' => substr(get_option('woocommerce_default_country'), 0, 2),
709 709
 			),
710 710
 		);
711 711
 
712 712
 		$data['order_data'] += $this->build_display_items();
713 713
 
714
-		wp_send_json( $data );
714
+		wp_send_json($data);
715 715
 	}
716 716
 
717 717
 	/**
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 	 * @see WC_Shipping::get_packages().
723 723
 	 */
724 724
 	public function ajax_get_shipping_options() {
725
-		check_ajax_referer( 'wc-stripe-payment-request-shipping', 'security' );
725
+		check_ajax_referer('wc-stripe-payment-request-shipping', 'security');
726 726
 
727 727
 		try {
728 728
 			// Set the shipping package.
@@ -738,34 +738,34 @@  discard block
 block discarded – undo
738 738
 				)
739 739
 			);
740 740
 
741
-			$this->calculate_shipping( apply_filters( 'wc_stripe_payment_request_shipping_posted_values', $posted ) );
741
+			$this->calculate_shipping(apply_filters('wc_stripe_payment_request_shipping_posted_values', $posted));
742 742
 
743 743
 			// Set the shipping options.
744 744
 			$data     = array();
745 745
 			$packages = WC()->shipping->get_packages();
746 746
 
747
-			if ( ! empty( $packages ) && WC()->customer->has_calculated_shipping() ) {
748
-				foreach ( $packages as $package_key => $package ) {
749
-					if ( empty( $package['rates'] ) ) {
750
-						throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) );
747
+			if ( ! empty($packages) && WC()->customer->has_calculated_shipping()) {
748
+				foreach ($packages as $package_key => $package) {
749
+					if (empty($package['rates'])) {
750
+						throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe'));
751 751
 					}
752 752
 
753
-					foreach ( $package['rates'] as $key => $rate ) {
753
+					foreach ($package['rates'] as $key => $rate) {
754 754
 						$data['shipping_options'][] = array(
755 755
 							'id'     => $rate->id,
756 756
 							'label'  => $rate->label,
757 757
 							'detail' => '',
758
-							'amount' => WC_Stripe_Helper::get_stripe_amount( $rate->cost ),
758
+							'amount' => WC_Stripe_Helper::get_stripe_amount($rate->cost),
759 759
 						);
760 760
 					}
761 761
 				}
762 762
 			} else {
763
-				throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) );
763
+				throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe'));
764 764
 			}
765 765
 
766
-			if ( isset( $data[0] ) ) {
766
+			if (isset($data[0])) {
767 767
 				// Auto select the first shipping method.
768
-				WC()->session->set( 'chosen_shipping_methods', array( $data[0]['id'] ) );
768
+				WC()->session->set('chosen_shipping_methods', array($data[0]['id']));
769 769
 			}
770 770
 
771 771
 			WC()->cart->calculate_totals();
@@ -773,12 +773,12 @@  discard block
 block discarded – undo
773 773
 			$data          += $this->build_display_items();
774 774
 			$data['result'] = 'success';
775 775
 
776
-			wp_send_json( $data );
777
-		} catch ( Exception $e ) {
776
+			wp_send_json($data);
777
+		} catch (Exception $e) {
778 778
 			$data          += $this->build_display_items();
779 779
 			$data['result'] = 'invalid_shipping_address';
780 780
 
781
-			wp_send_json( $data );
781
+			wp_send_json($data);
782 782
 		}
783 783
 	}
784 784
 
@@ -786,22 +786,22 @@  discard block
 block discarded – undo
786 786
 	 * Update shipping method.
787 787
 	 */
788 788
 	public function ajax_update_shipping_method() {
789
-		check_ajax_referer( 'wc-stripe-update-shipping-method', 'security' );
789
+		check_ajax_referer('wc-stripe-update-shipping-method', 'security');
790 790
 
791
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
792
-			define( 'WOOCOMMERCE_CART', true );
791
+		if ( ! defined('WOOCOMMERCE_CART')) {
792
+			define('WOOCOMMERCE_CART', true);
793 793
 		}
794 794
 
795
-		$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
796
-		$shipping_method         = filter_input( INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
795
+		$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
796
+		$shipping_method         = filter_input(INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
797 797
 
798
-		if ( is_array( $shipping_method ) ) {
799
-			foreach ( $shipping_method as $i => $value ) {
800
-				$chosen_shipping_methods[ $i ] = wc_clean( $value );
798
+		if (is_array($shipping_method)) {
799
+			foreach ($shipping_method as $i => $value) {
800
+				$chosen_shipping_methods[$i] = wc_clean($value);
801 801
 			}
802 802
 		}
803 803
 
804
-		WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods );
804
+		WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
805 805
 
806 806
 		WC()->cart->calculate_totals();
807 807
 
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 		$data          += $this->build_display_items();
810 810
 		$data['result'] = 'success';
811 811
 
812
-		wp_send_json( $data );
812
+		wp_send_json($data);
813 813
 	}
814 814
 
815 815
 	/**
@@ -820,45 +820,45 @@  discard block
 block discarded – undo
820 820
 	 * @return array $data
821 821
 	 */
822 822
 	public function ajax_get_selected_product_data() {
823
-		check_ajax_referer( 'wc-stripe-get-selected-product-data', 'security' );
823
+		check_ajax_referer('wc-stripe-get-selected-product-data', 'security');
824 824
 
825 825
 		try {
826
-			$product_id   = absint( $_POST['product_id'] );
827
-			$qty          = ! isset( $_POST['qty'] ) ? 1 : apply_filters( 'woocommerce_add_to_cart_quantity', absint( $_POST['qty'] ), $product_id );
828
-			$addon_value  = isset( $_POST['addon_value'] ) ? max( floatval( $_POST['addon_value'] ), 0 ) : 0;
829
-			$product      = wc_get_product( $product_id );
826
+			$product_id   = absint($_POST['product_id']);
827
+			$qty          = ! isset($_POST['qty']) ? 1 : apply_filters('woocommerce_add_to_cart_quantity', absint($_POST['qty']), $product_id);
828
+			$addon_value  = isset($_POST['addon_value']) ? max(floatval($_POST['addon_value']), 0) : 0;
829
+			$product      = wc_get_product($product_id);
830 830
 			$variation_id = null;
831 831
 
832
-			if ( ! is_a( $product, 'WC_Product' ) ) {
833
-				throw new Exception( sprintf( __( 'Product with the ID (%d) cannot be found.', 'woocommerce-gateway-stripe' ), $product_id ) );
832
+			if ( ! is_a($product, 'WC_Product')) {
833
+				throw new Exception(sprintf(__('Product with the ID (%d) cannot be found.', 'woocommerce-gateway-stripe'), $product_id));
834 834
 			}
835 835
 
836
-			if ( 'variable' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ) && isset( $_POST['attributes'] ) ) {
837
-				$attributes = wc_clean( wp_unslash( $_POST['attributes'] ) );
836
+			if ('variable' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type()) && isset($_POST['attributes'])) {
837
+				$attributes = wc_clean(wp_unslash($_POST['attributes']));
838 838
 
839
-				if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
840
-					$variation_id = $product->get_matching_variation( $attributes );
839
+				if (WC_Stripe_Helper::is_wc_lt('3.0')) {
840
+					$variation_id = $product->get_matching_variation($attributes);
841 841
 				} else {
842
-					$data_store   = WC_Data_Store::load( 'product' );
843
-					$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
842
+					$data_store   = WC_Data_Store::load('product');
843
+					$variation_id = $data_store->find_matching_product_variation($product, $attributes);
844 844
 				}
845 845
 
846
-				if ( ! empty( $variation_id ) ) {
847
-					$product = wc_get_product( $variation_id );
846
+				if ( ! empty($variation_id)) {
847
+					$product = wc_get_product($variation_id);
848 848
 				}
849 849
 			}
850 850
 
851 851
 			// Force quantity to 1 if sold individually and check for existing item in cart.
852
-			if ( $product->is_sold_individually() ) {
853
-				$qty = apply_filters( 'wc_stripe_payment_request_add_to_cart_sold_individually_quantity', 1, $qty, $product_id, $variation_id );
852
+			if ($product->is_sold_individually()) {
853
+				$qty = apply_filters('wc_stripe_payment_request_add_to_cart_sold_individually_quantity', 1, $qty, $product_id, $variation_id);
854 854
 			}
855 855
 
856
-			if ( ! $product->has_enough_stock( $qty ) ) {
856
+			if ( ! $product->has_enough_stock($qty)) {
857 857
 				/* translators: 1: product name 2: quantity in stock */
858
-				throw new Exception( sprintf( __( 'You cannot add that amount of "%1$s"; to the cart because there is not enough stock (%2$s remaining).', 'woocommerce-gateway-stripe' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity(), $product ) ) );
858
+				throw new Exception(sprintf(__('You cannot add that amount of "%1$s"; to the cart because there is not enough stock (%2$s remaining).', 'woocommerce-gateway-stripe'), $product->get_name(), wc_format_stock_quantity_for_display($product->get_stock_quantity(), $product)));
859 859
 			}
860 860
 
861
-			$total = $qty * ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->price : $product->get_price() ) + $addon_value;
861
+			$total = $qty * (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->price : $product->get_price()) + $addon_value;
862 862
 
863 863
 			$quantity_label = 1 < $qty ? ' (x' . $qty . ')' : '';
864 864
 
@@ -866,28 +866,28 @@  discard block
 block discarded – undo
866 866
 			$items = array();
867 867
 
868 868
 			$items[] = array(
869
-				'label'  => ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->name : $product->get_name() ) . $quantity_label,
870
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $total ),
869
+				'label'  => (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->name : $product->get_name()) . $quantity_label,
870
+				'amount' => WC_Stripe_Helper::get_stripe_amount($total),
871 871
 			);
872 872
 
873
-			if ( wc_tax_enabled() ) {
873
+			if (wc_tax_enabled()) {
874 874
 				$items[] = array(
875
-					'label'   => __( 'Tax', 'woocommerce-gateway-stripe' ),
875
+					'label'   => __('Tax', 'woocommerce-gateway-stripe'),
876 876
 					'amount'  => 0,
877 877
 					'pending' => true,
878 878
 				);
879 879
 			}
880 880
 
881
-			if ( wc_shipping_enabled() && $product->needs_shipping() ) {
881
+			if (wc_shipping_enabled() && $product->needs_shipping()) {
882 882
 				$items[] = array(
883
-					'label'   => __( 'Shipping', 'woocommerce-gateway-stripe' ),
883
+					'label'   => __('Shipping', 'woocommerce-gateway-stripe'),
884 884
 					'amount'  => 0,
885 885
 					'pending' => true,
886 886
 				);
887 887
 
888 888
 				$data['shippingOptions'] = array(
889 889
 					'id'     => 'pending',
890
-					'label'  => __( 'Pending', 'woocommerce-gateway-stripe' ),
890
+					'label'  => __('Pending', 'woocommerce-gateway-stripe'),
891 891
 					'detail' => '',
892 892
 					'amount' => 0,
893 893
 				);
@@ -896,17 +896,17 @@  discard block
 block discarded – undo
896 896
 			$data['displayItems'] = $items;
897 897
 			$data['total']        = array(
898 898
 				'label'   => $this->total_label,
899
-				'amount'  => WC_Stripe_Helper::get_stripe_amount( $total ),
899
+				'amount'  => WC_Stripe_Helper::get_stripe_amount($total),
900 900
 				'pending' => true,
901 901
 			);
902 902
 
903
-			$data['requestShipping'] = ( wc_shipping_enabled() && $product->needs_shipping() );
904
-			$data['currency']        = strtolower( get_woocommerce_currency() );
905
-			$data['country_code']    = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
903
+			$data['requestShipping'] = (wc_shipping_enabled() && $product->needs_shipping());
904
+			$data['currency']        = strtolower(get_woocommerce_currency());
905
+			$data['country_code']    = substr(get_option('woocommerce_default_country'), 0, 2);
906 906
 
907
-			wp_send_json( $data );
908
-		} catch ( Exception $e ) {
909
-			wp_send_json( array( 'error' => wp_strip_all_tags( $e->getMessage() ) ) );
907
+			wp_send_json($data);
908
+		} catch (Exception $e) {
909
+			wp_send_json(array('error' => wp_strip_all_tags($e->getMessage())));
910 910
 		}
911 911
 	}
912 912
 
@@ -918,37 +918,37 @@  discard block
 block discarded – undo
918 918
 	 * @return array $data
919 919
 	 */
920 920
 	public function ajax_add_to_cart() {
921
-		check_ajax_referer( 'wc-stripe-add-to-cart', 'security' );
921
+		check_ajax_referer('wc-stripe-add-to-cart', 'security');
922 922
 
923
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
924
-			define( 'WOOCOMMERCE_CART', true );
923
+		if ( ! defined('WOOCOMMERCE_CART')) {
924
+			define('WOOCOMMERCE_CART', true);
925 925
 		}
926 926
 
927 927
 		WC()->shipping->reset_shipping();
928 928
 
929
-		$product_id   = absint( $_POST['product_id'] );
930
-		$qty          = ! isset( $_POST['qty'] ) ? 1 : absint( $_POST['qty'] );
931
-		$product      = wc_get_product( $product_id );
932
-		$product_type = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type();
929
+		$product_id   = absint($_POST['product_id']);
930
+		$qty          = ! isset($_POST['qty']) ? 1 : absint($_POST['qty']);
931
+		$product      = wc_get_product($product_id);
932
+		$product_type = WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type();
933 933
 
934 934
 		// First empty the cart to prevent wrong calculation.
935 935
 		WC()->cart->empty_cart();
936 936
 
937
-		if ( ( 'variable' === $product_type || 'variable-subscription' === $product_type ) && isset( $_POST['attributes'] ) ) {
938
-			$attributes = wc_clean( wp_unslash( $_POST['attributes'] ) );
937
+		if (('variable' === $product_type || 'variable-subscription' === $product_type) && isset($_POST['attributes'])) {
938
+			$attributes = wc_clean(wp_unslash($_POST['attributes']));
939 939
 
940
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
941
-				$variation_id = $product->get_matching_variation( $attributes );
940
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
941
+				$variation_id = $product->get_matching_variation($attributes);
942 942
 			} else {
943
-				$data_store   = WC_Data_Store::load( 'product' );
944
-				$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
943
+				$data_store   = WC_Data_Store::load('product');
944
+				$variation_id = $data_store->find_matching_product_variation($product, $attributes);
945 945
 			}
946 946
 
947
-			WC()->cart->add_to_cart( $product->get_id(), $qty, $variation_id, $attributes );
947
+			WC()->cart->add_to_cart($product->get_id(), $qty, $variation_id, $attributes);
948 948
 		}
949 949
 
950
-		if ( 'simple' === $product_type || 'subscription' === $product_type ) {
951
-			WC()->cart->add_to_cart( $product->get_id(), $qty );
950
+		if ('simple' === $product_type || 'subscription' === $product_type) {
951
+			WC()->cart->add_to_cart($product->get_id(), $qty);
952 952
 		}
953 953
 
954 954
 		WC()->cart->calculate_totals();
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
 		$data          += $this->build_display_items();
958 958
 		$data['result'] = 'success';
959 959
 
960
-		wp_send_json( $data );
960
+		wp_send_json($data);
961 961
 	}
962 962
 
963 963
 	/**
@@ -970,31 +970,31 @@  discard block
 block discarded – undo
970 970
 	 * @version 4.0.0
971 971
 	 */
972 972
 	public function normalize_state() {
973
-		$billing_country  = ! empty( $_POST['billing_country'] ) ? wc_clean( $_POST['billing_country'] ) : '';
974
-		$shipping_country = ! empty( $_POST['shipping_country'] ) ? wc_clean( $_POST['shipping_country'] ) : '';
975
-		$billing_state    = ! empty( $_POST['billing_state'] ) ? wc_clean( $_POST['billing_state'] ) : '';
976
-		$shipping_state   = ! empty( $_POST['shipping_state'] ) ? wc_clean( $_POST['shipping_state'] ) : '';
973
+		$billing_country  = ! empty($_POST['billing_country']) ? wc_clean($_POST['billing_country']) : '';
974
+		$shipping_country = ! empty($_POST['shipping_country']) ? wc_clean($_POST['shipping_country']) : '';
975
+		$billing_state    = ! empty($_POST['billing_state']) ? wc_clean($_POST['billing_state']) : '';
976
+		$shipping_state   = ! empty($_POST['shipping_state']) ? wc_clean($_POST['shipping_state']) : '';
977 977
 
978
-		if ( $billing_state && $billing_country ) {
979
-			$valid_states = WC()->countries->get_states( $billing_country );
978
+		if ($billing_state && $billing_country) {
979
+			$valid_states = WC()->countries->get_states($billing_country);
980 980
 
981 981
 			// Valid states found for country.
982
-			if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) {
983
-				foreach ( $valid_states as $state_abbr => $state ) {
984
-					if ( preg_match( '/' . preg_quote( $state ) . '/i', $billing_state ) ) {
982
+			if ( ! empty($valid_states) && is_array($valid_states) && sizeof($valid_states) > 0) {
983
+				foreach ($valid_states as $state_abbr => $state) {
984
+					if (preg_match('/' . preg_quote($state) . '/i', $billing_state)) {
985 985
 						$_POST['billing_state'] = $state_abbr;
986 986
 					}
987 987
 				}
988 988
 			}
989 989
 		}
990 990
 
991
-		if ( $shipping_state && $shipping_country ) {
992
-			$valid_states = WC()->countries->get_states( $shipping_country );
991
+		if ($shipping_state && $shipping_country) {
992
+			$valid_states = WC()->countries->get_states($shipping_country);
993 993
 
994 994
 			// Valid states found for country.
995
-			if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) {
996
-				foreach ( $valid_states as $state_abbr => $state ) {
997
-					if ( preg_match( '/' . preg_quote( $state ) . '/i', $shipping_state ) ) {
995
+			if ( ! empty($valid_states) && is_array($valid_states) && sizeof($valid_states) > 0) {
996
+				foreach ($valid_states as $state_abbr => $state) {
997
+					if (preg_match('/' . preg_quote($state) . '/i', $shipping_state)) {
998 998
 						$_POST['shipping_state'] = $state_abbr;
999 999
 					}
1000 1000
 				}
@@ -1009,19 +1009,19 @@  discard block
 block discarded – undo
1009 1009
 	 * @version 4.0.0
1010 1010
 	 */
1011 1011
 	public function ajax_create_order() {
1012
-		if ( WC()->cart->is_empty() ) {
1013
-			wp_send_json_error( __( 'Empty cart', 'woocommerce-gateway-stripe' ) );
1012
+		if (WC()->cart->is_empty()) {
1013
+			wp_send_json_error(__('Empty cart', 'woocommerce-gateway-stripe'));
1014 1014
 		}
1015 1015
 
1016
-		if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) {
1017
-			define( 'WOOCOMMERCE_CHECKOUT', true );
1016
+		if ( ! defined('WOOCOMMERCE_CHECKOUT')) {
1017
+			define('WOOCOMMERCE_CHECKOUT', true);
1018 1018
 		}
1019 1019
 
1020 1020
 		$this->normalize_state();
1021 1021
 
1022 1022
 		WC()->checkout()->process_checkout();
1023 1023
 
1024
-		die( 0 );
1024
+		die(0);
1025 1025
 	}
1026 1026
 
1027 1027
 	/**
@@ -1031,41 +1031,41 @@  discard block
 block discarded – undo
1031 1031
 	 * @version 4.0.0
1032 1032
 	 * @param array $address
1033 1033
 	 */
1034
-	protected function calculate_shipping( $address = array() ) {
1034
+	protected function calculate_shipping($address = array()) {
1035 1035
 		$country   = $address['country'];
1036 1036
 		$state     = $address['state'];
1037 1037
 		$postcode  = $address['postcode'];
1038 1038
 		$city      = $address['city'];
1039 1039
 		$address_1 = $address['address'];
1040 1040
 		$address_2 = $address['address_2'];
1041
-		$wc_states = WC()->countries->get_states( $country );
1041
+		$wc_states = WC()->countries->get_states($country);
1042 1042
 
1043 1043
 		/**
1044 1044
 		 * In some versions of Chrome, state can be a full name. So we need
1045 1045
 		 * to convert that to abbreviation as WC is expecting that.
1046 1046
 		 */
1047
-		if ( 2 < strlen( $state ) && ! empty( $wc_states ) ) {
1048
-			$state = array_search( ucwords( strtolower( $state ) ), $wc_states, true );
1047
+		if (2 < strlen($state) && ! empty($wc_states)) {
1048
+			$state = array_search(ucwords(strtolower($state)), $wc_states, true);
1049 1049
 		}
1050 1050
 
1051 1051
 		WC()->shipping->reset_shipping();
1052 1052
 
1053
-		if ( $postcode && WC_Validation::is_postcode( $postcode, $country ) ) {
1054
-			$postcode = wc_format_postcode( $postcode, $country );
1053
+		if ($postcode && WC_Validation::is_postcode($postcode, $country)) {
1054
+			$postcode = wc_format_postcode($postcode, $country);
1055 1055
 		}
1056 1056
 
1057
-		if ( $country ) {
1058
-			WC()->customer->set_location( $country, $state, $postcode, $city );
1059
-			WC()->customer->set_shipping_location( $country, $state, $postcode, $city );
1057
+		if ($country) {
1058
+			WC()->customer->set_location($country, $state, $postcode, $city);
1059
+			WC()->customer->set_shipping_location($country, $state, $postcode, $city);
1060 1060
 		} else {
1061
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? WC()->customer->set_to_base() : WC()->customer->set_billing_address_to_base();
1062
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? WC()->customer->set_shipping_to_base() : WC()->customer->set_shipping_address_to_base();
1061
+			WC_Stripe_Helper::is_wc_lt('3.0') ? WC()->customer->set_to_base() : WC()->customer->set_billing_address_to_base();
1062
+			WC_Stripe_Helper::is_wc_lt('3.0') ? WC()->customer->set_shipping_to_base() : WC()->customer->set_shipping_address_to_base();
1063 1063
 		}
1064 1064
 
1065
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
1066
-			WC()->customer->calculated_shipping( true );
1065
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
1066
+			WC()->customer->calculated_shipping(true);
1067 1067
 		} else {
1068
-			WC()->customer->set_calculated_shipping( true );
1068
+			WC()->customer->set_calculated_shipping(true);
1069 1069
 			WC()->customer->save();
1070 1070
 		}
1071 1071
 
@@ -1082,17 +1082,17 @@  discard block
 block discarded – undo
1082 1082
 		$packages[0]['destination']['address']   = $address_1;
1083 1083
 		$packages[0]['destination']['address_2'] = $address_2;
1084 1084
 
1085
-		foreach ( WC()->cart->get_cart() as $item ) {
1086
-			if ( $item['data']->needs_shipping() ) {
1087
-				if ( isset( $item['line_total'] ) ) {
1085
+		foreach (WC()->cart->get_cart() as $item) {
1086
+			if ($item['data']->needs_shipping()) {
1087
+				if (isset($item['line_total'])) {
1088 1088
 					$packages[0]['contents_cost'] += $item['line_total'];
1089 1089
 				}
1090 1090
 			}
1091 1091
 		}
1092 1092
 
1093
-		$packages = apply_filters( 'woocommerce_cart_shipping_packages', $packages );
1093
+		$packages = apply_filters('woocommerce_cart_shipping_packages', $packages);
1094 1094
 
1095
-		WC()->shipping->calculate_shipping( $packages );
1095
+		WC()->shipping->calculate_shipping($packages);
1096 1096
 	}
1097 1097
 
1098 1098
 	/**
@@ -1101,19 +1101,19 @@  discard block
 block discarded – undo
1101 1101
 	 * @since 3.1.0
1102 1102
 	 * @version 4.0.0
1103 1103
 	 */
1104
-	protected function build_shipping_methods( $shipping_methods ) {
1105
-		if ( empty( $shipping_methods ) ) {
1104
+	protected function build_shipping_methods($shipping_methods) {
1105
+		if (empty($shipping_methods)) {
1106 1106
 			return array();
1107 1107
 		}
1108 1108
 
1109 1109
 		$shipping = array();
1110 1110
 
1111
-		foreach ( $shipping_methods as $method ) {
1111
+		foreach ($shipping_methods as $method) {
1112 1112
 			$shipping[] = array(
1113 1113
 				'id'     => $method['id'],
1114 1114
 				'label'  => $method['label'],
1115 1115
 				'detail' => '',
1116
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $method['amount']['value'] ),
1116
+				'amount' => WC_Stripe_Helper::get_stripe_amount($method['amount']['value']),
1117 1117
 			);
1118 1118
 		}
1119 1119
 
@@ -1127,8 +1127,8 @@  discard block
 block discarded – undo
1127 1127
 	 * @version 4.0.0
1128 1128
 	 */
1129 1129
 	protected function build_display_items() {
1130
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
1131
-			define( 'WOOCOMMERCE_CART', true );
1130
+		if ( ! defined('WOOCOMMERCE_CART')) {
1131
+			define('WOOCOMMERCE_CART', true);
1132 1132
 		}
1133 1133
 
1134 1134
 		$items     = array();
@@ -1136,71 +1136,71 @@  discard block
 block discarded – undo
1136 1136
 		$discounts = 0;
1137 1137
 
1138 1138
 		// Default show only subtotal instead of itemization.
1139
-		if ( ! apply_filters( 'wc_stripe_payment_request_hide_itemization', true ) ) {
1140
-			foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
1139
+		if ( ! apply_filters('wc_stripe_payment_request_hide_itemization', true)) {
1140
+			foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
1141 1141
 				$amount         = $cart_item['line_subtotal'];
1142 1142
 				$subtotal      += $cart_item['line_subtotal'];
1143 1143
 				$quantity_label = 1 < $cart_item['quantity'] ? ' (x' . $cart_item['quantity'] . ')' : '';
1144 1144
 
1145
-				$product_name = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $cart_item['data']->post->post_title : $cart_item['data']->get_name();
1145
+				$product_name = WC_Stripe_Helper::is_wc_lt('3.0') ? $cart_item['data']->post->post_title : $cart_item['data']->get_name();
1146 1146
 
1147 1147
 				$item = array(
1148 1148
 					'label'  => $product_name . $quantity_label,
1149
-					'amount' => WC_Stripe_Helper::get_stripe_amount( $amount ),
1149
+					'amount' => WC_Stripe_Helper::get_stripe_amount($amount),
1150 1150
 				);
1151 1151
 
1152 1152
 				$items[] = $item;
1153 1153
 			}
1154 1154
 		}
1155 1155
 
1156
-		if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
1157
-			$discounts = wc_format_decimal( WC()->cart->get_cart_discount_total(), WC()->cart->dp );
1156
+		if (version_compare(WC_VERSION, '3.2', '<')) {
1157
+			$discounts = wc_format_decimal(WC()->cart->get_cart_discount_total(), WC()->cart->dp);
1158 1158
 		} else {
1159
-			$applied_coupons = array_values( WC()->cart->get_coupon_discount_totals() );
1159
+			$applied_coupons = array_values(WC()->cart->get_coupon_discount_totals());
1160 1160
 
1161
-			foreach ( $applied_coupons as $amount ) {
1161
+			foreach ($applied_coupons as $amount) {
1162 1162
 				$discounts += (float) $amount;
1163 1163
 			}
1164 1164
 		}
1165 1165
 
1166
-		$discounts   = wc_format_decimal( $discounts, WC()->cart->dp );
1167
-		$tax         = wc_format_decimal( WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp );
1168
-		$shipping    = wc_format_decimal( WC()->cart->shipping_total, WC()->cart->dp );
1169
-		$items_total = wc_format_decimal( WC()->cart->cart_contents_total, WC()->cart->dp ) + $discounts;
1170
-		$order_total = version_compare( WC_VERSION, '3.2', '<' ) ? wc_format_decimal( $items_total + $tax + $shipping - $discounts, WC()->cart->dp ) : WC()->cart->get_total( false );
1166
+		$discounts   = wc_format_decimal($discounts, WC()->cart->dp);
1167
+		$tax         = wc_format_decimal(WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp);
1168
+		$shipping    = wc_format_decimal(WC()->cart->shipping_total, WC()->cart->dp);
1169
+		$items_total = wc_format_decimal(WC()->cart->cart_contents_total, WC()->cart->dp) + $discounts;
1170
+		$order_total = version_compare(WC_VERSION, '3.2', '<') ? wc_format_decimal($items_total + $tax + $shipping - $discounts, WC()->cart->dp) : WC()->cart->get_total(false);
1171 1171
 
1172
-		if ( wc_tax_enabled() ) {
1172
+		if (wc_tax_enabled()) {
1173 1173
 			$items[] = array(
1174
-				'label'  => esc_html( __( 'Tax', 'woocommerce-gateway-stripe' ) ),
1175
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $tax ),
1174
+				'label'  => esc_html(__('Tax', 'woocommerce-gateway-stripe')),
1175
+				'amount' => WC_Stripe_Helper::get_stripe_amount($tax),
1176 1176
 			);
1177 1177
 		}
1178 1178
 
1179
-		if ( WC()->cart->needs_shipping() ) {
1179
+		if (WC()->cart->needs_shipping()) {
1180 1180
 			$items[] = array(
1181
-				'label'  => esc_html( __( 'Shipping', 'woocommerce-gateway-stripe' ) ),
1182
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $shipping ),
1181
+				'label'  => esc_html(__('Shipping', 'woocommerce-gateway-stripe')),
1182
+				'amount' => WC_Stripe_Helper::get_stripe_amount($shipping),
1183 1183
 			);
1184 1184
 		}
1185 1185
 
1186
-		if ( WC()->cart->has_discount() ) {
1186
+		if (WC()->cart->has_discount()) {
1187 1187
 			$items[] = array(
1188
-				'label'  => esc_html( __( 'Discount', 'woocommerce-gateway-stripe' ) ),
1189
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $discounts ),
1188
+				'label'  => esc_html(__('Discount', 'woocommerce-gateway-stripe')),
1189
+				'amount' => WC_Stripe_Helper::get_stripe_amount($discounts),
1190 1190
 			);
1191 1191
 		}
1192 1192
 
1193
-		if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
1193
+		if (version_compare(WC_VERSION, '3.2', '<')) {
1194 1194
 			$cart_fees = WC()->cart->fees;
1195 1195
 		} else {
1196 1196
 			$cart_fees = WC()->cart->get_fees();
1197 1197
 		}
1198 1198
 
1199 1199
 		// Include fees and taxes as display items.
1200
-		foreach ( $cart_fees as $key => $fee ) {
1200
+		foreach ($cart_fees as $key => $fee) {
1201 1201
 			$items[] = array(
1202 1202
 				'label'  => $fee->name,
1203
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $fee->amount ),
1203
+				'amount' => WC_Stripe_Helper::get_stripe_amount($fee->amount),
1204 1204
 			);
1205 1205
 		}
1206 1206
 
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 			'displayItems' => $items,
1209 1209
 			'total'        => array(
1210 1210
 				'label'   => $this->total_label,
1211
-				'amount'  => max( 0, apply_filters( 'woocommerce_stripe_calculated_total', WC_Stripe_Helper::get_stripe_amount( $order_total ), $order_total, WC()->cart ) ),
1211
+				'amount'  => max(0, apply_filters('woocommerce_stripe_calculated_total', WC_Stripe_Helper::get_stripe_amount($order_total), $order_total, WC()->cart)),
1212 1212
 				'pending' => false,
1213 1213
 			),
1214 1214
 		);
Please login to merge, or discard this patch.
includes/class-wc-gateway-stripe.php 1 patch
Spacing   +333 added lines, -333 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
 
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	public function __construct() {
86 86
 		$this->retry_interval = 1;
87 87
 		$this->id             = 'stripe';
88
-		$this->method_title   = __( 'Stripe', 'woocommerce-gateway-stripe' );
88
+		$this->method_title   = __('Stripe', 'woocommerce-gateway-stripe');
89 89
 		/* translators: 1) link to Stripe register page 2) link to Stripe api keys page */
90
-		$this->method_description = sprintf( __( 'Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification. <a href="%1$s" target="_blank">Sign up</a> for a Stripe account, and <a href="%2$s" target="_blank">get your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), 'https://dashboard.stripe.com/register', 'https://dashboard.stripe.com/account/apikeys' );
90
+		$this->method_description = sprintf(__('Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification. <a href="%1$s" target="_blank">Sign up</a> for a Stripe account, and <a href="%2$s" target="_blank">get your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), 'https://dashboard.stripe.com/register', 'https://dashboard.stripe.com/account/apikeys');
91 91
 		$this->has_fields         = true;
92 92
 		$this->supports           = array(
93 93
 			'products',
@@ -114,40 +114,40 @@  discard block
 block discarded – undo
114 114
 		$this->init_settings();
115 115
 
116 116
 		// Get setting values.
117
-		$this->title                = $this->get_option( 'title' );
118
-		$this->description          = $this->get_option( 'description' );
119
-		$this->enabled              = $this->get_option( 'enabled' );
120
-		$this->testmode             = 'yes' === $this->get_option( 'testmode' );
121
-		$this->inline_cc_form       = 'yes' === $this->get_option( 'inline_cc_form' );
122
-		$this->capture              = 'yes' === $this->get_option( 'capture', 'yes' );
123
-		$this->statement_descriptor = WC_Stripe_Helper::clean_statement_descriptor( $this->get_option( 'statement_descriptor' ) );
124
-		$this->saved_cards          = 'yes' === $this->get_option( 'saved_cards' );
125
-		$this->secret_key           = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
126
-		$this->publishable_key      = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' );
127
-		$this->payment_request      = 'yes' === $this->get_option( 'payment_request', 'yes' );
128
-
129
-		WC_Stripe_API::set_secret_key( $this->secret_key );
117
+		$this->title                = $this->get_option('title');
118
+		$this->description          = $this->get_option('description');
119
+		$this->enabled              = $this->get_option('enabled');
120
+		$this->testmode             = 'yes' === $this->get_option('testmode');
121
+		$this->inline_cc_form       = 'yes' === $this->get_option('inline_cc_form');
122
+		$this->capture              = 'yes' === $this->get_option('capture', 'yes');
123
+		$this->statement_descriptor = WC_Stripe_Helper::clean_statement_descriptor($this->get_option('statement_descriptor'));
124
+		$this->saved_cards          = 'yes' === $this->get_option('saved_cards');
125
+		$this->secret_key           = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
126
+		$this->publishable_key      = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key');
127
+		$this->payment_request      = 'yes' === $this->get_option('payment_request', 'yes');
128
+
129
+		WC_Stripe_API::set_secret_key($this->secret_key);
130 130
 
131 131
 		// Hooks.
132
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
133
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
134
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
135
-		add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_fee' ) );
136
-		add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_payout' ), 20 );
137
-		add_action( 'woocommerce_customer_save_address', array( $this, 'show_update_card_notice' ), 10, 2 );
138
-		add_filter( 'woocommerce_available_payment_gateways', array( $this, 'prepare_order_pay_page' ) );
139
-		add_action( 'woocommerce_account_view-order_endpoint', array( $this, 'check_intent_status_on_order_page' ), 1 );
140
-		add_filter( 'woocommerce_payment_successful_result', array( $this, 'modify_successful_payment_result' ), 99999, 2 );
141
-		add_action( 'set_logged_in_cookie', array( $this, 'set_cookie_on_current_request' ) );
142
-		add_filter( 'woocommerce_get_checkout_payment_url', array( $this, 'get_checkout_payment_url' ), 10, 2 );
132
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
133
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'));
134
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
135
+		add_action('woocommerce_admin_order_totals_after_total', array($this, 'display_order_fee'));
136
+		add_action('woocommerce_admin_order_totals_after_total', array($this, 'display_order_payout'), 20);
137
+		add_action('woocommerce_customer_save_address', array($this, 'show_update_card_notice'), 10, 2);
138
+		add_filter('woocommerce_available_payment_gateways', array($this, 'prepare_order_pay_page'));
139
+		add_action('woocommerce_account_view-order_endpoint', array($this, 'check_intent_status_on_order_page'), 1);
140
+		add_filter('woocommerce_payment_successful_result', array($this, 'modify_successful_payment_result'), 99999, 2);
141
+		add_action('set_logged_in_cookie', array($this, 'set_cookie_on_current_request'));
142
+		add_filter('woocommerce_get_checkout_payment_url', array($this, 'get_checkout_payment_url'), 10, 2);
143 143
 
144 144
 		// Note: display error is in the parent class.
145
-		add_action( 'admin_notices', array( $this, 'display_errors' ), 9999 );
145
+		add_action('admin_notices', array($this, 'display_errors'), 9999);
146 146
 
147
-		if ( WC_Stripe_Helper::is_pre_orders_exists() ) {
147
+		if (WC_Stripe_Helper::is_pre_orders_exists()) {
148 148
 			$this->pre_orders = new WC_Stripe_Pre_Orders_Compat();
149 149
 
150
-			add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this->pre_orders, 'process_pre_order_release_payment' ) );
150
+			add_action('wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array($this->pre_orders, 'process_pre_order_release_payment'));
151 151
 		}
152 152
 	}
153 153
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @since 4.0.2
158 158
 	 */
159 159
 	public function is_available() {
160
-		if ( is_add_payment_method_page() && ! $this->saved_cards ) {
160
+		if (is_add_payment_method_page() && ! $this->saved_cards) {
161 161
 			return false;
162 162
 		}
163 163
 
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 	 * @param int    $user_id      The ID of the current user.
172 172
 	 * @param string $load_address The address to load.
173 173
 	 */
174
-	public function show_update_card_notice( $user_id, $load_address ) {
175
-		if ( ! $this->saved_cards || ! WC_Stripe_Payment_Tokens::customer_has_saved_methods( $user_id ) || 'billing' !== $load_address ) {
174
+	public function show_update_card_notice($user_id, $load_address) {
175
+		if ( ! $this->saved_cards || ! WC_Stripe_Payment_Tokens::customer_has_saved_methods($user_id) || 'billing' !== $load_address) {
176 176
 			return;
177 177
 		}
178 178
 
179 179
 		/* translators: 1) Opening anchor tag 2) closing anchor tag */
180
-		wc_add_notice( sprintf( __( 'If your billing address has been changed for saved payment methods, be sure to remove any %1$ssaved payment methods%2$s on file and re-add them.', 'woocommerce-gateway-stripe' ), '<a href="' . esc_url( wc_get_endpoint_url( 'payment-methods' ) ) . '" class="wc-stripe-update-card-notice" style="text-decoration:underline;">', '</a>' ), 'notice' );
180
+		wc_add_notice(sprintf(__('If your billing address has been changed for saved payment methods, be sure to remove any %1$ssaved payment methods%2$s on file and re-add them.', 'woocommerce-gateway-stripe'), '<a href="' . esc_url(wc_get_endpoint_url('payment-methods')) . '" class="wc-stripe-update-card-notice" style="text-decoration:underline;">', '</a>'), 'notice');
181 181
 	}
182 182
 
183 183
 	/**
@@ -192,24 +192,24 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$icons_str = '';
194 194
 
195
-		$icons_str .= isset( $icons['visa'] ) ? $icons['visa'] : '';
196
-		$icons_str .= isset( $icons['amex'] ) ? $icons['amex'] : '';
197
-		$icons_str .= isset( $icons['mastercard'] ) ? $icons['mastercard'] : '';
195
+		$icons_str .= isset($icons['visa']) ? $icons['visa'] : '';
196
+		$icons_str .= isset($icons['amex']) ? $icons['amex'] : '';
197
+		$icons_str .= isset($icons['mastercard']) ? $icons['mastercard'] : '';
198 198
 
199
-		if ( 'USD' === get_woocommerce_currency() ) {
200
-			$icons_str .= isset( $icons['discover'] ) ? $icons['discover'] : '';
201
-			$icons_str .= isset( $icons['jcb'] ) ? $icons['jcb'] : '';
202
-			$icons_str .= isset( $icons['diners'] ) ? $icons['diners'] : '';
199
+		if ('USD' === get_woocommerce_currency()) {
200
+			$icons_str .= isset($icons['discover']) ? $icons['discover'] : '';
201
+			$icons_str .= isset($icons['jcb']) ? $icons['jcb'] : '';
202
+			$icons_str .= isset($icons['diners']) ? $icons['diners'] : '';
203 203
 		}
204 204
 
205
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
205
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
206 206
 	}
207 207
 
208 208
 	/**
209 209
 	 * Initialise Gateway Settings Form Fields
210 210
 	 */
211 211
 	public function init_form_fields() {
212
-		$this->form_fields = require( dirname( __FILE__ ) . '/admin/stripe-settings.php' );
212
+		$this->form_fields = require(dirname(__FILE__) . '/admin/stripe-settings.php');
213 213
 	}
214 214
 
215 215
 	/**
@@ -218,27 +218,27 @@  discard block
 block discarded – undo
218 218
 	public function payment_fields() {
219 219
 		global $wp;
220 220
 		$user                 = wp_get_current_user();
221
-		$display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards;
221
+		$display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards;
222 222
 		$total                = WC()->cart->total;
223 223
 		$user_email           = '';
224 224
 		$description          = $this->get_description();
225
-		$description          = ! empty( $description ) ? $description : '';
225
+		$description          = ! empty($description) ? $description : '';
226 226
 		$firstname            = '';
227 227
 		$lastname             = '';
228 228
 
229 229
 		// If paying from order, we need to get total from order not cart.
230
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { // wpcs: csrf ok.
231
-			$order      = wc_get_order( wc_clean( $wp->query_vars['order-pay'] ) ); // wpcs: csrf ok, sanitization ok.
230
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { // wpcs: csrf ok.
231
+			$order      = wc_get_order(wc_clean($wp->query_vars['order-pay'])); // wpcs: csrf ok, sanitization ok.
232 232
 			$total      = $order->get_total();
233
-			$user_email = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_email : $order->get_billing_email();
233
+			$user_email = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_email : $order->get_billing_email();
234 234
 		} else {
235
-			if ( $user->ID ) {
236
-				$user_email = get_user_meta( $user->ID, 'billing_email', true );
235
+			if ($user->ID) {
236
+				$user_email = get_user_meta($user->ID, 'billing_email', true);
237 237
 				$user_email = $user_email ? $user_email : $user->user_email;
238 238
 			}
239 239
 		}
240 240
 
241
-		if ( is_add_payment_method_page() ) {
241
+		if (is_add_payment_method_page()) {
242 242
 			$firstname       = $user->user_firstname;
243 243
 			$lastname        = $user->user_lastname;
244 244
 		}
@@ -247,33 +247,33 @@  discard block
 block discarded – undo
247 247
 
248 248
 		echo '<div
249 249
 			id="stripe-payment-data"
250
-			data-email="' . esc_attr( $user_email ) . '"
251
-			data-full-name="' . esc_attr( $firstname . ' ' . $lastname ) . '"
252
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '"
250
+			data-email="' . esc_attr($user_email) . '"
251
+			data-full-name="' . esc_attr($firstname . ' ' . $lastname) . '"
252
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '"
253 253
 		>';
254 254
 
255
-		if ( $this->testmode ) {
255
+		if ($this->testmode) {
256 256
 			/* translators: link to Stripe testing page */
257
-			$description .= ' ' . sprintf( __( 'TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the <a href="%s" target="_blank">Testing Stripe documentation</a> for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' );
257
+			$description .= ' ' . sprintf(__('TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the <a href="%s" target="_blank">Testing Stripe documentation</a> for more card numbers.', 'woocommerce-gateway-stripe'), 'https://stripe.com/docs/testing');
258 258
 		}
259 259
 
260
-		$description = trim( $description );
260
+		$description = trim($description);
261 261
 
262
-		echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id ); // wpcs: xss ok.
262
+		echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id); // wpcs: xss ok.
263 263
 
264
-		if ( $display_tokenization ) {
264
+		if ($display_tokenization) {
265 265
 			$this->tokenization_script();
266 266
 			$this->saved_payment_methods();
267 267
 		}
268 268
 
269 269
 		$this->elements_form();
270 270
 
271
-		if ( apply_filters( 'wc_stripe_display_save_payment_method_checkbox', $display_tokenization ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) { // wpcs: csrf ok.
271
+		if (apply_filters('wc_stripe_display_save_payment_method_checkbox', $display_tokenization) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) { // wpcs: csrf ok.
272 272
 
273 273
 			$this->save_payment_method_checkbox();
274 274
 		}
275 275
 
276
-		do_action( 'wc_stripe_cards_payment_fields', $this->id );
276
+		do_action('wc_stripe_cards_payment_fields', $this->id);
277 277
 
278 278
 		echo '</div>';
279 279
 
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
 	 */
289 289
 	public function elements_form() {
290 290
 		?>
291
-		<fieldset id="wc-<?php echo esc_attr( $this->id ); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
292
-			<?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?>
291
+		<fieldset id="wc-<?php echo esc_attr($this->id); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
292
+			<?php do_action('woocommerce_credit_card_form_start', $this->id); ?>
293 293
 
294
-			<?php if ( $this->inline_cc_form ) { ?>
294
+			<?php if ($this->inline_cc_form) { ?>
295 295
 				<label for="card-element">
296
-					<?php esc_html_e( 'Credit or debit card', 'woocommerce-gateway-stripe' ); ?>
296
+					<?php esc_html_e('Credit or debit card', 'woocommerce-gateway-stripe'); ?>
297 297
 				</label>
298 298
 
299 299
 				<div id="stripe-card-element" class="wc-stripe-elements-field">
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 				</div>
302 302
 			<?php } else { ?>
303 303
 				<div class="form-row form-row-wide">
304
-					<label for="stripe-card-element"><?php esc_html_e( 'Card Number', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
304
+					<label for="stripe-card-element"><?php esc_html_e('Card Number', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
305 305
 					<div class="stripe-card-group">
306 306
 						<div id="stripe-card-element" class="wc-stripe-elements-field">
307 307
 						<!-- a Stripe Element will be inserted here. -->
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 				</div>
313 313
 
314 314
 				<div class="form-row form-row-first">
315
-					<label for="stripe-exp-element"><?php esc_html_e( 'Expiry Date', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
315
+					<label for="stripe-exp-element"><?php esc_html_e('Expiry Date', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
316 316
 
317 317
 					<div id="stripe-exp-element" class="wc-stripe-elements-field">
318 318
 					<!-- a Stripe Element will be inserted here. -->
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 				</div>
321 321
 
322 322
 				<div class="form-row form-row-last">
323
-					<label for="stripe-cvc-element"><?php esc_html_e( 'Card Code (CVC)', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
323
+					<label for="stripe-cvc-element"><?php esc_html_e('Card Code (CVC)', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
324 324
 				<div id="stripe-cvc-element" class="wc-stripe-elements-field">
325 325
 				<!-- a Stripe Element will be inserted here. -->
326 326
 				</div>
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 			<!-- Used to display form errors -->
332 332
 			<div class="stripe-source-errors" role="alert"></div>
333 333
 			<br />
334
-			<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
334
+			<?php do_action('woocommerce_credit_card_form_end', $this->id); ?>
335 335
 			<div class="clear"></div>
336 336
 		</fieldset>
337 337
 		<?php
@@ -344,13 +344,13 @@  discard block
 block discarded – undo
344 344
 	 * @version 3.1.0
345 345
 	 */
346 346
 	public function admin_scripts() {
347
-		if ( 'woocommerce_page_wc-settings' !== get_current_screen()->id ) {
347
+		if ('woocommerce_page_wc-settings' !== get_current_screen()->id) {
348 348
 			return;
349 349
 		}
350 350
 
351
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
351
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
352 352
 
353
-		wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true );
353
+		wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true);
354 354
 	}
355 355
 
356 356
 	/**
@@ -367,102 +367,102 @@  discard block
 block discarded – undo
367 367
 			! is_product()
368 368
 			&& ! is_cart()
369 369
 			&& ! is_checkout()
370
-			&& ! isset( $_GET['pay_for_order'] ) // wpcs: csrf ok.
370
+			&& ! isset($_GET['pay_for_order']) // wpcs: csrf ok.
371 371
 			&& ! is_add_payment_method_page()
372
-			&& ! isset( $_GET['change_payment_method'] ) // wpcs: csrf ok.
373
-			&& ! ( ! empty( get_query_var( 'view-subscription' ) ) && is_callable( 'WCS_Early_Renewal_Manager::is_early_renewal_via_modal_enabled' ) && WCS_Early_Renewal_Manager::is_early_renewal_via_modal_enabled() )
374
-			|| ( is_order_received_page() )
372
+			&& ! isset($_GET['change_payment_method']) // wpcs: csrf ok.
373
+			&& ! ( ! empty(get_query_var('view-subscription')) && is_callable('WCS_Early_Renewal_Manager::is_early_renewal_via_modal_enabled') && WCS_Early_Renewal_Manager::is_early_renewal_via_modal_enabled())
374
+			|| (is_order_received_page())
375 375
 		) {
376 376
 			return;
377 377
 		}
378 378
 
379 379
 		// If Stripe is not enabled bail.
380
-		if ( 'no' === $this->enabled ) {
380
+		if ('no' === $this->enabled) {
381 381
 			return;
382 382
 		}
383 383
 
384 384
 		// If keys are not set bail.
385
-		if ( ! $this->are_keys_set() ) {
386
-			WC_Stripe_Logger::log( 'Keys are not set correctly.' );
385
+		if ( ! $this->are_keys_set()) {
386
+			WC_Stripe_Logger::log('Keys are not set correctly.');
387 387
 			return;
388 388
 		}
389 389
 
390 390
 		// If no SSL bail.
391
-		if ( ! $this->testmode && ! is_ssl() ) {
392
-			WC_Stripe_Logger::log( 'Stripe live mode requires SSL.' );
391
+		if ( ! $this->testmode && ! is_ssl()) {
392
+			WC_Stripe_Logger::log('Stripe live mode requires SSL.');
393 393
 			return;
394 394
 		}
395 395
 
396 396
 		$current_theme = wp_get_theme();
397 397
 
398
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
398
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
399 399
 
400
-		wp_register_style( 'stripe_styles', plugins_url( 'assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION );
401
-		wp_enqueue_style( 'stripe_styles' );
400
+		wp_register_style('stripe_styles', plugins_url('assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION);
401
+		wp_enqueue_style('stripe_styles');
402 402
 
403
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
404
-		wp_register_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripe' ), WC_STRIPE_VERSION, true );
403
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
404
+		wp_register_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripe'), WC_STRIPE_VERSION, true);
405 405
 
406 406
 		$stripe_params = array(
407 407
 			'key'                  => $this->publishable_key,
408
-			'i18n_terms'           => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ),
409
-			'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ),
408
+			'i18n_terms'           => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'),
409
+			'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'),
410 410
 		);
411 411
 
412 412
 		// If we're on the pay page we need to pass stripe.js the address of the order.
413
-		if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) { // wpcs: csrf ok.
414
-			$order_id = wc_clean( $wp->query_vars['order-pay'] ); // wpcs: csrf ok, sanitization ok, xss ok.
415
-			$order    = wc_get_order( $order_id );
416
-
417
-			if ( is_a( $order, 'WC_Order' ) ) {
418
-				$stripe_params['billing_first_name'] = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_first_name : $order->get_billing_first_name();
419
-				$stripe_params['billing_last_name']  = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_last_name : $order->get_billing_last_name();
420
-				$stripe_params['billing_address_1']  = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_address_1 : $order->get_billing_address_1();
421
-				$stripe_params['billing_address_2']  = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_address_2 : $order->get_billing_address_2();
422
-				$stripe_params['billing_state']      = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_state : $order->get_billing_state();
423
-				$stripe_params['billing_city']       = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_city : $order->get_billing_city();
424
-				$stripe_params['billing_postcode']   = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_postcode : $order->get_billing_postcode();
425
-				$stripe_params['billing_country']    = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_country : $order->get_billing_country();
413
+		if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) { // wpcs: csrf ok.
414
+			$order_id = wc_clean($wp->query_vars['order-pay']); // wpcs: csrf ok, sanitization ok, xss ok.
415
+			$order    = wc_get_order($order_id);
416
+
417
+			if (is_a($order, 'WC_Order')) {
418
+				$stripe_params['billing_first_name'] = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_first_name : $order->get_billing_first_name();
419
+				$stripe_params['billing_last_name']  = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_last_name : $order->get_billing_last_name();
420
+				$stripe_params['billing_address_1']  = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_address_1 : $order->get_billing_address_1();
421
+				$stripe_params['billing_address_2']  = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_address_2 : $order->get_billing_address_2();
422
+				$stripe_params['billing_state']      = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_state : $order->get_billing_state();
423
+				$stripe_params['billing_city']       = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_city : $order->get_billing_city();
424
+				$stripe_params['billing_postcode']   = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_postcode : $order->get_billing_postcode();
425
+				$stripe_params['billing_country']    = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_country : $order->get_billing_country();
426 426
 			}
427 427
 		}
428 428
 
429 429
 		$sepa_elements_options = apply_filters(
430 430
 			'wc_stripe_sepa_elements_options',
431 431
 			array(
432
-				'supportedCountries' => array( 'SEPA' ),
432
+				'supportedCountries' => array('SEPA'),
433 433
 				'placeholderCountry' => WC()->countries->get_base_country(),
434
-				'style'              => array( 'base' => array( 'fontSize' => '15px' ) ),
434
+				'style'              => array('base' => array('fontSize' => '15px')),
435 435
 			)
436 436
 		);
437 437
 
438
-		$stripe_params['no_prepaid_card_msg']       = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
439
-		$stripe_params['no_sepa_owner_msg']         = __( 'Please enter your IBAN account name.', 'woocommerce-gateway-stripe' );
440
-		$stripe_params['no_sepa_iban_msg']          = __( 'Please enter your IBAN account number.', 'woocommerce-gateway-stripe' );
441
-		$stripe_params['payment_intent_error']      = __( 'We couldn\'t initiate the payment. Please try again.', 'woocommerce-gateway-stripe' );
442
-		$stripe_params['sepa_mandate_notification'] = apply_filters( 'wc_stripe_sepa_mandate_notification', 'email' );
443
-		$stripe_params['allow_prepaid_card']        = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no';
438
+		$stripe_params['no_prepaid_card_msg']       = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
439
+		$stripe_params['no_sepa_owner_msg']         = __('Please enter your IBAN account name.', 'woocommerce-gateway-stripe');
440
+		$stripe_params['no_sepa_iban_msg']          = __('Please enter your IBAN account number.', 'woocommerce-gateway-stripe');
441
+		$stripe_params['payment_intent_error']      = __('We couldn\'t initiate the payment. Please try again.', 'woocommerce-gateway-stripe');
442
+		$stripe_params['sepa_mandate_notification'] = apply_filters('wc_stripe_sepa_mandate_notification', 'email');
443
+		$stripe_params['allow_prepaid_card']        = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no';
444 444
 		$stripe_params['inline_cc_form']            = $this->inline_cc_form ? 'yes' : 'no';
445
-		$stripe_params['is_checkout']               = ( is_checkout() && empty( $_GET['pay_for_order'] ) ) ? 'yes' : 'no'; // wpcs: csrf ok.
445
+		$stripe_params['is_checkout']               = (is_checkout() && empty($_GET['pay_for_order'])) ? 'yes' : 'no'; // wpcs: csrf ok.
446 446
 		$stripe_params['return_url']                = $this->get_stripe_return_url();
447
-		$stripe_params['ajaxurl']                   = WC_AJAX::get_endpoint( '%%endpoint%%' );
448
-		$stripe_params['stripe_nonce']              = wp_create_nonce( '_wc_stripe_nonce' );
447
+		$stripe_params['ajaxurl']                   = WC_AJAX::get_endpoint('%%endpoint%%');
448
+		$stripe_params['stripe_nonce']              = wp_create_nonce('_wc_stripe_nonce');
449 449
 		$stripe_params['statement_descriptor']      = $this->statement_descriptor;
450
-		$stripe_params['elements_options']          = apply_filters( 'wc_stripe_elements_options', array() );
450
+		$stripe_params['elements_options']          = apply_filters('wc_stripe_elements_options', array());
451 451
 		$stripe_params['sepa_elements_options']     = $sepa_elements_options;
452
-		$stripe_params['invalid_owner_name']        = __( 'Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe' );
453
-		$stripe_params['is_change_payment_page']    = isset( $_GET['change_payment_method'] ) ? 'yes' : 'no'; // wpcs: csrf ok.
454
-		$stripe_params['is_add_payment_page']       = is_wc_endpoint_url( 'add-payment-method' ) ? 'yes' : 'no';
455
-		$stripe_params['is_pay_for_order_page']     = is_wc_endpoint_url( 'order-pay' ) ? 'yes' : 'no';
456
-		$stripe_params['elements_styling']          = apply_filters( 'wc_stripe_elements_styling', false );
457
-		$stripe_params['elements_classes']          = apply_filters( 'wc_stripe_elements_classes', false );
452
+		$stripe_params['invalid_owner_name']        = __('Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe');
453
+		$stripe_params['is_change_payment_page']    = isset($_GET['change_payment_method']) ? 'yes' : 'no'; // wpcs: csrf ok.
454
+		$stripe_params['is_add_payment_page']       = is_wc_endpoint_url('add-payment-method') ? 'yes' : 'no';
455
+		$stripe_params['is_pay_for_order_page']     = is_wc_endpoint_url('order-pay') ? 'yes' : 'no';
456
+		$stripe_params['elements_styling']          = apply_filters('wc_stripe_elements_styling', false);
457
+		$stripe_params['elements_classes']          = apply_filters('wc_stripe_elements_classes', false);
458 458
 
459 459
 		// Merge localized messages to be use in JS.
460
-		$stripe_params = array_merge( $stripe_params, WC_Stripe_Helper::get_localized_messages() );
460
+		$stripe_params = array_merge($stripe_params, WC_Stripe_Helper::get_localized_messages());
461 461
 
462
-		wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
462
+		wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
463 463
 
464 464
 		$this->tokenization_script();
465
-		wp_enqueue_script( 'woocommerce_stripe' );
465
+		wp_enqueue_script('woocommerce_stripe');
466 466
 	}
467 467
 
468 468
 	/**
@@ -473,14 +473,14 @@  discard block
 block discarded – undo
473 473
 	 * @param object $prepared_source The object with source details.
474 474
 	 * @throws WC_Stripe_Exception An exception if the card is prepaid, but prepaid cards are not allowed.
475 475
 	 */
476
-	public function maybe_disallow_prepaid_card( $prepared_source ) {
476
+	public function maybe_disallow_prepaid_card($prepared_source) {
477 477
 		// Check if we don't allow prepaid credit cards.
478
-		if ( apply_filters( 'wc_stripe_allow_prepaid_card', true ) || ! $this->is_prepaid_card( $prepared_source->source_object ) ) {
478
+		if (apply_filters('wc_stripe_allow_prepaid_card', true) || ! $this->is_prepaid_card($prepared_source->source_object)) {
479 479
 			return;
480 480
 		}
481 481
 
482
-		$localized_message = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
483
-		throw new WC_Stripe_Exception( print_r( $prepared_source->source_object, true ), $localized_message );
482
+		$localized_message = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
483
+		throw new WC_Stripe_Exception(print_r($prepared_source->source_object, true), $localized_message);
484 484
 	}
485 485
 
486 486
 	/**
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
 	 * @param  object $prepared_source The source that should be verified.
491 491
 	 * @throws WC_Stripe_Exception     An exception if the source ID is missing.
492 492
 	 */
493
-	public function check_source( $prepared_source ) {
494
-		if ( empty( $prepared_source->source ) ) {
495
-			$localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
496
-			throw new WC_Stripe_Exception( print_r( $prepared_source, true ), $localized_message );
493
+	public function check_source($prepared_source) {
494
+		if (empty($prepared_source->source)) {
495
+			$localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
496
+			throw new WC_Stripe_Exception(print_r($prepared_source, true), $localized_message);
497 497
 		}
498 498
 	}
499 499
 
@@ -505,17 +505,17 @@  discard block
 block discarded – undo
505 505
 	 * @param WC_Order $order The order those payment is being processed.
506 506
 	 * @return bool           A flag that indicates that the customer does not exist and should be removed.
507 507
 	 */
508
-	public function maybe_remove_non_existent_customer( $error, $order ) {
509
-		if ( ! $this->is_no_such_customer_error( $error ) ) {
508
+	public function maybe_remove_non_existent_customer($error, $order) {
509
+		if ( ! $this->is_no_such_customer_error($error)) {
510 510
 			return false;
511 511
 		}
512 512
 
513
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
514
-			delete_user_option( $order->customer_user, '_stripe_customer_id' );
515
-			delete_post_meta( $order->get_id(), '_stripe_customer_id' );
513
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
514
+			delete_user_option($order->customer_user, '_stripe_customer_id');
515
+			delete_post_meta($order->get_id(), '_stripe_customer_id');
516 516
 		} else {
517
-			delete_user_option( $order->get_customer_id(), '_stripe_customer_id' );
518
-			$order->delete_meta_data( '_stripe_customer_id' );
517
+			delete_user_option($order->get_customer_id(), '_stripe_customer_id');
518
+			$order->delete_meta_data('_stripe_customer_id');
519 519
 			$order->save();
520 520
 		}
521 521
 
@@ -531,15 +531,15 @@  discard block
 block discarded – undo
531 531
 	 * @param boolean  $force_save_source Whether the payment source must be saved, like when dealing with a Subscription setup.
532 532
 	 * @return array                      Redirection data for `process_payment`.
533 533
 	 */
534
-	public function complete_free_order( $order, $prepared_source, $force_save_source ) {
535
-		if ( $force_save_source ) {
536
-			$intent_secret = $this->setup_intent( $order, $prepared_source );
534
+	public function complete_free_order($order, $prepared_source, $force_save_source) {
535
+		if ($force_save_source) {
536
+			$intent_secret = $this->setup_intent($order, $prepared_source);
537 537
 
538
-			if ( ! empty( $intent_secret ) ) {
538
+			if ( ! empty($intent_secret)) {
539 539
 				// `get_return_url()` must be called immediately before returning a value.
540 540
 				return array(
541 541
 					'result'              => 'success',
542
-					'redirect'            => $this->get_return_url( $order ),
542
+					'redirect'            => $this->get_return_url($order),
543 543
 					'setup_intent_secret' => $intent_secret,
544 544
 				);
545 545
 			}
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 		// Return thank you page redirect.
554 554
 		return array(
555 555
 			'result'   => 'success',
556
-			'redirect' => $this->get_return_url( $order ),
556
+			'redirect' => $this->get_return_url($order),
557 557
 		);
558 558
 	}
559 559
 
@@ -571,81 +571,81 @@  discard block
 block discarded – undo
571 571
 	 * @throws Exception If payment will not be accepted.
572 572
 	 * @return array|void
573 573
 	 */
574
-	public function process_payment( $order_id, $retry = true, $force_save_source = false, $previous_error = false, $use_order_source = false ) {
574
+	public function process_payment($order_id, $retry = true, $force_save_source = false, $previous_error = false, $use_order_source = false) {
575 575
 		try {
576
-			$order = wc_get_order( $order_id );
576
+			$order = wc_get_order($order_id);
577 577
 
578 578
 			// ToDo: `process_pre_order` saves the source to the order for a later payment.
579 579
 			// This might not work well with PaymentIntents.
580
-			if ( $this->maybe_process_pre_orders( $order_id ) ) {
581
-				return $this->pre_orders->process_pre_order( $order_id );
580
+			if ($this->maybe_process_pre_orders($order_id)) {
581
+				return $this->pre_orders->process_pre_order($order_id);
582 582
 			}
583 583
 
584 584
 			// Check whether there is an existing intent.
585
-			$intent = $this->get_intent_from_order( $order );
586
-			if ( isset( $intent->object ) && 'setup_intent' === $intent->object ) {
585
+			$intent = $this->get_intent_from_order($order);
586
+			if (isset($intent->object) && 'setup_intent' === $intent->object) {
587 587
 				$intent = false; // This function can only deal with *payment* intents
588 588
 			}
589 589
 
590 590
 			$stripe_customer_id = null;
591
-			if ( $intent && ! empty( $intent->customer ) ) {
591
+			if ($intent && ! empty($intent->customer)) {
592 592
 				$stripe_customer_id = $intent->customer;
593 593
 			}
594 594
 
595 595
 			// For some payments the source should already be present in the order.
596
-			if ( $use_order_source ) {
597
-				$prepared_source = $this->prepare_order_source( $order );
596
+			if ($use_order_source) {
597
+				$prepared_source = $this->prepare_order_source($order);
598 598
 			} else {
599
-				$prepared_source = $this->prepare_source( get_current_user_id(), $force_save_source, $stripe_customer_id );
599
+				$prepared_source = $this->prepare_source(get_current_user_id(), $force_save_source, $stripe_customer_id);
600 600
 			}
601 601
 
602
-			$this->maybe_disallow_prepaid_card( $prepared_source );
603
-			$this->check_source( $prepared_source );
604
-			$this->save_source_to_order( $order, $prepared_source );
602
+			$this->maybe_disallow_prepaid_card($prepared_source);
603
+			$this->check_source($prepared_source);
604
+			$this->save_source_to_order($order, $prepared_source);
605 605
 
606
-			if ( 0 >= $order->get_total() ) {
607
-				return $this->complete_free_order( $order, $prepared_source, $force_save_source );
606
+			if (0 >= $order->get_total()) {
607
+				return $this->complete_free_order($order, $prepared_source, $force_save_source);
608 608
 			}
609 609
 
610 610
 			// This will throw exception if not valid.
611
-			$this->validate_minimum_order_amount( $order );
611
+			$this->validate_minimum_order_amount($order);
612 612
 
613
-			WC_Stripe_Logger::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
613
+			WC_Stripe_Logger::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}");
614 614
 
615
-			if ( $intent ) {
616
-				$intent = $this->update_existing_intent( $intent, $order, $prepared_source );
615
+			if ($intent) {
616
+				$intent = $this->update_existing_intent($intent, $order, $prepared_source);
617 617
 			} else {
618
-				$intent = $this->create_intent( $order, $prepared_source );
618
+				$intent = $this->create_intent($order, $prepared_source);
619 619
 			}
620 620
 
621 621
 			// Confirm the intent after locking the order to make sure webhooks will not interfere.
622
-			if ( empty( $intent->error ) ) {
623
-				$this->lock_order_payment( $order, $intent );
624
-				$intent = $this->confirm_intent( $intent, $order, $prepared_source );
622
+			if (empty($intent->error)) {
623
+				$this->lock_order_payment($order, $intent);
624
+				$intent = $this->confirm_intent($intent, $order, $prepared_source);
625 625
 			}
626 626
 
627
-			if ( ! empty( $intent->error ) ) {
628
-				$this->maybe_remove_non_existent_customer( $intent->error, $order );
627
+			if ( ! empty($intent->error)) {
628
+				$this->maybe_remove_non_existent_customer($intent->error, $order);
629 629
 
630 630
 				// We want to retry.
631
-				if ( $this->is_retryable_error( $intent->error ) ) {
632
-					return $this->retry_after_error( $intent, $order, $retry, $force_save_source, $previous_error, $use_order_source );
631
+				if ($this->is_retryable_error($intent->error)) {
632
+					return $this->retry_after_error($intent, $order, $retry, $force_save_source, $previous_error, $use_order_source);
633 633
 				}
634 634
 
635
-				$this->unlock_order_payment( $order );
636
-				$this->throw_localized_message( $intent, $order );
635
+				$this->unlock_order_payment($order);
636
+				$this->throw_localized_message($intent, $order);
637 637
 			}
638 638
 
639
-			if ( ! empty( $intent ) ) {
639
+			if ( ! empty($intent)) {
640 640
 				// Use the last charge within the intent to proceed.
641
-				$response = end( $intent->charges->data );
641
+				$response = end($intent->charges->data);
642 642
 
643 643
 				// If the intent requires a 3DS flow, redirect to it.
644
-				if ( 'requires_action' === $intent->status ) {
645
-					$this->unlock_order_payment( $order );
644
+				if ('requires_action' === $intent->status) {
645
+					$this->unlock_order_payment($order);
646 646
 
647
-					if ( is_wc_endpoint_url( 'order-pay' ) ) {
648
-						$redirect_url = add_query_arg( 'wc-stripe-confirmation', 1, $order->get_checkout_payment_url( false ) );
647
+					if (is_wc_endpoint_url('order-pay')) {
648
+						$redirect_url = add_query_arg('wc-stripe-confirmation', 1, $order->get_checkout_payment_url(false));
649 649
 
650 650
 						return array(
651 651
 							'result'   => 'success',
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 
661 661
 						return array(
662 662
 							'result'                => 'success',
663
-							'redirect'              => $this->get_return_url( $order ),
663
+							'redirect'              => $this->get_return_url($order),
664 664
 							'payment_intent_secret' => $intent->client_secret,
665 665
 						);
666 666
 					}
@@ -668,30 +668,30 @@  discard block
 block discarded – undo
668 668
 			}
669 669
 
670 670
 			// Process valid response.
671
-			$this->process_response( $response, $order );
671
+			$this->process_response($response, $order);
672 672
 
673 673
 			// Remove cart.
674
-			if ( isset( WC()->cart ) ) {
674
+			if (isset(WC()->cart)) {
675 675
 				WC()->cart->empty_cart();
676 676
 			}
677 677
 
678 678
 			// Unlock the order.
679
-			$this->unlock_order_payment( $order );
679
+			$this->unlock_order_payment($order);
680 680
 
681 681
 			// Return thank you page redirect.
682 682
 			return array(
683 683
 				'result'   => 'success',
684
-				'redirect' => $this->get_return_url( $order ),
684
+				'redirect' => $this->get_return_url($order),
685 685
 			);
686 686
 
687
-		} catch ( WC_Stripe_Exception $e ) {
688
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
689
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
687
+		} catch (WC_Stripe_Exception $e) {
688
+			wc_add_notice($e->getLocalizedMessage(), 'error');
689
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
690 690
 
691
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
691
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
692 692
 
693 693
 			/* translators: error message */
694
-			$order->update_status( 'failed' );
694
+			$order->update_status('failed');
695 695
 
696 696
 			return array(
697 697
 				'result'   => 'fail',
@@ -707,17 +707,17 @@  discard block
 block discarded – undo
707 707
 	 *
708 708
 	 * @param int $order_id The ID of the order.
709 709
 	 */
710
-	public function display_order_fee( $order_id ) {
711
-		if ( apply_filters( 'wc_stripe_hide_display_order_fee', false, $order_id ) ) {
710
+	public function display_order_fee($order_id) {
711
+		if (apply_filters('wc_stripe_hide_display_order_fee', false, $order_id)) {
712 712
 			return;
713 713
 		}
714 714
 
715
-		$order = wc_get_order( $order_id );
715
+		$order = wc_get_order($order_id);
716 716
 
717
-		$fee      = WC_Stripe_Helper::get_stripe_fee( $order );
718
-		$currency = WC_Stripe_Helper::get_stripe_currency( $order );
717
+		$fee      = WC_Stripe_Helper::get_stripe_fee($order);
718
+		$currency = WC_Stripe_Helper::get_stripe_currency($order);
719 719
 
720
-		if ( ! $fee || ! $currency ) {
720
+		if ( ! $fee || ! $currency) {
721 721
 			return;
722 722
 		}
723 723
 
@@ -725,12 +725,12 @@  discard block
 block discarded – undo
725 725
 
726 726
 		<tr>
727 727
 			<td class="label stripe-fee">
728
-				<?php echo wc_help_tip( __( 'This represents the fee Stripe collects for the transaction.', 'woocommerce-gateway-stripe' ) ); // wpcs: xss ok. ?>
729
-				<?php esc_html_e( 'Stripe Fee:', 'woocommerce-gateway-stripe' ); ?>
728
+				<?php echo wc_help_tip(__('This represents the fee Stripe collects for the transaction.', 'woocommerce-gateway-stripe')); // wpcs: xss ok. ?>
729
+				<?php esc_html_e('Stripe Fee:', 'woocommerce-gateway-stripe'); ?>
730 730
 			</td>
731 731
 			<td width="1%"></td>
732 732
 			<td class="total">
733
-				-&nbsp;<?php echo wc_price( $fee, array( 'currency' => $currency ) ); // wpcs: xss ok. ?>
733
+				-&nbsp;<?php echo wc_price($fee, array('currency' => $currency)); // wpcs: xss ok. ?>
734 734
 			</td>
735 735
 		</tr>
736 736
 
@@ -744,17 +744,17 @@  discard block
 block discarded – undo
744 744
 	 *
745 745
 	 * @param int $order_id The ID of the order.
746 746
 	 */
747
-	public function display_order_payout( $order_id ) {
748
-		if ( apply_filters( 'wc_stripe_hide_display_order_payout', false, $order_id ) ) {
747
+	public function display_order_payout($order_id) {
748
+		if (apply_filters('wc_stripe_hide_display_order_payout', false, $order_id)) {
749 749
 			return;
750 750
 		}
751 751
 
752
-		$order = wc_get_order( $order_id );
752
+		$order = wc_get_order($order_id);
753 753
 
754
-		$net      = WC_Stripe_Helper::get_stripe_net( $order );
755
-		$currency = WC_Stripe_Helper::get_stripe_currency( $order );
754
+		$net      = WC_Stripe_Helper::get_stripe_net($order);
755
+		$currency = WC_Stripe_Helper::get_stripe_currency($order);
756 756
 
757
-		if ( ! $net || ! $currency ) {
757
+		if ( ! $net || ! $currency) {
758 758
 			return;
759 759
 		}
760 760
 
@@ -762,12 +762,12 @@  discard block
 block discarded – undo
762 762
 
763 763
 		<tr>
764 764
 			<td class="label stripe-payout">
765
-				<?php echo wc_help_tip( __( 'This represents the net total that will be credited to your Stripe bank account. This may be in the currency that is set in your Stripe account.', 'woocommerce-gateway-stripe' ) ); // wpcs: xss ok. ?>
766
-				<?php esc_html_e( 'Stripe Payout:', 'woocommerce-gateway-stripe' ); ?>
765
+				<?php echo wc_help_tip(__('This represents the net total that will be credited to your Stripe bank account. This may be in the currency that is set in your Stripe account.', 'woocommerce-gateway-stripe')); // wpcs: xss ok. ?>
766
+				<?php esc_html_e('Stripe Payout:', 'woocommerce-gateway-stripe'); ?>
767 767
 			</td>
768 768
 			<td width="1%"></td>
769 769
 			<td class="total">
770
-				<?php echo wc_price( $net, array( 'currency' => $currency ) ); // wpcs: xss ok. ?>
770
+				<?php echo wc_price($net, array('currency' => $currency)); // wpcs: xss ok. ?>
771 771
 			</td>
772 772
 		</tr>
773 773
 
@@ -783,13 +783,13 @@  discard block
 block discarded – undo
783 783
 	 *
784 784
 	 * @return string The localized error message.
785 785
 	 */
786
-	public function get_localized_error_message_from_response( $response ) {
786
+	public function get_localized_error_message_from_response($response) {
787 787
 		$localized_messages = WC_Stripe_Helper::get_localized_messages();
788 788
 
789
-		if ( 'card_error' === $response->error->type ) {
790
-			$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
789
+		if ('card_error' === $response->error->type) {
790
+			$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
791 791
 		} else {
792
-			$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
792
+			$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
793 793
 		}
794 794
 
795 795
 		return $localized_message;
@@ -803,12 +803,12 @@  discard block
 block discarded – undo
803 803
 	 * @param  WC_Order $order     The order to add a note to.
804 804
 	 * @throws WC_Stripe_Exception An exception with the right message.
805 805
 	 */
806
-	public function throw_localized_message( $response, $order ) {
807
-		$localized_message = $this->get_localized_error_message_from_response( $response );
806
+	public function throw_localized_message($response, $order) {
807
+		$localized_message = $this->get_localized_error_message_from_response($response);
808 808
 
809
-		$order->add_order_note( $localized_message );
809
+		$order->add_order_note($localized_message);
810 810
 
811
-		throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
811
+		throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
812 812
 	}
813 813
 
814 814
 	/**
@@ -824,22 +824,22 @@  discard block
 block discarded – undo
824 824
 	 * @throws WC_Stripe_Exception        If the payment is not accepted.
825 825
 	 * @return array|void
826 826
 	 */
827
-	public function retry_after_error( $response, $order, $retry, $force_save_source, $previous_error, $use_order_source ) {
828
-		if ( ! $retry ) {
829
-			$localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' );
830
-			$order->add_order_note( $localized_message );
831
-			throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.
827
+	public function retry_after_error($response, $order, $retry, $force_save_source, $previous_error, $use_order_source) {
828
+		if ( ! $retry) {
829
+			$localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe');
830
+			$order->add_order_note($localized_message);
831
+			throw new WC_Stripe_Exception(print_r($response, true), $localized_message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.
832 832
 		}
833 833
 
834 834
 		// Don't do anymore retries after this.
835
-		if ( 5 <= $this->retry_interval ) {
836
-			return $this->process_payment( $order->get_id(), false, $force_save_source, $response->error, $previous_error );
835
+		if (5 <= $this->retry_interval) {
836
+			return $this->process_payment($order->get_id(), false, $force_save_source, $response->error, $previous_error);
837 837
 		}
838 838
 
839
-		sleep( $this->retry_interval );
839
+		sleep($this->retry_interval);
840 840
 		$this->retry_interval++;
841 841
 
842
-		return $this->process_payment( $order->get_id(), true, $force_save_source, $response->error, $previous_error, $use_order_source );
842
+		return $this->process_payment($order->get_id(), true, $force_save_source, $response->error, $previous_error, $use_order_source);
843 843
 	}
844 844
 
845 845
 	/**
@@ -850,23 +850,23 @@  discard block
 block discarded – undo
850 850
 	 * @param WC_Payment_Gateway[] $gateways A list of all available gateways.
851 851
 	 * @return WC_Payment_Gateway[]          Either the same list or an empty one in the right conditions.
852 852
 	 */
853
-	public function prepare_order_pay_page( $gateways ) {
854
-		if ( ! is_wc_endpoint_url( 'order-pay' ) || ! isset( $_GET['wc-stripe-confirmation'] ) ) { // wpcs: csrf ok.
853
+	public function prepare_order_pay_page($gateways) {
854
+		if ( ! is_wc_endpoint_url('order-pay') || ! isset($_GET['wc-stripe-confirmation'])) { // wpcs: csrf ok.
855 855
 			return $gateways;
856 856
 		}
857 857
 
858 858
 		try {
859 859
 			$this->prepare_intent_for_order_pay_page();
860
-		} catch ( WC_Stripe_Exception $e ) {
860
+		} catch (WC_Stripe_Exception $e) {
861 861
 			// Just show the full order pay page if there was a problem preparing the Payment Intent
862 862
 			return $gateways;
863 863
 		}
864 864
 
865
-		add_filter( 'woocommerce_checkout_show_terms', '__return_false' );
866
-		add_filter( 'woocommerce_pay_order_button_html', '__return_false' );
867
-		add_filter( 'woocommerce_available_payment_gateways', '__return_empty_array' );
868
-		add_filter( 'woocommerce_no_available_payment_methods_message', array( $this, 'change_no_available_methods_message' ) );
869
-		add_action( 'woocommerce_pay_order_after_submit', array( $this, 'render_payment_intent_inputs' ) );
865
+		add_filter('woocommerce_checkout_show_terms', '__return_false');
866
+		add_filter('woocommerce_pay_order_button_html', '__return_false');
867
+		add_filter('woocommerce_available_payment_gateways', '__return_empty_array');
868
+		add_filter('woocommerce_no_available_payment_methods_message', array($this, 'change_no_available_methods_message'));
869
+		add_action('woocommerce_pay_order_after_submit', array($this, 'render_payment_intent_inputs'));
870 870
 
871 871
 		return array();
872 872
 	}
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
 	 * @return string the new message.
880 880
 	 */
881 881
 	public function change_no_available_methods_message() {
882
-		return wpautop( __( "Almost there!\n\nYour order has already been created, the only thing that still needs to be done is for you to authorize the payment with your bank.", 'woocommerce-gateway-stripe' ) );
882
+		return wpautop(__("Almost there!\n\nYour order has already been created, the only thing that still needs to be done is for you to authorize the payment with your bank.", 'woocommerce-gateway-stripe'));
883 883
 	}
884 884
 
885 885
 	/**
@@ -890,19 +890,19 @@  discard block
 block discarded – undo
890 890
 	 * @throws WC_Stripe_Exception
891 891
 	 * @since 4.3
892 892
 	 */
893
-	public function prepare_intent_for_order_pay_page( $order = null ) {
894
-		if ( ! isset( $order ) || empty( $order ) ) {
895
-			$order = wc_get_order( absint( get_query_var( 'order-pay' ) ) );
893
+	public function prepare_intent_for_order_pay_page($order = null) {
894
+		if ( ! isset($order) || empty($order)) {
895
+			$order = wc_get_order(absint(get_query_var('order-pay')));
896 896
 		}
897
-		$intent = $this->get_intent_from_order( $order );
897
+		$intent = $this->get_intent_from_order($order);
898 898
 
899
-		if ( ! $intent ) {
900
-			throw new WC_Stripe_Exception( 'Payment Intent not found', __( 'Payment Intent not found for order #' . $order->get_id(), 'woocommerce-gateway-stripe' ) );
899
+		if ( ! $intent) {
900
+			throw new WC_Stripe_Exception('Payment Intent not found', __('Payment Intent not found for order #' . $order->get_id(), 'woocommerce-gateway-stripe'));
901 901
 		}
902 902
 
903
-		if ( 'requires_payment_method' === $intent->status && isset( $intent->last_payment_error )
904
-		     && 'authentication_required' === $intent->last_payment_error->code ) {
905
-			$level3_data = $this->get_level3_data_from_order( $order );
903
+		if ('requires_payment_method' === $intent->status && isset($intent->last_payment_error)
904
+		     && 'authentication_required' === $intent->last_payment_error->code) {
905
+			$level3_data = $this->get_level3_data_from_order($order);
906 906
 			$intent      = WC_Stripe_API::request_with_level3_data(
907 907
 				array(
908 908
 					'payment_method' => $intent->last_payment_error->source->id,
@@ -912,8 +912,8 @@  discard block
 block discarded – undo
912 912
 				$order
913 913
 			);
914 914
 
915
-			if ( isset( $intent->error ) ) {
916
-				throw new WC_Stripe_Exception( print_r( $intent, true ), $intent->error->message );
915
+			if (isset($intent->error)) {
916
+				throw new WC_Stripe_Exception(print_r($intent, true), $intent->error->message);
917 917
 			}
918 918
 		}
919 919
 
@@ -928,26 +928,26 @@  discard block
 block discarded – undo
928 928
 	 * @throws WC_Stripe_Exception
929 929
 	 * @since 4.2
930 930
 	 */
931
-	public function render_payment_intent_inputs( $order = null ) {
932
-		if ( ! isset( $order ) || empty( $order ) ) {
933
-			$order = wc_get_order( absint( get_query_var( 'order-pay' ) ) );
931
+	public function render_payment_intent_inputs($order = null) {
932
+		if ( ! isset($order) || empty($order)) {
933
+			$order = wc_get_order(absint(get_query_var('order-pay')));
934 934
 		}
935
-		if ( ! isset( $this->order_pay_intent ) ) {
936
-			$this->prepare_intent_for_order_pay_page( $order );
935
+		if ( ! isset($this->order_pay_intent)) {
936
+			$this->prepare_intent_for_order_pay_page($order);
937 937
 		}
938 938
 
939 939
 		$verification_url = add_query_arg(
940 940
 			array(
941 941
 				'order'            => $order->get_id(),
942
-				'nonce'            => wp_create_nonce( 'wc_stripe_confirm_pi' ),
943
-				'redirect_to'      => rawurlencode( $this->get_return_url( $order ) ),
942
+				'nonce'            => wp_create_nonce('wc_stripe_confirm_pi'),
943
+				'redirect_to'      => rawurlencode($this->get_return_url($order)),
944 944
 				'is_pay_for_order' => true,
945 945
 			),
946
-			WC_AJAX::get_endpoint( 'wc_stripe_verify_intent' )
946
+			WC_AJAX::get_endpoint('wc_stripe_verify_intent')
947 947
 		);
948 948
 
949
-		echo '<input type="hidden" id="stripe-intent-id" value="' . esc_attr( $this->order_pay_intent->client_secret ) . '" />';
950
-		echo '<input type="hidden" id="stripe-intent-return" value="' . esc_attr( $verification_url ) . '" />';
949
+		echo '<input type="hidden" id="stripe-intent-id" value="' . esc_attr($this->order_pay_intent->client_secret) . '" />';
950
+		echo '<input type="hidden" id="stripe-intent-return" value="' . esc_attr($verification_url) . '" />';
951 951
 	}
952 952
 
953 953
 	/**
@@ -957,11 +957,11 @@  discard block
 block discarded – undo
957 957
 	 * @param WC_Payment_Token $token Payment Token.
958 958
 	 * @return string                 Generated payment method HTML
959 959
 	 */
960
-	public function get_saved_payment_method_option_html( $token ) {
961
-		$html          = parent::get_saved_payment_method_option_html( $token );
960
+	public function get_saved_payment_method_option_html($token) {
961
+		$html          = parent::get_saved_payment_method_option_html($token);
962 962
 		$error_wrapper = '<div class="stripe-source-errors" role="alert"></div>';
963 963
 
964
-		return preg_replace( '~</(\w+)>\s*$~', "$error_wrapper</$1>", $html );
964
+		return preg_replace('~</(\w+)>\s*$~', "$error_wrapper</$1>", $html);
965 965
 	}
966 966
 
967 967
 	/**
@@ -971,18 +971,18 @@  discard block
 block discarded – undo
971 971
 	 * @since 4.2.0
972 972
 	 * @param int $order_id The ID that will be used for the thank you page.
973 973
 	 */
974
-	public function check_intent_status_on_order_page( $order_id ) {
975
-		if ( empty( $order_id ) || absint( $order_id ) <= 0 ) {
974
+	public function check_intent_status_on_order_page($order_id) {
975
+		if (empty($order_id) || absint($order_id) <= 0) {
976 976
 			return;
977 977
 		}
978 978
 
979
-		$order = wc_get_order( absint( $order_id ) );
979
+		$order = wc_get_order(absint($order_id));
980 980
 
981
-		if ( ! $order ) {
981
+		if ( ! $order) {
982 982
 			return;
983 983
 		}
984 984
 
985
-		$this->verify_intent_after_checkout( $order );
985
+		$this->verify_intent_after_checkout($order);
986 986
 	}
987 987
 
988 988
 	/**
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
 	 * @param int   $order_id The ID of the order which is being paid for.
997 997
 	 * @return array
998 998
 	 */
999
-	public function modify_successful_payment_result( $result, $order_id ) {
1000
-		if ( ! isset( $result['payment_intent_secret'] ) && ! isset( $result['setup_intent_secret'] ) ) {
999
+	public function modify_successful_payment_result($result, $order_id) {
1000
+		if ( ! isset($result['payment_intent_secret']) && ! isset($result['setup_intent_secret'])) {
1001 1001
 			// Only redirects with intents need to be modified.
1002 1002
 			return $result;
1003 1003
 		}
@@ -1006,16 +1006,16 @@  discard block
 block discarded – undo
1006 1006
 		$verification_url = add_query_arg(
1007 1007
 			array(
1008 1008
 				'order'       => $order_id,
1009
-				'nonce'       => wp_create_nonce( 'wc_stripe_confirm_pi' ),
1010
-				'redirect_to' => rawurlencode( $result['redirect'] ),
1009
+				'nonce'       => wp_create_nonce('wc_stripe_confirm_pi'),
1010
+				'redirect_to' => rawurlencode($result['redirect']),
1011 1011
 			),
1012
-			WC_AJAX::get_endpoint( 'wc_stripe_verify_intent' )
1012
+			WC_AJAX::get_endpoint('wc_stripe_verify_intent')
1013 1013
 		);
1014 1014
 
1015
-		if ( isset( $result['payment_intent_secret'] ) ) {
1016
-			$redirect = sprintf( '#confirm-pi-%s:%s', $result['payment_intent_secret'], rawurlencode( $verification_url ) );
1017
-		} else if ( isset( $result['setup_intent_secret'] ) ) {
1018
-			$redirect = sprintf( '#confirm-si-%s:%s', $result['setup_intent_secret'], rawurlencode( $verification_url ) );
1015
+		if (isset($result['payment_intent_secret'])) {
1016
+			$redirect = sprintf('#confirm-pi-%s:%s', $result['payment_intent_secret'], rawurlencode($verification_url));
1017
+		} else if (isset($result['setup_intent_secret'])) {
1018
+			$redirect = sprintf('#confirm-si-%s:%s', $result['setup_intent_secret'], rawurlencode($verification_url));
1019 1019
 		}
1020 1020
 
1021 1021
 		return array(
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 	/**
1028 1028
 	 * Proceed with current request using new login session (to ensure consistent nonce).
1029 1029
 	 */
1030
-	public function set_cookie_on_current_request( $cookie ) {
1031
-		$_COOKIE[ LOGGED_IN_COOKIE ] = $cookie;
1030
+	public function set_cookie_on_current_request($cookie) {
1031
+		$_COOKIE[LOGGED_IN_COOKIE] = $cookie;
1032 1032
 	}
1033 1033
 
1034 1034
 	/**
@@ -1038,48 +1038,48 @@  discard block
 block discarded – undo
1038 1038
 	 * @since 4.2.0
1039 1039
 	 * @param WC_Order $order The order which is in a transitional state.
1040 1040
 	 */
1041
-	public function verify_intent_after_checkout( $order ) {
1042
-		$payment_method = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method();
1043
-		if ( $payment_method !== $this->id ) {
1041
+	public function verify_intent_after_checkout($order) {
1042
+		$payment_method = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method();
1043
+		if ($payment_method !== $this->id) {
1044 1044
 			// If this is not the payment method, an intent would not be available.
1045 1045
 			return;
1046 1046
 		}
1047 1047
 
1048
-		$intent = $this->get_intent_from_order( $order );
1049
-		if ( ! $intent ) {
1048
+		$intent = $this->get_intent_from_order($order);
1049
+		if ( ! $intent) {
1050 1050
 			// No intent, redirect to the order received page for further actions.
1051 1051
 			return;
1052 1052
 		}
1053 1053
 
1054 1054
 		// A webhook might have modified or locked the order while the intent was retreived. This ensures we are reading the right status.
1055
-		clean_post_cache( $order->get_id() );
1056
-		$order = wc_get_order( $order->get_id() );
1055
+		clean_post_cache($order->get_id());
1056
+		$order = wc_get_order($order->get_id());
1057 1057
 
1058
-		if ( ! $order->has_status( array( 'pending', 'failed' ) ) ) {
1058
+		if ( ! $order->has_status(array('pending', 'failed'))) {
1059 1059
 			// If payment has already been completed, this function is redundant.
1060 1060
 			return;
1061 1061
 		}
1062 1062
 
1063
-		if ( $this->lock_order_payment( $order, $intent ) ) {
1063
+		if ($this->lock_order_payment($order, $intent)) {
1064 1064
 			return;
1065 1065
 		}
1066 1066
 
1067
-		if ( 'setup_intent' === $intent->object && 'succeeded' === $intent->status ) {
1067
+		if ('setup_intent' === $intent->object && 'succeeded' === $intent->status) {
1068 1068
 			WC()->cart->empty_cart();
1069
-			if ( WC_Stripe_Helper::is_pre_orders_exists() && WC_Pre_Orders_Order::order_contains_pre_order( $order ) ) {
1070
-				WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order );
1069
+			if (WC_Stripe_Helper::is_pre_orders_exists() && WC_Pre_Orders_Order::order_contains_pre_order($order)) {
1070
+				WC_Pre_Orders_Order::mark_order_as_pre_ordered($order);
1071 1071
 			} else {
1072 1072
 				$order->payment_complete();
1073 1073
 			}
1074
-		} else if ( 'succeeded' === $intent->status || 'requires_capture' === $intent->status ) {
1074
+		} else if ('succeeded' === $intent->status || 'requires_capture' === $intent->status) {
1075 1075
 			// Proceed with the payment completion.
1076
-			$this->handle_intent_verification_success( $order, $intent );
1077
-		} else if ( 'requires_payment_method' === $intent->status ) {
1076
+			$this->handle_intent_verification_success($order, $intent);
1077
+		} else if ('requires_payment_method' === $intent->status) {
1078 1078
 			// `requires_payment_method` means that SCA got denied for the current payment method.
1079
-			$this->handle_intent_verification_failure( $order, $intent );
1079
+			$this->handle_intent_verification_failure($order, $intent);
1080 1080
 		}
1081 1081
 
1082
-		$this->unlock_order_payment( $order );
1082
+		$this->unlock_order_payment($order);
1083 1083
 	}
1084 1084
 
1085 1085
 	/**
@@ -1089,8 +1089,8 @@  discard block
 block discarded – undo
1089 1089
 	 * @param WC_Order $order The order whose verification succeeded.
1090 1090
 	 * @param stdClass $intent The Payment Intent object.
1091 1091
 	 */
1092
-	protected function handle_intent_verification_success( $order, $intent ) {
1093
-		$this->process_response( end( $intent->charges->data ), $order );
1092
+	protected function handle_intent_verification_success($order, $intent) {
1093
+		$this->process_response(end($intent->charges->data), $order);
1094 1094
 	}
1095 1095
 
1096 1096
 	/**
@@ -1100,8 +1100,8 @@  discard block
 block discarded – undo
1100 1100
 	 * @param WC_Order $order The order whose verification failed.
1101 1101
 	 * @param stdClass $intent The Payment Intent object.
1102 1102
 	 */
1103
-	protected function handle_intent_verification_failure( $order, $intent ) {
1104
-		$this->failed_sca_auth( $order, $intent );
1103
+	protected function handle_intent_verification_failure($order, $intent) {
1104
+		$this->failed_sca_auth($order, $intent);
1105 1105
 	}
1106 1106
 
1107 1107
 	/**
@@ -1111,18 +1111,18 @@  discard block
 block discarded – undo
1111 1111
 	 * @param WC_Order $order  The order which should be checked.
1112 1112
 	 * @param object   $intent The intent, associated with the order.
1113 1113
 	 */
1114
-	public function failed_sca_auth( $order, $intent ) {
1114
+	public function failed_sca_auth($order, $intent) {
1115 1115
 		// If the order has already failed, do not repeat the same message.
1116
-		if ( $order->has_status( 'failed' ) ) {
1116
+		if ($order->has_status('failed')) {
1117 1117
 			return;
1118 1118
 		}
1119 1119
 
1120 1120
 		// Load the right message and update the status.
1121
-		$status_message = isset( $intent->last_payment_error )
1121
+		$status_message = isset($intent->last_payment_error)
1122 1122
 			/* translators: 1) The error message that was received from Stripe. */
1123
-			? sprintf( __( 'Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe' ), $intent->last_payment_error->message )
1124
-			: __( 'Stripe SCA authentication failed.', 'woocommerce-gateway-stripe' );
1125
-		$order->update_status( 'failed', $status_message );
1123
+			? sprintf(__('Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe'), $intent->last_payment_error->message)
1124
+			: __('Stripe SCA authentication failed.', 'woocommerce-gateway-stripe');
1125
+		$order->update_status('failed', $status_message);
1126 1126
 	}
1127 1127
 
1128 1128
 	/**
@@ -1133,10 +1133,10 @@  discard block
 block discarded – undo
1133 1133
 	 *
1134 1134
 	 * @return string Checkout URL for the given order.
1135 1135
 	 */
1136
-	public function get_checkout_payment_url( $pay_url, $order ) {
1136
+	public function get_checkout_payment_url($pay_url, $order) {
1137 1137
 		global $wp;
1138
-		if ( isset( $_GET['wc-stripe-confirmation'] ) && isset( $wp->query_vars['order-pay'] ) && $wp->query_vars['order-pay'] == $order->get_id() ) {
1139
-			$pay_url = add_query_arg( 'wc-stripe-confirmation', 1, $pay_url );
1138
+		if (isset($_GET['wc-stripe-confirmation']) && isset($wp->query_vars['order-pay']) && $wp->query_vars['order-pay'] == $order->get_id()) {
1139
+			$pay_url = add_query_arg('wc-stripe-confirmation', 1, $pay_url);
1140 1140
 		}
1141 1141
 		return $pay_url;
1142 1142
 	}
@@ -1146,63 +1146,63 @@  discard block
 block discarded – undo
1146 1146
 	 */
1147 1147
 	public function process_admin_options() {
1148 1148
 		// Load all old values before the new settings get saved.
1149
-		$old_publishable_key      = $this->get_option( 'publishable_key' );
1150
-		$old_secret_key           = $this->get_option( 'secret_key' );
1151
-		$old_test_publishable_key = $this->get_option( 'test_publishable_key' );
1152
-		$old_test_secret_key      = $this->get_option( 'test_secret_key' );
1149
+		$old_publishable_key      = $this->get_option('publishable_key');
1150
+		$old_secret_key           = $this->get_option('secret_key');
1151
+		$old_test_publishable_key = $this->get_option('test_publishable_key');
1152
+		$old_test_secret_key      = $this->get_option('test_secret_key');
1153 1153
 
1154 1154
 		parent::process_admin_options();
1155 1155
 
1156 1156
 		// Load all old values after the new settings have been saved.
1157
-		$new_publishable_key      = $this->get_option( 'publishable_key' );
1158
-		$new_secret_key           = $this->get_option( 'secret_key' );
1159
-		$new_test_publishable_key = $this->get_option( 'test_publishable_key' );
1160
-		$new_test_secret_key      = $this->get_option( 'test_secret_key' );
1157
+		$new_publishable_key      = $this->get_option('publishable_key');
1158
+		$new_secret_key           = $this->get_option('secret_key');
1159
+		$new_test_publishable_key = $this->get_option('test_publishable_key');
1160
+		$new_test_secret_key      = $this->get_option('test_secret_key');
1161 1161
 
1162 1162
 		// Checks whether a value has transitioned from a non-empty value to a new one.
1163
-		$has_changed = function( $old_value, $new_value ) {
1164
-			return ! empty( $old_value ) && ( $old_value !== $new_value );
1163
+		$has_changed = function($old_value, $new_value) {
1164
+			return ! empty($old_value) && ($old_value !== $new_value);
1165 1165
 		};
1166 1166
 
1167 1167
 		// Look for updates.
1168 1168
 		if (
1169
-			$has_changed( $old_publishable_key, $new_publishable_key )
1170
-			|| $has_changed( $old_secret_key, $new_secret_key )
1171
-			|| $has_changed( $old_test_publishable_key, $new_test_publishable_key )
1172
-			|| $has_changed( $old_test_secret_key, $new_test_secret_key )
1169
+			$has_changed($old_publishable_key, $new_publishable_key)
1170
+			|| $has_changed($old_secret_key, $new_secret_key)
1171
+			|| $has_changed($old_test_publishable_key, $new_test_publishable_key)
1172
+			|| $has_changed($old_test_secret_key, $new_test_secret_key)
1173 1173
 		) {
1174
-			update_option( 'wc_stripe_show_changed_keys_notice', 'yes' );
1174
+			update_option('wc_stripe_show_changed_keys_notice', 'yes');
1175 1175
 		}
1176 1176
 	}
1177 1177
 
1178
-	public function validate_publishable_key_field( $key, $value ) {
1179
-		$value = $this->validate_text_field( $key, $value );
1180
-		if ( ! empty( $value ) && ! preg_match( '/^pk_live_/', $value ) ) {
1181
-			throw new Exception( __( 'The "Live Publishable Key" should start with "pk_live", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1178
+	public function validate_publishable_key_field($key, $value) {
1179
+		$value = $this->validate_text_field($key, $value);
1180
+		if ( ! empty($value) && ! preg_match('/^pk_live_/', $value)) {
1181
+			throw new Exception(__('The "Live Publishable Key" should start with "pk_live", enter the correct key.', 'woocommerce-gateway-stripe'));
1182 1182
 		}
1183 1183
 		return $value;
1184 1184
 	}
1185 1185
 
1186
-	public function validate_secret_key_field( $key, $value ) {
1187
-		$value = $this->validate_text_field( $key, $value );
1188
-		if ( ! empty( $value ) && ! preg_match( '/^[rs]k_live_/', $value ) ) {
1189
-			throw new Exception( __( 'The "Live Secret Key" should start with "sk_live" or "rk_live", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1186
+	public function validate_secret_key_field($key, $value) {
1187
+		$value = $this->validate_text_field($key, $value);
1188
+		if ( ! empty($value) && ! preg_match('/^[rs]k_live_/', $value)) {
1189
+			throw new Exception(__('The "Live Secret Key" should start with "sk_live" or "rk_live", enter the correct key.', 'woocommerce-gateway-stripe'));
1190 1190
 		}
1191 1191
 		return $value;
1192 1192
 	}
1193 1193
 
1194
-	public function validate_test_publishable_key_field( $key, $value ) {
1195
-		$value = $this->validate_text_field( $key, $value );
1196
-		if ( ! empty( $value ) && ! preg_match( '/^pk_test_/', $value ) ) {
1197
-			throw new Exception( __( 'The "Test Publishable Key" should start with "pk_test", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1194
+	public function validate_test_publishable_key_field($key, $value) {
1195
+		$value = $this->validate_text_field($key, $value);
1196
+		if ( ! empty($value) && ! preg_match('/^pk_test_/', $value)) {
1197
+			throw new Exception(__('The "Test Publishable Key" should start with "pk_test", enter the correct key.', 'woocommerce-gateway-stripe'));
1198 1198
 		}
1199 1199
 		return $value;
1200 1200
 	}
1201 1201
 
1202
-	public function validate_test_secret_key_field( $key, $value ) {
1203
-		$value = $this->validate_text_field( $key, $value );
1204
-		if ( ! empty( $value ) && ! preg_match( '/^[rs]k_test_/', $value ) ) {
1205
-			throw new Exception( __( 'The "Test Secret Key" should start with "sk_test" or "rk_test", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1202
+	public function validate_test_secret_key_field($key, $value) {
1203
+		$value = $this->validate_text_field($key, $value);
1204
+		if ( ! empty($value) && ! preg_match('/^[rs]k_test_/', $value)) {
1205
+			throw new Exception(__('The "Test Secret Key" should start with "sk_test" or "rk_test", enter the correct key.', 'woocommerce-gateway-stripe'));
1206 1206
 		}
1207 1207
 		return $value;
1208 1208
 	}
Please login to merge, or discard this patch.