Completed
Push — master ( 61011b...7e2fd1 )
by Radoslav
01:55
created
includes/payment-methods/class-wc-stripe-payment-request.php 1 patch
Spacing   +296 added lines, -296 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,30 +161,30 @@  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
-		add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_html' ), 1 );
167
-		add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_separator_html' ), 2 );
166
+		add_action('woocommerce_after_add_to_cart_quantity', array($this, 'display_payment_request_button_html'), 1);
167
+		add_action('woocommerce_after_add_to_cart_quantity', array($this, 'display_payment_request_button_separator_html'), 2);
168 168
 
169
-		add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_payment_request_button_html' ), 1 );
170
-		add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_payment_request_button_separator_html' ), 2 );
169
+		add_action('woocommerce_proceed_to_checkout', array($this, 'display_payment_request_button_html'), 1);
170
+		add_action('woocommerce_proceed_to_checkout', array($this, 'display_payment_request_button_separator_html'), 2);
171 171
 
172
-		add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_payment_request_button_html' ), 1 );
173
-		add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_payment_request_button_separator_html' ), 2 );
172
+		add_action('woocommerce_checkout_before_customer_details', array($this, 'display_payment_request_button_html'), 1);
173
+		add_action('woocommerce_checkout_before_customer_details', array($this, 'display_payment_request_button_separator_html'), 2);
174 174
 
175
-		add_action( 'wc_ajax_wc_stripe_get_cart_details', array( $this, 'ajax_get_cart_details' ) );
176
-		add_action( 'wc_ajax_wc_stripe_get_shipping_options', array( $this, 'ajax_get_shipping_options' ) );
177
-		add_action( 'wc_ajax_wc_stripe_update_shipping_method', array( $this, 'ajax_update_shipping_method' ) );
178
-		add_action( 'wc_ajax_wc_stripe_create_order', array( $this, 'ajax_create_order' ) );
179
-		add_action( 'wc_ajax_wc_stripe_add_to_cart', array( $this, 'ajax_add_to_cart' ) );
180
-		add_action( 'wc_ajax_wc_stripe_get_selected_product_data', array( $this, 'ajax_get_selected_product_data' ) );
181
-		add_action( 'wc_ajax_wc_stripe_clear_cart', array( $this, 'ajax_clear_cart' ) );
182
-		add_action( 'wc_ajax_wc_stripe_log_errors', array( $this, 'ajax_log_errors' ) );
175
+		add_action('wc_ajax_wc_stripe_get_cart_details', array($this, 'ajax_get_cart_details'));
176
+		add_action('wc_ajax_wc_stripe_get_shipping_options', array($this, 'ajax_get_shipping_options'));
177
+		add_action('wc_ajax_wc_stripe_update_shipping_method', array($this, 'ajax_update_shipping_method'));
178
+		add_action('wc_ajax_wc_stripe_create_order', array($this, 'ajax_create_order'));
179
+		add_action('wc_ajax_wc_stripe_add_to_cart', array($this, 'ajax_add_to_cart'));
180
+		add_action('wc_ajax_wc_stripe_get_selected_product_data', array($this, 'ajax_get_selected_product_data'));
181
+		add_action('wc_ajax_wc_stripe_clear_cart', array($this, 'ajax_clear_cart'));
182
+		add_action('wc_ajax_wc_stripe_log_errors', array($this, 'ajax_log_errors'));
183 183
 
184
-		add_filter( 'woocommerce_gateway_title', array( $this, 'filter_gateway_title' ), 10, 2 );
185
-		add_filter( 'woocommerce_validate_postcode', array( $this, 'postal_code_validation' ), 10, 3 );
184
+		add_filter('woocommerce_gateway_title', array($this, 'filter_gateway_title'), 10, 2);
185
+		add_filter('woocommerce_validate_postcode', array($this, 'postal_code_validation'), 10, 3);
186 186
 
187
-		add_action( 'woocommerce_checkout_order_processed', array( $this, 'add_order_meta' ), 10, 2 );
187
+		add_action('woocommerce_checkout_order_processed', array($this, 'add_order_meta'), 10, 2);
188 188
 	}
189 189
 
190 190
 	/**
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @return string
196 196
 	 */
197 197
 	public function get_button_type() {
198
-		return isset( $this->stripe_settings['payment_request_button_type'] ) ? $this->stripe_settings['payment_request_button_type'] : 'default';
198
+		return isset($this->stripe_settings['payment_request_button_type']) ? $this->stripe_settings['payment_request_button_type'] : 'default';
199 199
 	}
200 200
 
201 201
 	/**
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 * @return string
207 207
 	 */
208 208
 	public function get_button_theme() {
209
-		return isset( $this->stripe_settings['payment_request_button_theme'] ) ? $this->stripe_settings['payment_request_button_theme'] : 'dark';
209
+		return isset($this->stripe_settings['payment_request_button_theme']) ? $this->stripe_settings['payment_request_button_theme'] : 'dark';
210 210
 	}
211 211
 
212 212
 	/**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 * @return string
218 218
 	 */
219 219
 	public function get_button_height() {
220
-		return isset( $this->stripe_settings['payment_request_button_height'] ) ? str_replace( 'px', '', $this->stripe_settings['payment_request_button_height'] ) : '64';
220
+		return isset($this->stripe_settings['payment_request_button_height']) ? str_replace('px', '', $this->stripe_settings['payment_request_button_height']) : '64';
221 221
 	}
222 222
 
223 223
 	/**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 * @return string
251 251
 	 */
252 252
 	public function get_button_label() {
253
-		return isset( $this->stripe_settings['payment_request_button_label'] ) ? $this->stripe_settings['payment_request_button_label'] : 'Buy now';
253
+		return isset($this->stripe_settings['payment_request_button_label']) ? $this->stripe_settings['payment_request_button_label'] : 'Buy now';
254 254
 	}
255 255
 
256 256
 	/**
@@ -260,22 +260,22 @@  discard block
 block discarded – undo
260 260
 	 * @version 4.0.0
261 261
 	 */
