Completed
Pull Request — master (#1192)
by Dwain
01:49
created
templates/emails/failed-preorder-authentication.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit; // Exit if accessed directly
4 4
 }
5 5
 ?>
6 6
 
7
-<?php do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
7
+<?php do_action('woocommerce_email_header', $email_heading, $email); ?>
8 8
 
9 9
 <?php
10
-$pre_wc_30 = version_compare( WC_VERSION, '3.0', '<' );
10
+$pre_wc_30 = version_compare(WC_VERSION, '3.0', '<');
11 11
 $billing_email = $pre_wc_30 ? $order->billing_email : $order->get_billing_email();
12 12
 $billing_phone = $pre_wc_30 ? $order->billing_phone : $order->get_billing_phone();
13 13
 
@@ -16,19 +16,19 @@  discard block
 block discarded – undo
16 16
 	echo wp_kses(
17 17
 		sprintf(
18 18
 			// translators: %s is a link to the payment re-authentication URL.
19
-			_x( 'Your pre-order is now available, but payment cannot be completed automatically. %s', 'In failed SCA authentication for a pre-order.', 'woocommerce-gateway-stripe' ),
20
-			'<a href="' . esc_url( $authorization_url ) . '">' . esc_html__( 'Authorize the payment now &raquo;', 'woocommerce-gateway-stripe' ) . '</a>'
19
+			_x('Your pre-order is now available, but payment cannot be completed automatically. %s', 'In failed SCA authentication for a pre-order.', 'woocommerce-gateway-stripe'),
20
+			'<a href="' . esc_url($authorization_url) . '">' . esc_html__('Authorize the payment now &raquo;', 'woocommerce-gateway-stripe') . '</a>'
21 21
 		),
22
-		array( 'a' => array( 'href' => true ) )
22
+		array('a' => array('href' => true))
23 23
 	);
24 24
 ?></p>
25 25
 
26
-<?php if ( $email->get_custom_message() ) : ?>
27
-	<blockquote><?php echo wpautop( wptexturize( $email->get_custom_message() ) ); ?></blockquote>
26
+<?php if ($email->get_custom_message()) : ?>
27
+	<blockquote><?php echo wpautop(wptexturize($email->get_custom_message())); ?></blockquote>
28 28
 <?php endif; ?>
29 29
 
30 30
 <?php
31
-do_action( 'woocommerce_email_before_order_table', $order, false, $plain_text, $email );
31
+do_action('woocommerce_email_before_order_table', $order, false, $plain_text, $email);
32 32
 
33 33
 /*
34 34
  * @hooked WC_Emails::order_details() Shows the order details table.
@@ -36,28 +36,28 @@  discard block
 block discarded – undo
36 36
  * @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
37 37
  * @since 2.5.0
38 38
  */