262 262
 	public function get_product_data() {
263
-		if ( ! is_product() ) {
263
+		if ( ! is_product()) {
264 264
 			return false;
265 265
 		}
266 266
 
267 267
 		global $post;
268 268
 
269
-		$product = wc_get_product( $post->ID );
269
+		$product = wc_get_product($post->ID);
270 270
 
271
-		if ( 'variable' === $product->get_type() ) {
272
-			$attributes = wc_clean( wp_unslash( $_GET ) );
271
+		if ('variable' === $product->get_type()) {
272
+			$attributes = wc_clean(wp_unslash($_GET));
273 273
 
274
-			$data_store   = WC_Data_Store::load( 'product' );
275
-			$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
274
+			$data_store   = WC_Data_Store::load('product');
275
+			$variation_id = $data_store->find_matching_product_variation($product, $attributes);
276 276
 
277
-			if ( ! empty( $variation_id ) ) {
278
-				$product = wc_get_product( $variation_id );
277
+			if ( ! empty($variation_id)) {
278
+				$product = wc_get_product($variation_id);
279 279
 			}
280 280
 		}
281 281
 
@@ -284,27 +284,27 @@  discard block
 block discarded – undo
284 284
 
285 285
 		$items[] = array(
286 286
 			'label'  => $product->get_name(),
287
-			'amount' => WC_Stripe_Helper::get_stripe_amount( $product->get_price() ),
287
+			'amount' => WC_Stripe_Helper::get_stripe_amount($product->get_price()),
288 288
 		);
289 289
 
290
-		if ( wc_tax_enabled() ) {
290
+		if (wc_tax_enabled()) {
291 291
 			$items[] = array(
292
-				'label'   => __( 'Tax', 'woocommerce-gateway-stripe' ),
292
+				'label'   => __('Tax', 'woocommerce-gateway-stripe'),
293 293
 				'amount'  => 0,
294 294
 				'pending' => true,
295 295
 			);
296 296
 		}
297 297
 
298
-		if ( wc_shipping_enabled() && $product->needs_shipping() ) {
298
+		if (wc_shipping_enabled() && $product->needs_shipping()) {
299 299
 			$items[] = array(
300
-				'label'   => __( 'Shipping', 'woocommerce-gateway-stripe' ),
300
+				'label'   => __('Shipping', 'woocommerce-gateway-stripe'),
301 301
 				'amount'  => 0,
302 302
 				'pending' => true,
303 303
 			);
304 304
 
305 305
 			$data['shippingOptions'] = array(
306 306
 				'id'     => 'pending',
307
-				'label'  => __( 'Pending', 'woocommerce-gateway-stripe' ),
307
+				'label'  => __('Pending', 'woocommerce-gateway-stripe'),
308 308
 				'detail' => '',
309 309
 				'amount' => 0,
310 310
 			);
@@ -312,37 +312,37 @@  discard block
 block discarded – undo
312 312
 
313 313
 		$data['displayItems'] = $items;
314 314
 		$data['total']        = array(
315
-			'label'   => apply_filters( 'wc_stripe_payment_request_total_label', $this->total_label ),
316
-			'amount'  => WC_Stripe_Helper::get_stripe_amount( $product->get_price() ),
315
+			'label'   => apply_filters('wc_stripe_payment_request_total_label', $this->total_label),
316
+			'amount'  => WC_Stripe_Helper::get_stripe_amount($product->get_price()),
317 317
 			'pending' => true,
318 318
 		);
319 319
 
320
-		$data['requestShipping'] = ( wc_shipping_enabled() && $product->needs_shipping() );
321
-		$data['currency']        = strtolower( get_woocommerce_currency() );
322
-		$data['country_code']    = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
320
+		$data['requestShipping'] = (wc_shipping_enabled() && $product->needs_shipping());
321
+		$data['currency']        = strtolower(get_woocommerce_currency());
322
+		$data['country_code']    = substr(get_option('woocommerce_default_country'), 0, 2);
323 323
 
324
-		return apply_filters( 'wc_stripe_payment_request_product_data', $data, $product );
324
+		return apply_filters('wc_stripe_payment_request_product_data', $data, $product);
325 325
 	}
326 326
 
327 327
 	/**
328 328
 	 * Filters the gateway title to reflect Payment Request type
329 329
 	 *
330 330
 	 */
331
-	public function filter_gateway_title( $title, $id ) {
331
+	public function filter_gateway_title($title, $id) {
332 332
 		global $post;
333 333
 
334
-		if ( ! is_object( $post ) ) {
334
+		if ( ! is_object($post)) {
335 335
 			return $title;
336 336
 		}
337 337
 
338
-		$order        = wc_get_order( $post->ID );
339
-		$method_title = is_object( $order ) ? $order->get_payment_method_title() : '';
338
+		$order        = wc_get_order($post->ID);
339
+		$method_title = is_object($order) ? $order->get_payment_method_title() : '';
340 340
 
341
-		if ( 'stripe' === $id && ! empty( $method_title ) && 'Apple Pay (Stripe)' === $method_title ) {
341
+		if ('stripe' === $id && ! empty($method_title) && 'Apple Pay (Stripe)' === $method_title) {
342 342
 			return $method_title;
343 343
 		}
344 344
 
345
-		if ( 'stripe' === $id && ! empty( $method_title ) && 'Chrome Payment Request (Stripe)' === $method_title ) {
345
+		if ('stripe' === $id && ! empty($method_title) && 'Chrome Payment Request (Stripe)' === $method_title) {
346 346
 			return $method_title;
347 347
 		}
348 348
 
@@ -355,16 +355,16 @@  discard block
 block discarded – undo
355 355
 	 * @since 3.1.4
356 356
 	 * @version 4.0.0
357 357
 	 */
358
-	public function postal_code_validation( $valid, $postcode, $country ) {
358
+	public function postal_code_validation($valid, $postcode, $country) {
359 359
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
360 360
 
361
-		if ( ! isset( $gateways['stripe'] ) ) {
361
+		if ( ! isset($gateways['stripe'])) {
362 362
 			return $valid;
363 363
 		}
364 364
 
365
-		$payment_request_type = isset( $_POST['payment_request_type'] ) ? wc_clean( $_POST['payment_request_type'] ) : '';
365
+		$payment_request_type = isset($_POST['payment_request_type']) ? wc_clean($_POST['payment_request_type']) : '';
366 366
 
367
-		if ( 'apple_pay' !== $payment_request_type ) {
367
+		if ('apple_pay' !== $payment_request_type) {
368 368
 			return $valid;
369 369
 		}
370 370
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 		 * the order and not let it go through. The remedy for now is just to remove this validation.
375 375
 		 * Note that this only works with shipping providers that don't validate full postal codes.
376 376
 		 */
377
-		if ( 'GB' === $country || 'CA' === $country ) {
377
+		if ('GB' === $country || 'CA' === $country) {
378 378
 			return true;
379 379
 		}
380 380
 
@@ -389,22 +389,22 @@  discard block
 block discarded – undo
389 389
 	 * @param int $order_id
390 390
 	 * @param array $posted_data The posted data from checkout form.
391 391
 	 */
392
-	public function add_order_meta( $order_id, $posted_data ) {
393
-		if ( empty( $_POST['payment_request_type'] ) ) {
392
+	public function add_order_meta($order_id, $posted_data) {
393
+		if (empty($_POST['payment_request_type'])) {
394 394
 			return;
395 395
 		}
396 396
 
397
-		$order = wc_get_order( $order_id );
397
+		$order = wc_get_order($order_id);
398 398
 
399
-		$payment_request_type = wc_clean( $_POST['payment_request_type'] );
399
+		$payment_request_type = wc_clean($_POST['payment_request_type']);
400 400
 
401
-		if ( 'apple_pay' === $payment_request_type ) {
402
-			$order->set_payment_method_title( 'Apple Pay (Stripe)' );
401
+		if ('apple_pay' === $payment_request_type) {
402
+			$order->set_payment_method_title('Apple Pay (Stripe)');
403 403
 			$order->save();
404 404
 		}
405 405
 
406
-		if ( 'payment_request_api' === $payment_request_type ) {
407
-			$order->set_payment_method_title( 'Chrome Payment Request (Stripe)' );
406
+		if ('payment_request_api' === $payment_request_type) {
407
+			$order->set_payment_method_title('Chrome Payment Request (Stripe)');
408 408
 			$order->save();
409 409
 		}
410 410
 	}
@@ -442,20 +442,20 @@  discard block
 block discarded – undo
442 442
 	 * @return bool
443 443
 	 */
444 444
 	public function allowed_items_in_cart() {
445
-		foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
446
-			$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
445
+		foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
446
+			$_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);
447 447
 
448
-			if ( ! in_array( $_product->get_type(), $this->supported_product_types() ) ) {
448
+			if ( ! in_array($_product->get_type(), $this->supported_product_types())) {
449 449
 				return false;
450 450
 			}
451 451
 
452 452
 			// Trial subscriptions with shipping are not supported
453
-			if ( class_exists( 'WC_Subscriptions_Order' ) && WC_Subscriptions_Cart::cart_contains_subscription() && $_product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $_product ) > 0 ) {
453
+			if (class_exists('WC_Subscriptions_Order') && WC_Subscriptions_Cart::cart_contains_subscription() && $_product->needs_shipping() && WC_Subscriptions_Product::get_trial_length($_product) > 0) {
454 454
 				return false;
455 455
 			}
456 456
 
457 457
 			// Pre Orders compatbility where we don't support charge upon release.
458
-			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() ) ) {
458
+			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())) {
459 459
 				return false;
460 460
 			}
461 461
 		}
@@ -471,59 +471,59 @@  discard block
 block discarded – undo
471 471
 	 */
472 472
 	public function scripts() {
473 473
 		// If keys are not set bail.
474
-		if ( ! $this->are_keys_set() ) {
475
-			WC_Stripe_Logger::log( 'Keys are not set correctly.' );
474
+		if ( ! $this->are_keys_set()) {
475
+			WC_Stripe_Logger::log('Keys are not set correctly.');
476 476
 			return;
477 477
 		}
478 478
 
479 479
 		// If no SSL bail.
480
-		if ( ! $this->testmode && ! is_ssl() ) {
481
-			WC_Stripe_Logger::log( 'Stripe Payment Request live mode requires SSL.' );
480
+		if ( ! $this->testmode && ! is_ssl()) {
481
+			WC_Stripe_Logger::log('Stripe Payment Request live mode requires SSL.');
482 482
 			return;
483 483
 		}
484 484
 
485
-		if ( ! is_product() && ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) ) {
485
+		if ( ! is_product() && ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order'])) {
486 486
 			return;
487 487
 		}
488 488
 
489
-		if ( is_product() && ! $this->should_show_payment_button_on_product_page() ) {
489
+		if (is_product() && ! $this->should_show_payment_button_on_product_page()) {
490 490
 			return;
491 491
 		}
492 492
 
493
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
493
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
494 494
 
495 495
 		$stripe_params = array(
496
-			'ajax_url'        => WC_AJAX::get_endpoint( '%%endpoint%%' ),
496
+			'ajax_url'        => WC_AJAX::get_endpoint('%%endpoint%%'),
497 497
 			'stripe'          => array(
498 498
 				'key'                => $this->publishable_key,
499
-				'allow_prepaid_card' => apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no',
499
+				'allow_prepaid_card' => apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no',
500 500
 			),
501 501
 			'nonce'           => array(
502
-				'payment'                   => wp_create_nonce( 'wc-stripe-payment-request' ),
503
-				'shipping'                  => wp_create_nonce( 'wc-stripe-payment-request-shipping' ),
504
-				'update_shipping'           => wp_create_nonce( 'wc-stripe-update-shipping-method' ),
505
-				'checkout'                  => wp_create_nonce( 'woocommerce-process_checkout' ),
506
-				'add_to_cart'               => wp_create_nonce( 'wc-stripe-add-to-cart' ),
507
-				'get_selected_product_data' => wp_create_nonce( 'wc-stripe-get-selected-product-data' ),
508
-				'log_errors'                => wp_create_nonce( 'wc-stripe-log-errors' ),
509
-				'clear_cart'                => wp_create_nonce( 'wc-stripe-clear-cart' ),
502
+				'payment'                   => wp_create_nonce('wc-stripe-payment-request'),
503
+				'shipping'                  => wp_create_nonce('wc-stripe-payment-request-shipping'),
504
+				'update_shipping'           => wp_create_nonce('wc-stripe-update-shipping-method'),
505
+				'checkout'                  => wp_create_nonce('woocommerce-process_checkout'),
506
+				'add_to_cart'               => wp_create_nonce('wc-stripe-add-to-cart'),
507
+				'get_selected_product_data' => wp_create_nonce('wc-stripe-get-selected-product-data'),
508
+				'log_errors'                => wp_create_nonce('wc-stripe-log-errors'),
509
+				'clear_cart'                => wp_create_nonce('wc-stripe-clear-cart'),
510 510
 			),
511 511
 			'i18n'            => array(
512
-				'no_prepaid_card'  => __( 'Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe' ),
512
+				'no_prepaid_card'  => __('Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe'),
513 513
 				/* translators: Do not translate the [option] placeholder */
514
-				'unknown_shipping' => __( 'Unknown shipping option "[option]".', 'woocommerce-gateway-stripe' ),
514
+				'unknown_shipping' => __('Unknown shipping option "[option]".', 'woocommerce-gateway-stripe'),
515 515
 			),
516 516
 			'checkout'        => array(
517 517
 				'url'            => wc_get_checkout_url(),
518
-				'currency_code'  => strtolower( get_woocommerce_currency() ),
519
-				'country_code'   => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
518
+				'currency_code'  => strtolower(get_woocommerce_currency()),
519
+				'country_code'   => substr(get_option('woocommerce_default_country'), 0, 2),
520 520
 				'needs_shipping' => WC()->cart->needs_shipping() ? 'yes' : 'no',
521 521
 			),
522 522
 			'button'          => array(
523 523
 				'type'   => $this->get_button_type(),
524 524
 				'theme'  => $this->get_button_theme(),
525 525
 				'height' => $this->get_button_height(),
526
-				'locale' => apply_filters( 'wc_stripe_payment_request_button_locale', substr( get_locale(), 0, 2 ) ), // Default format is en_US.
526
+				'locale' => apply_filters('wc_stripe_payment_request_button_locale', substr(get_locale(), 0, 2)), // Default format is en_US.
527 527
 				'is_custom' => $this->is_custom_button(),
528 528
 				'css_selector' => $this->custom_button_selector(),
529 529
 			),
@@ -531,15 +531,15 @@  discard block
 block discarded – undo
531 531
 			'product'         => $this->get_product_data(),
532 532
 		);
533 533
 
534
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
535
-		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 );
534
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
535
+		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);
536 536
 
537
-		wp_localize_script( 'wc_stripe_payment_request', 'wc_stripe_payment_request_params', apply_filters( 'wc_stripe_payment_request_params', $stripe_params ) );
537
+		wp_localize_script('wc_stripe_payment_request', 'wc_stripe_payment_request_params', apply_filters('wc_stripe_payment_request_params', $stripe_params));
538 538
 
539
-		wp_enqueue_script( 'wc_stripe_payment_request' );
539
+		wp_enqueue_script('wc_stripe_payment_request');
540 540
 
541 541
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
542
-		if ( isset( $gateways['stripe'] ) ) {
542
+		if (isset($gateways['stripe'])) {
543 543
 			$gateways['stripe']->payment_scripts();
544 544
 		}
545 545
 	}
@@ -555,23 +555,23 @@  discard block
 block discarded – undo
555 555
 
556 556
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
557 557
 
558
-		if ( ! isset( $gateways['stripe'] ) ) {
558
+		if ( ! isset($gateways['stripe'])) {
559 559
 			return;
560 560
 		}
561 561
 
562
-		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) {
562
+		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset($_GET['pay_for_order'])) {
563 563
 			return;
564 564
 		}
565 565
 
566
-		if ( is_checkout() && ! apply_filters( 'wc_stripe_show_payment_request_on_checkout', false, $post ) ) {
566
+		if (is_checkout() && ! apply_filters('wc_stripe_show_payment_request_on_checkout', false, $post)) {
567 567
 			return;
568 568
 		}
569 569
 
570
-		if ( is_product() && ! $this->should_show_payment_button_on_product_page() ) {
570
+		if (is_product() && ! $this->should_show_payment_button_on_product_page()) {
571 571
 			return;
572 572
 		} else {
573
-			if ( ! $this->allowed_items_in_cart() ) {
574
-				WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' );
573
+			if ( ! $this->allowed_items_in_cart()) {
574
+				WC_Stripe_Logger::log('Items in the cart has unsupported product type ( Payment Request button disabled )');
575 575
 				return;
576 576
 			}
577 577
 		}
@@ -579,10 +579,10 @@  discard block
 block discarded – undo
579 579
 		<div id="wc-stripe-payment-request-wrapper" style="clear:both;padding-top:1.5em;display:none;">
580 580
 			<div id="wc-stripe-payment-request-button">
581 581
 				<?php
582
-					if ( $this->is_custom_button() ) {
583
-						$label = esc_html( $this->get_button_label() );
584
-						$class_name = esc_attr( 'button ' .  $this->get_button_theme() );
585
-						$style = esc_attr( 'height:' . $this->get_button_height() . 'px;' );
582
+					if ($this->is_custom_button()) {
583
+						$label = esc_html($this->get_button_label());
584
+						$class_name = esc_attr('button ' . $this->get_button_theme());
585
+						$style = esc_attr('height:' . $this->get_button_height() . 'px;');
586 586
 						echo "<button id=\"wc-stripe-custom-button\" class=\"$class_name\" style=\"$style\"> $label </button>";
587 587
 					}
588 588
 				?>
@@ -603,28 +603,28 @@  discard block
 block discarded – undo
603 603
 
604 604
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
605 605
 
606
-		if ( ! isset( $gateways['stripe'] ) ) {
606
+		if ( ! isset($gateways['stripe'])) {
607 607
 			return;
608 608
 		}
609 609
 
610
-		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) {
610
+		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset($_GET['pay_for_order'])) {
611 611
 			return;
612 612
 		}
613 613
 
614
-		if ( is_checkout() && ! apply_filters( 'wc_stripe_show_payment_request_on_checkout', false, $post ) ) {
614
+		if (is_checkout() && ! apply_filters('wc_stripe_show_payment_request_on_checkout', false, $post)) {
615 615
 			return;
616 616
 		}
617 617
 
618
-		if ( is_product() && ! $this->should_show_payment_button_on_product_page() ) {
618
+		if (is_product() && ! $this->should_show_payment_button_on_product_page()) {
619 619
 			return;
620 620
 		} else {
621
-			if ( ! $this->allowed_items_in_cart() ) {
622
-				WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' );
621
+			if ( ! $this->allowed_items_in_cart()) {
622
+				WC_Stripe_Logger::log('Items in the cart has unsupported product type ( Payment Request button disabled )');
623 623
 				return;
624 624
 			}
625 625
 		}
626 626
 		?>
627
-		<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>
627
+		<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>
628 628
 		<?php
629 629
 	}
630 630
 
@@ -640,32 +640,32 @@  discard block
 block discarded – undo
640 640
 	private function should_show_payment_button_on_product_page() {
641 641
 		global $post;
642 642
 
643
-		$product = wc_get_product( $post->ID );
643
+		$product = wc_get_product($post->ID);
644 644
 
645
-		if ( apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false, $post ) ) {
645
+		if (apply_filters('wc_stripe_hide_payment_request_on_product_page', false, $post)) {
646 646
 			return false;
647 647
 		}
648 648
 
649
-		if ( ! is_object( $product ) || ! in_array( $product->get_type(), $this->supported_product_types() ) ) {
649
+		if ( ! is_object($product) || ! in_array($product->get_type(), $this->supported_product_types())) {
650 650
 			return false;
651 651
 		}
652 652
 
653 653
 		// Trial subscriptions with shipping are not supported
654
-		if ( class_exists( 'WC_Subscriptions_Order' ) && $product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $product ) > 0 ) {
654
+		if (class_exists('WC_Subscriptions_Order') && $product->needs_shipping() && WC_Subscriptions_Product::get_trial_length($product) > 0) {
655 655
 			return false;
656 656
 		}
657 657
 
658 658
 		// Pre Orders charge upon release not supported.
659
-		if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Product::product_is_charged_upon_release( $product ) ) {
660
-			WC_Stripe_Logger::log( 'Pre Order charge upon release is not supported. ( Payment Request button disabled )' );
659
+		if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Product::product_is_charged_upon_release($product)) {
660
+			WC_Stripe_Logger::log('Pre Order charge upon release is not supported. ( Payment Request button disabled )');
661 661
 			return false;
662 662
 		}
663 663
 
664 664
 		// File upload addon not supported
665
-		if ( class_exists( 'WC_Product_Addons_Helper' ) ) {
666
-			$product_addons = WC_Product_Addons_Helper::get_product_addons( $product->get_id() );
667
-			foreach ( $product_addons as $addon ) {
668
-				if ( 'file_upload' === $addon['type'] ) {
665
+		if (class_exists('WC_Product_Addons_Helper')) {
666
+			$product_addons = WC_Product_Addons_Helper::get_product_addons($product->get_id());
667
+			foreach ($product_addons as $addon) {
668
+				if ('file_upload' === $addon['type']) {
669 669
 					return false;
670 670
 				}
671 671
 			}
@@ -681,11 +681,11 @@  discard block
 block discarded – undo
681 681
 	 * @version 4.0.0
682 682
 	 */
683 683
 	public function ajax_log_errors() {
684
-		check_ajax_referer( 'wc-stripe-log-errors', 'security' );
684
+		check_ajax_referer('wc-stripe-log-errors', 'security');
685 685
 
686
-		$errors = wc_clean( stripslashes( $_POST['errors'] ) );
686
+		$errors = wc_clean(stripslashes($_POST['errors']));
687 687
 
688
-		WC_Stripe_Logger::log( $errors );
688
+		WC_Stripe_Logger::log($errors);
689 689
 
690 690
 		exit;
691 691
 	}
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 	 * @version 4.0.0
698 698
 	 */
699 699
 	public function ajax_clear_cart() {
700
-		check_ajax_referer( 'wc-stripe-clear-cart', 'security' );
700
+		check_ajax_referer('wc-stripe-clear-cart', 'security');
701 701
 
702 702
 		WC()->cart->empty_cart();
703 703
 		exit;
@@ -707,10 +707,10 @@  discard block
 block discarded – undo
707 707
 	 * Get cart details.
708 708
 	 */
709 709
 	public function ajax_get_cart_details() {
710
-		check_ajax_referer( 'wc-stripe-payment-request', 'security' );
710
+		check_ajax_referer('wc-stripe-payment-request', 'security');
711 711
 
712
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
713
-			define( 'WOOCOMMERCE_CART', true );
712
+		if ( ! defined('WOOCOMMERCE_CART')) {
713
+			define('WOOCOMMERCE_CART', true);
714 714
 		}
715 715
 
716 716
 		WC()->cart->calculate_totals();
@@ -721,14 +721,14 @@  discard block
 block discarded – undo
721 721
 		$data = array(
722 722
 			'shipping_required' => WC()->cart->needs_shipping(),
723 723
 			'order_data'        => array(
724
-				'currency'     => strtolower( $currency ),
725
-				'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
724
+				'currency'     => strtolower($currency),
725
+				'country_code' => substr(get_option('woocommerce_default_country'), 0, 2),
726 726
 			),
727 727
 		);
728 728
 
729 729
 		$data['order_data'] += $this->build_display_items();
730 730
 
731
-		wp_send_json( $data );
731
+		wp_send_json($data);
732 732
 	}
733 733
 
734 734
 	/**
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 	 * @see WC_Shipping::get_packages().
740 740
 	 */
741 741
 	public function ajax_get_shipping_options() {
742
-		check_ajax_referer( 'wc-stripe-payment-request-shipping', 'security' );
742
+		check_ajax_referer('wc-stripe-payment-request-shipping', 'security');
743 743
 
744 744
 		$shipping_address = filter_input_array(
745 745
 			INPUT_POST,
@@ -753,8 +753,8 @@  discard block
 block discarded – undo
753 753
 			)
754 754
 		);
755 755
 
756
-		$data = $this->get_shipping_options( $shipping_address );
757
-		wp_send_json( $data );
756
+		$data = $this->get_shipping_options($shipping_address);
757
+		wp_send_json($data);
758 758
 	}
759 759
 
760 760
 	/**
@@ -765,65 +765,65 @@  discard block
 block discarded – undo
765 765
 	 * @return array Shipping options data.
766 766
 	 * phpcs:ignore Squiz.Commenting.FunctionCommentThrowTag
767 767
 	 */
768
-	public function get_shipping_options( $shipping_address ) {
768
+	public function get_shipping_options($shipping_address) {
769 769
 		try {
770 770
 			// Set the shipping options.
771 771
 			$data = array();
772 772
 
773 773
 			// Remember current shipping method before resetting.
774
-			$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
775
-			$this->calculate_shipping( apply_filters( 'wc_stripe_payment_request_shipping_posted_values', $shipping_address ) );
774
+			$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
775
+			$this->calculate_shipping(apply_filters('wc_stripe_payment_request_shipping_posted_values', $shipping_address));
776 776
 
777 777
 			$packages = WC()->shipping->get_packages();
778 778
 
779
-			if ( ! empty( $packages ) && WC()->customer->has_calculated_shipping() ) {
780
-				foreach ( $packages as $package_key => $package ) {
781
-					if ( empty( $package['rates'] ) ) {
782
-						throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) );
779
+			if ( ! empty($packages) && WC()->customer->has_calculated_shipping()) {
780
+				foreach ($packages as $package_key => $package) {
781
+					if (empty($package['rates'])) {
782
+						throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe'));
783 783
 					}
784 784
 
785
-					foreach ( $package['rates'] as $key => $rate ) {
785
+					foreach ($package['rates'] as $key => $rate) {
786 786
 						$data['shipping_options'][] = array(
787 787
 							'id'     => $rate->id,
788 788
 							'label'  => $rate->label,
789 789
 							'detail' => '',
790
-							'amount' => WC_Stripe_Helper::get_stripe_amount( $rate->cost ),
790
+							'amount' => WC_Stripe_Helper::get_stripe_amount($rate->cost),
791 791
 						);
792 792
 					}
793 793
 				}
794 794
 			} else {
795
-				throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) );
795
+				throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe'));
796 796
 			}
797 797
 
798 798
 			// The first shipping option is automatically applied on the client.
799 799
 			// Keep chosen shipping method by sorting shipping options if the method still available for new address.
800 800
 			// Fallback to the first available shipping method.
801
-			if ( isset( $data['shipping_options'][0] ) ) {
802
-				if ( isset( $chosen_shipping_methods[0] ) ) {
801
+			if (isset($data['shipping_options'][0])) {
802
+				if (isset($chosen_shipping_methods[0])) {
803 803
 					$chosen_method_id         = $chosen_shipping_methods[0];
804
-					$compare_shipping_options = function ( $a, $b ) use ( $chosen_method_id ) {
805
-						if ( $a['id'] === $chosen_method_id ) {
804
+					$compare_shipping_options = function($a, $b) use ($chosen_method_id) {
805
+						if ($a['id'] === $chosen_method_id) {
806 806
 							return -1;
807 807
 						}
808 808
 
809
-						if ( $b['id'] === $chosen_method_id ) {
809
+						if ($b['id'] === $chosen_method_id) {
810 810
 							return 1;
811 811
 						}
812 812
 
813 813
 						return 0;
814 814
 					};
815
-					usort( $data['shipping_options'], $compare_shipping_options );
815
+					usort($data['shipping_options'], $compare_shipping_options);
816 816
 				}
817 817
 
818 818
 				$first_shipping_method_id = $data['shipping_options'][0]['id'];
819
-				$this->update_shipping_method( [ $first_shipping_method_id ] );
819
+				$this->update_shipping_method([$first_shipping_method_id]);
820 820
 			}
821 821
 
822 822
 			WC()->cart->calculate_totals();
823 823
 
824 824
 			$data          += $this->build_display_items();
825 825
 			$data['result'] = 'success';
826
-		} catch ( Exception $e ) {
826
+		} catch (Exception $e) {
827 827
 			$data          += $this->build_display_items();
828 828
 			$data['result'] = 'invalid_shipping_address';
829 829
 		}
@@ -835,14 +835,14 @@  discard block
 block discarded – undo
835 835
 	 * Update shipping method.
836 836
 	 */
837 837
 	public function ajax_update_shipping_method() {
838
-		check_ajax_referer( 'wc-stripe-update-shipping-method', 'security' );
838
+		check_ajax_referer('wc-stripe-update-shipping-method', 'security');
839 839
 
840
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
841
-			define( 'WOOCOMMERCE_CART', true );
840
+		if ( ! defined('WOOCOMMERCE_CART')) {
841
+			define('WOOCOMMERCE_CART', true);
842 842
 		}
843 843
 
844
-		$shipping_methods = filter_input( INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
845
-		$this->update_shipping_method( $shipping_methods );
844
+		$shipping_methods = filter_input(INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
845
+		$this->update_shipping_method($shipping_methods);
846 846
 
847 847
 		WC()->cart->calculate_totals();
848 848
 
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 		$data          += $this->build_display_items();
851 851
 		$data['result'] = 'success';
852 852
 
853
-		wp_send_json( $data );
853
+		wp_send_json($data);
854 854
 	}
855 855
 
856 856
 	/**
@@ -858,16 +858,16 @@  discard block
 block discarded – undo
858 858
 	 *
859 859
 	 * @param array $shipping_methods Array of selected shipping methods ids.
860 860
 	 */
861
-	public function update_shipping_method( $shipping_methods ) {
862
-		$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
861
+	public function update_shipping_method($shipping_methods) {
862
+		$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
863 863
 
864
-		if ( is_array( $shipping_methods ) ) {
865
-			foreach ( $shipping_methods as $i => $value ) {
866
-				$chosen_shipping_methods[ $i ] = wc_clean( $value );
864
+		if (is_array($shipping_methods)) {
865
+			foreach ($shipping_methods as $i => $value) {
866
+				$chosen_shipping_methods[$i] = wc_clean($value);
867 867
 			}
868 868
 		}
869 869
 
870
-		WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods );
870
+		WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
871 871
 	}
872 872
 
873 873
 	/**
@@ -878,38 +878,38 @@  discard block
 block discarded – undo
878 878
 	 * @return array $data
879 879
 	 */
880 880
 	public function ajax_get_selected_product_data() {
881
-		check_ajax_referer( 'wc-stripe-get-selected-product-data', 'security' );
881
+		check_ajax_referer('wc-stripe-get-selected-product-data', 'security');
882 882
 
883 883
 		try {
884
-			$product_id   = absint( $_POST['product_id'] );
885
-			$qty          = ! isset( $_POST['qty'] ) ? 1 : apply_filters( 'woocommerce_add_to_cart_quantity', absint( $_POST['qty'] ), $product_id );
886
-			$addon_value  = isset( $_POST['addon_value'] ) ? max( floatval( $_POST['addon_value'] ), 0 ) : 0;
887
-			$product      = wc_get_product( $product_id );
884
+			$product_id   = absint($_POST['product_id']);
885
+			$qty          = ! isset($_POST['qty']) ? 1 : apply_filters('woocommerce_add_to_cart_quantity', absint($_POST['qty']), $product_id);
886
+			$addon_value  = isset($_POST['addon_value']) ? max(floatval($_POST['addon_value']), 0) : 0;
887
+			$product      = wc_get_product($product_id);
888 888
 			$variation_id = null;
889 889
 
890
-			if ( ! is_a( $product, 'WC_Product' ) ) {
891
-				throw new Exception( sprintf( __( 'Product with the ID (%d) cannot be found.', 'woocommerce-gateway-stripe' ), $product_id ) );
890
+			if ( ! is_a($product, 'WC_Product')) {
891
+				throw new Exception(sprintf(__('Product with the ID (%d) cannot be found.', 'woocommerce-gateway-stripe'), $product_id));
892 892
 			}
893 893
 
894
-			if ( 'variable' === $product->get_type() && isset( $_POST['attributes'] ) ) {
895
-				$attributes = wc_clean( wp_unslash( $_POST['attributes'] ) );
894
+			if ('variable' === $product->get_type() && isset($_POST['attributes'])) {
895
+				$attributes = wc_clean(wp_unslash($_POST['attributes']));
896 896
 
897
-				$data_store   = WC_Data_Store::load( 'product' );
898
-				$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
897
+				$data_store   = WC_Data_Store::load('product');
898
+				$variation_id = $data_store->find_matching_product_variation($product, $attributes);
899 899
 
900
-				if ( ! empty( $variation_id ) ) {
901
-					$product = wc_get_product( $variation_id );
900
+				if ( ! empty($variation_id)) {
901
+					$product = wc_get_product($variation_id);
902 902
 				}
903 903
 			}
904 904
 
905 905
 			// Force quantity to 1 if sold individually and check for existing item in cart.
906
-			if ( $product->is_sold_individually() ) {
907
-				$qty = apply_filters( 'wc_stripe_payment_request_add_to_cart_sold_individually_quantity', 1, $qty, $product_id, $variation_id );
906
+			if ($product->is_sold_individually()) {
907
+				$qty = apply_filters('wc_stripe_payment_request_add_to_cart_sold_individually_quantity', 1, $qty, $product_id, $variation_id);
908 908
 			}
909 909
 
910
-			if ( ! $product->has_enough_stock( $qty ) ) {
910
+			if ( ! $product->has_enough_stock($qty)) {
911 911
 				/* translators: 1: product name 2: quantity in stock */
912
-				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 ) ) );
912
+				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)));
913 913
 			}
914 914
 
915 915
 			$total = $qty * $product->get_price() + $addon_value;
@@ -921,27 +921,27 @@  discard block
 block discarded – undo
921 921
 
922 922
 			$items[] = array(
923 923
 				'label'  => $product->get_name() . $quantity_label,
924
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $total ),
924
+				'amount' => WC_Stripe_Helper::get_stripe_amount($total),
925 925
 			);
926 926
 
927
-			if ( wc_tax_enabled() ) {
927
+			if (wc_tax_enabled()) {
928 928
 				$items[] = array(
929
-					'label'   => __( 'Tax', 'woocommerce-gateway-stripe' ),
929
+					'label'   => __('Tax', 'woocommerce-gateway-stripe'),
930 930
 					'amount'  => 0,
931 931
 					'pending' => true,
932 932
 				);
933 933
 			}
934 934
 
935
-			if ( wc_shipping_enabled() && $product->needs_shipping() ) {
935
+			if (wc_shipping_enabled() && $product->needs_shipping()) {
936 936
 				$items[] = array(
937
-					'label'   => __( 'Shipping', 'woocommerce-gateway-stripe' ),
937
+					'label'   => __('Shipping', 'woocommerce-gateway-stripe'),
938 938
 					'amount'  => 0,
939 939
 					'pending' => true,
940 940
 				);
941 941
 
942 942
 				$data['shippingOptions'] = array(
943 943
 					'id'     => 'pending',
944
-					'label'  => __( 'Pending', 'woocommerce-gateway-stripe' ),
944
+					'label'  => __('Pending', 'woocommerce-gateway-stripe'),
945 945
 					'detail' => '',
946 946
 					'amount' => 0,
947 947
 				);
@@ -950,17 +950,17 @@  discard block
 block discarded – undo
950 950
 			$data['displayItems'] = $items;
951 951
 			$data['total']        = array(
952 952
 				'label'   => $this->total_label,
953
-				'amount'  => WC_Stripe_Helper::get_stripe_amount( $total ),
953
+				'amount'  => WC_Stripe_Helper::get_stripe_amount($total),
954 954
 				'pending' => true,
955 955
 			);
956 956
 
957
-			$data['requestShipping'] = ( wc_shipping_enabled() && $product->needs_shipping() );
958
-			$data['currency']        = strtolower( get_woocommerce_currency() );
959
-			$data['country_code']    = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
957
+			$data['requestShipping'] = (wc_shipping_enabled() && $product->needs_shipping());
958
+			$data['currency']        = strtolower(get_woocommerce_currency());
959
+			$data['country_code']    = substr(get_option('woocommerce_default_country'), 0, 2);
960 960
 
961
-			wp_send_json( $data );
962
-		} catch ( Exception $e ) {
963
-			wp_send_json( array( 'error' => wp_strip_all_tags( $e->getMessage() ) ) );
961
+			wp_send_json($data);
962
+		} catch (Exception $e) {
963
+			wp_send_json(array('error' => wp_strip_all_tags($e->getMessage())));
964 964
 		}
965 965
 	}
966 966
 
@@ -972,33 +972,33 @@  discard block
 block discarded – undo
972 972
 	 * @return array $data
973 973
 	 */
974 974
 	public function ajax_add_to_cart() {
975
-		check_ajax_referer( 'wc-stripe-add-to-cart', 'security' );
975
+		check_ajax_referer('wc-stripe-add-to-cart', 'security');
976 976
 
977
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
978
-			define( 'WOOCOMMERCE_CART', true );
977
+		if ( ! defined('WOOCOMMERCE_CART')) {
978
+			define('WOOCOMMERCE_CART', true);
979 979
 		}
980 980
 
981 981
 		WC()->shipping->reset_shipping();
982 982
 
983
-		$product_id   = absint( $_POST['product_id'] );
984
-		$qty          = ! isset( $_POST['qty'] ) ? 1 : absint( $_POST['qty'] );
985
-		$product      = wc_get_product( $product_id );
983
+		$product_id   = absint($_POST['product_id']);
984
+		$qty          = ! isset($_POST['qty']) ? 1 : absint($_POST['qty']);
985
+		$product      = wc_get_product($product_id);
986 986
 		$product_type = $product->get_type();
987 987
 
988 988
 		// First empty the cart to prevent wrong calculation.
989 989
 		WC()->cart->empty_cart();
990 990
 
991
-		if ( ( 'variable' === $product_type || 'variable-subscription' === $product_type ) && isset( $_POST['attributes'] ) ) {
992
-			$attributes = wc_clean( wp_unslash( $_POST['attributes'] ) );
991
+		if (('variable' === $product_type || 'variable-subscription' === $product_type) && isset($_POST['attributes'])) {
992
+			$attributes = wc_clean(wp_unslash($_POST['attributes']));
993 993
 
994
-			$data_store   = WC_Data_Store::load( 'product' );
995
-			$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
994
+			$data_store   = WC_Data_Store::load('product');
995
+			$variation_id = $data_store->find_matching_product_variation($product, $attributes);
996 996
 
997
-			WC()->cart->add_to_cart( $product->get_id(), $qty, $variation_id, $attributes );
997
+			WC()->cart->add_to_cart($product->get_id(), $qty, $variation_id, $attributes);
998 998
 		}
999 999
 
1000
-		if ( 'simple' === $product_type || 'subscription' === $product_type ) {
1001
-			WC()->cart->add_to_cart( $product->get_id(), $qty );
1000
+		if ('simple' === $product_type || 'subscription' === $product_type) {
1001
+			WC()->cart->add_to_cart($product->get_id(), $qty);
1002 1002
 		}
1003 1003
 
1004 1004
 		WC()->cart->calculate_totals();
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
 		$data          += $this->build_display_items();
1008 1008
 		$data['result'] = 'success';
1009 1009
 
1010
-		wp_send_json( $data );
1010
+		wp_send_json($data);
1011 1011
 	}
1012 1012
 
1013 1013
 	/**
@@ -1020,31 +1020,31 @@  discard block
 block discarded – undo
1020 1020
 	 * @version 4.0.0
1021 1021
 	 */
1022 1022
 	public function normalize_state() {
1023
-		$billing_country  = ! empty( $_POST['billing_country'] ) ? wc_clean( $_POST['billing_country'] ) : '';
1024
-		$shipping_country = ! empty( $_POST['shipping_country'] ) ? wc_clean( $_POST['shipping_country'] ) : '';
1025
-		$billing_state    = ! empty( $_POST['billing_state'] ) ? wc_clean( $_POST['billing_state'] ) : '';
1026
-		$shipping_state   = ! empty( $_POST['shipping_state'] ) ? wc_clean( $_POST['shipping_state'] ) : '';
1023
+		$billing_country  = ! empty($_POST['billing_country']) ? wc_clean($_POST['billing_country']) : '';
1024
+		$shipping_country = ! empty($_POST['shipping_country']) ? wc_clean($_POST['shipping_country']) : '';
1025
+		$billing_state    = ! empty($_POST['billing_state']) ? wc_clean($_POST['billing_state']) : '';
1026
+		$shipping_state   = ! empty($_POST['shipping_state']) ? wc_clean($_POST['shipping_state']) : '';
1027 1027
 
1028
-		if ( $billing_state && $billing_country ) {
1029
-			$valid_states = WC()->countries->get_states( $billing_country );
1028
+		if ($billing_state && $billing_country) {
1029
+			$valid_states = WC()->countries->get_states($billing_country);
1030 1030
 
1031 1031
 			// Valid states found for country.
1032
-			if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) {
1033
-				foreach ( $valid_states as $state_abbr => $state ) {
1034
-					if ( preg_match( '/' . preg_quote( $state ) . '/i', $billing_state ) ) {
1032
+			if ( ! empty($valid_states) && is_array($valid_states) && sizeof($valid_states) > 0) {
1033
+				foreach ($valid_states as $state_abbr => $state) {
1034
+					if (preg_match('/' . preg_quote($state) . '/i', $billing_state)) {
1035 1035
 						$_POST['billing_state'] = $state_abbr;
1036 1036
 					}
1037 1037
 				}
1038 1038
 			}
1039 1039
 		}
1040 1040
 
1041
-		if ( $shipping_state && $shipping_country ) {
1042
-			$valid_states = WC()->countries->get_states( $shipping_country );
1041
+		if ($shipping_state && $shipping_country) {
1042
+			$valid_states = WC()->countries->get_states($shipping_country);
1043 1043
 
1044 1044
 			// Valid states found for country.
1045
-			if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) {
1046
-				foreach ( $valid_states as $state_abbr => $state ) {
1047
-					if ( preg_match( '/' . preg_quote( $state ) . '/i', $shipping_state ) ) {
1045
+			if ( ! empty($valid_states) && is_array($valid_states) && sizeof($valid_states) > 0) {
1046
+				foreach ($valid_states as $state_abbr => $state) {
1047
+					if (preg_match('/' . preg_quote($state) . '/i', $shipping_state)) {
1048 1048
 						$_POST['shipping_state'] = $state_abbr;
1049 1049
 					}
1050 1050
 				}
@@ -1059,19 +1059,19 @@  discard block
 block discarded – undo
1059 1059
 	 * @version 4.0.0
1060 1060
 	 */
1061 1061
 	public function ajax_create_order() {
1062
-		if ( WC()->cart->is_empty() ) {
1063
-			wp_send_json_error( __( 'Empty cart', 'woocommerce-gateway-stripe' ) );
1062
+		if (WC()->cart->is_empty()) {
1063
+			wp_send_json_error(__('Empty cart', 'woocommerce-gateway-stripe'));
1064 1064
 		}
1065 1065
 
1066
-		if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) {
1067
-			define( 'WOOCOMMERCE_CHECKOUT', true );
1066
+		if ( ! defined('WOOCOMMERCE_CHECKOUT')) {
1067
+			define('WOOCOMMERCE_CHECKOUT', true);
1068 1068
 		}
1069 1069
 
1070 1070
 		$this->normalize_state();
1071 1071
 
1072 1072
 		WC()->checkout()->process_checkout();
1073 1073
 
1074
-		die( 0 );
1074
+		die(0);
1075 1075
 	}
1076 1076
 
1077 1077
 	/**
@@ -1081,38 +1081,38 @@  discard block
 block discarded – undo
1081 1081
 	 * @version 4.0.0
1082 1082
 	 * @param array $address
1083 1083
 	 */
1084
-	protected function calculate_shipping( $address = array() ) {
1084
+	protected function calculate_shipping($address = array()) {
1085 1085
 		$country   = $address['country'];
1086 1086
 		$state     = $address['state'];
1087 1087
 		$postcode  = $address['postcode'];
1088 1088
 		$city      = $address['city'];
1089 1089
 		$address_1 = $address['address'];
1090 1090
 		$address_2 = $address['address_2'];
1091
-		$wc_states = WC()->countries->get_states( $country );
1091
+		$wc_states = WC()->countries->get_states($country);
1092 1092
 
1093 1093
 		/**
1094 1094
 		 * In some versions of Chrome, state can be a full name. So we need
1095 1095
 		 * to convert that to abbreviation as WC is expecting that.
1096 1096
 		 */
1097
-		if ( 2 < strlen( $state ) && ! empty( $wc_states ) && ! isset( $wc_states[ $state ] ) ) {
1098
-			$state = array_search( ucwords( strtolower( $state ) ), $wc_states, true );
1097
+		if (2 < strlen($state) && ! empty($wc_states) && ! isset($wc_states[$state])) {
1098
+			$state = array_search(ucwords(strtolower($state)), $wc_states, true);
1099 1099
 		}
1100 1100
 
1101 1101
 		WC()->shipping->reset_shipping();
1102 1102
 
1103
-		if ( $postcode && WC_Validation::is_postcode( $postcode, $country ) ) {
1104
-			$postcode = wc_format_postcode( $postcode, $country );
1103
+		if ($postcode && WC_Validation::is_postcode($postcode, $country)) {
1104
+			$postcode = wc_format_postcode($postcode, $country);
1105 1105
 		}
1106 1106
 
1107
-		if ( $country ) {
1108
-			WC()->customer->set_location( $country, $state, $postcode, $city );
1109
-			WC()->customer->set_shipping_location( $country, $state, $postcode, $city );
1107
+		if ($country) {
1108
+			WC()->customer->set_location($country, $state, $postcode, $city);
1109
+			WC()->customer->set_shipping_location($country, $state, $postcode, $city);
1110 1110
 		} else {
1111 1111
 			WC()->customer->set_billing_address_to_base();
1112 1112
 			WC()->customer->set_shipping_address_to_base();
1113 1113
 		}
1114 1114
 
1115
-		WC()->customer->set_calculated_shipping( true );
1115
+		WC()->customer->set_calculated_shipping(true);
1116 1116
 		WC()->customer->save();
1117 1117
 
1118 1118
 		$packages = array();
@@ -1128,17 +1128,17 @@  discard block
 block discarded – undo
1128 1128
 		$packages[0]['destination']['address']   = $address_1;
1129 1129
 		$packages[0]['destination']['address_2'] = $address_2;
1130 1130
 
1131
-		foreach ( WC()->cart->get_cart() as $item ) {
1132
-			if ( $item['data']->needs_shipping() ) {
1133
-				if ( isset( $item['line_total'] ) ) {
1131
+		foreach (WC()->cart->get_cart() as $item) {
1132
+			if ($item['data']->needs_shipping()) {
1133
+				if (isset($item['line_total'])) {
1134 1134
 					$packages[0]['contents_cost'] += $item['line_total'];
1135 1135
 				}
1136 1136
 			}
1137 1137
 		}
1138 1138
 
1139
-		$packages = apply_filters( 'woocommerce_cart_shipping_packages', $packages );
1139
+		$packages = apply_filters('woocommerce_cart_shipping_packages', $packages);
1140 1140
 
1141
-		WC()->shipping->calculate_shipping( $packages );
1141
+		WC()->shipping->calculate_shipping($packages);
1142 1142
 	}
1143 1143
 
1144 1144
 	/**
@@ -1147,19 +1147,19 @@  discard block
 block discarded – undo
1147 1147
 	 * @since 3.1.0
1148 1148
 	 * @version 4.0.0
1149 1149
 	 */
1150
-	protected function build_shipping_methods( $shipping_methods ) {
1151
-		if ( empty( $shipping_methods ) ) {
1150
+	protected function build_shipping_methods($shipping_methods) {
1151
+		if (empty($shipping_methods)) {
1152 1152
 			return array();
1153 1153
 		}
1154 1154
 
1155 1155
 		$shipping = array();
1156 1156
 
1157
-		foreach ( $shipping_methods as $method ) {
1157
+		foreach ($shipping_methods as $method) {
1158 1158
 			$shipping[] = array(
1159 1159
 				'id'     => $method['id'],
1160 1160
 				'label'  => $method['label'],
1161 1161
 				'detail' => '',
1162
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $method['amount']['value'] ),
1162
+				'amount' => WC_Stripe_Helper::get_stripe_amount($method['amount']['value']),
1163 1163
 			);
1164 1164
 		}
1165 1165
 
@@ -1173,8 +1173,8 @@  discard block
 block discarded – undo
1173 1173
 	 * @version 4.0.0
1174 1174
 	 */
1175 1175
 	protected function build_display_items() {
1176
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
1177
-			define( 'WOOCOMMERCE_CART', true );
1176
+		if ( ! defined('WOOCOMMERCE_CART')) {
1177
+			define('WOOCOMMERCE_CART', true);
1178 1178
 		}
1179 1179
 
1180 1180
 		$items     = array();
@@ -1182,8 +1182,8 @@  discard block
 block discarded – undo
1182 1182
 		$discounts = 0;
1183 1183
 
1184 1184
 		// Default show only subtotal instead of itemization.
1185
-		if ( ! apply_filters( 'wc_stripe_payment_request_hide_itemization', true ) ) {
1186
-			foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
1185
+		if ( ! apply_filters('wc_stripe_payment_request_hide_itemization', true)) {
1186
+			foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
1187 1187
 				$amount         = $cart_item['line_subtotal'];
1188 1188
 				$subtotal      += $cart_item['line_subtotal'];
1189 1189
 				$quantity_label = 1 < $cart_item['quantity'] ? ' (x' . $cart_item['quantity'] . ')' : '';
@@ -1192,61 +1192,61 @@  discard block
 block discarded – undo
1192 1192
 
1193 1193
 				$item = array(
1194 1194
 					'label'  => $product_name . $quantity_label,
1195
-					'amount' => WC_Stripe_Helper::get_stripe_amount( $amount ),
1195
+					'amount' => WC_Stripe_Helper::get_stripe_amount($amount),
1196 1196
 				);
1197 1197
 
1198 1198
 				$items[] = $item;
1199 1199
 			}
1200 1200
 		}
1201 1201
 
1202
-		if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
1203
-			$discounts = wc_format_decimal( WC()->cart->get_cart_discount_total(), WC()->cart->dp );
1202
+		if (version_compare(WC_VERSION, '3.2', '<')) {
1203
+			$discounts = wc_format_decimal(WC()->cart->get_cart_discount_total(), WC()->cart->dp);
1204 1204
 		} else {
1205
-			$applied_coupons = array_values( WC()->cart->get_coupon_discount_totals() );
1205
+			$applied_coupons = array_values(WC()->cart->get_coupon_discount_totals());
1206 1206
 
1207
-			foreach ( $applied_coupons as $amount ) {
1207
+			foreach ($applied_coupons as $amount) {
1208 1208
 				$discounts += (float) $amount;
1209 1209
 			}
1210 1210
 		}
1211 1211
 
1212
-		$discounts   = wc_format_decimal( $discounts, WC()->cart->dp );
1213
-		$tax         = wc_format_decimal( WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp );
1214
-		$shipping    = wc_format_decimal( WC()->cart->shipping_total, WC()->cart->dp );
1215
-		$items_total = wc_format_decimal( WC()->cart->cart_contents_total, WC()->cart->dp ) + $discounts;
1216
-		$order_total = version_compare( WC_VERSION, '3.2', '<' ) ? wc_format_decimal( $items_total + $tax + $shipping - $discounts, WC()->cart->dp ) : WC()->cart->get_total( false );
1212
+		$discounts   = wc_format_decimal($discounts, WC()->cart->dp);
1213
+		$tax         = wc_format_decimal(WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp);
1214
+		$shipping    = wc_format_decimal(WC()->cart->shipping_total, WC()->cart->dp);
1215
+		$items_total = wc_format_decimal(WC()->cart->cart_contents_total, WC()->cart->dp) + $discounts;
1216
+		$order_total = version_compare(WC_VERSION, '3.2', '<') ? wc_format_decimal($items_total + $tax + $shipping - $discounts, WC()->cart->dp) : WC()->cart->get_total(false);
1217 1217
 
1218
-		if ( wc_tax_enabled() ) {
1218
+		if (wc_tax_enabled()) {
1219 1219
 			$items[] = array(
1220
-				'label'  => esc_html( __( 'Tax', 'woocommerce-gateway-stripe' ) ),
1221
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $tax ),
1220
+				'label'  => esc_html(__('Tax', 'woocommerce-gateway-stripe')),
1221
+				'amount' => WC_Stripe_Helper::get_stripe_amount($tax),
1222 1222
 			);
1223 1223
 		}
1224 1224
 
1225
-		if ( WC()->cart->needs_shipping() ) {
1225
+		if (WC()->cart->needs_shipping()) {
1226 1226
 			$items[] = array(
1227
-				'label'  => esc_html( __( 'Shipping', 'woocommerce-gateway-stripe' ) ),
1228
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $shipping ),
1227
+				'label'  => esc_html(__('Shipping', 'woocommerce-gateway-stripe')),
1228
+				'amount' => WC_Stripe_Helper::get_stripe_amount($shipping),
1229 1229
 			);
1230 1230
 		}
1231 1231
 
1232
-		if ( WC()->cart->has_discount() ) {
1232
+		if (WC()->cart->has_discount()) {
1233 1233
 			$items[] = array(
1234
-				'label'  => esc_html( __( 'Discount', 'woocommerce-gateway-stripe' ) ),
1235
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $discounts ),
1234
+				'label'  => esc_html(__('Discount', 'woocommerce-gateway-stripe')),
1235
+				'amount' => WC_Stripe_Helper::get_stripe_amount($discounts),
1236 1236
 			);
1237 1237
 		}
1238 1238
 
1239
-		if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
1239
+		if (version_compare(WC_VERSION, '3.2', '<')) {
1240 1240
 			$cart_fees = WC()->cart->fees;
1241 1241
 		} else {
1242 1242
 			$cart_fees = WC()->cart->get_fees();
1243 1243
 		}
1244 1244
 
1245 1245
 		// Include fees and taxes as display items.
1246
-		foreach ( $cart_fees as $key => $fee ) {
1246
+		foreach ($cart_fees as $key => $fee) {
1247 1247
 			$items[] = array(
1248 1248
 				'label'  => $fee->name,
1249
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $fee->amount ),
1249
+				'amount' => WC_Stripe_Helper::get_stripe_amount($fee->amount),
1250 1250
 			);
1251 1251
 		}
1252 1252
 
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
 			'displayItems' => $items,
1255 1255
 			'total'        => array(
1256 1256
 				'label'   => $this->total_label,
1257
-				'amount'  => max( 0, apply_filters( 'woocommerce_stripe_calculated_total', WC_Stripe_Helper::get_stripe_amount( $order_total ), $order_total, WC()->cart ) ),
1257
+				'amount'  => max(0, apply_filters('woocommerce_stripe_calculated_total', WC_Stripe_Helper::get_stripe_amount($order_total), $order_total, WC()->cart)),
1258 1258
 				'pending' => false,
1259 1259
 			),
1260 1260
 		);
Please login to merge, or discard this patch.