39
-do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
39
+do_action('woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email);
40 40
 
41 41
 /*
42 42
  * @hooked WC_Emails::order_meta() Shows order meta data.
43 43
  */
44
-do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
44
+do_action('woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email);
45 45
 
46
-do_action( 'woocommerce_email_after_order_table', $order, false, $plain_text, $email );
46
+do_action('woocommerce_email_after_order_table', $order, false, $plain_text, $email);
47 47
 
48 48
 /*
49 49
  * @hooked WC_Emails::customer_details() Shows customer details
50 50
  * @hooked WC_Emails::email_address() Shows email address
51 51
  */
52
-do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
52
+do_action('woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email);
53 53
 
54 54
 ?>
55 55
 <p>
56
-<?php esc_html_e( 'Thanks for shopping with us.', 'woocommerce-gateway-stripe' ); ?>
56
+<?php esc_html_e('Thanks for shopping with us.', 'woocommerce-gateway-stripe'); ?>
57 57
 </p>
58 58
 <?php
59 59
 
60 60
 /*
61 61
  * @hooked WC_Emails::email_footer() Output the email footer
62 62
  */
63
-do_action( 'woocommerce_email_footer', $email );
63
+do_action('woocommerce_email_footer', $email);
Please login to merge, or discard this patch.
templates/emails/plain/failed-preorder-authentication.php 1 patch
Spacing   +6 added lines, -6 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; // Exit if accessed directly
4 4
 }
5 5
 
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
 
8 8
 printf(
9 9
 	// translators: %s is a link to the payment re-authentication URL.
10
-	_x( 'Your pre-order is now available, but payment cannot be completed automatically. Please complete the payment now: %s', 'woocommerce-gateway-stripe' ),
10
+	_x('Your pre-order is now available, but payment cannot be completed automatically. Please complete the payment now: %s', 'woocommerce-gateway-stripe'),
11 11
 	$authorization_url
12 12
 );
13 13
 
14
-if ( $email->get_custom_message() ) :
14
+if ($email->get_custom_message()) :
15 15
 
16 16
 	echo "----------\n\n";
17
-	echo wptexturize( $email->get_custom_message() ) . "\n\n";
17
+	echo wptexturize($email->get_custom_message()) . "\n\n";
18 18
 	echo "----------\n\n";
19 19
 
20 20
 endif;
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 
23 23
 echo "\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n";
24 24
 
25
-do_action( 'woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email );
25
+do_action('woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email);
26 26
 
27 27
 echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
28 28
 
29
-echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
29
+echo apply_filters('woocommerce_email_footer_text', get_option('woocommerce_email_footer_text'));
Please login to merge, or discard this patch.
includes/compat/class-wc-stripe-pre-orders-compat.php 1 patch
Spacing   +49 added lines, -49 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
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	public $saved_cards;
12 12
 
13 13
 	public function __construct() {
14
-		$this->saved_cards = WC_Stripe_Helper::get_settings( 'stripe', 'saved_cards' );
14
+		$this->saved_cards = WC_Stripe_Helper::get_settings('stripe', 'saved_cards');
15 15
 	}
16 16
 
17 17
 	/**
@@ -19,22 +19,22 @@  discard block
 block discarded – undo
19 19
 	 * @param  int  $order_id
20 20
 	 * @return boolean
21 21
 	 */
22
-	public function is_pre_order( $order_id ) {
23
-		return WC_Pre_Orders_Order::order_contains_pre_order( $order_id );
22
+	public function is_pre_order($order_id) {
23
+		return WC_Pre_Orders_Order::order_contains_pre_order($order_id);
24 24
 	}
25 25
 
26 26
 	/**
27 27
 	 * Remove order meta
28 28
 	 * @param object $order
29 29
 	 */
30
-	public function remove_order_source_before_retry( $order ) {
31
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
32
-			delete_post_meta( $order->id, '_stripe_source_id' );
30
+	public function remove_order_source_before_retry($order) {
31
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
32
+			delete_post_meta($order->id, '_stripe_source_id');
33 33
 			// For BW compat will remove in the future.
34
-			delete_post_meta( $order->id, '_stripe_card_id' );
34
+			delete_post_meta($order->id, '_stripe_card_id');
35 35
 		} else {
36
-			$order->delete_meta_data( '_stripe_source_id' );
37
-			$order->delete_meta_data( '_stripe_card_id' );
36
+			$order->delete_meta_data('_stripe_source_id');
37
+			$order->delete_meta_data('_stripe_card_id');
38 38
 			$order->save();
39 39
 		}
40 40
 	}
@@ -43,31 +43,31 @@  discard block
 block discarded – undo
43 43
 	 * Process the pre-order when pay upon release is used.
44 44
 	 * @param int $order_id
45 45
 	 */
46
-	public function process_pre_order( $order_id ) {
46
+	public function process_pre_order($order_id) {
47 47
 		try {
48
-			$order = wc_get_order( $order_id );
48
+			$order = wc_get_order($order_id);
49 49
 
50 50
 			// This will throw exception if not valid.
51
-			$this->validate_minimum_order_amount( $order );
51
+			$this->validate_minimum_order_amount($order);
52 52
 
53
-			$prepared_source = $this->prepare_source( get_current_user_id(), true );
53
+			$prepared_source = $this->prepare_source(get_current_user_id(), true);
54 54
 
55 55
 			// We need a source on file to continue.
56
-			if ( empty( $prepared_source->customer ) || empty( $prepared_source->source ) ) {
57
-				throw new WC_Stripe_Exception( __( 'Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe' ) );
56
+			if (empty($prepared_source->customer) || empty($prepared_source->source)) {
57
+				throw new WC_Stripe_Exception(__('Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe'));
58 58
 			}
59 59
 
60 60
 			// Setup the response early to allow later modifications.
61 61
 			$response = array(
62 62
 				'result'   => 'success',
63
-				'redirect' => $this->get_return_url( $order ),
63
+				'redirect' => $this->get_return_url($order),
64 64
 			);
65 65
 
66
-			$this->save_source_to_order( $order, $prepared_source );
66
+			$this->save_source_to_order($order, $prepared_source);
67 67
 
68 68
 			// Try setting up a payment intent.
69
-			$intent_secret = $this->setup_intent( $order, $prepared_source );
70
-			if ( ! empty( $intent_secret ) ) {
69
+			$intent_secret = $this->setup_intent($order, $prepared_source);
70
+			if ( ! empty($intent_secret)) {
71 71
 				$response['setup_intent_secret'] = $intent_secret;
72 72
 				return $response;
73 73
 			}
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
 			WC()->cart->empty_cart();
77 77
 
78 78
 			// Is pre ordered!
79
-			WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order );
79
+			WC_Pre_Orders_Order::mark_order_as_pre_ordered($order);
80 80
 
81 81
 			// Return thank you page redirect
82 82
 			return $response;
83
-		} catch ( WC_Stripe_Exception $e ) {
84
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
85
-			WC_Stripe_Logger::log( 'Pre Orders Error: ' . $e->getMessage() );
83
+		} catch (WC_Stripe_Exception $e) {
84
+			wc_add_notice($e->getLocalizedMessage(), 'error');
85
+			WC_Stripe_Logger::log('Pre Orders Error: ' . $e->getMessage());
86 86
 
87 87
 			return array(
88 88
 				'result'   => 'success',
89
-				'redirect' => $order->get_checkout_payment_url( true ),
89
+				'redirect' => $order->get_checkout_payment_url(true),
90 90
 			);
91 91
 		}
92 92
 	}
@@ -99,50 +99,50 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @return void
101 101
 	 */
102
-	public function process_pre_order_release_payment( $order, $retry = true ) {
102
+	public function process_pre_order_release_payment($order, $retry = true) {
103 103
 		try {
104
-			$source   = $this->prepare_order_source( $order );
105
-			$response = $this->create_and_confirm_intent_for_off_session( $order, $source );
104
+			$source   = $this->prepare_order_source($order);
105
+			$response = $this->create_and_confirm_intent_for_off_session($order, $source);
106 106
 
107
-			$is_authentication_required = $this->is_authentication_required_for_payment( $response );
107
+			$is_authentication_required = $this->is_authentication_required_for_payment($response);
108 108
 
109
-			if ( ! empty( $response->error ) && ! $is_authentication_required ) {
110
-				if ( ! $retry ) {
111
-					throw new Exception( $response->error->message );
109
+			if ( ! empty($response->error) && ! $is_authentication_required) {
110
+				if ( ! $retry) {
111
+					throw new Exception($response->error->message);
112 112
 				}
113
-				$this->remove_order_source_before_retry( $order );
114
-				$this->process_pre_order_release_payment( $order, false );
115
-			} else if ( $is_authentication_required ) {
116
-				$charge = end( $response->error->payment_intent->charges->data );
113
+				$this->remove_order_source_before_retry($order);
114
+				$this->process_pre_order_release_payment($order, false);
115
+			} else if ($is_authentication_required) {
116
+				$charge = end($response->error->payment_intent->charges->data);
117 117
 				$id = $charge->id;
118
-				$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
118
+				$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
119 119
 
120
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_transaction_id', $id ) : $order->set_transaction_id( $id );
121
-				$order->update_status( 'failed', sprintf( __( 'Stripe charge awaiting authentication by user: %s.', 'woocommerce-gateway-stripe' ), $id ) );
122
-				if ( is_callable( array( $order, 'save' ) ) ) {
120
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_transaction_id', $id) : $order->set_transaction_id($id);
121
+				$order->update_status('failed', sprintf(__('Stripe charge awaiting authentication by user: %s.', 'woocommerce-gateway-stripe'), $id));
122
+				if (is_callable(array($order, 'save'))) {
123 123
 					$order->save();
124 124
 				}
125 125
 
126 126
 				WC_Emails::instance();
127 127
 
128
-				do_action( 'wc_gateway_stripe_process_payment_authentication_required', $order );
128
+				do_action('wc_gateway_stripe_process_payment_authentication_required', $order);
129 129
 
130
-				throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
130
+				throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
131 131
 			} else {
132 132
 				// Successful
133
-				$this->process_response( end( $response->charges->data ), $order );
133
+				$this->process_response(end($response->charges->data), $order);
134 134
 			}
135
-		} catch ( Exception $e ) {
136
-			$error_message = is_callable( array( $e, 'getLocalizedMessage' ) ) ? $e->getLocalizedMessage() : $e->getMessage();
135
+		} catch (Exception $e) {
136
+			$error_message = is_callable(array($e, 'getLocalizedMessage')) ? $e->getLocalizedMessage() : $e->getMessage();
137 137
 			/* translators: error message */
138
-			$order_note = sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $error_message );
138
+			$order_note = sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $error_message);
139 139
 
140 140
 			// Mark order as failed if not already set,
141 141
 			// otherwise, make sure we add the order note so we can detect when someone fails to check out multiple times
142
-			if ( ! $order->has_status( 'failed' ) ) {
143
-				$order->update_status( 'failed', $order_note );
142
+			if ( ! $order->has_status('failed')) {
143
+				$order->update_status('failed', $order_note);
144 144
 			} else {
145
-				$order->add_order_note( $order_note );
145
+				$order->add_order_note($order_note);
146 146
 			}
147 147
 		}
148 148
 	}
Please login to merge, or discard this patch.
templates/emails/failed-renewal-authentication-requested.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@  discard block
 block discarded – undo
6 6
  * @version 4.3.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Output the email header.
15 15
  */
16
-do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
16
+do_action('woocommerce_email_header', $email_heading, $email); ?>
17 17
 
18 18
 <p>
19 19
 	<?php
@@ -27,31 +27,31 @@  discard block
 block discarded – undo
27 27
 			),
28 28
 			$order->get_order_number(),
29 29
 			$order->get_formatted_billing_full_name(),
30
-			wcs_get_human_time_diff( $retry->get_time() )
30
+			wcs_get_human_time_diff($retry->get_time())
31 31
 		)
32 32
 	);
33 33
 	?>
34 34
 </p>
35
-<p><?php esc_html_e( 'The renewal order is as follows:', 'woocommerce-gateway-stripe' ); ?></p>
35
+<p><?php esc_html_e('The renewal order is as follows:', 'woocommerce-gateway-stripe'); ?></p>
36 36
 
37 37
 <?php
38 38
 
39 39
 /**
40 40
  * Shows the order details table.
41 41
  */
42
-do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
42
+do_action('woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email);
43 43
 
44 44
 /**
45 45
 * Shows order meta data.
46 46
 */
47
-do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
47
+do_action('woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email);
48 48
 
49 49
 /**
50 50
 * Shows customer details, and email address.
51 51
 */
52
-do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
52
+do_action('woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email);
53 53
 
54 54
 /**
55 55
 * Output the email footer.
56 56
 */
57
-do_action( 'woocommerce_email_footer', $email );
57
+do_action('woocommerce_email_footer', $email);
Please login to merge, or discard this patch.
templates/emails/plain/failed-renewal-authentication-requested.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @version 4.3.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
@@ -21,29 +21,29 @@  discard block
 block discarded – undo
21 21
 	),
22 22
 	$order->get_order_number(),
23 23
 	$order->get_formatted_billing_full_name(),
24
-	wcs_get_human_time_diff( $retry->get_time() )
24
+	wcs_get_human_time_diff($retry->get_time())
25 25
 ) . "\n\n";
26
-printf( __( 'The renewal order is as follows:', 'woocommerce-gateway-stripe' ) ) . "\n\n";
26
+printf(__('The renewal order is as follows:', 'woocommerce-gateway-stripe')) . "\n\n";
27 27
 
28 28
 echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
29 29
 
30 30
 /**
31 31
  * Shows the order details table.
32 32
  */
33
-do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
33
+do_action('woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email);
34 34
 
35 35
 echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
36 36
 
37 37
 /**
38 38
 * Shows order meta data.
39 39
 */
40
-do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
40
+do_action('woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email);
41 41
 
42 42
 /**
43 43
 * Shows customer details, and email address.
44 44
 */
45
-do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
45
+do_action('woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email);
46 46
 
47 47
 echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
48 48
 
49
-echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
49
+echo apply_filters('woocommerce_email_footer_text', get_option('woocommerce_email_footer_text'));
Please login to merge, or discard this patch.
includes/compat/class-wc-stripe-email-failed-authentication-retry.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @extends     WC_Email_Failed_Order
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
 	 */
27 27
 	public function __construct() {
28 28
 		$this->id          = 'failed_authentication_requested';
29
-		$this->title       = __( 'Payment Authentication Requested Email', 'woocommerce-gateway-stripe' );
30
-		$this->description = __( 'Payment authentication requested emails are sent to chosen recipient(s) when an attempt to automatically process a subscription renewal payment fails because the transaction requires an SCA verification, the customer is requested to authenticate the payment, and a retry rule has been applied to notify the customer again within a certain time period.', 'woocommerce-gateway-stripe' );
29
+		$this->title       = __('Payment Authentication Requested Email', 'woocommerce-gateway-stripe');
30
+		$this->description = __('Payment authentication requested emails are sent to chosen recipient(s) when an attempt to automatically process a subscription renewal payment fails because the transaction requires an SCA verification, the customer is requested to authenticate the payment, and a retry rule has been applied to notify the customer again within a certain time period.', 'woocommerce-gateway-stripe');
31 31
 
32
-		$this->heading = __( 'Automatic renewal payment failed due to authentication required', 'woocommerce-gateway-stripe' );
33
-		$this->subject = __( '[{site_title}] Automatic payment failed for {order_number}. Customer asked to authenticate payment and will be notified again {retry_time}', 'woocommerce-gateway-stripe' );
32
+		$this->heading = __('Automatic renewal payment failed due to authentication required', 'woocommerce-gateway-stripe');
33
+		$this->subject = __('[{site_title}] Automatic payment failed for {order_number}. Customer asked to authenticate payment and will be notified again {retry_time}', 'woocommerce-gateway-stripe');
34 34
 
35 35
 		$this->template_html  = 'emails/failed-renewal-authentication-requested.php';
36 36
 		$this->template_plain = 'emails/plain/failed-renewal-authentication-requested.php';
37
-		$this->template_base  = plugin_dir_path( WC_STRIPE_MAIN_FILE ) . 'templates/';
37
+		$this->template_base  = plugin_dir_path(WC_STRIPE_MAIN_FILE) . 'templates/';
38 38
 
39
-		$this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
39
+		$this->recipient = $this->get_option('recipient', get_option('admin_email'));
40 40
 
41 41
 		// We want all the parent's methods, with none of its properties, so call its parent's constructor, rather than my parent constructor.
42 42
 		WC_Email::__construct();
@@ -66,26 +66,26 @@  discard block
 block discarded – undo
66 66
 	 * @param int           $order_id The order ID.
67 67
 	 * @param WC_Order|null $order Order object.
68 68
 	 */
69
-	public function trigger( $order_id, $order = null ) {
69
+	public function trigger($order_id, $order = null) {
70 70
 		$this->object = $order;
71 71
 
72 72
 		$this->find['retry-time'] = '{retry_time}';
73
-		if ( class_exists( 'WCS_Retry_Manager' ) && function_exists( 'wcs_get_human_time_diff' ) ) {
74
-			$this->retry = WCS_Retry_Manager::store()->get_last_retry_for_order( wcs_get_objects_property( $order, 'id' ) );
75
-			$this->replace['retry-time'] = wcs_get_human_time_diff( $this->retry->get_time() );
73
+		if (class_exists('WCS_Retry_Manager') && function_exists('wcs_get_human_time_diff')) {
74
+			$this->retry = WCS_Retry_Manager::store()->get_last_retry_for_order(wcs_get_objects_property($order, 'id'));
75
+			$this->replace['retry-time'] = wcs_get_human_time_diff($this->retry->get_time());
76 76
 		} else {
77
-			WC_Stripe_Logger::log( 'WCS_Retry_Manager class or does not exist. Not able to send admnin email about customer notification for authentication required for renewal payment.' );
77
+			WC_Stripe_Logger::log('WCS_Retry_Manager class or does not exist. Not able to send admnin email about customer notification for authentication required for renewal payment.');
78 78
 			return;
79 79
 		}
80 80
 
81 81
 		$this->find['order-number']    = '{order_number}';
82 82
 		$this->replace['order-number'] = $this->object->get_order_number();
83 83
 
84
-		if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
84
+		if ( ! $this->is_enabled() || ! $this->get_recipient()) {
85 85
 			return;
86 86
 		}
87 87
 
88
-		$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
88
+		$this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
89 89
 	}
90 90
 
91 91
 	/**
Please login to merge, or discard this patch.
includes/compat/class-wc-stripe-email-failed-renewal-authentication.php 1 patch
Spacing   +21 added lines, -21 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; // Exit if accessed directly.
4 4
 }
5 5
 
@@ -14,20 +14,20 @@  discard block
 block discarded – undo
14 14
 	 *
15 15
 	 * @param WC_Email[] $email_classes All existing instances of WooCommerce emails.
16 16
 	 */
17
-	public function __construct( $email_classes = array() ) {
17
+	public function __construct($email_classes = array()) {
18 18
 		$this->id             = 'failed_renewal_authentication';
19
-		$this->title          = __( 'Failed Subscription Renewal SCA Authentication', 'woocommerce-gateway-stripe' );
20
-		$this->description    = __( 'Sent to a customer when a renewal fails because the transaction requires an SCA verification. The email contains renewal order information and payment links.', 'woocommerce-gateway-stripe' );
19
+		$this->title          = __('Failed Subscription Renewal SCA Authentication', 'woocommerce-gateway-stripe');
20
+		$this->description    = __('Sent to a customer when a renewal fails because the transaction requires an SCA verification. The email contains renewal order information and payment links.', 'woocommerce-gateway-stripe');
21 21
 		$this->customer_email = true;
22 22
 
23 23
 		$this->template_html  = 'emails/failed-renewal-authentication.php';
24 24
 		$this->template_plain = 'emails/plain/failed-renewal-authentication.php';
25
-		$this->template_base  = plugin_dir_path( WC_STRIPE_MAIN_FILE ) . 'templates/';
25
+		$this->template_base  = plugin_dir_path(WC_STRIPE_MAIN_FILE) . 'templates/';
26 26
 
27 27
 		// Triggers the email at the correct hook.
28
-		add_action( 'wc_gateway_stripe_process_payment_authentication_required', array( $this, 'trigger' ) );
28
+		add_action('wc_gateway_stripe_process_payment_authentication_required', array($this, 'trigger'));
29 29
 
30
-		if ( isset( $email_classes['WCS_Email_Customer_Renewal_Invoice'] ) ) {
30
+		if (isset($email_classes['WCS_Email_Customer_Renewal_Invoice'])) {
31 31
 			$this->original_email = $email_classes['WCS_Email_Customer_Renewal_Invoice'];
32 32
 		}
33 33
 
@@ -40,21 +40,21 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @param WC_Order $order The order that is being paid.
42 42
 	 */
43
-	public function trigger( $order ) {
44
-		if ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order->get_id() ) || wcs_is_subscription( $order->get_id() ) || wcs_order_contains_renewal( $order->get_id() ) ) ) {
45
-			parent::trigger( $order );
43
+	public function trigger($order) {
44
+		if (function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order->get_id()) || wcs_is_subscription($order->get_id()) || wcs_order_contains_renewal($order->get_id()))) {
45
+			parent::trigger($order);
46 46
 
47 47
 			// Prevent the renewal email from WooCommerce Subscriptions from being sent.
48
-			if ( isset( $this->original_email ) ) {
49
-				remove_action( 'woocommerce_generated_manual_renewal_order_renewal_notification', array( $this->original_email, 'trigger' ) );
50
-				remove_action( 'woocommerce_order_status_failed_renewal_notification', array( $this->original_email, 'trigger' ) );
48
+			if (isset($this->original_email)) {
49
+				remove_action('woocommerce_generated_manual_renewal_order_renewal_notification', array($this->original_email, 'trigger'));
50
+				remove_action('woocommerce_order_status_failed_renewal_notification', array($this->original_email, 'trigger'));
51 51
 			}
52 52
 
53 53
 			// Prevent the retry email from WooCommerce Subscriptions from being sent.
54
-			add_filter( 'wcs_get_retry_rule_raw', array( $this, 'prevent_retry_notification_email' ), 100, 3 );
54
+			add_filter('wcs_get_retry_rule_raw', array($this, 'prevent_retry_notification_email'), 100, 3);
55 55
 
56 56
 			// Send email to store owner indicating communication is happening with the customer to request authentication.
57
-			add_filter( 'wcs_get_retry_rule_raw', array( $this, 'set_store_owner_custom_email' ), 100, 3 );
57
+			add_filter('wcs_get_retry_rule_raw', array($this, 'set_store_owner_custom_email'), 100, 3);
58 58
 		}
59 59
 	}
60 60
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * @return string
65 65
 	 */
66 66
 	public function get_default_subject() {
67
-		return __( 'Payment authorization needed for renewal of {site_title} order {order_number}', 'woocommerce-gateway-stripe' );
67
+		return __('Payment authorization needed for renewal of {site_title} order {order_number}', 'woocommerce-gateway-stripe');
68 68
 	}
69 69
 
70 70
 	/**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @return string
74 74
 	 */
75 75
 	public function get_default_heading() {
76
-		return __( 'Payment authorization needed for renewal of order {order_number}', 'woocommerce-gateway-stripe' );
76
+		return __('Payment authorization needed for renewal of order {order_number}', 'woocommerce-gateway-stripe');
77 77
 	}
78 78
 
79 79
 	/**
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 * @param int   $order_id     The ID of the order that needs payment.
85 85
 	 * @return array
86 86
 	 */
87
-	public function prevent_retry_notification_email( $rule_array, $retry_number, $order_id ) {
88
-		if ( wcs_get_objects_property( $this->object, 'id' ) === $order_id ) {
87
+	public function prevent_retry_notification_email($rule_array, $retry_number, $order_id) {
88
+		if (wcs_get_objects_property($this->object, 'id') === $order_id) {
89 89
 			$rule_array['email_template_customer'] = '';
90 90
 		}
91 91
 
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 	 * @param int   $order_id     The ID of the order that needs payment.
101 101
 	 * @return array
102 102
 	 */
103
-	public function set_store_owner_custom_email( $rule_array, $retry_number, $order_id ) {
103
+	public function set_store_owner_custom_email($rule_array, $retry_number, $order_id) {
104 104
 		if (
105
-			wcs_get_objects_property( $this->object, 'id' ) === $order_id &&
105
+			wcs_get_objects_property($this->object, 'id') === $order_id &&
106 106
 			'' !== $rule_array['email_template_admin'] // Only send our email if a retry admin email was already going to be sent.
107 107
 		) {
108 108
 			$rule_array['email_template_admin'] = 'WC_Stripe_Email_Failed_Authentication_Retry';
Please login to merge, or discard this patch.
includes/class-wc-stripe-apple-pay-registration.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @since 4.0.6
6 6
  */
7 7
 
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if ( ! defined('ABSPATH')) {
9 9
 	exit;
10 10
 }
11 11
 
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
 	public $apple_pay_verify_notice;
61 61
 
62 62
 	public function __construct() {
63
-		add_action( 'woocommerce_stripe_updated', array( $this, 'update_verification_file' ) );
63
+		add_action('woocommerce_stripe_updated', array($this, 'update_verification_file'));
64 64
 
65
-		$this->stripe_settings         = get_option( 'woocommerce_stripe_settings', array() );
66
-		$this->stripe_enabled          = $this->get_option( 'enabled' );
67
-		$this->payment_request         = 'yes' === $this->get_option( 'payment_request', 'yes' );
68
-		$this->apple_pay_domain_set    = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' );
65
+		$this->stripe_settings         = get_option('woocommerce_stripe_settings', array());
66
+		$this->stripe_enabled          = $this->get_option('enabled');
67
+		$this->payment_request         = 'yes' === $this->get_option('payment_request', 'yes');
68
+		$this->apple_pay_domain_set    = 'yes' === $this->get_option('apple_pay_domain_set', 'no');
69 69
 		$this->apple_pay_verify_notice = '';
70
-		$this->testmode                = 'yes' === $this->get_option( 'testmode', 'no' );
71
-		$this->secret_key              = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
70
+		$this->testmode                = 'yes' === $this->get_option('testmode', 'no');
71
+		$this->secret_key              = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
72 72
 
73
-		if ( empty( $this->stripe_settings ) ) {
73
+		if (empty($this->stripe_settings)) {
74 74
 			return;
75 75
 		}
76 76
 
77 77
 		$this->init_apple_pay();
78 78
 
79
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
79
+		add_action('admin_notices', array($this, 'admin_notices'));
80 80
 	}
81 81
 
82 82
 	/**
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
 	 * @param string default
88 88
 	 * @return string $setting_value
89 89
 	 */
90
-	public function get_option( $setting = '', $default = '' ) {
91
-		if ( empty( $this->stripe_settings ) ) {
90
+	public function get_option($setting = '', $default = '') {
91
+		if (empty($this->stripe_settings)) {
92 92
 			return $default;
93 93
 		}
94 94
 
95
-		if ( ! empty( $this->stripe_settings[ $setting ] ) ) {
96
-			return $this->stripe_settings[ $setting ];
95
+		if ( ! empty($this->stripe_settings[$setting])) {
96
+			return $this->stripe_settings[$setting];
97 97
 		}
98 98
 
99 99
 		return $default;
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	public function init_apple_pay() {
109 109
 		if (
110 110
 			is_admin() &&
111
-			isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] &&
112
-			isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'] &&
113
-			isset( $_GET['section'] ) && 'stripe' === $_GET['section'] &&
111
+			isset($_GET['page']) && 'wc-settings' === $_GET['page'] &&
112
+			isset($_GET['tab']) && 'checkout' === $_GET['tab'] &&
113
+			isset($_GET['section']) && 'stripe' === $_GET['section'] &&
114 114
 			$this->payment_request
115 115
 		) {
116 116
 			$this->process_apple_pay_verification();
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 	 * @version 3.1.0
125 125
 	 * @param string $secret_key
126 126
 	 */
127
-	private function register_apple_pay_domain( $secret_key = '' ) {
128
-		if ( empty( $secret_key ) ) {
129
-			throw new Exception( __( 'Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe' ) );
127
+	private function register_apple_pay_domain($secret_key = '') {
128
+		if (empty($secret_key)) {
129
+			throw new Exception(__('Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe'));
130 130
 		}
131 131
 
132 132
 		$endpoint = 'https://api.stripe.com/v1/apple_pay/domains';
@@ -144,22 +144,22 @@  discard block
 block discarded – undo
144 144
 			$endpoint,
145 145
 			array(
146 146
 				'headers' => $headers,
147
-				'body'    => http_build_query( $data ),
147
+				'body'    => http_build_query($data),
148 148
 			)
149 149
 		);
150 150
 
151
-		if ( is_wp_error( $response ) ) {
151
+		if (is_wp_error($response)) {
152 152
 			/* translators: error message */
153
-			throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) );
153
+			throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $response->get_error_message()));
154 154
 		}
155 155
 
156
-		if ( 200 !== $response['response']['code'] ) {
157
-			$parsed_response = json_decode( $response['body'] );
156
+		if (200 !== $response['response']['code']) {
157
+			$parsed_response = json_decode($response['body']);
158 158
 
159 159
 			$this->apple_pay_verify_notice = $parsed_response->error->message;
160 160
 
161 161
 			/* translators: error message */
162
-			throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $parsed_response->error->message ) );
162
+			throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $parsed_response->error->message));
163 163
 		}
164 164
 	}
165 165
 
@@ -172,31 +172,31 @@  discard block
 block discarded – undo
172 172
 	 * @since 4.3.0
173 173
 	 * @return bool True on success, false on failure.
174 174
 	 */
175
-	public function update_verification_file( $force = false ) {
176
-			$path     = untrailingslashit( $_SERVER['DOCUMENT_ROOT'] );
175
+	public function update_verification_file($force = false) {
176
+			$path     = untrailingslashit($_SERVER['DOCUMENT_ROOT']);
177 177
 			$dir      = '.well-known';
178 178
 			$file     = 'apple-developer-merchantid-domain-association';
179 179
 			$fullpath = $path . '/' . $dir . '/' . $file;
180 180
 
181
-			$existing_contents = @file_get_contents( $fullpath );
182
-			$new_contents = @file_get_contents( WC_STRIPE_PLUGIN_PATH . '/' . $file );
183
-			if ( ( ! $existing_contents && ! $force ) || $existing_contents === $new_contents ) {
181
+			$existing_contents = @file_get_contents($fullpath);
182
+			$new_contents = @file_get_contents(WC_STRIPE_PLUGIN_PATH . '/' . $file);
183
+			if (( ! $existing_contents && ! $force) || $existing_contents === $new_contents) {
184 184
 				return true;
185 185
 			}
186 186
 
187
-			if ( ! file_exists( $path . '/' . $dir ) ) {
188
-				if ( ! @mkdir( $path . '/' . $dir, 0755 ) ) { // @codingStandardsIgnoreLine
189
-					WC_Stripe_Logger::log( 'Error: ' . __( 'Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe' ) );
187
+			if ( ! file_exists($path . '/' . $dir)) {
188
+				if ( ! @mkdir($path . '/' . $dir, 0755)) { // @codingStandardsIgnoreLine
189
+					WC_Stripe_Logger::log('Error: ' . __('Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe'));
190 190
 					return false;
191 191
 				}
192 192
 			}
193 193
 
194
-			if ( ! @copy( WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath ) ) { // @codingStandardsIgnoreLine
195
-				WC_Stripe_Logger::log( 'Error: ' . __( 'Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe' ) );
194
+			if ( ! @copy(WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath)) { // @codingStandardsIgnoreLine
195
+				WC_Stripe_Logger::log('Error: ' . __('Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe'));
196 196
 				return false;
197 197
 			}
198 198
 
199
-			WC_Stripe_Logger::log( 'Domain association file updated.' );
199
+			WC_Stripe_Logger::log('Domain association file updated.');
200 200
 			return true;
201 201
 	}
202 202
 
@@ -207,31 +207,31 @@  discard block
 block discarded – undo
207 207
 	 * @version 3.1.0
208 208
 	 */
209 209
 	public function process_apple_pay_verification() {
210
-		if ( ! $this->update_verification_file( true ) ) {
210
+		if ( ! $this->update_verification_file(true)) {
211 211
 			$this->stripe_settings['apple_pay_domain_set'] = 'no';
212
-			update_option( 'woocommerce_stripe_settings', $this->stripe_settings );
212
+			update_option('woocommerce_stripe_settings', $this->stripe_settings);
213 213
 			return;
214 214
 		}
215 215
 
216 216
 		try {
217 217
 			// At this point then the domain association folder and file should be available.
218 218
 			// Proceed to verify/and or verify again.
219
-			$this->register_apple_pay_domain( $this->secret_key );
219
+			$this->register_apple_pay_domain($this->secret_key);
220 220
 
221 221
 			// No errors to this point, verification success!
222 222
 			$this->stripe_settings['apple_pay_domain_set'] = 'yes';
223 223
 			$this->apple_pay_domain_set                    = true;
224 224
 
225
-			update_option( 'woocommerce_stripe_settings', $this->stripe_settings );
225
+			update_option('woocommerce_stripe_settings', $this->stripe_settings);
226 226
 
227
-			WC_Stripe_Logger::log( 'Your domain has been verified with Apple Pay!' );
227
+			WC_Stripe_Logger::log('Your domain has been verified with Apple Pay!');
228 228
 
229
-		} catch ( Exception $e ) {
229
+		} catch (Exception $e) {
230 230
 			$this->stripe_settings['apple_pay_domain_set'] = 'no';
231 231
 
232
-			update_option( 'woocommerce_stripe_settings', $this->stripe_settings );
232
+			update_option('woocommerce_stripe_settings', $this->stripe_settings);
233 233
 
234
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
234
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
235 235
 		}
236 236
 	}
237 237
 
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
 	 * @since 4.0.6
242 242
 	 */
243 243
 	public function admin_notices() {
244
-		if ( ! $this->stripe_enabled ) {
244
+		if ( ! $this->stripe_enabled) {
245 245
 			return;
246 246
 		}
247 247
 
248
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
248
+		if ( ! current_user_can('manage_woocommerce')) {
249 249
 			return;
250 250
 		}
251 251
 
252
-		if ( $this->payment_request && ! empty( $this->apple_pay_verify_notice ) ) {
252
+		if ($this->payment_request && ! empty($this->apple_pay_verify_notice)) {
253 253
 			$allowed_html = array(
254 254
 				'a' => array(
255 255
 					'href'  => array(),
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 				),
258 258
 			);
259 259
 
260
-			echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses( make_clickable( $this->apple_pay_verify_notice ), $allowed_html ) . '</p></div>';
260
+			echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses(make_clickable($this->apple_pay_verify_notice), $allowed_html) . '</p></div>';
261 261
 		}
262 262
 
263 263
 		/**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
 		 * when setting screen is displayed. So if domain verification is not set,
266 266
 		 * something went wrong so lets notify user.
267 267
 		 */
268
-		if ( ! empty( $this->secret_key ) && $this->payment_request && ! $this->apple_pay_domain_set ) {
268
+		if ( ! empty($this->secret_key) && $this->payment_request && ! $this->apple_pay_domain_set) {
269 269
 			/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
270
-			echo '<div class="error stripe-apple-pay-message"><p>' . sprintf( __( 'Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe' ), '<a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">', '</a>' ) . '</p></div>';
270
+			echo '<div class="error stripe-apple-pay-message"><p>' . sprintf(__('Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe'), '<a href="' . admin_url('admin.php?page=wc-status&tab=logs') . '">', '</a>') . '</p></div>';
271 271
 		}
272 272
 	}
273 273
 }
Please login to merge, or discard this patch.
includes/payment-methods/class-wc-stripe-payment-request.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * Get this instance.
131 131
 	 *
132 132
 	 * @since 4.0.6
133
-	 * @return class
133
+	 * @return WC_Stripe_Payment_Request
134 134
 	 */
135 135
 	public static function instance() {
136 136
 		return self::$_this;
@@ -604,7 +604,6 @@  discard block
 block discarded – undo
604 604
 	 *
605 605
 	 * @since 4.3.2
606 606
 	 *
607
-	 * @param object $post
608 607
 	 *
609 608
 	 * @return bool
610 609
 	 */
Please login to merge, or discard this patch.
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.