Completed
Pull Request — master (#867)
by Radoslav
02:02
created
includes/payment-methods/class-wc-gateway-stripe-eps.php 1 patch
Spacing   +67 added lines, -67 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
 
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function __construct() {
59 59
 		$this->id           = 'stripe_eps';
60
-		$this->method_title = __( 'Stripe EPS', 'woocommerce-gateway-stripe' );
60
+		$this->method_title = __('Stripe EPS', 'woocommerce-gateway-stripe');
61 61
 		/* translators: link */
62
-		$this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
62
+		$this->method_description = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe'));
63 63
 		$this->supports           = array(
64 64
 			'products',
65 65
 			'refunds',
@@ -71,23 +71,23 @@  discard block
 block discarded – undo
71 71
 		// Load the settings.
72 72
 		$this->init_settings();
73 73
 
74
-		$main_settings              = get_option( 'woocommerce_stripe_settings' );
75
-		$this->title                = $this->get_option( 'title' );
76
-		$this->description          = $this->get_option( 'description' );
77
-		$this->enabled              = $this->get_option( 'enabled' );
78
-		$this->testmode             = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false;
79
-		$this->saved_cards          = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false;
80
-		$this->publishable_key      = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : '';
81
-		$this->secret_key           = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : '';
82
-		$this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : '';
83
-
84
-		if ( $this->testmode ) {
85
-			$this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : '';
86
-			$this->secret_key      = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : '';
74
+		$main_settings              = get_option('woocommerce_stripe_settings');
75
+		$this->title                = $this->get_option('title');
76
+		$this->description          = $this->get_option('description');
77
+		$this->enabled              = $this->get_option('enabled');
78
+		$this->testmode             = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false;
79
+		$this->saved_cards          = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false;
80
+		$this->publishable_key      = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : '';
81
+		$this->secret_key           = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : '';
82
+		$this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : '';
83
+
84
+		if ($this->testmode) {
85
+			$this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : '';
86
+			$this->secret_key      = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : '';
87 87
 		}
88 88
 
89
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
90
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
89
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
90
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
91 91
 	}
92 92
 
93 93
 	/**
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @return bool
115 115
 	 */
116 116
 	public function is_available() {
117
-		if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
117
+		if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
118 118
 			return false;
119 119
 		}
120 120
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 
134 134
 		$icons_str = '';
135 135
 
136
-		$icons_str .= isset( $icons['eps'] ) ? $icons['eps'] : '';
136
+		$icons_str .= isset($icons['eps']) ? $icons['eps'] : '';
137 137
 
138
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
138
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
139 139
 	}
140 140
 
141 141
 	/**
@@ -146,19 +146,19 @@  discard block
 block discarded – undo
146 146
 	 * @access public
147 147
 	 */
148 148
 	public function payment_scripts() {
149
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) {
149
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) {
150 150
 			return;
151 151
 		}
152 152
 
153
-		wp_enqueue_style( 'stripe_styles' );
154
-		wp_enqueue_script( 'woocommerce_stripe' );
153
+		wp_enqueue_style('stripe_styles');
154
+		wp_enqueue_script('woocommerce_stripe');
155 155
 	}
156 156
 
157 157
 	/**
158 158
 	 * Initialize Gateway Settings Form Fields.
159 159
 	 */
160 160
 	public function init_form_fields() {
161
-		$this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-eps-settings.php' );
161
+		$this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-eps-settings.php');
162 162
 	}
163 163
 
164 164
 	/**
@@ -170,13 +170,13 @@  discard block
 block discarded – undo
170 170
 		$description = $this->get_description();
171 171
 
172 172
 		// If paying from order, we need to get total from order not cart.
173
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
174
-			$order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) );
173
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
174
+			$order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key'])));
175 175
 			$total = $order->get_total();
176 176
 		}
177 177
 
178
-		if ( is_add_payment_method_page() ) {
179
-			$pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' );
178
+		if (is_add_payment_method_page()) {
179
+			$pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe');
180 180
 			$total           = '';
181 181
 		} else {
182 182
 			$pay_button_text = '';
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
 
185 185
 		echo '<div
186 186
 			id="stripe-eps-payment-data"
187
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
188
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">';
187
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
188
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">';
189 189
 
190
-		if ( $description ) {
191
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id );
190
+		if ($description) {
191
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id);
192 192
 		}
193 193
 
194 194
 		echo '</div>';
@@ -202,24 +202,24 @@  discard block
 block discarded – undo
202 202
 	 * @param object $order
203 203
 	 * @return mixed
204 204
 	 */
205
-	public function create_source( $order ) {
206
-		$currency              = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency();
207
-		$order_id              = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
208
-		$return_url            = $this->get_stripe_return_url( $order );
205
+	public function create_source($order) {
206
+		$currency              = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency();
207
+		$order_id              = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
208
+		$return_url            = $this->get_stripe_return_url($order);
209 209
 		$post_data             = array();
210
-		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency );
211
-		$post_data['currency'] = strtolower( $currency );
210
+		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency);
211
+		$post_data['currency'] = strtolower($currency);
212 212
 		$post_data['type']     = 'eps';
213
-		$post_data['owner']    = $this->get_owner_details( $order );
214
-		$post_data['redirect'] = array( 'return_url' => $return_url );
213
+		$post_data['owner']    = $this->get_owner_details($order);
214
+		$post_data['redirect'] = array('return_url' => $return_url);
215 215
 
216
-		if ( ! empty( $this->statement_descriptor ) ) {
217
-			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor );
216
+		if ( ! empty($this->statement_descriptor)) {
217
+			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor);
218 218
 		}
219 219
 
220
-		WC_Stripe_Logger::log( 'Info: Begin creating EPS source' );
220
+		WC_Stripe_Logger::log('Info: Begin creating EPS source');
221 221
 
222
-		return WC_Stripe_API::request( $post_data, 'sources' );
222
+		return WC_Stripe_API::request($post_data, 'sources');
223 223
 	}
224 224
 
225 225
 	/**
@@ -233,51 +233,51 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @return array|void
235 235
 	 */
236
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
236
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
237 237
 		try {
238
-			$order = wc_get_order( $order_id );
238
+			$order = wc_get_order($order_id);
239 239
 
240 240
 			// This will throw exception if not valid.
241
-			$this->validate_minimum_order_amount( $order );
241
+			$this->validate_minimum_order_amount($order);
242 242
 
243 243
 			// This comes from the create account checkbox in the checkout page.
244
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
244
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
245 245
 
246
-			if ( $create_account ) {
247
-				$new_customer_id     = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id();
248
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
246
+			if ($create_account) {
247
+				$new_customer_id     = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id();
248
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
249 249
 				$new_stripe_customer->create_customer();
250 250
 			}
251 251
 
252
-			$response = $this->create_source( $order );
252
+			$response = $this->create_source($order);
253 253
 
254
-			if ( ! empty( $response->error ) ) {
255
-				$order->add_order_note( $response->error->message );
254
+			if ( ! empty($response->error)) {
255
+				$order->add_order_note($response->error->message);
256 256
 
257
-				throw new Exception( $response->error->message );
257
+				throw new Exception($response->error->message);
258 258
 			}
259 259
 
260
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
261
-				update_post_meta( $order_id, '_stripe_source_id', $response->id );
260
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
261
+				update_post_meta($order_id, '_stripe_source_id', $response->id);
262 262
 			} else {
263
-				$order->update_meta_data( '_stripe_source_id', $response->id );
263
+				$order->update_meta_data('_stripe_source_id', $response->id);
264 264
 				$order->save();
265 265
 			}
266 266
 
267
-			WC_Stripe_Logger::log( 'Info: Redirecting to EPS...' );
267
+			WC_Stripe_Logger::log('Info: Redirecting to EPS...');
268 268
 
269 269
 			return array(
270 270
 				'result'   => 'success',
271
-				'redirect' => esc_url_raw( $response->redirect->url ),
271
+				'redirect' => esc_url_raw($response->redirect->url),
272 272
 			);
273
-		} catch ( Exception $e ) {
274
-			wc_add_notice( $e->getMessage(), 'error' );
275
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
273
+		} catch (Exception $e) {
274
+			wc_add_notice($e->getMessage(), 'error');
275
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
276 276
 
277
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
277
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
278 278
 
279
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
280
-				$this->send_failed_order_email( $order_id );
279
+			if ($order->has_status(array('pending', 'failed'))) {
280
+				$this->send_failed_order_email($order_id);
281 281
 			}
282 282
 
283 283
 			return array(
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  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
 // if uninstall not called from WordPress exit
7
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
7
+if ( ! defined('WP_UNINSTALL_PLUGIN')) {
8 8
 	exit;
9 9
 }
10 10
 
@@ -13,31 +13,31 @@  discard block
 block discarded – undo
13 13
  * wp-config.php. This is to prevent data loss when deleting the plugin from the backend
14 14
  * and to ensure only the site owner can perform this action.
15 15
  */
16
-if ( defined( 'WC_REMOVE_ALL_DATA' ) && true === WC_REMOVE_ALL_DATA ) {
16
+if (defined('WC_REMOVE_ALL_DATA') && true === WC_REMOVE_ALL_DATA) {
17 17
 	// Delete options.
18
-	delete_option( 'woocommerce_stripe_settings' );
19
-	delete_option( 'wc_stripe_show_styles_notice' );
20
-	delete_option( 'wc_stripe_show_request_api_notice' );
21
-	delete_option( 'wc_stripe_show_apple_pay_notice' );
22
-	delete_option( 'wc_stripe_show_ssl_notice' );
23
-	delete_option( 'wc_stripe_show_keys_notice' );
24
-	delete_option( 'wc_stripe_show_alipay_notice' );
25
-	delete_option( 'wc_stripe_show_bancontact_notice' );
26
-	delete_option( 'wc_stripe_show_bitcoin_notice' );
27
-	delete_option( 'wc_stripe_show_eps_notice' );
28
-	delete_option( 'wc_stripe_show_giropay_notice' );
29
-	delete_option( 'wc_stripe_show_ideal_notice' );
30
-	delete_option( 'wc_stripe_show_multibanco_notice' );
31
-	delete_option( 'wc_stripe_show_p24_notice' );
32
-	delete_option( 'wc_stripe_show_sepa_notice' );
33
-	delete_option( 'wc_stripe_show_sofort_notice' );
34
-	delete_option( 'wc_stripe_version' );
35
-	delete_option( 'woocommerce_stripe_bancontact_settings' );
36
-	delete_option( 'woocommerce_stripe_alipay_settings' );
37
-	delete_option( 'woocommerce_stripe_bitcoin_settings' );
38
-	delete_option( 'woocommerce_stripe_ideal_settings' );
39
-	delete_option( 'woocommerce_stripe_p24_settings' );
40
-	delete_option( 'woocommerce_stripe_giropay_settings' );
41
-	delete_option( 'woocommerce_stripe_sepa_settings' );
42
-	delete_option( 'woocommerce_stripe_sofort_settings' );
18
+	delete_option('woocommerce_stripe_settings');
19
+	delete_option('wc_stripe_show_styles_notice');
20
+	delete_option('wc_stripe_show_request_api_notice');
21
+	delete_option('wc_stripe_show_apple_pay_notice');
22
+	delete_option('wc_stripe_show_ssl_notice');
23
+	delete_option('wc_stripe_show_keys_notice');
24
+	delete_option('wc_stripe_show_alipay_notice');
25
+	delete_option('wc_stripe_show_bancontact_notice');
26
+	delete_option('wc_stripe_show_bitcoin_notice');
27
+	delete_option('wc_stripe_show_eps_notice');
28
+	delete_option('wc_stripe_show_giropay_notice');
29
+	delete_option('wc_stripe_show_ideal_notice');
30
+	delete_option('wc_stripe_show_multibanco_notice');
31
+	delete_option('wc_stripe_show_p24_notice');
32
+	delete_option('wc_stripe_show_sepa_notice');
33
+	delete_option('wc_stripe_show_sofort_notice');
34
+	delete_option('wc_stripe_version');
35
+	delete_option('woocommerce_stripe_bancontact_settings');
36
+	delete_option('woocommerce_stripe_alipay_settings');
37
+	delete_option('woocommerce_stripe_bitcoin_settings');
38
+	delete_option('woocommerce_stripe_ideal_settings');
39
+	delete_option('woocommerce_stripe_p24_settings');
40
+	delete_option('woocommerce_stripe_giropay_settings');
41
+	delete_option('woocommerce_stripe_sepa_settings');
42
+	delete_option('woocommerce_stripe_sofort_settings');
43 43
 }
Please login to merge, or discard this patch.
includes/admin/class-wc-stripe-privacy.php 1 patch
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! class_exists( 'WC_Abstract_Privacy' ) ) {
2
+if ( ! class_exists('WC_Abstract_Privacy')) {
3 3
 	return;
4 4
 }
5 5
 
@@ -9,20 +9,20 @@  discard block
 block discarded – undo
9 9
 	 *
10 10
 	 */
11 11
 	public function __construct() {
12
-		parent::__construct( __( 'Stripe', 'woocommerce-gateway-stripe' ) );
12
+		parent::__construct(__('Stripe', 'woocommerce-gateway-stripe'));
13 13
 
14
-		$this->add_exporter( 'woocommerce-gateway-stripe-order-data', __( 'WooCommerce Stripe Order Data', 'woocommerce-gateway-stripe' ), array( $this, 'order_data_exporter' ) );
14
+		$this->add_exporter('woocommerce-gateway-stripe-order-data', __('WooCommerce Stripe Order Data', 'woocommerce-gateway-stripe'), array($this, 'order_data_exporter'));
15 15
 
16
-		if ( function_exists( 'wcs_get_subscriptions' ) ) {
17
-			$this->add_exporter( 'woocommerce-gateway-stripe-subscriptions-data', __( 'WooCommerce Stripe Subscriptions Data', 'woocommerce-gateway-stripe' ), array( $this, 'subscriptions_data_exporter' ) );
16
+		if (function_exists('wcs_get_subscriptions')) {
17
+			$this->add_exporter('woocommerce-gateway-stripe-subscriptions-data', __('WooCommerce Stripe Subscriptions Data', 'woocommerce-gateway-stripe'), array($this, 'subscriptions_data_exporter'));
18 18
 		}
19 19
 
20
-		$this->add_exporter( 'woocommerce-gateway-stripe-customer-data', __( 'WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe' ), array( $this, 'customer_data_exporter' ) );
20
+		$this->add_exporter('woocommerce-gateway-stripe-customer-data', __('WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe'), array($this, 'customer_data_exporter'));
21 21
 
22
-		$this->add_eraser( 'woocommerce-gateway-stripe-customer-data', __( 'WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe' ), array( $this, 'customer_data_eraser' ) );
23
-		$this->add_eraser( 'woocommerce-gateway-stripe-order-data', __( 'WooCommerce Stripe Data', 'woocommerce-gateway-stripe' ), array( $this, 'order_data_eraser' ) );
22
+		$this->add_eraser('woocommerce-gateway-stripe-customer-data', __('WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe'), array($this, 'customer_data_eraser'));
23
+		$this->add_eraser('woocommerce-gateway-stripe-order-data', __('WooCommerce Stripe Data', 'woocommerce-gateway-stripe'), array($this, 'order_data_eraser'));
24 24
 
25
-		add_filter( 'woocommerce_get_settings_account', array( $this, 'account_settings' ) );
25
+		add_filter('woocommerce_get_settings_account', array($this, 'account_settings'));
26 26
 	}
27 27
 
28 28
 	/**
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 	 * @param array $settings
32 32
 	 * @return array $settings Updated
33 33
 	 */
34
-	public function account_settings( $settings ) {
34
+	public function account_settings($settings) {
35 35
 		$insert_setting = array(
36 36
 			array(
37
-				'title'       => __( 'Retain Stripe Data', 'woocommerce-gateway-stripe' ),
38
-				'desc_tip'    => __( 'Retains any Stripe data such as Stripe customer ID, source ID.', 'woocommerce-gateway-stripe' ),
37
+				'title'       => __('Retain Stripe Data', 'woocommerce-gateway-stripe'),
38
+				'desc_tip'    => __('Retains any Stripe data such as Stripe customer ID, source ID.', 'woocommerce-gateway-stripe'),
39 39
 				'id'          => 'woocommerce_gateway_stripe_retention',
40 40
 				'type'        => 'relative_date_selector',
41
-				'placeholder' => __( 'N/A', 'woocommerce-gateway-stripe' ),
41
+				'placeholder' => __('N/A', 'woocommerce-gateway-stripe'),
42 42
 				'default'     => '',
43 43
 				'autoload'    => false,
44 44
 			),
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 
47 47
 		$index = null;
48 48
 
49
-		foreach ( $settings as $key => $value) {
50
-			if ( 'sectionend' === $value[ 'type' ] && 'personal_data_retention' === $value[ 'id' ] ) {
49
+		foreach ($settings as $key => $value) {
50
+			if ('sectionend' === $value['type'] && 'personal_data_retention' === $value['id']) {
51 51
 				$index = $key;
52 52
 				break;
53 53
 			}
54 54
 		}
55 55
 
56
-		if ( ! is_null( $index ) ) {
57
-			array_splice( $settings, $index, 0, $insert_setting );
56
+		if ( ! is_null($index)) {
57
+			array_splice($settings, $index, 0, $insert_setting);
58 58
 		}
59 59
 
60 60
 		return $settings;
@@ -68,22 +68,22 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @return array WP_Post
70 70
 	 */
71
-	protected function get_stripe_orders( $email_address, $page ) {
72
-		$user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
71
+	protected function get_stripe_orders($email_address, $page) {
72
+		$user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data.
73 73
 
74 74
 		$order_query = array(
75
-			'payment_method' => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ),
75
+			'payment_method' => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'),
76 76
 			'limit'          => 10,
77 77
 			'page'           => $page,
78 78
 		);
79 79
 
80
-		if ( $user instanceof WP_User ) {
80
+		if ($user instanceof WP_User) {
81 81
 			$order_query['customer_id'] = (int) $user->ID;
82 82
 		} else {
83 83
 			$order_query['billing_email'] = $email_address;
84 84
 		}
85 85
 
86
-		return wc_get_orders( $order_query );
86
+		return wc_get_orders($order_query);
87 87
 	}
88 88
 
89 89
 	/**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	public function get_privacy_message() {
94 94
 		/* translators: %s URL to docs */
95
-		return wpautop( sprintf( __( 'By using this extension, you may be storing personal data or sharing data with an external service. <a href="%s" target="_blank">Learn more about how this works, including what you may want to include in your privacy policy.</a>', 'woocommerce-gateway-stripe' ), 'https://docs.woocommerce.com/document/privacy-payments/#woocommerce-gateway-stripe' ) );
95
+		return wpautop(sprintf(__('By using this extension, you may be storing personal data or sharing data with an external service. <a href="%s" target="_blank">Learn more about how this works, including what you may want to include in your privacy policy.</a>', 'woocommerce-gateway-stripe'), 'https://docs.woocommerce.com/document/privacy-payments/#woocommerce-gateway-stripe'));
96 96
 	}
97 97
 
98 98
 	/**
@@ -103,34 +103,34 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return array
105 105
 	 */
106
-	public function order_data_exporter( $email_address, $page = 1 ) {
106
+	public function order_data_exporter($email_address, $page = 1) {
107 107
 		$done           = false;
108 108
 		$data_to_export = array();
109 109
 
110
-		$orders = $this->get_stripe_orders( $email_address, (int) $page );
110
+		$orders = $this->get_stripe_orders($email_address, (int) $page);
111 111
 
112 112
 		$done = true;
113 113
 
114
-		if ( 0 < count( $orders ) ) {
115
-			foreach ( $orders as $order ) {
114
+		if (0 < count($orders)) {
115
+			foreach ($orders as $order) {
116 116
 				$data_to_export[] = array(
117 117
 					'group_id'    => 'woocommerce_orders',
118
-					'group_label' => __( 'Orders', 'woocommerce-gateway-stripe' ),
118
+					'group_label' => __('Orders', 'woocommerce-gateway-stripe'),
119 119
 					'item_id'     => 'order-' . $order->get_id(),
120 120
 					'data'        => array(
121 121
 						array(
122
-							'name'  => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ),
123
-							'value' => get_post_meta( $order->get_id(), '_stripe_source_id', true ),
122
+							'name'  => __('Stripe payment id', 'woocommerce-gateway-stripe'),
123
+							'value' => get_post_meta($order->get_id(), '_stripe_source_id', true),
124 124
 						),
125 125
 						array(
126
-							'name'  => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ),
127
-							'value' => get_post_meta( $order->get_id(), '_stripe_customer_id', true ),
126
+							'name'  => __('Stripe customer id', 'woocommerce-gateway-stripe'),
127
+							'value' => get_post_meta($order->get_id(), '_stripe_customer_id', true),
128 128
 						),
129 129
 					),
130 130
 				);
131 131
 			}
132 132
 
133
-			$done = 10 > count( $orders );
133
+			$done = 10 > count($orders);
134 134
 		}
135 135
 
136 136
 		return array(
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @return array
149 149
 	 */
150
-	public function subscriptions_data_exporter( $email_address, $page = 1 ) {
150
+	public function subscriptions_data_exporter($email_address, $page = 1) {
151 151
 		$done           = false;
152 152
 		$page           = (int) $page;
153 153
 		$data_to_export = array();
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			'relation' => 'AND',
157 157
 			array(
158 158
 				'key'     => '_payment_method',
159
-				'value'   => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ),
159
+				'value'   => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'),
160 160
 				'compare' => 'IN',
161 161
 			),
162 162
 			array(
@@ -172,30 +172,30 @@  discard block
 block discarded – undo
172 172
 			'meta_query'     => $meta_query,
173 173
 		);
174 174
 
175
-		$subscriptions = wcs_get_subscriptions( $subscription_query );
175
+		$subscriptions = wcs_get_subscriptions($subscription_query);
176 176
 
177 177
 		$done = true;
178 178
 
179
-		if ( 0 < count( $subscriptions ) ) {
180
-			foreach ( $subscriptions as $subscription ) {
179
+		if (0 < count($subscriptions)) {
180
+			foreach ($subscriptions as $subscription) {
181 181
 				$data_to_export[] = array(
182 182
 					'group_id'    => 'woocommerce_subscriptions',
183
-					'group_label' => __( 'Subscriptions', 'woocommerce-gateway-stripe' ),
183
+					'group_label' => __('Subscriptions', 'woocommerce-gateway-stripe'),
184 184
 					'item_id'     => 'subscription-' . $subscription->get_id(),
185 185
 					'data'        => array(
186 186
 						array(
187
-							'name'  => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ),
188
-							'value' => get_post_meta( $subscription->get_id(), '_stripe_source_id', true ),
187
+							'name'  => __('Stripe payment id', 'woocommerce-gateway-stripe'),
188
+							'value' => get_post_meta($subscription->get_id(), '_stripe_source_id', true),
189 189
 						),
190 190
 						array(
191
-							'name'  => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ),
192
-							'value' => get_post_meta( $subscription->get_id(), '_stripe_customer_id', true ),
191
+							'name'  => __('Stripe customer id', 'woocommerce-gateway-stripe'),
192
+							'value' => get_post_meta($subscription->get_id(), '_stripe_customer_id', true),
193 193
 						),
194 194
 					),
195 195
 				);
196 196
 			}
197 197
 
198
-			$done = 10 > count( $subscriptions );
198
+			$done = 10 > count($subscriptions);
199 199
 		}
200 200
 
201 201
 		return array(
@@ -211,24 +211,24 @@  discard block
 block discarded – undo
211 211
 	 * @param int    $page  Page.
212 212
 	 * @return array An array of personal data in name value pairs
213 213
 	 */
214
-	public function customer_data_exporter( $email_address, $page ) {
215
-		$user           = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
214
+	public function customer_data_exporter($email_address, $page) {
215
+		$user           = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data.
216 216
 		$data_to_export = array();
217 217
 
218
-		if ( $user instanceof WP_User ) {
219
-			$stripe_user = new WC_Stripe_Customer( $user->ID );
218
+		if ($user instanceof WP_User) {
219
+			$stripe_user = new WC_Stripe_Customer($user->ID);
220 220
 
221 221
 			$data_to_export[] = array(
222 222
 				'group_id'    => 'woocommerce_customer',
223
-				'group_label' => __( 'Customer Data', 'woocommerce-gateway-stripe' ),
223
+				'group_label' => __('Customer Data', 'woocommerce-gateway-stripe'),
224 224
 				'item_id'     => 'user',
225 225
 				'data'        => array(
226 226
 					array(
227
-						'name'  => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ),
228
-						'value' => get_user_meta( $user->ID, '_stripe_source_id', true ),
227
+						'name'  => __('Stripe payment id', 'woocommerce-gateway-stripe'),
228
+						'value' => get_user_meta($user->ID, '_stripe_source_id', true),
229 229
 					),
230 230
 					array(
231
-						'name'  => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ),
231
+						'name'  => __('Stripe customer id', 'woocommerce-gateway-stripe'),
232 232
 						'value' => $stripe_user->get_id(),
233 233
 					),
234 234
 				),
@@ -248,25 +248,25 @@  discard block
 block discarded – undo
248 248
 	 * @param int    $page  Page.
249 249
 	 * @return array An array of personal data in name value pairs
250 250
 	 */
251
-	public function customer_data_eraser( $email_address, $page ) {
251
+	public function customer_data_eraser($email_address, $page) {
252 252
 		$page               = (int) $page;
253
-		$user               = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
253
+		$user               = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data.
254 254
 		$stripe_customer_id = '';
255 255
 		$stripe_source_id   = '';
256 256
 
257
-		if ( $user instanceof WP_User ) {
258
-			$stripe_customer_id = get_user_meta( $user->ID, '_stripe_customer_id', true );
259
-			$stripe_source_id   = get_user_meta( $user->ID, '_stripe_source_id', true );
257
+		if ($user instanceof WP_User) {
258
+			$stripe_customer_id = get_user_meta($user->ID, '_stripe_customer_id', true);
259
+			$stripe_source_id   = get_user_meta($user->ID, '_stripe_source_id', true);
260 260
 		}
261 261
 
262 262
 		$items_removed = false;
263 263
 		$messages      = array();
264 264
 
265
-		if ( ! empty( $stripe_customer_id ) || ! empty( $stripe_source_id ) ) {
265
+		if ( ! empty($stripe_customer_id) || ! empty($stripe_source_id)) {
266 266
 			$items_removed = true;
267
-			delete_user_meta( $user->ID, '_stripe_customer_id' );
268
-			delete_user_meta( $user->ID, '_stripe_source_id' );
269
-			$messages[] = __( 'Stripe User Data Erased.', 'woocommerce-gateway-stripe' );
267
+			delete_user_meta($user->ID, '_stripe_customer_id');
268
+			delete_user_meta($user->ID, '_stripe_source_id');
269
+			$messages[] = __('Stripe User Data Erased.', 'woocommerce-gateway-stripe');
270 270
 		}
271 271
 
272 272
 		return array(
@@ -284,29 +284,29 @@  discard block
 block discarded – undo
284 284
 	 * @param int    $page  Page.
285 285
 	 * @return array An array of personal data in name value pairs
286 286
 	 */
287
-	public function order_data_eraser( $email_address, $page ) {
288
-		$orders = $this->get_stripe_orders( $email_address, (int) $page );
287
+	public function order_data_eraser($email_address, $page) {
288
+		$orders = $this->get_stripe_orders($email_address, (int) $page);
289 289
 
290 290
 		$items_removed  = false;
291 291
 		$items_retained = false;
292 292
 		$messages       = array();
293 293
 
294
-		foreach ( (array) $orders as $order ) {
295
-			$order = wc_get_order( $order->get_id() );
294
+		foreach ((array) $orders as $order) {
295
+			$order = wc_get_order($order->get_id());
296 296
 
297
-			list( $removed, $retained, $msgs ) = $this->maybe_handle_order( $order );
297
+			list($removed, $retained, $msgs) = $this->maybe_handle_order($order);
298 298
 			$items_removed                    |= $removed;
299 299
 			$items_retained                   |= $retained;
300
-			$messages                          = array_merge( $messages, $msgs );
300
+			$messages                          = array_merge($messages, $msgs);
301 301
 
302
-			list( $removed, $retained, $msgs ) = $this->maybe_handle_subscription( $order );
302
+			list($removed, $retained, $msgs) = $this->maybe_handle_subscription($order);
303 303
 			$items_removed                    |= $removed;
304 304
 			$items_retained                   |= $retained;
305
-			$messages                          = array_merge( $messages, $msgs );
305
+			$messages                          = array_merge($messages, $msgs);
306 306
 		}
307 307
 
308 308
 		// Tell core if we have more orders to work on still
309
-		$done = count( $orders ) < 10;
309
+		$done = count($orders) < 10;
310 310
 
311 311
 		return array(
312 312
 			'items_removed'  => $items_removed,
@@ -322,47 +322,47 @@  discard block
 block discarded – undo
322 322
 	 * @param WC_Order $order
323 323
 	 * @return array
324 324
 	 */
325
-	protected function maybe_handle_subscription( $order ) {
326
-		if ( ! class_exists( 'WC_Subscriptions' ) ) {
327
-			return array( false, false, array() );
325
+	protected function maybe_handle_subscription($order) {
326
+		if ( ! class_exists('WC_Subscriptions')) {
327
+			return array(false, false, array());
328 328
 		}
329 329
 
330
-		if ( ! wcs_order_contains_subscription( $order ) ) {
331
-			return array( false, false, array() );
330
+		if ( ! wcs_order_contains_subscription($order)) {
331
+			return array(false, false, array());
332 332
 		}
333 333
 
334
-		$subscription    = current( wcs_get_subscriptions_for_order( $order->get_id() ) );
334
+		$subscription    = current(wcs_get_subscriptions_for_order($order->get_id()));
335 335
 		$subscription_id = $subscription->get_id();
336 336
 
337
-		$stripe_source_id = get_post_meta( $subscription_id, '_stripe_source_id', true );
337
+		$stripe_source_id = get_post_meta($subscription_id, '_stripe_source_id', true);
338 338
 
339
-		if ( empty( $stripe_source_id ) ) {
340
-			return array( false, false, array() );
339
+		if (empty($stripe_source_id)) {
340
+			return array(false, false, array());
341 341
 		}
342 342
 
343
-		if ( ! $this->is_retention_expired( $order->get_date_created()->getTimestamp() ) ) {
343
+		if ( ! $this->is_retention_expired($order->get_date_created()->getTimestamp())) {
344 344
 			/* translators: %d Order ID */
345
-			return array( false, true, array( sprintf( __( 'Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) );
345
+			return array(false, true, array(sprintf(__('Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id())));
346 346
 		}
347 347
 
348
-		if ( $subscription->has_status( apply_filters( 'wc_stripe_privacy_eraser_subs_statuses', array( 'on-hold', 'active' ) ) ) ) {
348
+		if ($subscription->has_status(apply_filters('wc_stripe_privacy_eraser_subs_statuses', array('on-hold', 'active')))) {
349 349
 			/* translators: %d Order ID */
350
-			return array( false, true, array( sprintf( __( 'Order ID %d contains an active Subscription. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) );
350
+			return array(false, true, array(sprintf(__('Order ID %d contains an active Subscription. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id())));
351 351
 		}
352 352
 
353
-		$renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders( $order->get_id() );
353
+		$renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders($order->get_id());
354 354
 
355
-		foreach ( $renewal_orders as $renewal_order_id ) {
356
-			delete_post_meta( $renewal_order_id, '_stripe_source_id' );
357
-			delete_post_meta( $renewal_order_id, '_stripe_refund_id' );
358
-			delete_post_meta( $renewal_order_id, '_stripe_customer_id' );
355
+		foreach ($renewal_orders as $renewal_order_id) {
356
+			delete_post_meta($renewal_order_id, '_stripe_source_id');
357
+			delete_post_meta($renewal_order_id, '_stripe_refund_id');
358
+			delete_post_meta($renewal_order_id, '_stripe_customer_id');
359 359
 		}
360 360
 
361
-		delete_post_meta( $subscription_id, '_stripe_source_id' );
362
-		delete_post_meta( $subscription_id, '_stripe_refund_id' );
363
-		delete_post_meta( $subscription_id, '_stripe_customer_id' );
361
+		delete_post_meta($subscription_id, '_stripe_source_id');
362
+		delete_post_meta($subscription_id, '_stripe_refund_id');
363
+		delete_post_meta($subscription_id, '_stripe_customer_id');
364 364
 
365
-		return array( true, false, array( __( 'Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe' ) ) );
365
+		return array(true, false, array(__('Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe')));
366 366
 	}
367 367
 
368 368
 	/**
@@ -371,61 +371,61 @@  discard block
 block discarded – undo
371 371
 	 * @param WC_Order $order
372 372
 	 * @return array
373 373
 	 */
374
-	protected function maybe_handle_order( $order ) {
374
+	protected function maybe_handle_order($order) {
375 375
 		$order_id           = $order->get_id();
376
-		$stripe_source_id   = get_post_meta( $order_id, '_stripe_source_id', true );
377
-		$stripe_refund_id   = get_post_meta( $order_id, '_stripe_refund_id', true );
378
-		$stripe_customer_id = get_post_meta( $order_id, '_stripe_customer_id', true );
376
+		$stripe_source_id   = get_post_meta($order_id, '_stripe_source_id', true);
377
+		$stripe_refund_id   = get_post_meta($order_id, '_stripe_refund_id', true);
378
+		$stripe_customer_id = get_post_meta($order_id, '_stripe_customer_id', true);
379 379
 
380
-		if ( ! $this->is_retention_expired( $order->get_date_created()->getTimestamp() ) ) {
380
+		if ( ! $this->is_retention_expired($order->get_date_created()->getTimestamp())) {
381 381
 			/* translators: %d Order ID */
382
-			return array( false, true, array( sprintf( __( 'Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) );
382
+			return array(false, true, array(sprintf(__('Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id())));
383 383
 		}
384 384
 
385
-		if ( empty( $stripe_source_id ) && empty( $stripe_refund_id ) && empty( $stripe_customer_id ) ) {
386
-			return array( false, false, array() );
385
+		if (empty($stripe_source_id) && empty($stripe_refund_id) && empty($stripe_customer_id)) {
386
+			return array(false, false, array());
387 387
 		}
388 388
 
389
-		delete_post_meta( $order_id, '_stripe_source_id' );
390
-		delete_post_meta( $order_id, '_stripe_refund_id' );
391
-		delete_post_meta( $order_id, '_stripe_customer_id' );
389
+		delete_post_meta($order_id, '_stripe_source_id');
390
+		delete_post_meta($order_id, '_stripe_refund_id');
391
+		delete_post_meta($order_id, '_stripe_customer_id');
392 392
 
393
-		return array( true, false, array( __( 'Stripe personal data erased.', 'woocommerce-gateway-stripe' ) ) );
393
+		return array(true, false, array(__('Stripe personal data erased.', 'woocommerce-gateway-stripe')));
394 394
 	}
395 395
 
396 396
 	/**
397 397
 	 * Checks if create date is passed retention duration.
398 398
 	 *
399 399
 	 */
400
-	public function is_retention_expired( $created_date ) {
401
-		$retention  = wc_parse_relative_date_option( get_option( 'woocommerce_gateway_stripe_retention' ) );
400
+	public function is_retention_expired($created_date) {
401
+		$retention  = wc_parse_relative_date_option(get_option('woocommerce_gateway_stripe_retention'));
402 402
 		$is_expired = false;
403
-		$time_span  = time() - strtotime( $created_date );
404
-		if ( empty( $retention ) || empty( $created_date ) ) {
403
+		$time_span  = time() - strtotime($created_date);
404
+		if (empty($retention) || empty($created_date)) {
405 405
 			return false;
406 406
 		}
407
-		switch ( $retention['unit'] ) {
407
+		switch ($retention['unit']) {
408 408
 			case 'days':
409 409
 				$retention = $retention['number'] * DAY_IN_SECONDS;
410
-				if ( $time_span > $retention ) {
410
+				if ($time_span > $retention) {
411 411
 					$is_expired = true;
412 412
 				}
413 413
 				break;
414 414
 			case 'weeks':
415 415
 				$retention = $retention['number'] * WEEK_IN_SECONDS;
416
-				if ( $time_span > $retention ) {
416
+				if ($time_span > $retention) {
417 417
 					$is_expired = true;
418 418
 				}
419 419
 				break;
420 420
 			case 'months':
421 421
 				$retention = $retention['number'] * MONTH_IN_SECONDS;
422
-				if ( $time_span > $retention ) {
422
+				if ($time_span > $retention) {
423 423
 					$is_expired = true;
424 424
 				}
425 425
 				break;
426 426
 			case 'years':
427 427
 				$retention = $retention['number'] * YEAR_IN_SECONDS;
428
-				if ( $time_span > $retention ) {
428
+				if ($time_span > $retention) {
429 429
 					$is_expired = true;
430 430
 				}
431 431
 				break;
Please login to merge, or discard this patch.
includes/admin/class-wc-stripe-admin-notices.php 1 patch
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 	 * @since 4.1.0
22 22
 	 */
23 23
 	public function __construct() {
24
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
25
-		add_action( 'wp_loaded', array( $this, 'hide_notices' ) );
24
+		add_action('admin_notices', array($this, 'admin_notices'));
25
+		add_action('wp_loaded', array($this, 'hide_notices'));
26 26
 	}
27 27
 
28 28
 	/**
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 * @since 1.0.0
32 32
 	 * @version 4.0.0
33 33
 	 */
34
-	public function add_admin_notice( $slug, $class, $message, $dismissible = false ) {
35
-		$this->notices[ $slug ] = array(
34
+	public function add_admin_notice($slug, $class, $message, $dismissible = false) {
35
+		$this->notices[$slug] = array(
36 36
 			'class'       => $class,
37 37
 			'message'     => $message,
38 38
 			'dismissible' => $dismissible,
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @version 4.0.0
47 47
 	 */
48 48
 	public function admin_notices() {
49
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
49
+		if ( ! current_user_can('manage_woocommerce')) {
50 50
 			return;
51 51
 		}
52 52
 
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
 		// All other payment methods.
57 57
 		$this->payment_methods_check_environment();
58 58
 
59
-		foreach ( (array) $this->notices as $notice_key => $notice ) {
60
-			echo '<div class="' . esc_attr( $notice['class'] ) . '" style="position:relative;">';
59
+		foreach ((array) $this->notices as $notice_key => $notice) {
60
+			echo '<div class="' . esc_attr($notice['class']) . '" style="position:relative;">';
61 61
 
62
-			if ( $notice['dismissible'] ) {
62
+			if ($notice['dismissible']) {
63 63
 				?>
64
-				<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-stripe-hide-notice', $notice_key ), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce' ) ); ?>" class="woocommerce-message-close notice-dismiss" style="position:relative;float:right;padding:9px 0px 9px 9px 9px;text-decoration:none;"></a>
64
+				<a href="<?php echo esc_url(wp_nonce_url(add_query_arg('wc-stripe-hide-notice', $notice_key), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce')); ?>" class="woocommerce-message-close notice-dismiss" style="position:relative;float:right;padding:9px 0px 9px 9px 9px;text-decoration:none;"></a>
65 65
 				<?php
66 66
 			}
67 67
 
68 68
 			echo '<p>';
69
-			echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) );
69
+			echo wp_kses($notice['message'], array('a' => array('href' => array())));
70 70
 			echo '</p></div>';
71 71
 		}
72 72
 	}
@@ -99,100 +99,100 @@  discard block
 block discarded – undo
99 99
 	 * @version 4.0.0
100 100
 	 */
101 101
 	public function stripe_check_environment() {
102
-		$show_style_notice  = get_option( 'wc_stripe_show_style_notice' );
103
-		$show_ssl_notice    = get_option( 'wc_stripe_show_ssl_notice' );
104
-		$show_keys_notice   = get_option( 'wc_stripe_show_keys_notice' );
105
-		$show_phpver_notice = get_option( 'wc_stripe_show_phpver_notice' );
106
-		$show_wcver_notice  = get_option( 'wc_stripe_show_wcver_notice' );
107
-		$show_curl_notice   = get_option( 'wc_stripe_show_curl_notice' );
108
-		$options            = get_option( 'woocommerce_stripe_settings' );
109
-		$testmode           = ( isset( $options['testmode'] ) && 'yes' === $options['testmode'] ) ? true : false;
110
-		$test_pub_key       = isset( $options['test_publishable_key'] ) ? $options['test_publishable_key'] : '';
111
-		$test_secret_key    = isset( $options['test_secret_key'] ) ? $options['test_secret_key'] : '';
112
-		$live_pub_key       = isset( $options['publishable_key'] ) ? $options['publishable_key'] : '';
113
-		$live_secret_key    = isset( $options['secret_key'] ) ? $options['secret_key'] : '';
114
-		$checkout_enabled   = isset( $options['stripe_checkout'] ) && 'yes' === $options['stripe_checkout'];
115
-
116
-		if ( isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) {
117
-			if ( $checkout_enabled ) {
102
+		$show_style_notice  = get_option('wc_stripe_show_style_notice');
103
+		$show_ssl_notice    = get_option('wc_stripe_show_ssl_notice');
104
+		$show_keys_notice   = get_option('wc_stripe_show_keys_notice');
105
+		$show_phpver_notice = get_option('wc_stripe_show_phpver_notice');
106
+		$show_wcver_notice  = get_option('wc_stripe_show_wcver_notice');
107
+		$show_curl_notice   = get_option('wc_stripe_show_curl_notice');
108
+		$options            = get_option('woocommerce_stripe_settings');
109
+		$testmode           = (isset($options['testmode']) && 'yes' === $options['testmode']) ? true : false;
110
+		$test_pub_key       = isset($options['test_publishable_key']) ? $options['test_publishable_key'] : '';
111
+		$test_secret_key    = isset($options['test_secret_key']) ? $options['test_secret_key'] : '';
112
+		$live_pub_key       = isset($options['publishable_key']) ? $options['publishable_key'] : '';
113
+		$live_secret_key    = isset($options['secret_key']) ? $options['secret_key'] : '';
114
+		$checkout_enabled   = isset($options['stripe_checkout']) && 'yes' === $options['stripe_checkout'];
115
+
116
+		if (isset($options['enabled']) && 'yes' === $options['enabled']) {
117
+			if ($checkout_enabled) {
118 118
 				$url = 'https://docs.woocommerce.com/document/stripe/modal-checkout';
119
-				$message = sprintf( __( 'WooCommerce Stripe - Support for Stripe Modal Checkout will be ending soon. This will impact the appearance of your checkout. <a href="%1$s" target="_blank">Click here to learn more.</a>', 'woocommerce-gateway-stripe' ), $url );
120
-				$this->add_admin_notice( 'legacy_checkout', 'notice notice-warning', $message );
119
+				$message = sprintf(__('WooCommerce Stripe - Support for Stripe Modal Checkout will be ending soon. This will impact the appearance of your checkout. <a href="%1$s" target="_blank">Click here to learn more.</a>', 'woocommerce-gateway-stripe'), $url);
120
+				$this->add_admin_notice('legacy_checkout', 'notice notice-warning', $message);
121 121
 			}
122 122
 
123
-			if ( empty( $show_style_notice ) ) {
123
+			if (empty($show_style_notice)) {
124 124
 				/* translators: 1) int version 2) int version */
125
-				$message = __( 'WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://docs.woocommerce.com/document/stripe/#section-45" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe' );
125
+				$message = __('WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://docs.woocommerce.com/document/stripe/#section-45" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe');
126 126
 
127
-				$this->add_admin_notice( 'style', 'error', $message, true );
127
+				$this->add_admin_notice('style', 'error', $message, true);
128 128
 
129 129
 				return;
130 130
 			}
131 131
 
132
-			if ( empty( $show_phpver_notice ) ) {
133
-				if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) {
132
+			if (empty($show_phpver_notice)) {
133
+				if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) {
134 134
 					/* translators: 1) int version 2) int version */
135
-					$message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' );
135
+					$message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe');
136 136
 
137
-					$this->add_admin_notice( 'phpver', 'error', sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() ), true );
137
+					$this->add_admin_notice('phpver', 'error', sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion()), true);
138 138
 
139 139
 					return;
140 140
 				}
141 141
 			}
142 142
 
143
-			if ( empty( $show_wcver_notice ) ) {
144
-				if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) {
143
+			if (empty($show_wcver_notice)) {
144
+				if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) {
145 145
 					/* translators: 1) int version 2) int version */
146
-					$message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' );
146
+					$message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe');
147 147
 
148
-					$this->add_admin_notice( 'wcver', 'notice notice-warning', sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION ), true );
148
+					$this->add_admin_notice('wcver', 'notice notice-warning', sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION), true);
149 149
 
150 150
 					return;
151 151
 				}
152 152
 			}
153 153
 
154
-			if ( empty( $show_curl_notice ) ) {
155
-				if ( ! function_exists( 'curl_init' ) ) {
156
-					$this->add_admin_notice( 'curl', 'notice notice-warning', __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' ), true );
154
+			if (empty($show_curl_notice)) {
155
+				if ( ! function_exists('curl_init')) {
156
+					$this->add_admin_notice('curl', 'notice notice-warning', __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe'), true);
157 157
 				}
158 158
 			}
159 159
 
160
-			if ( empty( $show_keys_notice ) ) {
160
+			if (empty($show_keys_notice)) {
161 161
 				$secret = WC_Stripe_API::get_secret_key();
162 162
 
163
-				if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) {
163
+				if (empty($secret) && ! (isset($_GET['page'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'])) {
164 164
 					$setting_link = $this->get_setting_link();
165 165
 					/* translators: 1) link */
166
-					$this->add_admin_notice( 'keys', 'notice notice-warning', sprintf( __( 'Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
166
+					$this->add_admin_notice('keys', 'notice notice-warning', sprintf(__('Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
167 167
 				}
168 168
 
169 169
 				// Check if keys are entered properly per live/test mode.
170
-				if ( $testmode ) {
170
+				if ($testmode) {
171 171
 					if (
172
-						! empty( $test_pub_key ) && ! preg_match( '/^pk_test_/', $test_pub_key )
173
-						|| ( ! empty( $test_secret_key ) && ! preg_match( '/^sk_test_/', $test_secret_key )
174
-						&& ! empty( $test_secret_key ) && ! preg_match( '/^rk_test_/', $test_secret_key ) ) ) {
172
+						! empty($test_pub_key) && ! preg_match('/^pk_test_/', $test_pub_key)
173
+						|| ( ! empty($test_secret_key) && ! preg_match('/^sk_test_/', $test_secret_key)
174
+						&& ! empty($test_secret_key) && ! preg_match('/^rk_test_/', $test_secret_key)) ) {
175 175
 						$setting_link = $this->get_setting_link();
176 176
 						/* translators: 1) link */
177
-						$this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
177
+						$this->add_admin_notice('keys', 'notice notice-error', sprintf(__('Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
178 178
 					}
179 179
 				} else {
180 180
 					if (
181
-						! empty( $live_pub_key ) && ! preg_match( '/^pk_live_/', $live_pub_key )
182
-						|| ( ! empty( $live_secret_key ) && ! preg_match( '/^sk_live_/', $live_secret_key )
183
-						&& ! empty( $live_secret_key ) && ! preg_match( '/^rk_live_/', $live_secret_key ) ) ) {
181
+						! empty($live_pub_key) && ! preg_match('/^pk_live_/', $live_pub_key)
182
+						|| ( ! empty($live_secret_key) && ! preg_match('/^sk_live_/', $live_secret_key)
183
+						&& ! empty($live_secret_key) && ! preg_match('/^rk_live_/', $live_secret_key)) ) {
184 184
 						$setting_link = $this->get_setting_link();
185 185
 						/* translators: 1) link */
186
-						$this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in live mode however your test keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
186
+						$this->add_admin_notice('keys', 'notice notice-error', sprintf(__('Stripe is in live mode however your test keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
187 187
 					}
188 188
 				}
189 189
 			}
190 190
 
191
-			if ( empty( $show_ssl_notice ) ) {
191
+			if (empty($show_ssl_notice)) {
192 192
 				// Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected.
193
-				if ( ! wc_checkout_is_https() ) {
193
+				if ( ! wc_checkout_is_https()) {
194 194
 					/* translators: 1) link */
195
-					$this->add_admin_notice( 'ssl', 'notice notice-warning', sprintf( __( 'Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe' ), 'https://en.wikipedia.org/wiki/Transport_Layer_Security' ), true );
195
+					$this->add_admin_notice('ssl', 'notice notice-warning', sprintf(__('Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe'), 'https://en.wikipedia.org/wiki/Transport_Layer_Security'), true);
196 196
 				}
197 197
 			}
198 198
 		}
@@ -206,17 +206,17 @@  discard block
 block discarded – undo
206 206
 	public function payment_methods_check_environment() {
207 207
 		$payment_methods = $this->get_payment_methods();
208 208
 
209
-		foreach ( $payment_methods as $method => $class ) {
210
-			$show_notice = get_option( 'wc_stripe_show_' . strtolower( $method ) . '_notice' );
209
+		foreach ($payment_methods as $method => $class) {
210
+			$show_notice = get_option('wc_stripe_show_' . strtolower($method) . '_notice');
211 211
 			$gateway     = new $class();
212 212
 
213
-			if ( 'yes' !== $gateway->enabled || 'no' === $show_notice ) {
213
+			if ('yes' !== $gateway->enabled || 'no' === $show_notice) {
214 214
 				continue;
215 215
 			}
216 216
 
217
-			if ( ! in_array( get_woocommerce_currency(), $gateway->get_supported_currency() ) ) {
217
+			if ( ! in_array(get_woocommerce_currency(), $gateway->get_supported_currency())) {
218 218
 				/* translators: %1$s Payment method, %2$s List of supported currencies */
219
-				$this->add_admin_notice( $method, 'notice notice-error', sprintf( __( '%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe' ), $method, implode( ', ', $gateway->get_supported_currency() ) ), true );
219
+				$this->add_admin_notice($method, 'notice notice-error', sprintf(__('%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe'), $method, implode(', ', $gateway->get_supported_currency())), true);
220 220
 			}
221 221
 		}
222 222
 	}
@@ -228,62 +228,62 @@  discard block
 block discarded – undo
228 228
 	 * @version 4.0.0
229 229
 	 */
230 230
 	public function hide_notices() {
231
-		if ( isset( $_GET['wc-stripe-hide-notice'] ) && isset( $_GET['_wc_stripe_notice_nonce'] ) ) {
232
-			if ( ! wp_verify_nonce( $_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce' ) ) {
233
-				wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe' ) );
231
+		if (isset($_GET['wc-stripe-hide-notice']) && isset($_GET['_wc_stripe_notice_nonce'])) {
232
+			if ( ! wp_verify_nonce($_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce')) {
233
+				wp_die(__('Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe'));
234 234
 			}
235 235
 
236
-			if ( ! current_user_can( 'manage_woocommerce' ) ) {
237
-				wp_die( __( 'Cheatin&#8217; huh?', 'woocommerce-gateway-stripe' ) );
236
+			if ( ! current_user_can('manage_woocommerce')) {
237
+				wp_die(__('Cheatin&#8217; huh?', 'woocommerce-gateway-stripe'));
238 238
 			}
239 239
 
240
-			$notice = wc_clean( $_GET['wc-stripe-hide-notice'] );
240
+			$notice = wc_clean($_GET['wc-stripe-hide-notice']);
241 241
 
242
-			switch ( $notice ) {
242
+			switch ($notice) {
243 243
 				case 'style':
244
-					update_option( 'wc_stripe_show_style_notice', 'no' );
244
+					update_option('wc_stripe_show_style_notice', 'no');
245 245
 					break;
246 246
 				case 'phpver':
247
-					update_option( 'wc_stripe_show_phpver_notice', 'no' );
247
+					update_option('wc_stripe_show_phpver_notice', 'no');
248 248
 					break;
249 249
 				case 'wcver':
250
-					update_option( 'wc_stripe_show_wcver_notice', 'no' );
250
+					update_option('wc_stripe_show_wcver_notice', 'no');
251 251
 					break;
252 252
 				case 'curl':
253
-					update_option( 'wc_stripe_show_curl_notice', 'no' );
253
+					update_option('wc_stripe_show_curl_notice', 'no');
254 254
 					break;
255 255
 				case 'ssl':
256
-					update_option( 'wc_stripe_show_ssl_notice', 'no' );
256
+					update_option('wc_stripe_show_ssl_notice', 'no');
257 257
 					break;
258 258
 				case 'keys':
259
-					update_option( 'wc_stripe_show_keys_notice', 'no' );
259
+					update_option('wc_stripe_show_keys_notice', 'no');
260 260
 					break;
261 261
 				case 'Alipay':
262
-					update_option( 'wc_stripe_show_alipay_notice', 'no' );
262
+					update_option('wc_stripe_show_alipay_notice', 'no');
263 263
 					break;
264 264
 				case 'Bancontact':
265
-					update_option( 'wc_stripe_show_bancontact_notice', 'no' );
265
+					update_option('wc_stripe_show_bancontact_notice', 'no');
266 266
 					break;
267 267
 				case 'EPS':
268
-					update_option( 'wc_stripe_show_eps_notice', 'no' );
268
+					update_option('wc_stripe_show_eps_notice', 'no');
269 269
 					break;
270 270
 				case 'Giropay':
271
-					update_option( 'wc_stripe_show_giropay_notice', 'no' );
271
+					update_option('wc_stripe_show_giropay_notice', 'no');
272 272
 					break;
273 273
 				case 'iDeal':
274
-					update_option( 'wc_stripe_show_ideal_notice', 'no' );
274
+					update_option('wc_stripe_show_ideal_notice', 'no');
275 275
 					break;
276 276
 				case 'Multibanco':
277
-					update_option( 'wc_stripe_show_multibanco_notice', 'no' );
277
+					update_option('wc_stripe_show_multibanco_notice', 'no');
278 278
 					break;
279 279
 				case 'P24':
280
-					update_option( 'wc_stripe_show_p24_notice', 'no' );
280
+					update_option('wc_stripe_show_p24_notice', 'no');
281 281
 					break;
282 282
 				case 'SEPA':
283
-					update_option( 'wc_stripe_show_sepa_notice', 'no' );
283
+					update_option('wc_stripe_show_sepa_notice', 'no');
284 284
 					break;
285 285
 				case 'SOFORT':
286
-					update_option( 'wc_stripe_show_sofort_notice', 'no' );
286
+					update_option('wc_stripe_show_sofort_notice', 'no');
287 287
 					break;
288 288
 			}
289 289
 		}
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 	 * @return string Setting link
298 298
 	 */
299 299
 	public function get_setting_link() {
300
-		$use_id_as_section = function_exists( 'WC' ) ? version_compare( WC()->version, '2.6', '>=' ) : false;
300
+		$use_id_as_section = function_exists('WC') ? version_compare(WC()->version, '2.6', '>=') : false;
301 301
 
302
-		$section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' );
302
+		$section_slug = $use_id_as_section ? 'stripe' : strtolower('WC_Gateway_Stripe');
303 303
 
304
-		return admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . $section_slug );
304
+		return admin_url('admin.php?page=wc-settings&tab=checkout&section=' . $section_slug);
305 305
 	}
306 306
 }
307 307
 
Please login to merge, or discard this patch.
includes/class-wc-stripe-order-handler.php 1 patch
Spacing   +99 added lines, -99 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
 
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 
24 24
 		$this->retry_interval = 1;
25 25
 
26
-		add_action( 'wp', array( $this, 'maybe_process_redirect_order' ) );
27
-		add_action( 'woocommerce_order_status_on-hold_to_processing', array( $this, 'capture_payment' ) );
28
-		add_action( 'woocommerce_order_status_on-hold_to_completed', array( $this, 'capture_payment' ) );
29
-		add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'cancel_payment' ) );
30
-		add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'cancel_payment' ) );
26
+		add_action('wp', array($this, 'maybe_process_redirect_order'));
27
+		add_action('woocommerce_order_status_on-hold_to_processing', array($this, 'capture_payment'));
28
+		add_action('woocommerce_order_status_on-hold_to_completed', array($this, 'capture_payment'));
29
+		add_action('woocommerce_order_status_on-hold_to_cancelled', array($this, 'cancel_payment'));
30
+		add_action('woocommerce_order_status_on-hold_to_refunded', array($this, 'cancel_payment'));
31 31
 	}
32 32
 
33 33
 	/**
@@ -51,25 +51,25 @@  discard block
 block discarded – undo
51 51
 	 * @param bool $retry
52 52
 	 * @param mix $previous_error Any error message from previous request.
53 53
 	 */
54
-	public function process_redirect_payment( $order_id, $retry = true, $previous_error = false ) {
54
+	public function process_redirect_payment($order_id, $retry = true, $previous_error = false) {
55 55
 		try {
56
-			$source = wc_clean( $_GET['source'] );
56
+			$source = wc_clean($_GET['source']);
57 57
 
58
-			if ( empty( $source ) ) {
58
+			if (empty($source)) {
59 59
 				return;
60 60
 			}
61 61
 
62
-			if ( empty( $order_id ) ) {
62
+			if (empty($order_id)) {
63 63
 				return;
64 64
 			}
65 65
 
66
-			$order = wc_get_order( $order_id );
66
+			$order = wc_get_order($order_id);
67 67
 
68
-			if ( ! is_object( $order ) ) {
68
+			if ( ! is_object($order)) {
69 69
 				return;
70 70
 			}
71 71
 
72
-			if ( 'processing' === $order->get_status() || 'completed' === $order->get_status() || 'on-hold' === $order->get_status() ) {
72
+			if ('processing' === $order->get_status() || 'completed' === $order->get_status() || 'on-hold' === $order->get_status()) {
73 73
 				return;
74 74
 			}
75 75
 
@@ -77,124 +77,124 @@  discard block
 block discarded – undo
77 77
 			$response = null;
78 78
 
79 79
 			// This will throw exception if not valid.
80
-			$this->validate_minimum_order_amount( $order );
80
+			$this->validate_minimum_order_amount($order);
81 81
 
82
-			WC_Stripe_Logger::log( "Info: (Redirect) Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
82
+			WC_Stripe_Logger::log("Info: (Redirect) Begin processing payment for order $order_id for the amount of {$order->get_total()}");
83 83
 
84 84
 			/**
85 85
 			 * First check if the source is chargeable at this time. If not,
86 86
 			 * webhook will take care of it later.
87 87
 			 */
88
-			$source_info = WC_Stripe_API::retrieve( 'sources/' . $source );
88
+			$source_info = WC_Stripe_API::retrieve('sources/' . $source);
89 89
 
90
-			if ( ! empty( $source_info->error ) ) {
91
-				throw new WC_Stripe_Exception( print_r( $source_info, true ), $source_info->error->message );
90
+			if ( ! empty($source_info->error)) {
91
+				throw new WC_Stripe_Exception(print_r($source_info, true), $source_info->error->message);
92 92
 			}
93 93
 
94
-			if ( 'failed' === $source_info->status || 'canceled' === $source_info->status ) {
95
-				throw new WC_Stripe_Exception( print_r( $source_info, true ), __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ) );
94
+			if ('failed' === $source_info->status || 'canceled' === $source_info->status) {
95
+				throw new WC_Stripe_Exception(print_r($source_info, true), __('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe'));
96 96
 			}
97 97
 
98 98
 			// If already consumed, then ignore request.
99
-			if ( 'consumed' === $source_info->status ) {
99
+			if ('consumed' === $source_info->status) {
100 100
 				return;
101 101
 			}
102 102
 
103 103
 			// If not chargeable, then ignore request.
104
-			if ( 'chargeable' !== $source_info->status ) {
104
+			if ('chargeable' !== $source_info->status) {
105 105
 				return;
106 106
 			}
107 107
 
108 108
 			// Prep source object.
109 109
 			$source_object           = new stdClass();
110 110
 			$source_object->token_id = '';
111
-			$source_object->customer = $this->get_stripe_customer_id( $order );
111
+			$source_object->customer = $this->get_stripe_customer_id($order);
112 112
 			$source_object->source   = $source_info->id;
113 113
 			$source_object->status   = 'chargeable';
114 114
 
115 115
 			/* If we're doing a retry and source is chargeable, we need to pass
116 116
 			 * a different idempotency key and retry for success.
117 117
 			 */
118
-			if ( $this->need_update_idempotency_key( $source_object, $previous_error ) ) {
119
-				add_filter( 'wc_stripe_idempotency_key', array( $this, 'change_idempotency_key' ), 10, 2 );
118
+			if ($this->need_update_idempotency_key($source_object, $previous_error)) {
119
+				add_filter('wc_stripe_idempotency_key', array($this, 'change_idempotency_key'), 10, 2);
120 120
 			}
121 121
 
122 122
 			// Make the request.
123
-			$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source_object ), 'charges', 'POST', true );
123
+			$response = WC_Stripe_API::request($this->generate_payment_request($order, $source_object), 'charges', 'POST', true);
124 124
 			$headers  = $response['headers'];
125 125
 			$response = $response['body'];
126 126
 
127
-			if ( ! empty( $response->error ) ) {
127
+			if ( ! empty($response->error)) {
128 128
 				// Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without.
129
-				if ( $this->is_no_such_customer_error( $response->error ) ) {
130
-					if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
131
-						delete_user_meta( $order->customer_user, '_stripe_customer_id' );
132
-						delete_post_meta( $order_id, '_stripe_customer_id' );
129
+				if ($this->is_no_such_customer_error($response->error)) {
130
+					if (WC_Stripe_Helper::is_wc_lt('3.0')) {
131
+						delete_user_meta($order->customer_user, '_stripe_customer_id');
132
+						delete_post_meta($order_id, '_stripe_customer_id');
133 133
 					} else {
134
-						delete_user_meta( $order->get_customer_id(), '_stripe_customer_id' );
135
-						$order->delete_meta_data( '_stripe_customer_id' );
134
+						delete_user_meta($order->get_customer_id(), '_stripe_customer_id');
135
+						$order->delete_meta_data('_stripe_customer_id');
136 136
 						$order->save();
137 137
 					}
138 138
 				}
139 139
 
140
-				if ( $this->is_no_such_token_error( $response->error ) && $prepared_source->token_id ) {
140
+				if ($this->is_no_such_token_error($response->error) && $prepared_source->token_id) {
141 141
 					// Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message.
142
-					$wc_token = WC_Payment_Tokens::get( $prepared_source->token_id );
142
+					$wc_token = WC_Payment_Tokens::get($prepared_source->token_id);
143 143
 					$wc_token->delete();
144
-					$localized_message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' );
145
-					$order->add_order_note( $localized_message );
146
-					throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
144
+					$localized_message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe');
145
+					$order->add_order_note($localized_message);
146
+					throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
147 147
 				}
148 148
 
149 149
 				// We want to retry.
150
-				if ( $this->is_retryable_error( $response->error ) ) {
151
-					if ( $retry ) {
150
+				if ($this->is_retryable_error($response->error)) {
151
+					if ($retry) {
152 152
 						// Don't do anymore retries after this.
153
-						if ( 5 <= $this->retry_interval ) {
154
-							return $this->process_redirect_payment( $order_id, false, $response->error );
153
+						if (5 <= $this->retry_interval) {
154
+							return $this->process_redirect_payment($order_id, false, $response->error);
155 155
 						}
156 156
 
157
-						sleep( $this->retry_interval );
157
+						sleep($this->retry_interval);
158 158
 
159 159
 						$this->retry_interval++;
160
-						return $this->process_redirect_payment( $order_id, true, $response->error );
160
+						return $this->process_redirect_payment($order_id, true, $response->error);
161 161
 					} else {
162
-						$localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' );
163
-						$order->add_order_note( $localized_message );
164
-						throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
162
+						$localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe');
163
+						$order->add_order_note($localized_message);
164
+						throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
165 165
 					}
166 166
 				}
167 167
 
168 168
 				$localized_messages = WC_Stripe_Helper::get_localized_messages();
169 169
 
170
-				if ( 'card_error' === $response->error->type ) {
171
-					$message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
170
+				if ('card_error' === $response->error->type) {
171
+					$message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
172 172
 				} else {
173
-					$message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
173
+					$message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
174 174
 				}
175 175
 
176
-				throw new WC_Stripe_Exception( print_r( $response, true ), $message );
176
+				throw new WC_Stripe_Exception(print_r($response, true), $message);
177 177
 			}
178 178
 
179 179
 			// To prevent double processing the order on WC side.
180
-			if ( ! $this->is_original_request( $headers ) ) {
180
+			if ( ! $this->is_original_request($headers)) {
181 181
 				return;
182 182
 			}
183 183
 
184
-			do_action( 'wc_gateway_stripe_process_redirect_payment', $response, $order );
184
+			do_action('wc_gateway_stripe_process_redirect_payment', $response, $order);
185 185
 
186
-			$this->process_response( $response, $order );
186
+			$this->process_response($response, $order);
187 187
 
188
-		} catch ( WC_Stripe_Exception $e ) {
189
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
188
+		} catch (WC_Stripe_Exception $e) {
189
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
190 190
 
191
-			do_action( 'wc_gateway_stripe_process_redirect_payment_error', $e, $order );
191
+			do_action('wc_gateway_stripe_process_redirect_payment_error', $e, $order);
192 192
 
193 193
 			/* translators: error message */
194
-			$order->update_status( 'failed', sprintf( __( 'Stripe payment failed: %s', 'woocommerce-gateway-stripe' ), $e->getLocalizedMessage() ) );
194
+			$order->update_status('failed', sprintf(__('Stripe payment failed: %s', 'woocommerce-gateway-stripe'), $e->getLocalizedMessage()));
195 195
 
196
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
197
-			wp_safe_redirect( wc_get_checkout_url() );
196
+			wc_add_notice($e->getLocalizedMessage(), 'error');
197
+			wp_safe_redirect(wc_get_checkout_url());
198 198
 			exit;
199 199
 		}
200 200
 	}
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
 	 * @version 4.0.0
207 207
 	 */
208 208
 	public function maybe_process_redirect_order() {
209
-		if ( ! is_order_received_page() || empty( $_GET['client_secret'] ) || empty( $_GET['source'] ) ) {
209
+		if ( ! is_order_received_page() || empty($_GET['client_secret']) || empty($_GET['source'])) {
210 210
 			return;
211 211
 		}
212 212
 
213
-		$order_id = wc_clean( $_GET['order_id'] );
213
+		$order_id = wc_clean($_GET['order_id']);
214 214
 
215
-		$this->process_redirect_payment( $order_id );
215
+		$this->process_redirect_payment($order_id);
216 216
 	}
217 217
 
218 218
 	/**
@@ -222,88 +222,88 @@  discard block
 block discarded – undo
222 222
 	 * @version 4.0.0
223 223
 	 * @param  int $order_id
224 224
 	 */
225
-	public function capture_payment( $order_id ) {
226
-		$order = wc_get_order( $order_id );
225
+	public function capture_payment($order_id) {
226
+		$order = wc_get_order($order_id);
227 227
 
228
-		if ( 'stripe' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method() ) ) {
229
-			$charge             = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_transaction_id', true ) : $order->get_transaction_id();
230
-			$captured           = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_stripe_charge_captured', true ) : $order->get_meta( '_stripe_charge_captured', true );
228
+		if ('stripe' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method())) {
229
+			$charge             = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_transaction_id', true) : $order->get_transaction_id();
230
+			$captured           = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_stripe_charge_captured', true) : $order->get_meta('_stripe_charge_captured', true);
231 231
 			$is_stripe_captured = false;
232 232
 
233
-			if ( $charge && 'no' === $captured ) {
233
+			if ($charge && 'no' === $captured) {
234 234
 				$order_total = $order->get_total();
235 235
 
236
-				if ( 0 < $order->get_total_refunded() ) {
236
+				if (0 < $order->get_total_refunded()) {
237 237
 					$order_total = $order_total - $order->get_total_refunded();
238 238
 				}
239 239
 
240
-				$intent = $this->get_intent_from_order( $order );
241
-				if ( $intent ) {
240
+				$intent = $this->get_intent_from_order($order);
241
+				if ($intent) {
242 242
 					// If the order has a Payment Intent, then the Intent itself must be captured, not the Charge
243
-					if ( ! empty( $intent->error ) ) {
243
+					if ( ! empty($intent->error)) {
244 244
 						/* translators: error message */
245
-						$order->add_order_note( sprintf( __( 'Unable to capture charge! %s', 'woocommerce-gateway-stripe' ), $intent->error->message ) );
246
-					} elseif ( 'requires_capture' === $intent->status ) {
245
+						$order->add_order_note(sprintf(__('Unable to capture charge! %s', 'woocommerce-gateway-stripe'), $intent->error->message));
246
+					} elseif ('requires_capture' === $intent->status) {
247 247
 						$result = WC_Stripe_API::request(
248 248
 							array(
249
-								'amount'   => WC_Stripe_Helper::get_stripe_amount( $order_total ),
249
+								'amount'   => WC_Stripe_Helper::get_stripe_amount($order_total),
250 250
 								'expand[]' => 'charges.data.balance_transaction',
251 251
 							),
252 252
 							'payment_intents/' . $intent->id . '/capture'
253 253
 						);
254 254
 
255
-						if ( ! empty( $result->error ) ) {
255
+						if ( ! empty($result->error)) {
256 256
 							/* translators: error message */
257
-							$order->update_status( 'failed', sprintf( __( 'Unable to capture charge! %s', 'woocommerce-gateway-stripe' ), $result->error->message ) );
257
+							$order->update_status('failed', sprintf(__('Unable to capture charge! %s', 'woocommerce-gateway-stripe'), $result->error->message));
258 258
 						} else {
259 259
 							$is_stripe_captured = true;
260
-							$result = end( $result->charges->data );
260
+							$result = end($result->charges->data);
261 261
 						}
262
-					} elseif ( 'succeeded' === $intent->status ) {
262
+					} elseif ('succeeded' === $intent->status) {
263 263
 						$is_stripe_captured = true;
264 264
 					}
265 265
 				} else {
266 266
 					// The order doesn't have a Payment Intent, fall back to capturing the Charge directly
267 267
 
268 268
 					// First retrieve charge to see if it has been captured.
269
-					$result = WC_Stripe_API::retrieve( 'charges/' . $charge );
269
+					$result = WC_Stripe_API::retrieve('charges/' . $charge);
270 270
 
271
-					if ( ! empty( $result->error ) ) {
271
+					if ( ! empty($result->error)) {
272 272
 						/* translators: error message */
273
-						$order->add_order_note( sprintf( __( 'Unable to capture charge! %s', 'woocommerce-gateway-stripe' ), $result->error->message ) );
274
-					} elseif ( false === $result->captured ) {
273
+						$order->add_order_note(sprintf(__('Unable to capture charge! %s', 'woocommerce-gateway-stripe'), $result->error->message));
274
+					} elseif (false === $result->captured) {
275 275
 						$result = WC_Stripe_API::request(
276 276
 							array(
277
-								'amount'   => WC_Stripe_Helper::get_stripe_amount( $order_total ),
277
+								'amount'   => WC_Stripe_Helper::get_stripe_amount($order_total),
278 278
 								'expand[]' => 'balance_transaction',
279 279
 							),
280 280
 							'charges/' . $charge . '/capture'
281 281
 						);
282 282
 
283
-						if ( ! empty( $result->error ) ) {
283
+						if ( ! empty($result->error)) {
284 284
 							/* translators: error message */
285
-							$order->update_status( 'failed', sprintf( __( 'Unable to capture charge! %s', 'woocommerce-gateway-stripe' ), $result->error->message ) );
285
+							$order->update_status('failed', sprintf(__('Unable to capture charge! %s', 'woocommerce-gateway-stripe'), $result->error->message));
286 286
 						} else {
287 287
 							$is_stripe_captured = true;
288 288
 						}
289
-					} elseif ( true === $result->captured ) {
289
+					} elseif (true === $result->captured) {
290 290
 						$is_stripe_captured = true;
291 291
 					}
292 292
 				}
293 293
 
294
-				if ( $is_stripe_captured ) {
294
+				if ($is_stripe_captured) {
295 295
 					/* translators: transaction id */
296
-					$order->add_order_note( sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $result->id ) );
297
-					WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_stripe_charge_captured', 'yes' ) : $order->update_meta_data( '_stripe_charge_captured', 'yes' );
296
+					$order->add_order_note(sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $result->id));
297
+					WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_stripe_charge_captured', 'yes') : $order->update_meta_data('_stripe_charge_captured', 'yes');
298 298
 
299 299
 					// Store other data such as fees
300
-					WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_transaction_id', $result->id ) : $order->set_transaction_id( $result->id );
300
+					WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_transaction_id', $result->id) : $order->set_transaction_id($result->id);
301 301
 
302
-					$this->update_fees( $order, $result->balance_transaction->id );
302
+					$this->update_fees($order, $result->balance_transaction->id);
303 303
 				}
304 304
 
305 305
 				// This hook fires when admin manually changes order status to processing or completed.
306
-				do_action( 'woocommerce_stripe_process_manual_capture', $order, $result );
306
+				do_action('woocommerce_stripe_process_manual_capture', $order, $result);
307 307
 			}
308 308
 		}
309 309
 	}
@@ -315,14 +315,14 @@  discard block
 block discarded – undo
315 315
 	 * @version 4.0.0
316 316
 	 * @param  int $order_id
317 317
 	 */
318
-	public function cancel_payment( $order_id ) {
319
-		$order = wc_get_order( $order_id );
318
+	public function cancel_payment($order_id) {
319
+		$order = wc_get_order($order_id);
320 320
 
321
-		if ( 'stripe' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method() ) ) {
322
-			$this->process_refund( $order_id );
321
+		if ('stripe' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method())) {
322
+			$this->process_refund($order_id);
323 323
 
324 324
 			// This hook fires when admin manually changes order status to cancel.
325
-			do_action( 'woocommerce_stripe_process_manual_cancel', $order );
325
+			do_action('woocommerce_stripe_process_manual_cancel', $order);
326 326
 		}
327 327
 	}
328 328
 }
Please login to merge, or discard this patch.
includes/class-wc-stripe-helper.php 1 patch
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 	 * @param object $order
23 23
 	 * @return string $currency
24 24
 	 */
25
-	public static function get_stripe_currency( $order = null ) {
26
-		if ( is_null( $order ) ) {
25
+	public static function get_stripe_currency($order = null) {
26
+		if (is_null($order)) {
27 27
 			return false;
28 28
 		}
29 29
 
30
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
30
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
31 31
 
32
-		return WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::META_NAME_STRIPE_CURRENCY, true ) : $order->get_meta( self::META_NAME_STRIPE_CURRENCY, true );
32
+		return WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::META_NAME_STRIPE_CURRENCY, true) : $order->get_meta(self::META_NAME_STRIPE_CURRENCY, true);
33 33
 	}
34 34
 
35 35
 	/**
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 	 * @param object $order
40 40
 	 * @param string $currency
41 41
 	 */
42
-	public static function update_stripe_currency( $order = null, $currency ) {
43
-		if ( is_null( $order ) ) {
42
+	public static function update_stripe_currency($order = null, $currency) {
43
+		if (is_null($order)) {
44 44
 			return false;
45 45
 		}
46 46
 
47
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
47
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
48 48
 
49
-		WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, self::META_NAME_STRIPE_CURRENCY, $currency ) : $order->update_meta_data( self::META_NAME_STRIPE_CURRENCY, $currency );
49
+		WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, self::META_NAME_STRIPE_CURRENCY, $currency) : $order->update_meta_data(self::META_NAME_STRIPE_CURRENCY, $currency);
50 50
 	}
51 51
 
52 52
 	/**
@@ -56,22 +56,22 @@  discard block
 block discarded – undo
56 56
 	 * @param object $order
57 57
 	 * @return string $amount
58 58
 	 */
59
-	public static function get_stripe_fee( $order = null ) {
60
-		if ( is_null( $order ) ) {
59
+	public static function get_stripe_fee($order = null) {
60
+		if (is_null($order)) {
61 61
 			return false;
62 62
 		}
63 63
 
64
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
64
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
65 65
 
66
-		$amount = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::META_NAME_FEE, true ) : $order->get_meta( self::META_NAME_FEE, true );
66
+		$amount = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::META_NAME_FEE, true) : $order->get_meta(self::META_NAME_FEE, true);
67 67
 
68 68
 		// If not found let's check for legacy name.
69
-		if ( empty( $amount ) ) {
70
-			$amount = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::LEGACY_META_NAME_FEE, true ) : $order->get_meta( self::LEGACY_META_NAME_FEE, true );
69
+		if (empty($amount)) {
70
+			$amount = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::LEGACY_META_NAME_FEE, true) : $order->get_meta(self::LEGACY_META_NAME_FEE, true);
71 71
 
72 72
 			// If found update to new name.
73
-			if ( $amount ) {
74
-				self::update_stripe_fee( $order, $amount );
73
+			if ($amount) {
74
+				self::update_stripe_fee($order, $amount);
75 75
 			}
76 76
 		}
77 77
 
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 	 * @param object $order
86 86
 	 * @param float $amount
87 87
 	 */
88
-	public static function update_stripe_fee( $order = null, $amount = 0.0 ) {
89
-		if ( is_null( $order ) ) {
88
+	public static function update_stripe_fee($order = null, $amount = 0.0) {
89
+		if (is_null($order)) {
90 90
 			return false;
91 91
 		}
92 92
 
93
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
93
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
94 94
 
95
-		WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, self::META_NAME_FEE, $amount ) : $order->update_meta_data( self::META_NAME_FEE, $amount );
95
+		WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, self::META_NAME_FEE, $amount) : $order->update_meta_data(self::META_NAME_FEE, $amount);
96 96
 	}
97 97
 
98 98
 	/**
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 	 * @since 4.1.0
102 102
 	 * @param object $order
103 103
 	 */
104
-	public static function delete_stripe_fee( $order = null ) {
105
-		if ( is_null( $order ) ) {
104
+	public static function delete_stripe_fee($order = null) {
105
+		if (is_null($order)) {
106 106
 			return false;
107 107
 		}
108 108
 
109
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
109
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
110 110
 
111
-		delete_post_meta( $order_id, self::META_NAME_FEE );
112
-		delete_post_meta( $order_id, self::LEGACY_META_NAME_FEE );
111
+		delete_post_meta($order_id, self::META_NAME_FEE);
112
+		delete_post_meta($order_id, self::LEGACY_META_NAME_FEE);
113 113
 	}
114 114
 
115 115
 	/**
@@ -119,22 +119,22 @@  discard block
 block discarded – undo
119 119
 	 * @param object $order
120 120
 	 * @return string $amount
121 121
 	 */
122
-	public static function get_stripe_net( $order = null ) {
123
-		if ( is_null( $order ) ) {
122
+	public static function get_stripe_net($order = null) {
123
+		if (is_null($order)) {
124 124
 			return false;
125 125
 		}
126 126
 
127
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
127
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
128 128
 
129
-		$amount = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::META_NAME_NET, true ) : $order->get_meta( self::META_NAME_NET, true );
129
+		$amount = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::META_NAME_NET, true) : $order->get_meta(self::META_NAME_NET, true);
130 130
 
131 131
 		// If not found let's check for legacy name.
132
-		if ( empty( $amount ) ) {
133
-			$amount = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::LEGACY_META_NAME_NET, true ) : $order->get_meta( self::LEGACY_META_NAME_NET, true );
132
+		if (empty($amount)) {
133
+			$amount = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::LEGACY_META_NAME_NET, true) : $order->get_meta(self::LEGACY_META_NAME_NET, true);
134 134
 
135 135
 			// If found update to new name.
136
-			if ( $amount ) {
137
-				self::update_stripe_net( $order, $amount );
136
+			if ($amount) {
137
+				self::update_stripe_net($order, $amount);
138 138
 			}
139 139
 		}
140 140
 
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 	 * @param object $order
149 149
 	 * @param float $amount
150 150
 	 */
151
-	public static function update_stripe_net( $order = null, $amount = 0.0 ) {
152
-		if ( is_null( $order ) ) {
151
+	public static function update_stripe_net($order = null, $amount = 0.0) {
152
+		if (is_null($order)) {
153 153
 			return false;
154 154
 		}
155 155
 
156
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
156
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
157 157
 
158
-		WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, self::META_NAME_NET, $amount ) : $order->update_meta_data( self::META_NAME_NET, $amount );
158
+		WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, self::META_NAME_NET, $amount) : $order->update_meta_data(self::META_NAME_NET, $amount);
159 159
 	}
160 160
 
161 161
 	/**
@@ -164,15 +164,15 @@  discard block
 block discarded – undo
164 164
 	 * @since 4.1.0
165 165
 	 * @param object $order
166 166
 	 */
167
-	public static function delete_stripe_net( $order = null ) {
168
-		if ( is_null( $order ) ) {
167
+	public static function delete_stripe_net($order = null) {
168
+		if (is_null($order)) {
169 169
 			return false;
170 170
 		}
171 171
 
172
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
172
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
173 173
 
174
-		delete_post_meta( $order_id, self::META_NAME_NET );
175
-		delete_post_meta( $order_id, self::LEGACY_META_NAME_NET );
174
+		delete_post_meta($order_id, self::META_NAME_NET);
175
+		delete_post_meta($order_id, self::LEGACY_META_NAME_NET);
176 176
 	}
177 177
 
178 178
 	/**
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @return float|int
185 185
 	 */
186
-	public static function get_stripe_amount( $total, $currency = '' ) {
187
-		if ( ! $currency ) {
186
+	public static function get_stripe_amount($total, $currency = '') {
187
+		if ( ! $currency) {
188 188
 			$currency = get_woocommerce_currency();
189 189
 		}
190 190
 
191
-		if ( in_array( strtolower( $currency ), self::no_decimal_currencies() ) ) {
192
-			return absint( $total );
191
+		if (in_array(strtolower($currency), self::no_decimal_currencies())) {
192
+			return absint($total);
193 193
 		} else {
194
-			return absint( wc_format_decimal( ( (float) $total * 100 ), wc_get_price_decimals() ) ); // In cents.
194
+			return absint(wc_format_decimal(((float) $total * 100), wc_get_price_decimals())); // In cents.
195 195
 		}
196 196
 	}
197 197
 
@@ -206,23 +206,23 @@  discard block
 block discarded – undo
206 206
 		return apply_filters(
207 207
 			'wc_stripe_localized_messages',
208 208
 			array(
209
-				'invalid_number'           => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ),
210
-				'invalid_expiry_month'     => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ),
211
-				'invalid_expiry_year'      => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ),
212
-				'invalid_cvc'              => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ),
213
-				'incorrect_number'         => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ),
214
-				'incomplete_number'        => __( 'The card number is incomplete.', 'woocommerce-gateway-stripe' ),
215
-				'incomplete_cvc'           => __( 'The card\'s security code is incomplete.', 'woocommerce-gateway-stripe' ),
216
-				'incomplete_expiry'        => __( 'The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe' ),
217
-				'expired_card'             => __( 'The card has expired.', 'woocommerce-gateway-stripe' ),
218
-				'incorrect_cvc'            => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ),
219
-				'incorrect_zip'            => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ),
220
-				'invalid_expiry_year_past' => __( 'The card\'s expiration year is in the past', 'woocommerce-gateway-stripe' ),
221
-				'card_declined'            => __( 'The card was declined.', 'woocommerce-gateway-stripe' ),
222
-				'missing'                  => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ),
223
-				'processing_error'         => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ),
224
-				'invalid_request_error'    => __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ),
225
-				'invalid_sofort_country'   => __( 'The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe' ),
209
+				'invalid_number'           => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'),
210
+				'invalid_expiry_month'     => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'),
211
+				'invalid_expiry_year'      => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'),
212
+				'invalid_cvc'              => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'),
213
+				'incorrect_number'         => __('The card number is incorrect.', 'woocommerce-gateway-stripe'),
214
+				'incomplete_number'        => __('The card number is incomplete.', 'woocommerce-gateway-stripe'),
215
+				'incomplete_cvc'           => __('The card\'s security code is incomplete.', 'woocommerce-gateway-stripe'),
216
+				'incomplete_expiry'        => __('The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe'),
217
+				'expired_card'             => __('The card has expired.', 'woocommerce-gateway-stripe'),
218
+				'incorrect_cvc'            => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'),
219
+				'incorrect_zip'            => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'),
220
+				'invalid_expiry_year_past' => __('The card\'s expiration year is in the past', 'woocommerce-gateway-stripe'),
221
+				'card_declined'            => __('The card was declined.', 'woocommerce-gateway-stripe'),
222
+				'missing'                  => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'),
223
+				'processing_error'         => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'),
224
+				'invalid_request_error'    => __('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe'),
225
+				'invalid_sofort_country'   => __('The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe'),
226 226
 			)
227 227
 		);
228 228
 	}
@@ -261,24 +261,24 @@  discard block
 block discarded – undo
261 261
 	 * @param string $type Type of number to format
262 262
 	 * @return string
263 263
 	 */
264
-	public static function format_balance_fee( $balance_transaction, $type = 'fee' ) {
265
-		if ( ! is_object( $balance_transaction ) ) {
264
+	public static function format_balance_fee($balance_transaction, $type = 'fee') {
265
+		if ( ! is_object($balance_transaction)) {
266 266
 			return;
267 267
 		}
268 268
 
269
-		if ( in_array( strtolower( $balance_transaction->currency ), self::no_decimal_currencies() ) ) {
270
-			if ( 'fee' === $type ) {
269
+		if (in_array(strtolower($balance_transaction->currency), self::no_decimal_currencies())) {
270
+			if ('fee' === $type) {
271 271
 				return $balance_transaction->fee;
272 272
 			}
273 273
 
274 274
 			return $balance_transaction->net;
275 275
 		}
276 276
 
277
-		if ( 'fee' === $type ) {
278
-			return number_format( $balance_transaction->fee / 100, 2, '.', '' );
277
+		if ('fee' === $type) {
278
+			return number_format($balance_transaction->fee / 100, 2, '.', '');
279 279
 		}
280 280
 
281
-		return number_format( $balance_transaction->net / 100, 2, '.', '' );
281
+		return number_format($balance_transaction->net / 100, 2, '.', '');
282 282
 	}
283 283
 
284 284
 	/**
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	public static function get_minimum_amount() {
288 288
 		// Check order amount
289
-		switch ( get_woocommerce_currency() ) {
289
+		switch (get_woocommerce_currency()) {
290 290
 			case 'USD':
291 291
 			case 'CAD':
292 292
 			case 'EUR':
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
 	 * @param string $method The payment method to get the settings from.
332 332
 	 * @param string $setting The name of the setting to get.
333 333
 	 */
334
-	public static function get_settings( $method = null, $setting = null ) {
335
-		$all_settings = null === $method ? get_option( 'woocommerce_stripe_settings', array() ) : get_option( 'woocommerce_stripe_' . $method . '_settings', array() );
334
+	public static function get_settings($method = null, $setting = null) {
335
+		$all_settings = null === $method ? get_option('woocommerce_stripe_settings', array()) : get_option('woocommerce_stripe_' . $method . '_settings', array());
336 336
 
337
-		if ( null === $setting ) {
337
+		if (null === $setting) {
338 338
 			return $all_settings;
339 339
 		}
340 340
 
341
-		return isset( $all_settings[ $setting ] ) ? $all_settings[ $setting ] : '';
341
+		return isset($all_settings[$setting]) ? $all_settings[$setting] : '';
342 342
 	}
343 343
 
344 344
 	/**
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	 * @return bool
349 349
 	 */
350 350
 	public static function is_pre_orders_exists() {
351
-		return class_exists( 'WC_Pre_Orders_Order' );
351
+		return class_exists('WC_Pre_Orders_Order');
352 352
 	}
353 353
 
354 354
 	/**
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 	 * @return bool
361 361
 	 */
362 362
 	public static function is_pre_30() {
363
-		error_log( 'is_pre_30() function has been deprecated since 4.1.11. Please use is_wc_lt( $version ) instead.' );
363
+		error_log('is_pre_30() function has been deprecated since 4.1.11. Please use is_wc_lt( $version ) instead.');
364 364
 
365
-		return self::is_wc_lt( '3.0' );
365
+		return self::is_wc_lt('3.0');
366 366
 	}
367 367
 
368 368
 	/**
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
 	 * @param string $version Version to check against.
373 373
 	 * @return bool
374 374
 	 */
375
-	public static function is_wc_lt( $version ) {
376
-		return version_compare( WC_VERSION, $version, '<' );
375
+	public static function is_wc_lt($version) {
376
+		return version_compare(WC_VERSION, $version, '<');
377 377
 	}
378 378
 
379 379
 	/**
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 	 * @return string
387 387
 	 */
388 388
 	public static function get_webhook_url() {
389
-		return add_query_arg( 'wc-api', 'wc_stripe', trailingslashit( get_home_url() ) );
389
+		return add_query_arg('wc-api', 'wc_stripe', trailingslashit(get_home_url()));
390 390
 	}
391 391
 
392 392
 	/**
@@ -396,13 +396,13 @@  discard block
 block discarded – undo
396 396
 	 * @version 4.0.0
397 397
 	 * @param string $source_id
398 398
 	 */
399
-	public static function get_order_by_source_id( $source_id ) {
399
+	public static function get_order_by_source_id($source_id) {
400 400
 		global $wpdb;
401 401
 
402
-		$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $source_id, '_stripe_source_id' ) );
402
+		$order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $source_id, '_stripe_source_id'));
403 403
 
404
-		if ( ! empty( $order_id ) ) {
405
-			return wc_get_order( $order_id );
404
+		if ( ! empty($order_id)) {
405
+			return wc_get_order($order_id);
406 406
 		}
407 407
 
408 408
 		return false;
@@ -415,17 +415,17 @@  discard block
 block discarded – undo
415 415
 	 * @since 4.1.16 Return false if charge_id is empty.
416 416
 	 * @param string $charge_id
417 417
 	 */
418
-	public static function get_order_by_charge_id( $charge_id ) {
418
+	public static function get_order_by_charge_id($charge_id) {
419 419
 		global $wpdb;
420 420
 
421
-		if ( empty( $charge_id ) ) {
421
+		if (empty($charge_id)) {
422 422
 			return false;
423 423
 		}
424 424
 
425
-		$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $charge_id, '_transaction_id' ) );
425
+		$order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $charge_id, '_transaction_id'));
426 426
 
427
-		if ( ! empty( $order_id ) ) {
428
-			return wc_get_order( $order_id );
427
+		if ( ! empty($order_id)) {
428
+			return wc_get_order($order_id);
429 429
 		}
430 430
 
431 431
 		return false;
@@ -438,13 +438,13 @@  discard block
 block discarded – undo
438 438
 	 * @param string $intent_id The ID of the intent.
439 439
 	 * @return WC_Order|bool Either an order or false when not found.
440 440
 	 */
441
-	public static function get_order_by_intent_id( $intent_id ) {
441
+	public static function get_order_by_intent_id($intent_id) {
442 442
 		global $wpdb;
443 443
 
444
-		$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $intent_id, '_stripe_intent_id' ) );
444
+		$order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $intent_id, '_stripe_intent_id'));
445 445
 
446
-		if ( ! empty( $order_id ) ) {
447
-			return wc_get_order( $order_id );
446
+		if ( ! empty($order_id)) {
447
+			return wc_get_order($order_id);
448 448
 		}
449 449
 
450 450
 		return false;
@@ -460,13 +460,13 @@  discard block
 block discarded – undo
460 460
 	 * @param string $statement_descriptor
461 461
 	 * @return string $statement_descriptor Sanitized statement descriptor
462 462
 	 */
463
-	public static function clean_statement_descriptor( $statement_descriptor = '' ) {
464
-		$disallowed_characters = array( '<', '>', '"', "'" );
463
+	public static function clean_statement_descriptor($statement_descriptor = '') {
464
+		$disallowed_characters = array('<', '>', '"', "'");
465 465
 
466 466
 		// Remove special characters.
467
-		$statement_descriptor = str_replace( $disallowed_characters, '', $statement_descriptor );
467
+		$statement_descriptor = str_replace($disallowed_characters, '', $statement_descriptor);
468 468
 
469
-		$statement_descriptor = substr( trim( $statement_descriptor ), 0, 22 );
469
+		$statement_descriptor = substr(trim($statement_descriptor), 0, 22);
470 470
 
471 471
 		return $statement_descriptor;
472 472
 	}
Please login to merge, or discard this patch.
includes/admin/stripe-settings.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -7,146 +7,146 @@  discard block
 block discarded – undo
7 7
 	'wc_stripe_settings',
8 8
 	array(
9 9
 		'enabled'                       => array(
10
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
11
-			'label'       => __( 'Enable Stripe', 'woocommerce-gateway-stripe' ),
10
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
11
+			'label'       => __('Enable Stripe', 'woocommerce-gateway-stripe'),
12 12
 			'type'        => 'checkbox',
13 13
 			'description' => '',
14 14
 			'default'     => 'no',
15 15
 		),
16 16
 		'title'                         => array(
17
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
17
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
18 18
 			'type'        => 'text',
19
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
20
-			'default'     => __( 'Credit Card (Stripe)', 'woocommerce-gateway-stripe' ),
19
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
20
+			'default'     => __('Credit Card (Stripe)', 'woocommerce-gateway-stripe'),
21 21
 			'desc_tip'    => true,
22 22
 		),
23 23
 		'description'                   => array(
24
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
24
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
25 25
 			'type'        => 'text',
26
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
27
-			'default'     => __( 'Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe' ),
26
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
27
+			'default'     => __('Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe'),
28 28
 			'desc_tip'    => true,
29 29
 		),
30 30
 		'webhook'                       => array(
31
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
31
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
32 32
 			'type'        => 'title',
33 33
 			/* translators: webhook URL */
34 34
 			'description' => $this->display_admin_settings_webhook_description(),
35 35
 		),
36 36
 		'testmode'                      => array(
37
-			'title'       => __( 'Test mode', 'woocommerce-gateway-stripe' ),
38
-			'label'       => __( 'Enable Test Mode', 'woocommerce-gateway-stripe' ),
37
+			'title'       => __('Test mode', 'woocommerce-gateway-stripe'),
38
+			'label'       => __('Enable Test Mode', 'woocommerce-gateway-stripe'),
39 39
 			'type'        => 'checkbox',
40
-			'description' => __( 'Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe' ),
40
+			'description' => __('Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe'),
41 41
 			'default'     => 'yes',
42 42
 			'desc_tip'    => true,
43 43
 		),
44 44
 		'test_publishable_key'          => array(
45
-			'title'       => __( 'Test Publishable Key', 'woocommerce-gateway-stripe' ),
45
+			'title'       => __('Test Publishable Key', 'woocommerce-gateway-stripe'),
46 46
 			'type'        => 'password',
47
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
47
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
48 48
 			'default'     => '',
49 49
 			'desc_tip'    => true,
50 50
 		),
51 51
 		'test_secret_key'               => array(
52
-			'title'       => __( 'Test Secret Key', 'woocommerce-gateway-stripe' ),
52
+			'title'       => __('Test Secret Key', 'woocommerce-gateway-stripe'),
53 53
 			'type'        => 'password',
54
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
54
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
55 55
 			'default'     => '',
56 56
 			'desc_tip'    => true,
57 57
 		),
58 58
 		'publishable_key'               => array(
59
-			'title'       => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ),
59
+			'title'       => __('Live Publishable Key', 'woocommerce-gateway-stripe'),
60 60
 			'type'        => 'password',
61
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
61
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
62 62
 			'default'     => '',
63 63
 			'desc_tip'    => true,
64 64
 		),
65 65
 		'secret_key'                    => array(
66
-			'title'       => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ),
66
+			'title'       => __('Live Secret Key', 'woocommerce-gateway-stripe'),
67 67
 			'type'        => 'password',
68
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
68
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
69 69
 			'default'     => '',
70 70
 			'desc_tip'    => true,
71 71
 		),
72 72
 		'inline_cc_form'                => array(
73
-			'title'       => __( 'Inline Credit Card Form', 'woocommerce-gateway-stripe' ),
73
+			'title'       => __('Inline Credit Card Form', 'woocommerce-gateway-stripe'),
74 74
 			'type'        => 'checkbox',
75
-			'description' => __( 'Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe' ),
75
+			'description' => __('Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe'),
76 76
 			'default'     => 'no',
77 77
 			'desc_tip'    => true,
78 78
 		),
79 79
 		'statement_descriptor'          => array(
80
-			'title'       => __( 'Statement Descriptor', 'woocommerce-gateway-stripe' ),
80
+			'title'       => __('Statement Descriptor', 'woocommerce-gateway-stripe'),
81 81
 			'type'        => 'text',
82
-			'description' => __( 'Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe' ),
82
+			'description' => __('Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe'),
83 83
 			'default'     => '',
84 84
 			'desc_tip'    => true,
85 85
 		),
86 86
 		'capture'                       => array(
87
-			'title'       => __( 'Capture', 'woocommerce-gateway-stripe' ),
88
-			'label'       => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ),
87
+			'title'       => __('Capture', 'woocommerce-gateway-stripe'),
88
+			'label'       => __('Capture charge immediately', 'woocommerce-gateway-stripe'),
89 89
 			'type'        => 'checkbox',
90
-			'description' => __( 'Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe' ),
90
+			'description' => __('Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe'),
91 91
 			'default'     => 'yes',
92 92
 			'desc_tip'    => true,
93 93
 		),
94 94
 		'payment_request'               => array(
95
-			'title'       => __( 'Payment Request Buttons', 'woocommerce-gateway-stripe' ),
95
+			'title'       => __('Payment Request Buttons', 'woocommerce-gateway-stripe'),
96 96
 			/* translators: 1) br tag 2) opening anchor tag 3) closing anchor tag */
97
-			'label'       => sprintf( __( 'Enable Payment Request Buttons. (Apple Pay/Chrome Payment Request API) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe' ), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>' ),
97
+			'label'       => sprintf(__('Enable Payment Request Buttons. (Apple Pay/Chrome Payment Request API) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe'), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>'),
98 98
 			'type'        => 'checkbox',
99
-			'description' => __( 'If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe' ),
99
+			'description' => __('If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe'),
100 100
 			'default'     => 'yes',
101 101
 			'desc_tip'    => true,
102 102
 		),
103 103
 		'payment_request_button_type'   => array(
104
-			'title'       => __( 'Payment Request Button Type', 'woocommerce-gateway-stripe' ),
105
-			'label'       => __( 'Button Type', 'woocommerce-gateway-stripe' ),
104
+			'title'       => __('Payment Request Button Type', 'woocommerce-gateway-stripe'),
105
+			'label'       => __('Button Type', 'woocommerce-gateway-stripe'),
106 106
 			'type'        => 'select',
107
-			'description' => __( 'Select the button type you would like to show.', 'woocommerce-gateway-stripe' ),
107
+			'description' => __('Select the button type you would like to show.', 'woocommerce-gateway-stripe'),
108 108
 			'default'     => 'buy',
109 109
 			'desc_tip'    => true,
110 110
 			'options'     => array(
111
-				'default' => __( 'Default', 'woocommerce-gateway-stripe' ),
112
-				'buy'     => __( 'Buy', 'woocommerce-gateway-stripe' ),
113
-				'donate'  => __( 'Donate', 'woocommerce-gateway-stripe' ),
111
+				'default' => __('Default', 'woocommerce-gateway-stripe'),
112
+				'buy'     => __('Buy', 'woocommerce-gateway-stripe'),
113
+				'donate'  => __('Donate', 'woocommerce-gateway-stripe'),
114 114
 			),
115 115
 		),
116 116
 		'payment_request_button_theme'  => array(
117
-			'title'       => __( 'Payment Request Button Theme', 'woocommerce-gateway-stripe' ),
118
-			'label'       => __( 'Button Theme', 'woocommerce-gateway-stripe' ),
117
+			'title'       => __('Payment Request Button Theme', 'woocommerce-gateway-stripe'),
118
+			'label'       => __('Button Theme', 'woocommerce-gateway-stripe'),
119 119
 			'type'        => 'select',
120
-			'description' => __( 'Select the button theme you would like to show.', 'woocommerce-gateway-stripe' ),
120
+			'description' => __('Select the button theme you would like to show.', 'woocommerce-gateway-stripe'),
121 121
 			'default'     => 'dark',
122 122
 			'desc_tip'    => true,
123 123
 			'options'     => array(
124
-				'dark'          => __( 'Dark', 'woocommerce-gateway-stripe' ),
125
-				'light'         => __( 'Light', 'woocommerce-gateway-stripe' ),
126
-				'light-outline' => __( 'Light-Outline', 'woocommerce-gateway-stripe' ),
124
+				'dark'          => __('Dark', 'woocommerce-gateway-stripe'),
125
+				'light'         => __('Light', 'woocommerce-gateway-stripe'),
126
+				'light-outline' => __('Light-Outline', 'woocommerce-gateway-stripe'),
127 127
 			),
128 128
 		),
129 129
 		'payment_request_button_height' => array(
130
-			'title'       => __( 'Payment Request Button Height', 'woocommerce-gateway-stripe' ),
131
-			'label'       => __( 'Button Height', 'woocommerce-gateway-stripe' ),
130
+			'title'       => __('Payment Request Button Height', 'woocommerce-gateway-stripe'),
131
+			'label'       => __('Button Height', 'woocommerce-gateway-stripe'),
132 132
 			'type'        => 'text',
133
-			'description' => __( 'Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe' ),
133
+			'description' => __('Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe'),
134 134
 			'default'     => '44',
135 135
 			'desc_tip'    => true,
136 136
 		),
137 137
 		'saved_cards'                   => array(
138
-			'title'       => __( 'Saved Cards', 'woocommerce-gateway-stripe' ),
139
-			'label'       => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ),
138
+			'title'       => __('Saved Cards', 'woocommerce-gateway-stripe'),
139
+			'label'       => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'),
140 140
 			'type'        => 'checkbox',
141
-			'description' => __( 'If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe' ),
141
+			'description' => __('If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe'),
142 142
 			'default'     => 'yes',
143 143
 			'desc_tip'    => true,
144 144
 		),
145 145
 		'logging'                       => array(
146
-			'title'       => __( 'Logging', 'woocommerce-gateway-stripe' ),
147
-			'label'       => __( 'Log debug messages', 'woocommerce-gateway-stripe' ),
146
+			'title'       => __('Logging', 'woocommerce-gateway-stripe'),
147
+			'label'       => __('Log debug messages', 'woocommerce-gateway-stripe'),
148 148
 			'type'        => 'checkbox',
149
-			'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ),
149
+			'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'),
150 150
 			'default'     => 'no',
151 151
 			'desc_tip'    => true,
152 152
 		),
Please login to merge, or discard this patch.
includes/payment-methods/class-wc-stripe-payment-request.php 1 patch
Spacing   +297 added lines, -297 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
 	/**
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @return bool
120 120
 	 */
121 121
 	public function are_keys_set() {
122
-		if ( empty( $this->secret_key ) || empty( $this->publishable_key ) ) {
122
+		if (empty($this->secret_key) || empty($this->publishable_key)) {
123 123
 			return false;
124 124
 		}
125 125
 
@@ -143,18 +143,18 @@  discard block
 block discarded – undo
143 143
 	 * @since 4.0.0
144 144
 	 */
145 145
 	public function set_session() {
146
-		if ( ! is_product() || ( isset( WC()->session ) && WC()->session->has_session() ) ) {
146
+		if ( ! is_product() || (isset(WC()->session) && WC()->session->has_session())) {
147 147
 			return;
148 148
 		}
149 149
 
150
-		$session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' );
150
+		$session_class = apply_filters('woocommerce_session_handler', 'WC_Session_Handler');
151 151
 		$wc_session    = new $session_class();
152 152
 
153
-		if ( version_compare( WC_VERSION, '3.3', '>=' ) ) {
153
+		if (version_compare(WC_VERSION, '3.3', '>=')) {
154 154
 			$wc_session->init();
155 155
 		}
156 156
 
157
-		$wc_session->set_customer_session_cookie( true );
157
+		$wc_session->set_customer_session_cookie(true);
158 158
 	}
159 159
 
160 160
 	/**
@@ -164,40 +164,40 @@  discard block
 block discarded – undo
164 164
 	 * @version 4.0.0
165 165
 	 */
166 166
 	public function init() {
167
-		add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ) );
167
+		add_action('wp_enqueue_scripts', array($this, 'scripts'));
168 168
 
169 169
 		/*
170 170
 		 * In order to display the Payment Request button in the correct position,
171 171
 		 * a new hook was added to WooCommerce 3.0. In older versions of WooCommerce,
172 172
 		 * CSS is used to position the button.
173 173
 		 */
174
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
175
-			add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_payment_request_button_html' ), 1 );
176
-			add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_payment_request_button_separator_html' ), 2 );
174
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
175
+			add_action('woocommerce_after_add_to_cart_button', array($this, 'display_payment_request_button_html'), 1);
176
+			add_action('woocommerce_after_add_to_cart_button', array($this, 'display_payment_request_button_separator_html'), 2);
177 177
 		} else {
178
-			add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_html' ), 1 );
179
-			add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_separator_html' ), 2 );
178
+			add_action('woocommerce_after_add_to_cart_quantity', array($this, 'display_payment_request_button_html'), 1);
179
+			add_action('woocommerce_after_add_to_cart_quantity', array($this, 'display_payment_request_button_separator_html'), 2);
180 180
 		}
181 181
 
182
-		add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_payment_request_button_html' ), 1 );
183
-		add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_payment_request_button_separator_html' ), 2 );
182
+		add_action('woocommerce_proceed_to_checkout', array($this, 'display_payment_request_button_html'), 1);
183
+		add_action('woocommerce_proceed_to_checkout', array($this, 'display_payment_request_button_separator_html'), 2);
184 184
 
185
-		add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_payment_request_button_html' ), 1 );
186
-		add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_payment_request_button_separator_html' ), 2 );
185
+		add_action('woocommerce_checkout_before_customer_details', array($this, 'display_payment_request_button_html'), 1);
186
+		add_action('woocommerce_checkout_before_customer_details', array($this, 'display_payment_request_button_separator_html'), 2);
187 187
 
188
-		add_action( 'wc_ajax_wc_stripe_get_cart_details', array( $this, 'ajax_get_cart_details' ) );
189
-		add_action( 'wc_ajax_wc_stripe_get_shipping_options', array( $this, 'ajax_get_shipping_options' ) );
190
-		add_action( 'wc_ajax_wc_stripe_update_shipping_method', array( $this, 'ajax_update_shipping_method' ) );
191
-		add_action( 'wc_ajax_wc_stripe_create_order', array( $this, 'ajax_create_order' ) );
192
-		add_action( 'wc_ajax_wc_stripe_add_to_cart', array( $this, 'ajax_add_to_cart' ) );
193
-		add_action( 'wc_ajax_wc_stripe_get_selected_product_data', array( $this, 'ajax_get_selected_product_data' ) );
194
-		add_action( 'wc_ajax_wc_stripe_clear_cart', array( $this, 'ajax_clear_cart' ) );
195
-		add_action( 'wc_ajax_wc_stripe_log_errors', array( $this, 'ajax_log_errors' ) );
188
+		add_action('wc_ajax_wc_stripe_get_cart_details', array($this, 'ajax_get_cart_details'));
189
+		add_action('wc_ajax_wc_stripe_get_shipping_options', array($this, 'ajax_get_shipping_options'));
190
+		add_action('wc_ajax_wc_stripe_update_shipping_method', array($this, 'ajax_update_shipping_method'));
191
+		add_action('wc_ajax_wc_stripe_create_order', array($this, 'ajax_create_order'));
192
+		add_action('wc_ajax_wc_stripe_add_to_cart', array($this, 'ajax_add_to_cart'));
193
+		add_action('wc_ajax_wc_stripe_get_selected_product_data', array($this, 'ajax_get_selected_product_data'));
194
+		add_action('wc_ajax_wc_stripe_clear_cart', array($this, 'ajax_clear_cart'));
195
+		add_action('wc_ajax_wc_stripe_log_errors', array($this, 'ajax_log_errors'));
196 196
 
197
-		add_filter( 'woocommerce_gateway_title', array( $this, 'filter_gateway_title' ), 10, 2 );
198
-		add_filter( 'woocommerce_validate_postcode', array( $this, 'postal_code_validation' ), 10, 3 );
197
+		add_filter('woocommerce_gateway_title', array($this, 'filter_gateway_title'), 10, 2);
198
+		add_filter('woocommerce_validate_postcode', array($this, 'postal_code_validation'), 10, 3);
199 199
 
200
-		add_action( 'woocommerce_checkout_order_processed', array( $this, 'add_order_meta' ), 10, 2 );
200
+		add_action('woocommerce_checkout_order_processed', array($this, 'add_order_meta'), 10, 2);
201 201
 	}
202 202
 
203 203
 	/**
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @return string
209 209
 	 */
210 210
 	public function get_button_type() {
211
-		return isset( $this->stripe_settings['payment_request_button_type'] ) ? $this->stripe_settings['payment_request_button_type'] : 'default';
211
+		return isset($this->stripe_settings['payment_request_button_type']) ? $this->stripe_settings['payment_request_button_type'] : 'default';
212 212
 	}
213 213
 
214 214
 	/**
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 * @return string
220 220
 	 */
221 221
 	public function get_button_theme() {
222
-		return isset( $this->stripe_settings['payment_request_button_theme'] ) ? $this->stripe_settings['payment_request_button_theme'] : 'dark';
222
+		return isset($this->stripe_settings['payment_request_button_theme']) ? $this->stripe_settings['payment_request_button_theme'] : 'dark';
223 223
 	}
224 224
 
225 225
 	/**
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 * @return string
231 231
 	 */
232 232
 	public function get_button_height() {
233
-		return isset( $this->stripe_settings['payment_request_button_height'] ) ? str_replace( 'px', '', $this->stripe_settings['payment_request_button_height'] ) : '64';
233
+		return isset($this->stripe_settings['payment_request_button_height']) ? str_replace('px', '', $this->stripe_settings['payment_request_button_height']) : '64';
234 234
 	}
235 235
 
236 236
 	/**
@@ -240,40 +240,40 @@  discard block
 block discarded – undo
240 240
 	 * @version 4.0.0
241 241
 	 */
242 242
 	public function get_product_data() {
243
-		if ( ! is_product() ) {
243
+		if ( ! is_product()) {
244 244
 			return false;
245 245
 		}
246 246
 
247 247
 		global $post;
248 248
 
249
-		$product = wc_get_product( $post->ID );
249
+		$product = wc_get_product($post->ID);
250 250
 
251 251
 		$data  = array();
252 252
 		$items = array();
253 253
 
254 254
 		$items[] = array(
255
-			'label'  => WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->name : $product->get_name(),
256
-			'amount' => WC_Stripe_Helper::get_stripe_amount( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->price : $product->get_price() ),
255
+			'label'  => WC_Stripe_Helper::is_wc_lt('3.0') ? $product->name : $product->get_name(),
256
+			'amount' => WC_Stripe_Helper::get_stripe_amount(WC_Stripe_Helper::is_wc_lt('3.0') ? $product->price : $product->get_price()),
257 257
 		);
258 258
 
259
-		if ( wc_tax_enabled() ) {
259
+		if (wc_tax_enabled()) {
260 260
 			$items[] = array(
261
-				'label'   => __( 'Tax', 'woocommerce-gateway-stripe' ),
261
+				'label'   => __('Tax', 'woocommerce-gateway-stripe'),
262 262
 				'amount'  => 0,
263 263
 				'pending' => true,
264 264
 			);
265 265
 		}
266 266
 
267
-		if ( wc_shipping_enabled() && $product->needs_shipping() ) {
267
+		if (wc_shipping_enabled() && $product->needs_shipping()) {
268 268
 			$items[] = array(
269
-				'label'   => __( 'Shipping', 'woocommerce-gateway-stripe' ),
269
+				'label'   => __('Shipping', 'woocommerce-gateway-stripe'),
270 270
 				'amount'  => 0,
271 271
 				'pending' => true,
272 272
 			);
273 273
 
274 274
 			$data['shippingOptions'] = array(
275 275
 				'id'     => 'pending',
276
-				'label'  => __( 'Pending', 'woocommerce-gateway-stripe' ),
276
+				'label'  => __('Pending', 'woocommerce-gateway-stripe'),
277 277
 				'detail' => '',
278 278
 				'amount' => 0,
279 279
 			);
@@ -281,41 +281,41 @@  discard block
 block discarded – undo
281 281
 
282 282
 		$data['displayItems'] = $items;
283 283
 		$data['total']        = array(
284
-			'label'   => apply_filters( 'wc_stripe_payment_request_total_label', $this->total_label ),
285
-			'amount'  => WC_Stripe_Helper::get_stripe_amount( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->price : $product->get_price() ),
284
+			'label'   => apply_filters('wc_stripe_payment_request_total_label', $this->total_label),
285
+			'amount'  => WC_Stripe_Helper::get_stripe_amount(WC_Stripe_Helper::is_wc_lt('3.0') ? $product->price : $product->get_price()),
286 286
 			'pending' => true,
287 287
 		);
288 288
 
289
-		$data['requestShipping'] = ( wc_shipping_enabled() && $product->needs_shipping() );
290
-		$data['currency']        = strtolower( get_woocommerce_currency() );
291
-		$data['country_code']    = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
289
+		$data['requestShipping'] = (wc_shipping_enabled() && $product->needs_shipping());
290
+		$data['currency']        = strtolower(get_woocommerce_currency());
291
+		$data['country_code']    = substr(get_option('woocommerce_default_country'), 0, 2);
292 292
 
293
-		return apply_filters( 'wc_stripe_payment_request_product_data', $data, $product );
293
+		return apply_filters('wc_stripe_payment_request_product_data', $data, $product);
294 294
 	}
295 295
 
296 296
 	/**
297 297
 	 * Filters the gateway title to reflect Payment Request type
298 298
 	 *
299 299
 	 */
300
-	public function filter_gateway_title( $title, $id ) {
300
+	public function filter_gateway_title($title, $id) {
301 301
 		global $post;
302 302
 
303
-		if ( ! is_object( $post ) ) {
303
+		if ( ! is_object($post)) {
304 304
 			return $title;
305 305
 		}
306 306
 
307
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
308
-			$method_title = get_post_meta( $post->ID, '_payment_method_title', true );
307
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
308
+			$method_title = get_post_meta($post->ID, '_payment_method_title', true);
309 309
 		} else {
310
-			$order        = wc_get_order( $post->ID );
311
-			$method_title = is_object( $order ) ? $order->get_payment_method_title() : '';
310
+			$order        = wc_get_order($post->ID);
311
+			$method_title = is_object($order) ? $order->get_payment_method_title() : '';
312 312
 		}
313 313
 
314
-		if ( 'stripe' === $id && ! empty( $method_title ) && 'Apple Pay (Stripe)' === $method_title ) {
314
+		if ('stripe' === $id && ! empty($method_title) && 'Apple Pay (Stripe)' === $method_title) {
315 315
 			return $method_title;
316 316
 		}
317 317
 
318
-		if ( 'stripe' === $id && ! empty( $method_title ) && 'Chrome Payment Request (Stripe)' === $method_title ) {
318
+		if ('stripe' === $id && ! empty($method_title) && 'Chrome Payment Request (Stripe)' === $method_title) {
319 319
 			return $method_title;
320 320
 		}
321 321
 
@@ -328,16 +328,16 @@  discard block
 block discarded – undo
328 328
 	 * @since 3.1.4
329 329
 	 * @version 4.0.0
330 330
 	 */
331
-	public function postal_code_validation( $valid, $postcode, $country ) {
331
+	public function postal_code_validation($valid, $postcode, $country) {
332 332
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
333 333
 
334
-		if ( ! isset( $gateways['stripe'] ) ) {
334
+		if ( ! isset($gateways['stripe'])) {
335 335
 			return $valid;
336 336
 		}
337 337
 
338
-		$payment_request_type = isset( $_POST['payment_request_type'] ) ? wc_clean( $_POST['payment_request_type'] ) : '';
338
+		$payment_request_type = isset($_POST['payment_request_type']) ? wc_clean($_POST['payment_request_type']) : '';
339 339
 
340
-		if ( 'apple_pay' !== $payment_request_type ) {
340
+		if ('apple_pay' !== $payment_request_type) {
341 341
 			return $valid;
342 342
 		}
343 343
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 		 * the order and not let it go through. The remedy for now is just to remove this validation.
348 348
 		 * Note that this only works with shipping providers that don't validate full postal codes.
349 349
 		 */
350
-		if ( 'GB' === $country || 'CA' === $country ) {
350
+		if ('GB' === $country || 'CA' === $country) {
351 351
 			return true;
352 352
 		}
353 353
 
@@ -362,29 +362,29 @@  discard block
 block discarded – undo
362 362
 	 * @param int $order_id
363 363
 	 * @param array $posted_data The posted data from checkout form.
364 364
 	 */
365
-	public function add_order_meta( $order_id, $posted_data ) {
366
-		if ( empty( $_POST['payment_request_type'] ) ) {
365
+	public function add_order_meta($order_id, $posted_data) {
366
+		if (empty($_POST['payment_request_type'])) {
367 367
 			return;
368 368
 		}
369 369
 
370
-		$order = wc_get_order( $order_id );
370
+		$order = wc_get_order($order_id);
371 371
 
372
-		$payment_request_type = wc_clean( $_POST['payment_request_type'] );
372
+		$payment_request_type = wc_clean($_POST['payment_request_type']);
373 373
 
374
-		if ( 'apple_pay' === $payment_request_type ) {
375
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
376
-				update_post_meta( $order_id, '_payment_method_title', 'Apple Pay (Stripe)' );
374
+		if ('apple_pay' === $payment_request_type) {
375
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
376
+				update_post_meta($order_id, '_payment_method_title', 'Apple Pay (Stripe)');
377 377
 			} else {
378
-				$order->set_payment_method_title( 'Apple Pay (Stripe)' );
378
+				$order->set_payment_method_title('Apple Pay (Stripe)');
379 379
 				$order->save();
380 380
 			}
381 381
 		}
382 382
 
383
-		if ( 'payment_request_api' === $payment_request_type ) {
384
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
385
-				update_post_meta( $order_id, '_payment_method_title', 'Chrome Payment Request (Stripe)' );
383
+		if ('payment_request_api' === $payment_request_type) {
384
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
385
+				update_post_meta($order_id, '_payment_method_title', 'Chrome Payment Request (Stripe)');
386 386
 			} else {
387
-				$order->set_payment_method_title( 'Chrome Payment Request (Stripe)' );
387
+				$order->set_payment_method_title('Chrome Payment Request (Stripe)');
388 388
 				$order->save();
389 389
 			}
390 390
 		}
@@ -421,15 +421,15 @@  discard block
 block discarded – undo
421 421
 	 * @return bool
422 422
 	 */
423 423
 	public function allowed_items_in_cart() {
424
-		foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
425
-			$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
424
+		foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
425
+			$_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);
426 426
 
427
-			if ( ! in_array( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $_product->product_type : $_product->get_type() ), $this->supported_product_types() ) ) {
427
+			if ( ! in_array((WC_Stripe_Helper::is_wc_lt('3.0') ? $_product->product_type : $_product->get_type()), $this->supported_product_types())) {
428 428
 				return false;
429 429
 			}
430 430
 
431 431
 			// Pre Orders compatbility where we don't support charge upon release.
432
-			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() ) ) {
432
+			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())) {
433 433
 				return false;
434 434
 			}
435 435
 		}
@@ -445,80 +445,80 @@  discard block
 block discarded – undo
445 445
 	 */
446 446
 	public function scripts() {
447 447
 		// If keys are not set bail.
448
-		if ( ! $this->are_keys_set() ) {
449
-			WC_Stripe_Logger::log( 'Keys are not set correctly.' );
448
+		if ( ! $this->are_keys_set()) {
449
+			WC_Stripe_Logger::log('Keys are not set correctly.');
450 450
 			return;
451 451
 		}
452 452
 
453 453
 		// If no SSL bail.
454
-		if ( ! $this->testmode && ! is_ssl() ) {
455
-			WC_Stripe_Logger::log( 'Stripe Payment Request live mode requires SSL.' );
454
+		if ( ! $this->testmode && ! is_ssl()) {
455
+			WC_Stripe_Logger::log('Stripe Payment Request live mode requires SSL.');
456 456
 			return;
457 457
 		}
458 458
 
459
-		if ( ! is_product() && ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) ) {
459
+		if ( ! is_product() && ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order'])) {
460 460
 			return;
461 461
 		}
462 462
 
463
-		if ( is_product() ) {
463
+		if (is_product()) {
464 464
 			global $post;
465 465
 
466
-			$product = wc_get_product( $post->ID );
466
+			$product = wc_get_product($post->ID);
467 467
 
468
-			if ( ! is_object( $product ) || ! in_array( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) {
468
+			if ( ! is_object($product) || ! in_array((WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type()), $this->supported_product_types())) {
469 469
 				return;
470 470
 			}
471 471
 
472
-			if ( apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false, $post ) ) {
472
+			if (apply_filters('wc_stripe_hide_payment_request_on_product_page', false, $post)) {
473 473
 				return;
474 474
 			}
475 475
 		}
476 476
 
477
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
477
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
478 478
 
479 479
 		$stripe_params = array(
480
-			'ajax_url'        => WC_AJAX::get_endpoint( '%%endpoint%%' ),
480
+			'ajax_url'        => WC_AJAX::get_endpoint('%%endpoint%%'),
481 481
 			'stripe'          => array(
482 482
 				'key'                => $this->publishable_key,
483
-				'allow_prepaid_card' => apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no',
483
+				'allow_prepaid_card' => apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no',
484 484
 			),
485 485
 			'nonce'           => array(
486
-				'payment'                   => wp_create_nonce( 'wc-stripe-payment-request' ),
487
-				'shipping'                  => wp_create_nonce( 'wc-stripe-payment-request-shipping' ),
488
-				'update_shipping'           => wp_create_nonce( 'wc-stripe-update-shipping-method' ),
489
-				'checkout'                  => wp_create_nonce( 'woocommerce-process_checkout' ),
490
-				'add_to_cart'               => wp_create_nonce( 'wc-stripe-add-to-cart' ),
491
-				'get_selected_product_data' => wp_create_nonce( 'wc-stripe-get-selected-product-data' ),
492
-				'log_errors'                => wp_create_nonce( 'wc-stripe-log-errors' ),
493
-				'clear_cart'                => wp_create_nonce( 'wc-stripe-clear-cart' ),
486
+				'payment'                   => wp_create_nonce('wc-stripe-payment-request'),
487
+				'shipping'                  => wp_create_nonce('wc-stripe-payment-request-shipping'),
488
+				'update_shipping'           => wp_create_nonce('wc-stripe-update-shipping-method'),
489
+				'checkout'                  => wp_create_nonce('woocommerce-process_checkout'),
490
+				'add_to_cart'               => wp_create_nonce('wc-stripe-add-to-cart'),
491
+				'get_selected_product_data' => wp_create_nonce('wc-stripe-get-selected-product-data'),
492
+				'log_errors'                => wp_create_nonce('wc-stripe-log-errors'),
493
+				'clear_cart'                => wp_create_nonce('wc-stripe-clear-cart'),
494 494
 			),
495 495
 			'i18n'            => array(
496
-				'no_prepaid_card'  => __( 'Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe' ),
496
+				'no_prepaid_card'  => __('Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe'),
497 497
 				/* translators: Do not translate the [option] placeholder */
498
-				'unknown_shipping' => __( 'Unknown shipping option "[option]".', 'woocommerce-gateway-stripe' ),
498
+				'unknown_shipping' => __('Unknown shipping option "[option]".', 'woocommerce-gateway-stripe'),
499 499
 			),
500 500
 			'checkout'        => array(
501 501
 				'url'            => wc_get_checkout_url(),
502
-				'currency_code'  => strtolower( get_woocommerce_currency() ),
503
-				'country_code'   => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
502
+				'currency_code'  => strtolower(get_woocommerce_currency()),
503
+				'country_code'   => substr(get_option('woocommerce_default_country'), 0, 2),
504 504
 				'needs_shipping' => WC()->cart->needs_shipping() ? 'yes' : 'no',
505 505
 			),
506 506
 			'button'          => array(
507 507
 				'type'   => $this->get_button_type(),
508 508
 				'theme'  => $this->get_button_theme(),
509 509
 				'height' => $this->get_button_height(),
510
-				'locale' => apply_filters( 'wc_stripe_payment_request_button_locale', substr( get_locale(), 0, 2 ) ), // Default format is en_US.
510
+				'locale' => apply_filters('wc_stripe_payment_request_button_locale', substr(get_locale(), 0, 2)), // Default format is en_US.
511 511
 			),
512 512
 			'is_product_page' => is_product(),
513 513
 			'product'         => $this->get_product_data(),
514 514
 		);
515 515
 
516
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
517
-		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 );
516
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
517
+		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);
518 518
 
519
-		wp_localize_script( 'wc_stripe_payment_request', 'wc_stripe_payment_request_params', apply_filters( 'wc_stripe_payment_request_params', $stripe_params ) );
519
+		wp_localize_script('wc_stripe_payment_request', 'wc_stripe_payment_request_params', apply_filters('wc_stripe_payment_request_params', $stripe_params));
520 520
 
521
-		wp_enqueue_script( 'wc_stripe_payment_request' );
521
+		wp_enqueue_script('wc_stripe_payment_request');
522 522
 	}
523 523
 
524 524
 	/**
@@ -532,37 +532,37 @@  discard block
 block discarded – undo
532 532
 
533 533
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
534 534
 
535
-		if ( ! isset( $gateways['stripe'] ) ) {
535
+		if ( ! isset($gateways['stripe'])) {
536 536
 			return;
537 537
 		}
538 538
 
539
-		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) {
539
+		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset($_GET['pay_for_order'])) {
540 540
 			return;
541 541
 		}
542 542
 
543
-		if ( is_product() && apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false, $post ) ) {
543
+		if (is_product() && apply_filters('wc_stripe_hide_payment_request_on_product_page', false, $post)) {
544 544
 			return;
545 545
 		}
546 546
 
547
-		if ( is_checkout() && ! apply_filters( 'wc_stripe_show_payment_request_on_checkout', false, $post ) ) {
547
+		if (is_checkout() && ! apply_filters('wc_stripe_show_payment_request_on_checkout', false, $post)) {
548 548
 			return;
549 549
 		}
550 550
 
551
-		if ( is_product() ) {
552
-			$product = wc_get_product( $post->ID );
551
+		if (is_product()) {
552
+			$product = wc_get_product($post->ID);
553 553
 
554
-			if ( ! is_object( $product ) || ! in_array( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) {
554
+			if ( ! is_object($product) || ! in_array((WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type()), $this->supported_product_types())) {
555 555
 				return;
556 556
 			}
557 557
 
558 558
 			// Pre Orders charge upon release not supported.
559
-			if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Product::product_is_charged_upon_release( $product ) ) {
560
-				WC_Stripe_Logger::log( 'Pre Order charge upon release is not supported. ( Payment Request button disabled )' );
559
+			if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Product::product_is_charged_upon_release($product)) {
560
+				WC_Stripe_Logger::log('Pre Order charge upon release is not supported. ( Payment Request button disabled )');
561 561
 				return;
562 562
 			}
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,42 +586,42 @@  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_product() && apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false, $post ) ) {
597
+		if (is_product() && apply_filters('wc_stripe_hide_payment_request_on_product_page', false, $post)) {
598 598
 			return;
599 599
 		}
600 600
 
601
-		if ( is_checkout() && ! apply_filters( 'wc_stripe_show_payment_request_on_checkout', false, $post ) ) {
601
+		if (is_checkout() && ! apply_filters('wc_stripe_show_payment_request_on_checkout', false, $post)) {
602 602
 			return;
603 603
 		}
604 604
 
605
-		if ( is_product() ) {
606
-			$product = wc_get_product( $post->ID );
605
+		if (is_product()) {
606
+			$product = wc_get_product($post->ID);
607 607
 
608
-			if ( ! is_object( $product ) || ! in_array( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) {
608
+			if ( ! is_object($product) || ! in_array((WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type()), $this->supported_product_types())) {
609 609
 				return;
610 610
 			}
611 611
 
612 612
 			// Pre Orders charge upon release not supported.
613
-			if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Product::product_is_charged_upon_release( $product ) ) {
614
-				WC_Stripe_Logger::log( 'Pre Order charge upon release is not supported. ( Payment Request button disabled )' );
613
+			if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Product::product_is_charged_upon_release($product)) {
614
+				WC_Stripe_Logger::log('Pre Order charge upon release is not supported. ( Payment Request button disabled )');
615 615
 				return;
616 616
 			}
617 617
 		} else {
618
-			if ( ! $this->allowed_items_in_cart() ) {
619
-				WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' );
618
+			if ( ! $this->allowed_items_in_cart()) {
619
+				WC_Stripe_Logger::log('Items in the cart has unsupported product type ( Payment Request button disabled )');
620 620
 				return;
621 621
 			}
622 622
 		}
623 623
 		?>
624
-		<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>
624
+		<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>
625 625
 		<?php
626 626
 	}
627 627
 
@@ -632,11 +632,11 @@  discard block
 block discarded – undo
632 632
 	 * @version 4.0.0
633 633
 	 */
634 634
 	public function ajax_log_errors() {
635
-		check_ajax_referer( 'wc-stripe-log-errors', 'security' );
635
+		check_ajax_referer('wc-stripe-log-errors', 'security');
636 636
 
637
-		$errors = wc_clean( stripslashes( $_POST['errors'] ) );
637
+		$errors = wc_clean(stripslashes($_POST['errors']));
638 638
 
639
-		WC_Stripe_Logger::log( $errors );
639
+		WC_Stripe_Logger::log($errors);
640 640
 
641 641
 		exit;
642 642
 	}
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 	 * @version 4.0.0
649 649
 	 */
650 650
 	public function ajax_clear_cart() {
651
-		check_ajax_referer( 'wc-stripe-clear-cart', 'security' );
651
+		check_ajax_referer('wc-stripe-clear-cart', 'security');
652 652
 
653 653
 		WC()->cart->empty_cart();
654 654
 		exit;
@@ -658,10 +658,10 @@  discard block
 block discarded – undo
658 658
 	 * Get cart details.
659 659
 	 */
660 660
 	public function ajax_get_cart_details() {
661
-		check_ajax_referer( 'wc-stripe-payment-request', 'security' );
661
+		check_ajax_referer('wc-stripe-payment-request', 'security');
662 662
 
663
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
664
-			define( 'WOOCOMMERCE_CART', true );
663
+		if ( ! defined('WOOCOMMERCE_CART')) {
664
+			define('WOOCOMMERCE_CART', true);
665 665
 		}
666 666
 
667 667
 		WC()->cart->calculate_totals();
@@ -672,14 +672,14 @@  discard block
 block discarded – undo
672 672
 		$data = array(
673 673
 			'shipping_required' => WC()->cart->needs_shipping(),
674 674
 			'order_data'        => array(
675
-				'currency'     => strtolower( $currency ),
676
-				'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
675
+				'currency'     => strtolower($currency),
676
+				'country_code' => substr(get_option('woocommerce_default_country'), 0, 2),
677 677
 			),
678 678
 		);
679 679
 
680 680
 		$data['order_data'] += $this->build_display_items();
681 681
 
682
-		wp_send_json( $data );
682
+		wp_send_json($data);
683 683
 	}
684 684
 
685 685
 	/**
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 	 * @see WC_Shipping::get_packages().
691 691
 	 */
692 692
 	public function ajax_get_shipping_options() {
693
-		check_ajax_referer( 'wc-stripe-payment-request-shipping', 'security' );
693
+		check_ajax_referer('wc-stripe-payment-request-shipping', 'security');
694 694
 
695 695
 		try {
696 696
 			// Set the shipping package.
@@ -706,34 +706,34 @@  discard block
 block discarded – undo
706 706
 				)
707 707
 			);
708 708
 
709
-			$this->calculate_shipping( apply_filters( 'wc_stripe_payment_request_shipping_posted_values', $posted ) );
709
+			$this->calculate_shipping(apply_filters('wc_stripe_payment_request_shipping_posted_values', $posted));
710 710
 
711 711
 			// Set the shipping options.
712 712
 			$data     = array();
713 713
 			$packages = WC()->shipping->get_packages();
714 714
 
715
-			if ( ! empty( $packages ) && WC()->customer->has_calculated_shipping() ) {
716
-				foreach ( $packages as $package_key => $package ) {
717
-					if ( empty( $package['rates'] ) ) {
718
-						throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) );
715
+			if ( ! empty($packages) && WC()->customer->has_calculated_shipping()) {
716
+				foreach ($packages as $package_key => $package) {
717
+					if (empty($package['rates'])) {
718
+						throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe'));
719 719
 					}
720 720
 
721
-					foreach ( $package['rates'] as $key => $rate ) {
721
+					foreach ($package['rates'] as $key => $rate) {
722 722
 						$data['shipping_options'][] = array(
723 723
 							'id'     => $rate->id,
724 724
 							'label'  => $rate->label,
725 725
 							'detail' => '',
726
-							'amount' => WC_Stripe_Helper::get_stripe_amount( $rate->cost ),
726
+							'amount' => WC_Stripe_Helper::get_stripe_amount($rate->cost),
727 727
 						);
728 728
 					}
729 729
 				}
730 730
 			} else {
731
-				throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) );
731
+				throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe'));
732 732
 			}
733 733
 
734
-			if ( isset( $data[0] ) ) {
734
+			if (isset($data[0])) {
735 735
 				// Auto select the first shipping method.
736
-				WC()->session->set( 'chosen_shipping_methods', array( $data[0]['id'] ) );
736
+				WC()->session->set('chosen_shipping_methods', array($data[0]['id']));
737 737
 			}
738 738
 
739 739
 			WC()->cart->calculate_totals();
@@ -741,12 +741,12 @@  discard block
 block discarded – undo
741 741
 			$data          += $this->build_display_items();
742 742
 			$data['result'] = 'success';
743 743
 
744
-			wp_send_json( $data );
745
-		} catch ( Exception $e ) {
744
+			wp_send_json($data);
745
+		} catch (Exception $e) {
746 746
 			$data          += $this->build_display_items();
747 747
 			$data['result'] = 'invalid_shipping_address';
748 748
 
749
-			wp_send_json( $data );
749
+			wp_send_json($data);
750 750
 		}
751 751
 	}
752 752
 
@@ -754,22 +754,22 @@  discard block
 block discarded – undo
754 754
 	 * Update shipping method.
755 755
 	 */
756 756
 	public function ajax_update_shipping_method() {
757
-		check_ajax_referer( 'wc-stripe-update-shipping-method', 'security' );
757
+		check_ajax_referer('wc-stripe-update-shipping-method', 'security');
758 758
 
759
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
760
-			define( 'WOOCOMMERCE_CART', true );
759
+		if ( ! defined('WOOCOMMERCE_CART')) {
760
+			define('WOOCOMMERCE_CART', true);
761 761
 		}
762 762
 
763
-		$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
764
-		$shipping_method         = filter_input( INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
763
+		$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
764
+		$shipping_method         = filter_input(INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
765 765
 
766
-		if ( is_array( $shipping_method ) ) {
767
-			foreach ( $shipping_method as $i => $value ) {
768
-				$chosen_shipping_methods[ $i ] = wc_clean( $value );
766
+		if (is_array($shipping_method)) {
767
+			foreach ($shipping_method as $i => $value) {
768
+				$chosen_shipping_methods[$i] = wc_clean($value);
769 769
 			}
770 770
 		}
771 771
 
772
-		WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods );
772
+		WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
773 773
 
774 774
 		WC()->cart->calculate_totals();
775 775
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 		$data          += $this->build_display_items();
778 778
 		$data['result'] = 'success';
779 779
 
780
-		wp_send_json( $data );
780
+		wp_send_json($data);
781 781
 	}
782 782
 
783 783
 	/**
@@ -788,46 +788,46 @@  discard block
 block discarded – undo
788 788
 	 * @return array $data
789 789
 	 */
790 790
 	public function ajax_get_selected_product_data() {
791
-		check_ajax_referer( 'wc-stripe-get-selected-product-data', 'security' );
791
+		check_ajax_referer('wc-stripe-get-selected-product-data', 'security');
792 792
 
793 793
 		try {
794
-			$product_id   = absint( $_POST['product_id'] );
795
-			$qty          = ! isset( $_POST['qty'] ) ? 1 : apply_filters( 'woocommerce_add_to_cart_quantity', absint( $_POST['qty'] ), $product_id );
796
-			$product      = wc_get_product( $product_id );
794
+			$product_id   = absint($_POST['product_id']);
795
+			$qty          = ! isset($_POST['qty']) ? 1 : apply_filters('woocommerce_add_to_cart_quantity', absint($_POST['qty']), $product_id);
796
+			$product      = wc_get_product($product_id);
797 797
 			$variation_id = null;
798 798
 
799
-			if ( ! is_a( $product, 'WC_Product' ) ) {
800
-				throw new Exception( sprintf( __( 'Product with the ID (%d) cannot be found.', 'woocommerce-gateway-stripe' ), $product_id ) );
799
+			if ( ! is_a($product, 'WC_Product')) {
800
+				throw new Exception(sprintf(__('Product with the ID (%d) cannot be found.', 'woocommerce-gateway-stripe'), $product_id));
801 801
 			}
802 802
 
803
-			if ( 'variable' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ) && isset( $_POST['attributes'] ) ) {
804
-				$attributes = array_map( 'wc_clean', $_POST['attributes'] );
803
+			if ('variable' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type()) && isset($_POST['attributes'])) {
804
+				$attributes = array_map('wc_clean', $_POST['attributes']);
805 805
 
806
-				if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
807
-					$variation_id = $product->get_matching_variation( $attributes );
806
+				if (WC_Stripe_Helper::is_wc_lt('3.0')) {
807
+					$variation_id = $product->get_matching_variation($attributes);
808 808
 				} else {
809
-					$data_store   = WC_Data_Store::load( 'product' );
810
-					$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
809
+					$data_store   = WC_Data_Store::load('product');
810
+					$variation_id = $data_store->find_matching_product_variation($product, $attributes);
811 811
 				}
812 812
 
813
-				if ( ! empty( $variation_id ) ) {
814
-					$product = wc_get_product( $variation_id );
813
+				if ( ! empty($variation_id)) {
814
+					$product = wc_get_product($variation_id);
815 815
 				}
816
-			} elseif ( 'simple' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ) ) {
817
-				$product = wc_get_product( $product_id );
816
+			} elseif ('simple' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type())) {
817
+				$product = wc_get_product($product_id);
818 818
 			}
819 819
 
820 820
 			// Force quantity to 1 if sold individually and check for existing item in cart.
821
-			if ( $product->is_sold_individually() ) {
822
-				$qty = apply_filters( 'wc_stripe_payment_request_add_to_cart_sold_individually_quantity', 1, $qty, $product_id, $variation_id );
821
+			if ($product->is_sold_individually()) {
822
+				$qty = apply_filters('wc_stripe_payment_request_add_to_cart_sold_individually_quantity', 1, $qty, $product_id, $variation_id);
823 823
 			}
824 824
 
825
-			if ( ! $product->has_enough_stock( $qty ) ) {
825
+			if ( ! $product->has_enough_stock($qty)) {
826 826
 				/* translators: 1: product name 2: quantity in stock */
827
-				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 ) ) );
827
+				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)));
828 828
 			}
829 829
 
830
-			$total = $qty * ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->price : $product->get_price() );
830
+			$total = $qty * (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->price : $product->get_price());
831 831
 
832 832
 			$quantity_label = 1 < $qty ? ' (x' . $qty . ')' : '';
833 833
 
@@ -835,28 +835,28 @@  discard block
 block discarded – undo
835 835
 			$items = array();
836 836
 
837 837
 			$items[] = array(
838
-				'label'  => ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->name : $product->get_name() ) . $quantity_label,
839
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $total ),
838
+				'label'  => (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->name : $product->get_name()) . $quantity_label,
839
+				'amount' => WC_Stripe_Helper::get_stripe_amount($total),
840 840
 			);
841 841
 
842
-			if ( wc_tax_enabled() ) {
842
+			if (wc_tax_enabled()) {
843 843
 				$items[] = array(
844
-					'label'   => __( 'Tax', 'woocommerce-gateway-stripe' ),
844
+					'label'   => __('Tax', 'woocommerce-gateway-stripe'),
845 845
 					'amount'  => 0,
846 846
 					'pending' => true,
847 847
 				);
848 848
 			}
849 849
 
850
-			if ( wc_shipping_enabled() && $product->needs_shipping() ) {
850
+			if (wc_shipping_enabled() && $product->needs_shipping()) {
851 851
 				$items[] = array(
852
-					'label'   => __( 'Shipping', 'woocommerce-gateway-stripe' ),
852
+					'label'   => __('Shipping', 'woocommerce-gateway-stripe'),
853 853
 					'amount'  => 0,
854 854
 					'pending' => true,
855 855
 				);
856 856
 
857 857
 				$data['shippingOptions'] = array(
858 858
 					'id'     => 'pending',
859
-					'label'  => __( 'Pending', 'woocommerce-gateway-stripe' ),
859
+					'label'  => __('Pending', 'woocommerce-gateway-stripe'),
860 860
 					'detail' => '',
861 861
 					'amount' => 0,
862 862
 				);
@@ -865,17 +865,17 @@  discard block
 block discarded – undo
865 865
 			$data['displayItems'] = $items;
866 866
 			$data['total']        = array(
867 867
 				'label'   => $this->total_label,
868
-				'amount'  => WC_Stripe_Helper::get_stripe_amount( $total ),
868
+				'amount'  => WC_Stripe_Helper::get_stripe_amount($total),
869 869
 				'pending' => true,
870 870
 			);
871 871
 
872
-			$data['requestShipping'] = ( wc_shipping_enabled() && $product->needs_shipping() );
873
-			$data['currency']        = strtolower( get_woocommerce_currency() );
874
-			$data['country_code']    = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
872
+			$data['requestShipping'] = (wc_shipping_enabled() && $product->needs_shipping());
873
+			$data['currency']        = strtolower(get_woocommerce_currency());
874
+			$data['country_code']    = substr(get_option('woocommerce_default_country'), 0, 2);
875 875
 
876
-			wp_send_json( $data );
877
-		} catch ( Exception $e ) {
878
-			wp_send_json( array( 'error' => wp_strip_all_tags( $e->getMessage() ) ) );
876
+			wp_send_json($data);
877
+		} catch (Exception $e) {
878
+			wp_send_json(array('error' => wp_strip_all_tags($e->getMessage())));
879 879
 		}
880 880
 	}
881 881
 
@@ -887,36 +887,36 @@  discard block
 block discarded – undo
887 887
 	 * @return array $data
888 888
 	 */
889 889
 	public function ajax_add_to_cart() {
890
-		check_ajax_referer( 'wc-stripe-add-to-cart', 'security' );
890
+		check_ajax_referer('wc-stripe-add-to-cart', 'security');
891 891
 
892
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
893
-			define( 'WOOCOMMERCE_CART', true );
892
+		if ( ! defined('WOOCOMMERCE_CART')) {
893
+			define('WOOCOMMERCE_CART', true);
894 894
 		}
895 895
 
896 896
 		WC()->shipping->reset_shipping();
897 897
 
898
-		$product_id = absint( $_POST['product_id'] );
899
-		$qty        = ! isset( $_POST['qty'] ) ? 1 : absint( $_POST['qty'] );
900
-		$product    = wc_get_product( $product_id );
898
+		$product_id = absint($_POST['product_id']);
899
+		$qty        = ! isset($_POST['qty']) ? 1 : absint($_POST['qty']);
900
+		$product    = wc_get_product($product_id);
901 901
 
902 902
 		// First empty the cart to prevent wrong calculation.
903 903
 		WC()->cart->empty_cart();
904 904
 
905
-		if ( 'variable' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ) && isset( $_POST['attributes'] ) ) {
906
-			$attributes = array_map( 'wc_clean', $_POST['attributes'] );
905
+		if ('variable' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type()) && isset($_POST['attributes'])) {
906
+			$attributes = array_map('wc_clean', $_POST['attributes']);
907 907
 
908
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
909
-				$variation_id = $product->get_matching_variation( $attributes );
908
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
909
+				$variation_id = $product->get_matching_variation($attributes);
910 910
 			} else {
911
-				$data_store   = WC_Data_Store::load( 'product' );
912
-				$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
911
+				$data_store   = WC_Data_Store::load('product');
912
+				$variation_id = $data_store->find_matching_product_variation($product, $attributes);
913 913
 			}
914 914
 
915
-			WC()->cart->add_to_cart( $product->get_id(), $qty, $variation_id, $attributes );
915
+			WC()->cart->add_to_cart($product->get_id(), $qty, $variation_id, $attributes);
916 916
 		}
917 917
 
918
-		if ( 'simple' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ) ) {
919
-			WC()->cart->add_to_cart( $product->get_id(), $qty );
918
+		if ('simple' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type())) {
919
+			WC()->cart->add_to_cart($product->get_id(), $qty);
920 920
 		}
921 921
 
922 922
 		WC()->cart->calculate_totals();
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 		$data          += $this->build_display_items();
926 926
 		$data['result'] = 'success';
927 927
 
928
-		wp_send_json( $data );
928
+		wp_send_json($data);
929 929
 	}
930 930
 
931 931
 	/**
@@ -938,31 +938,31 @@  discard block
 block discarded – undo
938 938
 	 * @version 4.0.0
939 939
 	 */
940 940
 	public function normalize_state() {
941
-		$billing_country  = ! empty( $_POST['billing_country'] ) ? wc_clean( $_POST['billing_country'] ) : '';
942
-		$shipping_country = ! empty( $_POST['shipping_country'] ) ? wc_clean( $_POST['shipping_country'] ) : '';
943
-		$billing_state    = ! empty( $_POST['billing_state'] ) ? wc_clean( $_POST['billing_state'] ) : '';
944
-		$shipping_state   = ! empty( $_POST['shipping_state'] ) ? wc_clean( $_POST['shipping_state'] ) : '';
941
+		$billing_country  = ! empty($_POST['billing_country']) ? wc_clean($_POST['billing_country']) : '';
942
+		$shipping_country = ! empty($_POST['shipping_country']) ? wc_clean($_POST['shipping_country']) : '';
943
+		$billing_state    = ! empty($_POST['billing_state']) ? wc_clean($_POST['billing_state']) : '';
944
+		$shipping_state   = ! empty($_POST['shipping_state']) ? wc_clean($_POST['shipping_state']) : '';
945 945
 
946
-		if ( $billing_state && $billing_country ) {
947
-			$valid_states = WC()->countries->get_states( $billing_country );
946
+		if ($billing_state && $billing_country) {
947
+			$valid_states = WC()->countries->get_states($billing_country);
948 948
 
949 949
 			// Valid states found for country.
950
-			if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) {
951
-				foreach ( $valid_states as $state_abbr => $state ) {
952
-					if ( preg_match( '/' . preg_quote( $state ) . '/i', $billing_state ) ) {
950
+			if ( ! empty($valid_states) && is_array($valid_states) && sizeof($valid_states) > 0) {
951
+				foreach ($valid_states as $state_abbr => $state) {
952
+					if (preg_match('/' . preg_quote($state) . '/i', $billing_state)) {
953 953
 						$_POST['billing_state'] = $state_abbr;
954 954
 					}
955 955
 				}
956 956
 			}
957 957
 		}
958 958
 
959
-		if ( $shipping_state && $shipping_country ) {
960
-			$valid_states = WC()->countries->get_states( $shipping_country );
959
+		if ($shipping_state && $shipping_country) {
960
+			$valid_states = WC()->countries->get_states($shipping_country);
961 961
 
962 962
 			// Valid states found for country.
963
-			if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) {
964
-				foreach ( $valid_states as $state_abbr => $state ) {
965
-					if ( preg_match( '/' . preg_quote( $state ) . '/i', $shipping_state ) ) {
963
+			if ( ! empty($valid_states) && is_array($valid_states) && sizeof($valid_states) > 0) {
964
+				foreach ($valid_states as $state_abbr => $state) {
965
+					if (preg_match('/' . preg_quote($state) . '/i', $shipping_state)) {
966 966
 						$_POST['shipping_state'] = $state_abbr;
967 967
 					}
968 968
 				}
@@ -977,19 +977,19 @@  discard block
 block discarded – undo
977 977
 	 * @version 4.0.0
978 978
 	 */
979 979
 	public function ajax_create_order() {
980
-		if ( WC()->cart->is_empty() ) {
981
-			wp_send_json_error( __( 'Empty cart', 'woocommerce-gateway-stripe' ) );
980
+		if (WC()->cart->is_empty()) {
981
+			wp_send_json_error(__('Empty cart', 'woocommerce-gateway-stripe'));
982 982
 		}
983 983
 
984
-		if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) {
985
-			define( 'WOOCOMMERCE_CHECKOUT', true );
984
+		if ( ! defined('WOOCOMMERCE_CHECKOUT')) {
985
+			define('WOOCOMMERCE_CHECKOUT', true);
986 986
 		}
987 987
 
988 988
 		$this->normalize_state();
989 989
 
990 990
 		WC()->checkout()->process_checkout();
991 991
 
992
-		die( 0 );
992
+		die(0);
993 993
 	}
994 994
 
995 995
 	/**
@@ -999,41 +999,41 @@  discard block
 block discarded – undo
999 999
 	 * @version 4.0.0
1000 1000
 	 * @param array $address
1001 1001
 	 */
1002
-	protected function calculate_shipping( $address = array() ) {
1002
+	protected function calculate_shipping($address = array()) {
1003 1003
 		$country   = $address['country'];
1004 1004
 		$state     = $address['state'];
1005 1005
 		$postcode  = $address['postcode'];
1006 1006
 		$city      = $address['city'];
1007 1007
 		$address_1 = $address['address'];
1008 1008
 		$address_2 = $address['address_2'];
1009
-		$wc_states = WC()->countries->get_states( $country );
1009
+		$wc_states = WC()->countries->get_states($country);
1010 1010
 
1011 1011
 		/**
1012 1012
 		 * In some versions of Chrome, state can be a full name. So we need
1013 1013
 		 * to convert that to abbreviation as WC is expecting that.
1014 1014
 		 */
1015
-		if ( 2 < strlen( $state ) && ! empty( $wc_states ) ) {
1016
-			$state = array_search( ucwords( strtolower( $state ) ), $wc_states, true );
1015
+		if (2 < strlen($state) && ! empty($wc_states)) {
1016
+			$state = array_search(ucwords(strtolower($state)), $wc_states, true);
1017 1017
 		}
1018 1018
 
1019 1019
 		WC()->shipping->reset_shipping();
1020 1020
 
1021
-		if ( $postcode && WC_Validation::is_postcode( $postcode, $country ) ) {
1022
-			$postcode = wc_format_postcode( $postcode, $country );
1021
+		if ($postcode && WC_Validation::is_postcode($postcode, $country)) {
1022
+			$postcode = wc_format_postcode($postcode, $country);
1023 1023
 		}
1024 1024
 
1025
-		if ( $country ) {
1026
-			WC()->customer->set_location( $country, $state, $postcode, $city );
1027
-			WC()->customer->set_shipping_location( $country, $state, $postcode, $city );
1025
+		if ($country) {
1026
+			WC()->customer->set_location($country, $state, $postcode, $city);
1027
+			WC()->customer->set_shipping_location($country, $state, $postcode, $city);
1028 1028
 		} else {
1029
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? WC()->customer->set_to_base() : WC()->customer->set_billing_address_to_base();
1030
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? WC()->customer->set_shipping_to_base() : WC()->customer->set_shipping_address_to_base();
1029
+			WC_Stripe_Helper::is_wc_lt('3.0') ? WC()->customer->set_to_base() : WC()->customer->set_billing_address_to_base();
1030
+			WC_Stripe_Helper::is_wc_lt('3.0') ? WC()->customer->set_shipping_to_base() : WC()->customer->set_shipping_address_to_base();
1031 1031
 		}
1032 1032
 
1033
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
1034
-			WC()->customer->calculated_shipping( true );
1033
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
1034
+			WC()->customer->calculated_shipping(true);
1035 1035
 		} else {
1036
-			WC()->customer->set_calculated_shipping( true );
1036
+			WC()->customer->set_calculated_shipping(true);
1037 1037
 			WC()->customer->save();
1038 1038
 		}
1039 1039
 
@@ -1050,17 +1050,17 @@  discard block
 block discarded – undo
1050 1050
 		$packages[0]['destination']['address']   = $address_1;
1051 1051
 		$packages[0]['destination']['address_2'] = $address_2;
1052 1052
 
1053
-		foreach ( WC()->cart->get_cart() as $item ) {
1054
-			if ( $item['data']->needs_shipping() ) {
1055
-				if ( isset( $item['line_total'] ) ) {
1053
+		foreach (WC()->cart->get_cart() as $item) {
1054
+			if ($item['data']->needs_shipping()) {
1055
+				if (isset($item['line_total'])) {
1056 1056
 					$packages[0]['contents_cost'] += $item['line_total'];
1057 1057
 				}
1058 1058
 			}
1059 1059
 		}
1060 1060
 
1061
-		$packages = apply_filters( 'woocommerce_cart_shipping_packages', $packages );
1061
+		$packages = apply_filters('woocommerce_cart_shipping_packages', $packages);
1062 1062
 
1063
-		WC()->shipping->calculate_shipping( $packages );
1063
+		WC()->shipping->calculate_shipping($packages);
1064 1064
 	}
1065 1065
 
1066 1066
 	/**
@@ -1069,19 +1069,19 @@  discard block
 block discarded – undo
1069 1069
 	 * @since 3.1.0
1070 1070
 	 * @version 4.0.0
1071 1071
 	 */
1072
-	protected function build_shipping_methods( $shipping_methods ) {
1073
-		if ( empty( $shipping_methods ) ) {
1072
+	protected function build_shipping_methods($shipping_methods) {
1073
+		if (empty($shipping_methods)) {
1074 1074
 			return array();
1075 1075
 		}
1076 1076
 
1077 1077
 		$shipping = array();
1078 1078
 
1079
-		foreach ( $shipping_methods as $method ) {
1079
+		foreach ($shipping_methods as $method) {
1080 1080
 			$shipping[] = array(
1081 1081
 				'id'     => $method['id'],
1082 1082
 				'label'  => $method['label'],
1083 1083
 				'detail' => '',
1084
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $method['amount']['value'] ),
1084
+				'amount' => WC_Stripe_Helper::get_stripe_amount($method['amount']['value']),
1085 1085
 			);
1086 1086
 		}
1087 1087
 
@@ -1095,8 +1095,8 @@  discard block
 block discarded – undo
1095 1095
 	 * @version 4.0.0
1096 1096
 	 */
1097 1097
 	protected function build_display_items() {
1098
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
1099
-			define( 'WOOCOMMERCE_CART', true );
1098
+		if ( ! defined('WOOCOMMERCE_CART')) {
1099
+			define('WOOCOMMERCE_CART', true);
1100 1100
 		}
1101 1101
 
1102 1102
 		$items     = array();
@@ -1104,71 +1104,71 @@  discard block
 block discarded – undo
1104 1104
 		$discounts = 0;
1105 1105
 
1106 1106
 		// Default show only subtotal instead of itemization.
1107
-		if ( ! apply_filters( 'wc_stripe_payment_request_hide_itemization', true ) ) {
1108
-			foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
1107
+		if ( ! apply_filters('wc_stripe_payment_request_hide_itemization', true)) {
1108
+			foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
1109 1109
 				$amount         = $cart_item['line_subtotal'];
1110 1110
 				$subtotal      += $cart_item['line_subtotal'];
1111 1111
 				$quantity_label = 1 < $cart_item['quantity'] ? ' (x' . $cart_item['quantity'] . ')' : '';
1112 1112
 
1113
-				$product_name = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $cart_item['data']->post->post_title : $cart_item['data']->get_name();
1113
+				$product_name = WC_Stripe_Helper::is_wc_lt('3.0') ? $cart_item['data']->post->post_title : $cart_item['data']->get_name();
1114 1114
 
1115 1115
 				$item = array(
1116 1116
 					'label'  => $product_name . $quantity_label,
1117
-					'amount' => WC_Stripe_Helper::get_stripe_amount( $amount ),
1117
+					'amount' => WC_Stripe_Helper::get_stripe_amount($amount),
1118 1118
 				);
1119 1119
 
1120 1120
 				$items[] = $item;
1121 1121
 			}
1122 1122
 		}
1123 1123
 
1124
-		if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
1125
-			$discounts = wc_format_decimal( WC()->cart->get_cart_discount_total(), WC()->cart->dp );
1124
+		if (version_compare(WC_VERSION, '3.2', '<')) {
1125
+			$discounts = wc_format_decimal(WC()->cart->get_cart_discount_total(), WC()->cart->dp);
1126 1126
 		} else {
1127
-			$applied_coupons = array_values( WC()->cart->get_coupon_discount_totals() );
1127
+			$applied_coupons = array_values(WC()->cart->get_coupon_discount_totals());
1128 1128
 
1129
-			foreach ( $applied_coupons as $amount ) {
1129
+			foreach ($applied_coupons as $amount) {
1130 1130
 				$discounts += (float) $amount;
1131 1131
 			}
1132 1132
 		}
1133 1133
 
1134
-		$discounts   = wc_format_decimal( $discounts, WC()->cart->dp );
1135
-		$tax         = wc_format_decimal( WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp );
1136
-		$shipping    = wc_format_decimal( WC()->cart->shipping_total, WC()->cart->dp );
1137
-		$items_total = wc_format_decimal( WC()->cart->cart_contents_total, WC()->cart->dp ) + $discounts;
1138
-		$order_total = version_compare( WC_VERSION, '3.2', '<' ) ? wc_format_decimal( $items_total + $tax + $shipping - $discounts, WC()->cart->dp ) : WC()->cart->get_total( false );
1134
+		$discounts   = wc_format_decimal($discounts, WC()->cart->dp);
1135
+		$tax         = wc_format_decimal(WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp);
1136
+		$shipping    = wc_format_decimal(WC()->cart->shipping_total, WC()->cart->dp);
1137
+		$items_total = wc_format_decimal(WC()->cart->cart_contents_total, WC()->cart->dp) + $discounts;
1138
+		$order_total = version_compare(WC_VERSION, '3.2', '<') ? wc_format_decimal($items_total + $tax + $shipping - $discounts, WC()->cart->dp) : WC()->cart->get_total(false);
1139 1139
 
1140
-		if ( wc_tax_enabled() ) {
1140
+		if (wc_tax_enabled()) {
1141 1141
 			$items[] = array(
1142
-				'label'  => esc_html( __( 'Tax', 'woocommerce-gateway-stripe' ) ),
1143
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $tax ),
1142
+				'label'  => esc_html(__('Tax', 'woocommerce-gateway-stripe')),
1143
+				'amount' => WC_Stripe_Helper::get_stripe_amount($tax),
1144 1144
 			);
1145 1145
 		}
1146 1146
 
1147
-		if ( WC()->cart->needs_shipping() ) {
1147
+		if (WC()->cart->needs_shipping()) {
1148 1148
 			$items[] = array(
1149
-				'label'  => esc_html( __( 'Shipping', 'woocommerce-gateway-stripe' ) ),
1150
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $shipping ),
1149
+				'label'  => esc_html(__('Shipping', 'woocommerce-gateway-stripe')),
1150
+				'amount' => WC_Stripe_Helper::get_stripe_amount($shipping),
1151 1151
 			);
1152 1152
 		}
1153 1153
 
1154
-		if ( WC()->cart->has_discount() ) {
1154
+		if (WC()->cart->has_discount()) {
1155 1155
 			$items[] = array(
1156
-				'label'  => esc_html( __( 'Discount', 'woocommerce-gateway-stripe' ) ),
1157
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $discounts ),
1156
+				'label'  => esc_html(__('Discount', 'woocommerce-gateway-stripe')),
1157
+				'amount' => WC_Stripe_Helper::get_stripe_amount($discounts),
1158 1158
 			);
1159 1159
 		}
1160 1160
 
1161
-		if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
1161
+		if (version_compare(WC_VERSION, '3.2', '<')) {
1162 1162
 			$cart_fees = WC()->cart->fees;
1163 1163
 		} else {
1164 1164
 			$cart_fees = WC()->cart->get_fees();
1165 1165
 		}
1166 1166
 
1167 1167
 		// Include fees and taxes as display items.
1168
-		foreach ( $cart_fees as $key => $fee ) {
1168
+		foreach ($cart_fees as $key => $fee) {
1169 1169
 			$items[] = array(
1170 1170
 				'label'  => $fee->name,
1171
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $fee->amount ),
1171
+				'amount' => WC_Stripe_Helper::get_stripe_amount($fee->amount),
1172 1172
 			);
1173 1173
 		}
1174 1174
 
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 			'displayItems' => $items,
1177 1177
 			'total'        => array(
1178 1178
 				'label'   => $this->total_label,
1179
-				'amount'  => max( 0, apply_filters( 'woocommerce_stripe_calculated_total', WC_Stripe_Helper::get_stripe_amount( $order_total ), $order_total, WC()->cart ) ),
1179
+				'amount'  => max(0, apply_filters('woocommerce_stripe_calculated_total', WC_Stripe_Helper::get_stripe_amount($order_total), $order_total, WC()->cart)),
1180 1180
 				'pending' => false,
1181 1181
 			),
1182 1182
 		);
Please login to merge, or discard this patch.
includes/class-wc-gateway-stripe.php 1 patch
Spacing   +269 added lines, -269 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	public function __construct() {
86 86
 		$this->retry_interval = 1;
87 87
 		$this->id             = 'stripe';
88
-		$this->method_title   = __( 'Stripe', 'woocommerce-gateway-stripe' );
88
+		$this->method_title   = __('Stripe', 'woocommerce-gateway-stripe');
89 89
 		/* translators: 1) link to Stripe register page 2) link to Stripe api keys page */
90
-		$this->method_description = sprintf( __( 'Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification. <a href="%1$s" target="_blank">Sign up</a> for a Stripe account, and <a href="%2$s" target="_blank">get your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), 'https://dashboard.stripe.com/register', 'https://dashboard.stripe.com/account/apikeys' );
90
+		$this->method_description = sprintf(__('Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification. <a href="%1$s" target="_blank">Sign up</a> for a Stripe account, and <a href="%2$s" target="_blank">get your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), 'https://dashboard.stripe.com/register', 'https://dashboard.stripe.com/account/apikeys');
91 91
 		$this->has_fields         = true;
92 92
 		$this->supports           = array(
93 93
 			'products',
@@ -114,35 +114,35 @@  discard block
 block discarded – undo
114 114
 		$this->init_settings();
115 115
 
116 116
 		// Get setting values.
117
-		$this->title                = $this->get_option( 'title' );
118
-		$this->description          = $this->get_option( 'description' );
119
-		$this->enabled              = $this->get_option( 'enabled' );
120
-		$this->testmode             = 'yes' === $this->get_option( 'testmode' );
121
-		$this->inline_cc_form       = 'yes' === $this->get_option( 'inline_cc_form' );
122
-		$this->capture              = 'yes' === $this->get_option( 'capture', 'yes' );
123
-		$this->statement_descriptor = WC_Stripe_Helper::clean_statement_descriptor( $this->get_option( 'statement_descriptor' ) );
124
-		$this->saved_cards          = 'yes' === $this->get_option( 'saved_cards' );
125
-		$this->secret_key           = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
126
-		$this->publishable_key      = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' );
127
-		$this->payment_request      = 'yes' === $this->get_option( 'payment_request', 'yes' );
128
-
129
-		WC_Stripe_API::set_secret_key( $this->secret_key );
117
+		$this->title                = $this->get_option('title');
118
+		$this->description          = $this->get_option('description');
119
+		$this->enabled              = $this->get_option('enabled');
120
+		$this->testmode             = 'yes' === $this->get_option('testmode');
121
+		$this->inline_cc_form       = 'yes' === $this->get_option('inline_cc_form');
122
+		$this->capture              = 'yes' === $this->get_option('capture', 'yes');
123
+		$this->statement_descriptor = WC_Stripe_Helper::clean_statement_descriptor($this->get_option('statement_descriptor'));
124
+		$this->saved_cards          = 'yes' === $this->get_option('saved_cards');
125
+		$this->secret_key           = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
126
+		$this->publishable_key      = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key');
127
+		$this->payment_request      = 'yes' === $this->get_option('payment_request', 'yes');
128
+
129
+		WC_Stripe_API::set_secret_key($this->secret_key);
130 130
 
131 131
 		// Hooks.
132
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
133
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
134
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
135
-		add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_fee' ) );
136
-		add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_payout' ), 20 );
137
-		add_action( 'woocommerce_customer_save_address', array( $this, 'show_update_card_notice' ), 10, 2 );
138
-		add_filter( 'woocommerce_available_payment_gateways', array( $this, 'prepare_order_pay_page' ) );
139
-		add_action( 'woocommerce_account_view-order_endpoint', array( $this, 'check_intent_status_on_order_page' ), 1 );
140
-		add_filter( 'woocommerce_payment_successful_result', array( $this, 'modify_successful_payment_result' ), 99999, 2 );
141
-
142
-		if ( WC_Stripe_Helper::is_pre_orders_exists() ) {
132
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
133
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'));
134
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
135
+		add_action('woocommerce_admin_order_totals_after_total', array($this, 'display_order_fee'));
136
+		add_action('woocommerce_admin_order_totals_after_total', array($this, 'display_order_payout'), 20);
137
+		add_action('woocommerce_customer_save_address', array($this, 'show_update_card_notice'), 10, 2);
138
+		add_filter('woocommerce_available_payment_gateways', array($this, 'prepare_order_pay_page'));
139
+		add_action('woocommerce_account_view-order_endpoint', array($this, 'check_intent_status_on_order_page'), 1);
140
+		add_filter('woocommerce_payment_successful_result', array($this, 'modify_successful_payment_result'), 99999, 2);
141
+
142
+		if (WC_Stripe_Helper::is_pre_orders_exists()) {
143 143
 			$this->pre_orders = new WC_Stripe_Pre_Orders_Compat();
144 144
 
145
-			add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this->pre_orders, 'process_pre_order_release_payment' ) );
145
+			add_action('wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array($this->pre_orders, 'process_pre_order_release_payment'));
146 146
 		}
147 147
 	}
148 148
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @return bool
154 154
 	 */
155 155
 	public function are_keys_set() {
156
-		if ( empty( $this->secret_key ) || empty( $this->publishable_key ) ) {
156
+		if (empty($this->secret_key) || empty($this->publishable_key)) {
157 157
 			return false;
158 158
 		}
159 159
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @since 4.0.2
167 167
 	 */
168 168
 	public function is_available() {
169
-		if ( is_add_payment_method_page() && ! $this->saved_cards ) {
169
+		if (is_add_payment_method_page() && ! $this->saved_cards) {
170 170
 			return false;
171 171
 		}
172 172
 
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
 	 * @param int    $user_id      The ID of the current user.
181 181
 	 * @param string $load_address The address to load.
182 182
 	 */
183
-	public function show_update_card_notice( $user_id, $load_address ) {
184
-		if ( ! $this->saved_cards || ! WC_Stripe_Payment_Tokens::customer_has_saved_methods( $user_id ) || 'billing' !== $load_address ) {
183
+	public function show_update_card_notice($user_id, $load_address) {
184
+		if ( ! $this->saved_cards || ! WC_Stripe_Payment_Tokens::customer_has_saved_methods($user_id) || 'billing' !== $load_address) {
185 185
 			return;
186 186
 		}
187 187
 
188 188
 		/* translators: 1) Opening anchor tag 2) closing anchor tag */
189
-		wc_add_notice( sprintf( __( 'If your billing address has been changed for saved payment methods, be sure to remove any %1$ssaved payment methods%2$s on file and re-add them.', 'woocommerce-gateway-stripe' ), '<a href="' . esc_url( wc_get_endpoint_url( 'payment-methods' ) ) . '" class="wc-stripe-update-card-notice" style="text-decoration:underline;">', '</a>' ), 'notice' );
189
+		wc_add_notice(sprintf(__('If your billing address has been changed for saved payment methods, be sure to remove any %1$ssaved payment methods%2$s on file and re-add them.', 'woocommerce-gateway-stripe'), '<a href="' . esc_url(wc_get_endpoint_url('payment-methods')) . '" class="wc-stripe-update-card-notice" style="text-decoration:underline;">', '</a>'), 'notice');
190 190
 	}
191 191
 
192 192
 	/**
@@ -201,31 +201,31 @@  discard block
 block discarded – undo
201 201
 
202 202
 		$icons_str = '';
203 203
 
204
-		$icons_str .= isset( $icons['visa'] ) ? $icons['visa'] : '';
205
-		$icons_str .= isset( $icons['amex'] ) ? $icons['amex'] : '';
206
-		$icons_str .= isset( $icons['mastercard'] ) ? $icons['mastercard'] : '';
204
+		$icons_str .= isset($icons['visa']) ? $icons['visa'] : '';
205
+		$icons_str .= isset($icons['amex']) ? $icons['amex'] : '';
206
+		$icons_str .= isset($icons['mastercard']) ? $icons['mastercard'] : '';
207 207
 
208
-		if ( 'USD' === get_woocommerce_currency() ) {
209
-			$icons_str .= isset( $icons['discover'] ) ? $icons['discover'] : '';
210
-			$icons_str .= isset( $icons['jcb'] ) ? $icons['jcb'] : '';
211
-			$icons_str .= isset( $icons['diners'] ) ? $icons['diners'] : '';
208
+		if ('USD' === get_woocommerce_currency()) {
209
+			$icons_str .= isset($icons['discover']) ? $icons['discover'] : '';
210
+			$icons_str .= isset($icons['jcb']) ? $icons['jcb'] : '';
211
+			$icons_str .= isset($icons['diners']) ? $icons['diners'] : '';
212 212
 		}
213 213
 
214
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
214
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
215 215
 	}
216 216
 
217 217
 	/**
218 218
 	 * Initialise Gateway Settings Form Fields
219 219
 	 */
220 220
 	public function init_form_fields() {
221
-		$this->form_fields = require( dirname( __FILE__ ) . '/admin/stripe-settings.php' );
221
+		$this->form_fields = require(dirname(__FILE__) . '/admin/stripe-settings.php');
222 222
 
223
-		if ( 'yes' === $this->get_option( 'three_d_secure' ) ) {
224
-			if ( isset( $_REQUEST['stripe_dismiss_3ds'] ) && wp_verify_nonce( $_REQUEST['stripe_dismiss_3ds'], 'no-3ds' ) ) { // wpcs: sanitization ok.
225
-				$this->update_option( '3ds_setting_notice_dismissed', true );
223
+		if ('yes' === $this->get_option('three_d_secure')) {
224
+			if (isset($_REQUEST['stripe_dismiss_3ds']) && wp_verify_nonce($_REQUEST['stripe_dismiss_3ds'], 'no-3ds')) { // wpcs: sanitization ok.
225
+				$this->update_option('3ds_setting_notice_dismissed', true);
226 226
 			}
227 227
 
228
-			add_action( 'admin_notices', array( $this, 'display_three_d_secure_notice' ) );
228
+			add_action('admin_notices', array($this, 'display_three_d_secure_notice'));
229 229
 		}
230 230
 	}
231 231
 
@@ -234,34 +234,34 @@  discard block
 block discarded – undo
234 234
 	 */
235 235
 	public function payment_fields() {
236 236
 		$user                 = wp_get_current_user();
237
-		$display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards;
237
+		$display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards;
238 238
 		$total                = WC()->cart->total;
239 239
 		$user_email           = '';
240 240
 		$description          = $this->get_description();
241
-		$description          = ! empty( $description ) ? $description : '';
241
+		$description          = ! empty($description) ? $description : '';
242 242
 		$firstname            = '';
243 243
 		$lastname             = '';
244 244
 
245 245
 		// If paying from order, we need to get total from order not cart.
246
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { // wpcs: csrf ok.
247
-			$order      = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); // wpcs: csrf ok, sanitization ok.
246
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { // wpcs: csrf ok.
247
+			$order      = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); // wpcs: csrf ok, sanitization ok.
248 248
 			$total      = $order->get_total();
249
-			$user_email = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_email : $order->get_billing_email();
249
+			$user_email = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_email : $order->get_billing_email();
250 250
 		} else {
251
-			if ( $user->ID ) {
252
-				$user_email = get_user_meta( $user->ID, 'billing_email', true );
251
+			if ($user->ID) {
252
+				$user_email = get_user_meta($user->ID, 'billing_email', true);
253 253
 				$user_email = $user_email ? $user_email : $user->user_email;
254 254
 			}
255 255
 		}
256 256
 
257
-		if ( is_add_payment_method_page() ) {
258
-			$pay_button_text = __( 'Add Card', 'woocommerce-gateway-stripe' );
257
+		if (is_add_payment_method_page()) {
258
+			$pay_button_text = __('Add Card', 'woocommerce-gateway-stripe');
259 259
 			$total           = '';
260 260
 			$firstname       = $user->user_firstname;
261 261
 			$lastname        = $user->user_lastname;
262 262
 
263
-		} elseif ( function_exists( 'wcs_order_contains_subscription' ) && isset( $_GET['change_payment_method'] ) ) { // wpcs: csrf ok.
264
-			$pay_button_text = __( 'Change Payment Method', 'woocommerce-gateway-stripe' );
263
+		} elseif (function_exists('wcs_order_contains_subscription') && isset($_GET['change_payment_method'])) { // wpcs: csrf ok.
264
+			$pay_button_text = __('Change Payment Method', 'woocommerce-gateway-stripe');
265 265
 			$total           = '';
266 266
 		} else {
267 267
 			$pay_button_text = '';
@@ -271,37 +271,37 @@  discard block
 block discarded – undo
271 271
 
272 272
 		echo '<div
273 273
 			id="stripe-payment-data"
274
-			data-panel-label="' . esc_attr( $pay_button_text ) . '"
275
-			data-email="' . esc_attr( $user_email ) . '"
276
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
277
-			data-name="' . esc_attr( $this->statement_descriptor ) . '"
278
-			data-full-name="' . esc_attr( $firstname . ' ' . $lastname ) . '"
279
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '"
280
-			data-allow-remember-me="' . esc_attr( apply_filters( 'wc_stripe_allow_remember_me', true ) ? 'true' : 'false' ) . '"
274
+			data-panel-label="' . esc_attr($pay_button_text) . '"
275
+			data-email="' . esc_attr($user_email) . '"
276
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
277
+			data-name="' . esc_attr($this->statement_descriptor) . '"
278
+			data-full-name="' . esc_attr($firstname . ' ' . $lastname) . '"
279
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '"
280
+			data-allow-remember-me="' . esc_attr(apply_filters('wc_stripe_allow_remember_me', true) ? 'true' : 'false') . '"
281 281
 		>';
282 282
 
283
-		if ( $this->testmode ) {
283
+		if ($this->testmode) {
284 284
 			/* translators: link to Stripe testing page */
285
-			$description .= ' ' . sprintf( __( 'TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the <a href="%s" target="_blank">Testing Stripe documentation</a> for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' );
285
+			$description .= ' ' . sprintf(__('TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the <a href="%s" target="_blank">Testing Stripe documentation</a> for more card numbers.', 'woocommerce-gateway-stripe'), 'https://stripe.com/docs/testing');
286 286
 		}
287 287
 
288
-		$description = trim( $description );
288
+		$description = trim($description);
289 289
 
290
-		echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id ); // wpcs: xss ok.
290
+		echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id); // wpcs: xss ok.
291 291
 
292
-		if ( $display_tokenization ) {
292
+		if ($display_tokenization) {
293 293
 			$this->tokenization_script();
294 294
 			$this->saved_payment_methods();
295 295
 		}
296 296
 
297 297
 		$this->elements_form();
298 298
 
299
-		if ( apply_filters( 'wc_stripe_display_save_payment_method_checkbox', $display_tokenization ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) { // wpcs: csrf ok.
299
+		if (apply_filters('wc_stripe_display_save_payment_method_checkbox', $display_tokenization) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) { // wpcs: csrf ok.
300 300
 
301 301
 			$this->save_payment_method_checkbox();
302 302
 		}
303 303
 
304
-		do_action( 'wc_stripe_cards_payment_fields', $this->id );
304
+		do_action('wc_stripe_cards_payment_fields', $this->id);
305 305
 
306 306
 		echo '</div>';
307 307
 
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
 	 */
317 317
 	public function elements_form() {
318 318
 		?>
319
-		<fieldset id="wc-<?php echo esc_attr( $this->id ); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
320
-			<?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?>
319
+		<fieldset id="wc-<?php echo esc_attr($this->id); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
320
+			<?php do_action('woocommerce_credit_card_form_start', $this->id); ?>
321 321
 
322
-			<?php if ( $this->inline_cc_form ) { ?>
322
+			<?php if ($this->inline_cc_form) { ?>
323 323
 				<label for="card-element">
324
-					<?php esc_html_e( 'Credit or debit card', 'woocommerce-gateway-stripe' ); ?>
324
+					<?php esc_html_e('Credit or debit card', 'woocommerce-gateway-stripe'); ?>
325 325
 				</label>
326 326
 
327 327
 				<div id="stripe-card-element" class="wc-stripe-elements-field">
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 				</div>
330 330
 			<?php } else { ?>
331 331
 				<div class="form-row form-row-wide">
332
-					<label for="stripe-card-element"><?php esc_html_e( 'Card Number', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
332
+					<label for="stripe-card-element"><?php esc_html_e('Card Number', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
333 333
 					<div class="stripe-card-group">
334 334
 						<div id="stripe-card-element" class="wc-stripe-elements-field">
335 335
 						<!-- a Stripe Element will be inserted here. -->
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 				</div>
341 341
 
342 342
 				<div class="form-row form-row-first">
343
-					<label for="stripe-exp-element"><?php esc_html_e( 'Expiry Date', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
343
+					<label for="stripe-exp-element"><?php esc_html_e('Expiry Date', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
344 344
 
345 345
 					<div id="stripe-exp-element" class="wc-stripe-elements-field">
346 346
 					<!-- a Stripe Element will be inserted here. -->
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 				</div>
349 349
 
350 350
 				<div class="form-row form-row-last">
351
-					<label for="stripe-cvc-element"><?php esc_html_e( 'Card Code (CVC)', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
351
+					<label for="stripe-cvc-element"><?php esc_html_e('Card Code (CVC)', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
352 352
 				<div id="stripe-cvc-element" class="wc-stripe-elements-field">
353 353
 				<!-- a Stripe Element will be inserted here. -->
354 354
 				</div>
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 			<!-- Used to display form errors -->
360 360
 			<div class="stripe-source-errors" role="alert"></div>
361 361
 			<br />
362
-			<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
362
+			<?php do_action('woocommerce_credit_card_form_end', $this->id); ?>
363 363
 			<div class="clear"></div>
364 364
 		</fieldset>
365 365
 		<?php
@@ -372,13 +372,13 @@  discard block
 block discarded – undo
372 372
 	 * @version 3.1.0
373 373
 	 */
374 374
 	public function admin_scripts() {
375
-		if ( 'woocommerce_page_wc-settings' !== get_current_screen()->id ) {
375
+		if ('woocommerce_page_wc-settings' !== get_current_screen()->id) {
376 376
 			return;
377 377
 		}
378 378
 
379
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
379
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
380 380
 
381
-		wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true );
381
+		wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true);
382 382
 	}
383 383
 
384 384
 	/**
@@ -390,97 +390,97 @@  discard block
 block discarded – undo
390 390
 	 * @version 4.0.0
391 391
 	 */
392 392
 	public function payment_scripts() {
393
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) { // wpcs: csrf ok.
393
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) { // wpcs: csrf ok.
394 394
 			return;
395 395
 		}
396 396
 
397 397
 		// If Stripe is not enabled bail.
398
-		if ( 'no' === $this->enabled ) {
398
+		if ('no' === $this->enabled) {
399 399
 			return;
400 400
 		}
401 401
 
402 402
 		// If keys are not set bail.
403
-		if ( ! $this->are_keys_set() ) {
404
-			WC_Stripe_Logger::log( 'Keys are not set correctly.' );
403
+		if ( ! $this->are_keys_set()) {
404
+			WC_Stripe_Logger::log('Keys are not set correctly.');
405 405
 			return;
406 406
 		}
407 407
 
408 408
 		// If no SSL bail.
409
-		if ( ! $this->testmode && ! is_ssl() ) {
410
-			WC_Stripe_Logger::log( 'Stripe live mode requires SSL.' );
409
+		if ( ! $this->testmode && ! is_ssl()) {
410
+			WC_Stripe_Logger::log('Stripe live mode requires SSL.');
411 411
 			return;
412 412
 		}
413 413
 
414 414
 		$current_theme = wp_get_theme();
415 415
 
416
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
416
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
417 417
 
418
-		wp_register_style( 'stripe_styles', plugins_url( 'assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION );
419
-		wp_enqueue_style( 'stripe_styles' );
418
+		wp_register_style('stripe_styles', plugins_url('assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION);
419
+		wp_enqueue_style('stripe_styles');
420 420
 
421
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
422
-		wp_register_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripe' ), WC_STRIPE_VERSION, true );
421
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
422
+		wp_register_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripe'), WC_STRIPE_VERSION, true);
423 423
 
424 424
 		$stripe_params = array(
425 425
 			'key'                  => $this->publishable_key,
426
-			'i18n_terms'           => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ),
427
-			'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ),
426
+			'i18n_terms'           => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'),
427
+			'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'),
428 428
 		);
429 429
 
430 430
 		// If we're on the pay page we need to pass stripe.js the address of the order.
431
-		if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) { // wpcs: csrf ok.
432
-			$order_id = wc_get_order_id_by_order_key( urldecode( $_GET['key'] ) ); // wpcs: csrf ok, sanitization ok, xss ok.
433
-			$order    = wc_get_order( $order_id );
434
-
435
-			if ( is_a( $order, 'WC_Order' ) ) {
436
-				$stripe_params['billing_first_name'] = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_first_name : $order->get_billing_first_name();
437
-				$stripe_params['billing_last_name']  = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_last_name : $order->get_billing_last_name();
438
-				$stripe_params['billing_address_1']  = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_address_1 : $order->get_billing_address_1();
439
-				$stripe_params['billing_address_2']  = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_address_2 : $order->get_billing_address_2();
440
-				$stripe_params['billing_state']      = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_state : $order->get_billing_state();
441
-				$stripe_params['billing_city']       = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_city : $order->get_billing_city();
442
-				$stripe_params['billing_postcode']   = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_postcode : $order->get_billing_postcode();
443
-				$stripe_params['billing_country']    = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_country : $order->get_billing_country();
431
+		if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) { // wpcs: csrf ok.
432
+			$order_id = wc_get_order_id_by_order_key(urldecode($_GET['key'])); // wpcs: csrf ok, sanitization ok, xss ok.
433
+			$order    = wc_get_order($order_id);
434
+
435
+			if (is_a($order, 'WC_Order')) {
436
+				$stripe_params['billing_first_name'] = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_first_name : $order->get_billing_first_name();
437
+				$stripe_params['billing_last_name']  = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_last_name : $order->get_billing_last_name();
438
+				$stripe_params['billing_address_1']  = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_address_1 : $order->get_billing_address_1();
439
+				$stripe_params['billing_address_2']  = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_address_2 : $order->get_billing_address_2();
440
+				$stripe_params['billing_state']      = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_state : $order->get_billing_state();
441
+				$stripe_params['billing_city']       = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_city : $order->get_billing_city();
442
+				$stripe_params['billing_postcode']   = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_postcode : $order->get_billing_postcode();
443
+				$stripe_params['billing_country']    = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_country : $order->get_billing_country();
444 444
 			}
445 445
 		}
446 446
 
447 447
 		$sepa_elements_options = apply_filters(
448 448
 			'wc_stripe_sepa_elements_options',
449 449
 			array(
450
-				'supportedCountries' => array( 'SEPA' ),
450
+				'supportedCountries' => array('SEPA'),
451 451
 				'placeholderCountry' => WC()->countries->get_base_country(),
452
-				'style'              => array( 'base' => array( 'fontSize' => '15px' ) ),
452
+				'style'              => array('base' => array('fontSize' => '15px')),
453 453
 			)
454 454
 		);
455 455
 
456
-		$stripe_params['no_prepaid_card_msg']       = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
457
-		$stripe_params['no_sepa_owner_msg']         = __( 'Please enter your IBAN account name.', 'woocommerce-gateway-stripe' );
458
-		$stripe_params['no_sepa_iban_msg']          = __( 'Please enter your IBAN account number.', 'woocommerce-gateway-stripe' );
459
-		$stripe_params['payment_intent_error']      = __( 'We couldn\'t initiate the payment. Please try again.', 'woocommerce-gateway-stripe' );
460
-		$stripe_params['sepa_mandate_notification'] = apply_filters( 'wc_stripe_sepa_mandate_notification', 'email' );
461
-		$stripe_params['allow_prepaid_card']        = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no';
456
+		$stripe_params['no_prepaid_card_msg']       = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
457
+		$stripe_params['no_sepa_owner_msg']         = __('Please enter your IBAN account name.', 'woocommerce-gateway-stripe');
458
+		$stripe_params['no_sepa_iban_msg']          = __('Please enter your IBAN account number.', 'woocommerce-gateway-stripe');
459
+		$stripe_params['payment_intent_error']      = __('We couldn\'t initiate the payment. Please try again.', 'woocommerce-gateway-stripe');
460
+		$stripe_params['sepa_mandate_notification'] = apply_filters('wc_stripe_sepa_mandate_notification', 'email');
461
+		$stripe_params['allow_prepaid_card']        = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no';
462 462
 		$stripe_params['inline_cc_form']            = $this->inline_cc_form ? 'yes' : 'no';
463
-		$stripe_params['is_checkout']               = ( is_checkout() && empty( $_GET['pay_for_order'] ) ) ? 'yes' : 'no'; // wpcs: csrf ok.
463
+		$stripe_params['is_checkout']               = (is_checkout() && empty($_GET['pay_for_order'])) ? 'yes' : 'no'; // wpcs: csrf ok.
464 464
 		$stripe_params['return_url']                = $this->get_stripe_return_url();
465
-		$stripe_params['ajaxurl']                   = WC_AJAX::get_endpoint( '%%endpoint%%' );
466
-		$stripe_params['stripe_nonce']              = wp_create_nonce( '_wc_stripe_nonce' );
465
+		$stripe_params['ajaxurl']                   = WC_AJAX::get_endpoint('%%endpoint%%');
466
+		$stripe_params['stripe_nonce']              = wp_create_nonce('_wc_stripe_nonce');
467 467
 		$stripe_params['statement_descriptor']      = $this->statement_descriptor;
468
-		$stripe_params['elements_options']          = apply_filters( 'wc_stripe_elements_options', array() );
468
+		$stripe_params['elements_options']          = apply_filters('wc_stripe_elements_options', array());
469 469
 		$stripe_params['sepa_elements_options']     = $sepa_elements_options;
470
-		$stripe_params['invalid_owner_name']        = __( 'Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe' );
471
-		$stripe_params['is_change_payment_page']    = isset( $_GET['change_payment_method'] ) ? 'yes' : 'no'; // wpcs: csrf ok.
472
-		$stripe_params['is_add_payment_page']       = is_wc_endpoint_url( 'add-payment-method' ) ? 'yes' : 'no';
473
-		$stripe_params['is_pay_for_order_page']     = is_wc_endpoint_url( 'order-pay' ) ? 'yes' : 'no';
474
-		$stripe_params['elements_styling']          = apply_filters( 'wc_stripe_elements_styling', false );
475
-		$stripe_params['elements_classes']          = apply_filters( 'wc_stripe_elements_classes', false );
470
+		$stripe_params['invalid_owner_name']        = __('Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe');
471
+		$stripe_params['is_change_payment_page']    = isset($_GET['change_payment_method']) ? 'yes' : 'no'; // wpcs: csrf ok.
472
+		$stripe_params['is_add_payment_page']       = is_wc_endpoint_url('add-payment-method') ? 'yes' : 'no';
473
+		$stripe_params['is_pay_for_order_page']     = is_wc_endpoint_url('order-pay') ? 'yes' : 'no';
474
+		$stripe_params['elements_styling']          = apply_filters('wc_stripe_elements_styling', false);
475
+		$stripe_params['elements_classes']          = apply_filters('wc_stripe_elements_classes', false);
476 476
 
477 477
 		// Merge localized messages to be use in JS.
478
-		$stripe_params = array_merge( $stripe_params, WC_Stripe_Helper::get_localized_messages() );
478
+		$stripe_params = array_merge($stripe_params, WC_Stripe_Helper::get_localized_messages());
479 479
 
480
-		wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
480
+		wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
481 481
 
482 482
 		$this->tokenization_script();
483
-		wp_enqueue_script( 'woocommerce_stripe' );
483
+		wp_enqueue_script('woocommerce_stripe');
484 484
 	}
485 485
 
486 486
 	/**
@@ -489,14 +489,14 @@  discard block
 block discarded – undo
489 489
 	 * @since 4.2.0
490 490
 	 * @param WC_Order $order The order that is being created.
491 491
 	 */
492
-	public function maybe_create_customer( $order ) {
492
+	public function maybe_create_customer($order) {
493 493
 		// This comes from the create account checkbox in the checkout page.
494
-		if ( empty( $_POST['createaccount'] ) ) { // wpcs: csrf ok.
494
+		if (empty($_POST['createaccount'])) { // wpcs: csrf ok.
495 495
 			return;
496 496
 		}
497 497
 
498
-		$new_customer_id     = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id();
499
-		$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
498
+		$new_customer_id     = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id();
499
+		$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
500 500
 		$new_stripe_customer->create_customer();
501 501
 	}
502 502
 
@@ -508,14 +508,14 @@  discard block
 block discarded – undo
508 508
 	 * @param object $prepared_source The object with source details.
509 509
 	 * @throws WC_Stripe_Exception An exception if the card is prepaid, but prepaid cards are not allowed.
510 510
 	 */
511
-	public function maybe_disallow_prepaid_card( $prepared_source ) {
511
+	public function maybe_disallow_prepaid_card($prepared_source) {
512 512
 		// Check if we don't allow prepaid credit cards.
513
-		if ( apply_filters( 'wc_stripe_allow_prepaid_card', true ) || ! $this->is_prepaid_card( $prepared_source->source_object ) ) {
513
+		if (apply_filters('wc_stripe_allow_prepaid_card', true) || ! $this->is_prepaid_card($prepared_source->source_object)) {
514 514
 			return;
515 515
 		}
516 516
 
517
-		$localized_message = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
518
-		throw new WC_Stripe_Exception( print_r( $prepared_source->source_object, true ), $localized_message );
517
+		$localized_message = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
518
+		throw new WC_Stripe_Exception(print_r($prepared_source->source_object, true), $localized_message);
519 519
 	}
520 520
 
521 521
 	/**
@@ -525,10 +525,10 @@  discard block
 block discarded – undo
525 525
 	 * @param  object $prepared_source The source that should be verified.
526 526
 	 * @throws WC_Stripe_Exception     An exception if the source ID is missing.
527 527
 	 */
528
-	public function check_source( $prepared_source ) {
529
-		if ( empty( $prepared_source->source ) ) {
530
-			$localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
531
-			throw new WC_Stripe_Exception( print_r( $prepared_source, true ), $localized_message );
528
+	public function check_source($prepared_source) {
529
+		if (empty($prepared_source->source)) {
530
+			$localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
531
+			throw new WC_Stripe_Exception(print_r($prepared_source, true), $localized_message);
532 532
 		}
533 533
 	}
534 534
 
@@ -540,17 +540,17 @@  discard block
 block discarded – undo
540 540
 	 * @param WC_Order $order The order those payment is being processed.
541 541
 	 * @return bool           A flag that indicates that the customer does not exist and should be removed.
542 542
 	 */
543
-	public function maybe_remove_non_existent_customer( $error, $order ) {
544
-		if ( ! $this->is_no_such_customer_error( $error ) ) {
543
+	public function maybe_remove_non_existent_customer($error, $order) {
544
+		if ( ! $this->is_no_such_customer_error($error)) {
545 545
 			return false;
546 546
 		}
547 547
 
548
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
549
-			delete_user_meta( $order->customer_user, '_stripe_customer_id' );
550
-			delete_post_meta( $order->get_id(), '_stripe_customer_id' );
548
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
549
+			delete_user_meta($order->customer_user, '_stripe_customer_id');
550
+			delete_post_meta($order->get_id(), '_stripe_customer_id');
551 551
 		} else {
552
-			delete_user_meta( $order->get_customer_id(), '_stripe_customer_id' );
553
-			$order->delete_meta_data( '_stripe_customer_id' );
552
+			delete_user_meta($order->get_customer_id(), '_stripe_customer_id');
553
+			$order->delete_meta_data('_stripe_customer_id');
554 554
 			$order->save();
555 555
 		}
556 556
 
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 	 * @param WC_Order $order The order to complete.
565 565
 	 * @return array          Redirection data for `process_payment`.
566 566
 	 */
567
-	public function complete_free_order( $order ) {
567
+	public function complete_free_order($order) {
568 568
 		$order->payment_complete();
569 569
 
570 570
 		// Remove cart.
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 		// Return thank you page redirect.
574 574
 		return array(
575 575
 			'result'   => 'success',
576
-			'redirect' => $this->get_return_url( $order ),
576
+			'redirect' => $this->get_return_url($order),
577 577
 		);
578 578
 	}
579 579
 
@@ -590,60 +590,60 @@  discard block
 block discarded – undo
590 590
 	 * @throws Exception If payment will not be accepted.
591 591
 	 * @return array|void
592 592
 	 */
593
-	public function process_payment( $order_id, $retry = true, $force_save_source = false, $previous_error = false ) {
593
+	public function process_payment($order_id, $retry = true, $force_save_source = false, $previous_error = false) {
594 594
 		try {
595
-			$order = wc_get_order( $order_id );
595
+			$order = wc_get_order($order_id);
596 596
 
597 597
 			// ToDo: `process_pre_order` saves the source to the order for a later payment.
598 598
 			// This might not work well with PaymentIntents.
599
-			if ( $this->maybe_process_pre_orders( $order_id ) ) {
600
-				return $this->pre_orders->process_pre_order( $order_id );
599
+			if ($this->maybe_process_pre_orders($order_id)) {
600
+				return $this->pre_orders->process_pre_order($order_id);
601 601
 			}
602 602
 
603
-			$this->maybe_create_customer( $order );
603
+			$this->maybe_create_customer($order);
604 604
 
605
-			$prepared_source = $this->prepare_source( get_current_user_id(), $force_save_source );
605
+			$prepared_source = $this->prepare_source(get_current_user_id(), $force_save_source);
606 606
 
607
-			$this->maybe_disallow_prepaid_card( $prepared_source );
608
-			$this->check_source( $prepared_source );
609
-			$this->save_source_to_order( $order, $prepared_source );
607
+			$this->maybe_disallow_prepaid_card($prepared_source);
608
+			$this->check_source($prepared_source);
609
+			$this->save_source_to_order($order, $prepared_source);
610 610
 
611
-			if ( 0 >= $order->get_total() ) {
612
-				return $this->complete_free_order( $order );
611
+			if (0 >= $order->get_total()) {
612
+				return $this->complete_free_order($order);
613 613
 			}
614 614
 
615 615
 			// This will throw exception if not valid.
616
-			$this->validate_minimum_order_amount( $order );
616
+			$this->validate_minimum_order_amount($order);
617 617
 
618
-			WC_Stripe_Logger::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
618
+			WC_Stripe_Logger::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}");
619 619
 
620
-			$intent = $this->get_intent_from_order( $order );
621
-			if ( $intent ) {
622
-				$intent = $this->update_existing_intent( $intent, $order, $prepared_source );
620
+			$intent = $this->get_intent_from_order($order);
621
+			if ($intent) {
622
+				$intent = $this->update_existing_intent($intent, $order, $prepared_source);
623 623
 			} else {
624
-				$intent   = $this->create_and_confirm_intent( $order, $prepared_source );
624
+				$intent   = $this->create_and_confirm_intent($order, $prepared_source);
625 625
 				$response = $intent;
626 626
 			}
627 627
 
628
-			if ( ! empty( $response->error ) ) {
629
-				$this->maybe_remove_non_existent_customer( $response->error, $order );
628
+			if ( ! empty($response->error)) {
629
+				$this->maybe_remove_non_existent_customer($response->error, $order);
630 630
 
631 631
 				// We want to retry.
632
-				if ( $this->is_retryable_error( $response->error ) ) {
633
-					return $this->retry_after_error( $response, $order, $retry, $force_save_source, $previous_error );
632
+				if ($this->is_retryable_error($response->error)) {
633
+					return $this->retry_after_error($response, $order, $retry, $force_save_source, $previous_error);
634 634
 				}
635 635
 
636
-				$this->throw_localized_message( $response, $order );
636
+				$this->throw_localized_message($response, $order);
637 637
 			}
638 638
 
639
-			if ( ! empty( $intent ) ) {
639
+			if ( ! empty($intent)) {
640 640
 				// Use the last charge within the intent to proceed.
641
-				$response = end( $intent->charges->data );
641
+				$response = end($intent->charges->data);
642 642
 
643 643
 				// If the intent requires a 3DS flow, redirect to it.
644
-				if ( 'requires_action' === $intent->status ) {
645
-					if ( is_wc_endpoint_url( 'order-pay' ) ) {
646
-						$redirect_url = add_query_arg( 'wc-stripe-confirmation', 1, $order->get_checkout_payment_url( false ) );
644
+				if ('requires_action' === $intent->status) {
645
+					if (is_wc_endpoint_url('order-pay')) {
646
+						$redirect_url = add_query_arg('wc-stripe-confirmation', 1, $order->get_checkout_payment_url(false));
647 647
 
648 648
 						return array(
649 649
 							'result'   => 'success',
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 
659 659
 						return array(
660 660
 							'result'           => 'success',
661
-							'redirect'         => $this->get_return_url( $order ),
661
+							'redirect'         => $this->get_return_url($order),
662 662
 							'intent_secret'    => $intent->client_secret,
663 663
 						);
664 664
 					}
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 			}
667 667
 
668 668
 			// Process valid response.
669
-			$this->process_response( $response, $order );
669
+			$this->process_response($response, $order);
670 670
 
671 671
 			// Remove cart.
672 672
 			WC()->cart->empty_cart();
@@ -674,17 +674,17 @@  discard block
 block discarded – undo
674 674
 			// Return thank you page redirect.
675 675
 			return array(
676 676
 				'result'   => 'success',
677
-				'redirect' => $this->get_return_url( $order ),
677
+				'redirect' => $this->get_return_url($order),
678 678
 			);
679 679
 
680
-		} catch ( WC_Stripe_Exception $e ) {
681
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
682
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
680
+		} catch (WC_Stripe_Exception $e) {
681
+			wc_add_notice($e->getLocalizedMessage(), 'error');
682
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
683 683
 
684
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
684
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
685 685
 
686 686
 			/* translators: error message */
687
-			$order->update_status( 'failed' );
687
+			$order->update_status('failed');
688 688
 
689 689
 			return array(
690 690
 				'result'   => 'fail',
@@ -700,17 +700,17 @@  discard block
 block discarded – undo
700 700
 	 *
701 701
 	 * @param int $order_id The ID of the order.
702 702
 	 */
703
-	public function display_order_fee( $order_id ) {
704
-		if ( apply_filters( 'wc_stripe_hide_display_order_fee', false, $order_id ) ) {
703
+	public function display_order_fee($order_id) {
704
+		if (apply_filters('wc_stripe_hide_display_order_fee', false, $order_id)) {
705 705
 			return;
706 706
 		}
707 707
 
708
-		$order = wc_get_order( $order_id );
708
+		$order = wc_get_order($order_id);
709 709
 
710
-		$fee      = WC_Stripe_Helper::get_stripe_fee( $order );
711
-		$currency = WC_Stripe_Helper::get_stripe_currency( $order );
710
+		$fee      = WC_Stripe_Helper::get_stripe_fee($order);
711
+		$currency = WC_Stripe_Helper::get_stripe_currency($order);
712 712
 
713
-		if ( ! $fee || ! $currency ) {
713
+		if ( ! $fee || ! $currency) {
714 714
 			return;
715 715
 		}
716 716
 
@@ -718,12 +718,12 @@  discard block
 block discarded – undo
718 718
 
719 719
 		<tr>
720 720
 			<td class="label stripe-fee">
721
-				<?php echo wc_help_tip( __( 'This represents the fee Stripe collects for the transaction.', 'woocommerce-gateway-stripe' ) ); // wpcs: xss ok. ?>
722
-				<?php esc_html_e( 'Stripe Fee:', 'woocommerce-gateway-stripe' ); ?>
721
+				<?php echo wc_help_tip(__('This represents the fee Stripe collects for the transaction.', 'woocommerce-gateway-stripe')); // wpcs: xss ok. ?>
722
+				<?php esc_html_e('Stripe Fee:', 'woocommerce-gateway-stripe'); ?>
723 723
 			</td>
724 724
 			<td width="1%"></td>
725 725
 			<td class="total">
726
-				-&nbsp;<?php echo wc_price( $fee, array( 'currency' => $currency ) ); // wpcs: xss ok. ?>
726
+				-&nbsp;<?php echo wc_price($fee, array('currency' => $currency)); // wpcs: xss ok. ?>
727 727
 			</td>
728 728
 		</tr>
729 729
 
@@ -737,17 +737,17 @@  discard block
 block discarded – undo
737 737
 	 *
738 738
 	 * @param int $order_id The ID of the order.
739 739
 	 */
740
-	public function display_order_payout( $order_id ) {
741
-		if ( apply_filters( 'wc_stripe_hide_display_order_payout', false, $order_id ) ) {
740
+	public function display_order_payout($order_id) {
741
+		if (apply_filters('wc_stripe_hide_display_order_payout', false, $order_id)) {
742 742
 			return;
743 743
 		}
744 744
 
745
-		$order = wc_get_order( $order_id );
745
+		$order = wc_get_order($order_id);
746 746
 
747
-		$net      = WC_Stripe_Helper::get_stripe_net( $order );
748
-		$currency = WC_Stripe_Helper::get_stripe_currency( $order );
747
+		$net      = WC_Stripe_Helper::get_stripe_net($order);
748
+		$currency = WC_Stripe_Helper::get_stripe_currency($order);
749 749
 
750
-		if ( ! $net || ! $currency ) {
750
+		if ( ! $net || ! $currency) {
751 751
 			return;
752 752
 		}
753 753
 
@@ -755,12 +755,12 @@  discard block
 block discarded – undo
755 755
 
756 756
 		<tr>
757 757
 			<td class="label stripe-payout">
758
-				<?php echo wc_help_tip( __( 'This represents the net total that will be credited to your Stripe bank account. This may be in the currency that is set in your Stripe account.', 'woocommerce-gateway-stripe' ) ); // wpcs: xss ok. ?>
759
-				<?php esc_html_e( 'Stripe Payout:', 'woocommerce-gateway-stripe' ); ?>
758
+				<?php echo wc_help_tip(__('This represents the net total that will be credited to your Stripe bank account. This may be in the currency that is set in your Stripe account.', 'woocommerce-gateway-stripe')); // wpcs: xss ok. ?>
759
+				<?php esc_html_e('Stripe Payout:', 'woocommerce-gateway-stripe'); ?>
760 760
 			</td>
761 761
 			<td width="1%"></td>
762 762
 			<td class="total">
763
-				<?php echo wc_price( $net, array( 'currency' => $currency ) ); // wpcs: xss ok. ?>
763
+				<?php echo wc_price($net, array('currency' => $currency)); // wpcs: xss ok. ?>
764 764
 			</td>
765 765
 		</tr>
766 766
 
@@ -773,16 +773,16 @@  discard block
 block discarded – undo
773 773
 	 * @since 4.2.0
774 774
 	 */
775 775
 	public function display_three_d_secure_notice() {
776
-		if ( $this->get_option( '3ds_setting_notice_dismissed' ) ) {
776
+		if ($this->get_option('3ds_setting_notice_dismissed')) {
777 777
 			return;
778 778
 		}
779 779
 		?>
780
-		<div data-nonce="<?php echo esc_attr( wp_create_nonce( 'no-3ds' ) ); ?>" class="notice notice-warning is-dismissible wc-stripe-3ds-missing">
780
+		<div data-nonce="<?php echo esc_attr(wp_create_nonce('no-3ds')); ?>" class="notice notice-warning is-dismissible wc-stripe-3ds-missing">
781 781
 			<p>
782 782
 				<?php
783 783
 				$url = 'https://stripe.com/docs/payments/dynamic-3ds';
784 784
 				/* translators: 1) A URL that explains Stripe Radar. */
785
-				$message = __( '<strong>WooCommerce Stripe Gateway:</strong> We see that you had the "Require 3D secure when applicable" setting turned on. This setting is not available here anymore, because it is now replaced by Stripe Radar. You can learn more about it <a href="%s">here</a>.', 'woocommerce-gateway-stripe' );
785
+				$message = __('<strong>WooCommerce Stripe Gateway:</strong> We see that you had the "Require 3D secure when applicable" setting turned on. This setting is not available here anymore, because it is now replaced by Stripe Radar. You can learn more about it <a href="%s">here</a>.', 'woocommerce-gateway-stripe');
786 786
 
787 787
 				$allowed_tags = array(
788 788
 					'strong' => array(),
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 						'href' => array(),
791 791
 					),
792 792
 				);
793
-				printf( wp_kses( $message, $allowed_tags ), esc_url( $url ) );
793
+				printf(wp_kses($message, $allowed_tags), esc_url($url));
794 794
 				?>
795 795
 			</p>
796 796
 		</div>
@@ -805,18 +805,18 @@  discard block
 block discarded – undo
805 805
 	 * @param  WC_Order $order     The order to add a note to.
806 806
 	 * @throws WC_Stripe_Exception An exception with the right message.
807 807
 	 */
808
-	public function throw_localized_message( $response, $order ) {
808
+	public function throw_localized_message($response, $order) {
809 809
 		$localized_messages = WC_Stripe_Helper::get_localized_messages();
810 810
 
811
-		if ( 'card_error' === $response->error->type ) {
812
-			$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
811
+		if ('card_error' === $response->error->type) {
812
+			$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
813 813
 		} else {
814
-			$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
814
+			$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
815 815
 		}
816 816
 
817
-		$order->add_order_note( $localized_message );
817
+		$order->add_order_note($localized_message);
818 818
 
819
-		throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
819
+		throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
820 820
 	}
821 821
 
822 822
 	/**
@@ -831,22 +831,22 @@  discard block
 block discarded – undo
831 831
 	 * @throws WC_Stripe_Exception        If the payment is not accepted.
832 832
 	 * @return array|void
833 833
 	 */
834
-	public function retry_after_error( $response, $order, $retry, $force_save_source, $previous_error ) {
835
-		if ( ! $retry ) {
836
-			$localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' );
837
-			$order->add_order_note( $localized_message );
838
-			throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.
834
+	public function retry_after_error($response, $order, $retry, $force_save_source, $previous_error) {
835
+		if ( ! $retry) {
836
+			$localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe');
837
+			$order->add_order_note($localized_message);
838
+			throw new WC_Stripe_Exception(print_r($response, true), $localized_message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.
839 839
 		}
840 840
 
841 841
 		// Don't do anymore retries after this.
842
-		if ( 5 <= $this->retry_interval ) {
843
-			return $this->process_payment( $order->get_id(), false, $force_save_source, $response->error, $previous_error );
842
+		if (5 <= $this->retry_interval) {
843
+			return $this->process_payment($order->get_id(), false, $force_save_source, $response->error, $previous_error);
844 844
 		}
845 845
 
846
-		sleep( $this->retry_interval );
846
+		sleep($this->retry_interval);
847 847
 		$this->retry_interval++;
848 848
 
849
-		return $this->process_payment( $order->get_id(), true, $force_save_source, $response->error, $previous_error );
849
+		return $this->process_payment($order->get_id(), true, $force_save_source, $response->error, $previous_error);
850 850
 	}
851 851
 
852 852
 	/**
@@ -857,16 +857,16 @@  discard block
 block discarded – undo
857 857
 	 * @param WC_Payment_Gateway[] $gateways A list of all available gateways.
858 858
 	 * @return WC_Payment_Gateway[]          Either the same list or an empty one in the right conditions.
859 859
 	 */
860
-	public function prepare_order_pay_page( $gateways ) {
861
-		if ( ! is_wc_endpoint_url( 'order-pay' ) || ! isset( $_GET['wc-stripe-confirmation'] ) ) { // wpcs: csrf ok.
860
+	public function prepare_order_pay_page($gateways) {
861
+		if ( ! is_wc_endpoint_url('order-pay') || ! isset($_GET['wc-stripe-confirmation'])) { // wpcs: csrf ok.
862 862
 			return $gateways;
863 863
 		}
864 864
 
865
-		add_filter( 'woocommerce_checkout_show_terms', '__return_false' );
866
-		add_filter( 'woocommerce_pay_order_button_html', '__return_false' );
867
-		add_filter( 'woocommerce_available_payment_gateways', array( $this, '__return_empty_array' ) );
868
-		add_filter( 'woocommerce_no_available_payment_methods_message', array( $this, 'change_no_available_methods_message' ) );
869
-		add_action( 'woocommerce_pay_order_after_submit', array( $this, 'render_payment_intent_inputs' ) );
865
+		add_filter('woocommerce_checkout_show_terms', '__return_false');
866
+		add_filter('woocommerce_pay_order_button_html', '__return_false');
867
+		add_filter('woocommerce_available_payment_gateways', array($this, '__return_empty_array'));
868
+		add_filter('woocommerce_no_available_payment_methods_message', array($this, 'change_no_available_methods_message'));
869
+		add_action('woocommerce_pay_order_after_submit', array($this, 'render_payment_intent_inputs'));
870 870
 
871 871
 		return array();
872 872
 	}
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
 	 * @return string the new message.
880 880
 	 */
881 881
 	public function change_no_available_methods_message() {
882
-		return wpautop( __( "Almost there!\n\nYour order has already been created, the only thing that still needs to be done is for you to authorize the payment with your bank.", 'woocommerce-gateway-stripe' ) );
882
+		return wpautop(__("Almost there!\n\nYour order has already been created, the only thing that still needs to be done is for you to authorize the payment with your bank.", 'woocommerce-gateway-stripe'));
883 883
 	}
884 884
 
885 885
 	/**
@@ -888,21 +888,21 @@  discard block
 block discarded – undo
888 888
 	 * @since 4.2
889 889
 	 */
890 890
 	public function render_payment_intent_inputs() {
891
-		$order     = wc_get_order( absint( get_query_var( 'order-pay' ) ) );
892
-		$intent    = $this->get_intent_from_order( $order );
891
+		$order     = wc_get_order(absint(get_query_var('order-pay')));
892
+		$intent    = $this->get_intent_from_order($order);
893 893
 
894 894
 		$verification_url = add_query_arg(
895 895
 			array(
896 896
 				'order'            => $order->get_id(),
897
-				'nonce'            => wp_create_nonce( 'wc_stripe_confirm_pi' ),
898
-				'redirect_to'      => rawurlencode( $this->get_return_url( $order ) ),
897
+				'nonce'            => wp_create_nonce('wc_stripe_confirm_pi'),
898
+				'redirect_to'      => rawurlencode($this->get_return_url($order)),
899 899
 				'is_pay_for_order' => true,
900 900
 			),
901
-			WC_AJAX::get_endpoint( 'wc_stripe_verify_intent' )
901
+			WC_AJAX::get_endpoint('wc_stripe_verify_intent')
902 902
 		);
903 903
 
904
-		echo '<input type="hidden" id="stripe-intent-id" value="' . esc_attr( $intent->client_secret ) . '" />';
905
-		echo '<input type="hidden" id="stripe-intent-return" value="' . esc_attr( $verification_url ) . '" />';
904
+		echo '<input type="hidden" id="stripe-intent-id" value="' . esc_attr($intent->client_secret) . '" />';
905
+		echo '<input type="hidden" id="stripe-intent-return" value="' . esc_attr($verification_url) . '" />';
906 906
 	}
907 907
 
908 908
 	/**
@@ -912,11 +912,11 @@  discard block
 block discarded – undo
912 912
 	 * @param WC_Payment_Token $token Payment Token.
913 913
 	 * @return string                 Generated payment method HTML
914 914
 	 */
915
-	public function get_saved_payment_method_option_html( $token ) {
916
-		$html          = parent::get_saved_payment_method_option_html( $token );
915
+	public function get_saved_payment_method_option_html($token) {
916
+		$html          = parent::get_saved_payment_method_option_html($token);
917 917
 		$error_wrapper = '<div class="stripe-source-errors" role="alert"></div>';
918 918
 
919
-		return preg_replace( '~</(\w+)>\s*$~', "$error_wrapper</$1>", $html );
919
+		return preg_replace('~</(\w+)>\s*$~', "$error_wrapper</$1>", $html);
920 920
 	}
921 921
 
922 922
 	/**
@@ -926,13 +926,13 @@  discard block
 block discarded – undo
926 926
 	 * @since 4.2.0
927 927
 	 * @param int $order_id The ID that will be used for the thank you page.
928 928
 	 */
929
-	public function check_intent_status_on_order_page( $order_id ) {
930
-		if ( empty( $order_id ) || absint( $order_id ) <= 0 ) {
929
+	public function check_intent_status_on_order_page($order_id) {
930
+		if (empty($order_id) || absint($order_id) <= 0) {
931 931
 			return;
932 932
 		}
933 933
 
934
-		$order = wc_get_order( absint( $order_id ) );
935
-		$this->verify_intent_after_checkout( $order );
934
+		$order = wc_get_order(absint($order_id));
935
+		$this->verify_intent_after_checkout($order);
936 936
 	}
937 937
 
938 938
 	/**
@@ -946,9 +946,9 @@  discard block
 block discarded – undo
946 946
 	 * @param int   $order_id The ID of the order which is being paid for.
947 947
 	 * @return array
948 948
 	 */
949
-	public function modify_successful_payment_result( $result, $order_id ) {
949
+	public function modify_successful_payment_result($result, $order_id) {
950 950
 		// Only redirects with intents need to be modified.
951
-		if ( ! isset( $result['intent_secret'] ) ) {
951
+		if ( ! isset($result['intent_secret'])) {
952 952
 			return $result;
953 953
 		}
954 954
 
@@ -956,14 +956,14 @@  discard block
 block discarded – undo
956 956
 		$verification_url = add_query_arg(
957 957
 			array(
958 958
 				'order'       => $order_id,
959
-				'nonce'       => wp_create_nonce( 'wc_stripe_confirm_pi' ),
960
-				'redirect_to' => rawurlencode( $result['redirect'] ),
959
+				'nonce'       => wp_create_nonce('wc_stripe_confirm_pi'),
960
+				'redirect_to' => rawurlencode($result['redirect']),
961 961
 			),
962
-			WC_AJAX::get_endpoint( 'wc_stripe_verify_intent' )
962
+			WC_AJAX::get_endpoint('wc_stripe_verify_intent')
963 963
 		);
964 964
 
965 965
 		// Combine into a hash.
966
-		$redirect = sprintf( '#confirm-pi-%s:%s', $result['intent_secret'], rawurlencode( $verification_url ) );
966
+		$redirect = sprintf('#confirm-pi-%s:%s', $result['intent_secret'], rawurlencode($verification_url));
967 967
 
968 968
 		return array(
969 969
 			'result'   => 'success',
@@ -978,37 +978,37 @@  discard block
 block discarded – undo
978 978
 	 * @since 4.2.0
979 979
 	 * @param WC_Order $order The order which is in a transitional state.
980 980
 	 */
981
-	public function verify_intent_after_checkout( $order ) {
982
-		if ( 'pending' !== $order->get_status() && 'failed' !== $order->get_status() ) {
981
+	public function verify_intent_after_checkout($order) {
982
+		if ('pending' !== $order->get_status() && 'failed' !== $order->get_status()) {
983 983
 			// If payment has already been completed, this function is redundant.
984 984
 			return;
985 985
 		}
986 986
 
987
-		$payment_method = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method();
988
-		if ( $payment_method !== $this->id ) {
987
+		$payment_method = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method();
988
+		if ($payment_method !== $this->id) {
989 989
 			// If this is not the payment method, an intent would not be available.
990 990
 			return;
991 991
 		}
992 992
 
993
-		$intent = $this->get_intent_from_order( $order );
994
-		if ( ! $intent ) {
993
+		$intent = $this->get_intent_from_order($order);
994
+		if ( ! $intent) {
995 995
 			// No intent, redirect to the order received page for further actions.
996 996
 			return;
997 997
 		}
998 998
 
999
-		if ( $this->lock_order_payment( $order, $intent ) ) {
999
+		if ($this->lock_order_payment($order, $intent)) {
1000 1000
 			return;
1001 1001
 		}
1002 1002
 
1003
-		if ( 'succeeded' === $intent->status ) {
1003
+		if ('succeeded' === $intent->status) {
1004 1004
 			// Proceed with the payment completion.
1005
-			$this->process_response( end( $intent->charges->data ), $order );
1006
-		} else if ( 'requires_payment_method' === $intent->status ) {
1005
+			$this->process_response(end($intent->charges->data), $order);
1006
+		} else if ('requires_payment_method' === $intent->status) {
1007 1007
 			// `requires_payment_method` means that SCA got denied for the current payment method.
1008
-			$this->failed_sca_auth( $order, $intent );
1008
+			$this->failed_sca_auth($order, $intent);
1009 1009
 		}
1010 1010
 
1011
-		$this->unlock_order_payment( $order );
1011
+		$this->unlock_order_payment($order);
1012 1012
 	}
1013 1013
 
1014 1014
 	/**
@@ -1018,19 +1018,19 @@  discard block
 block discarded – undo
1018 1018
 	 * @param WC_Order $order  The order which should be checked.
1019 1019
 	 * @param object   $intent The intent, associated with the order.
1020 1020
 	 */
1021
-	public function failed_sca_auth( $order, $intent ) {
1021
+	public function failed_sca_auth($order, $intent) {
1022 1022
 		// If the order has already failed, do not repeat the same message.
1023
-		if ( 'failed' === $order->get_status() ) {
1023
+		if ('failed' === $order->get_status()) {
1024 1024
 			return;
1025 1025
 		}
1026 1026
 
1027 1027
 		// Load the right message and update the status.
1028
-		$status_message = ( $intent->last_payment_error )
1028
+		$status_message = ($intent->last_payment_error)
1029 1029
 			/* translators: 1) The error message that was received from Stripe. */
1030
-			? sprintf( __( 'Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe' ), $intent->last_payment_error->message )
1031
-			: __( 'Stripe SCA authentication failed.', 'woocommerce-gateway-stripe' );
1032
-		$order->update_status( 'failed', $status_message );
1030
+			? sprintf(__('Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe'), $intent->last_payment_error->message)
1031
+			: __('Stripe SCA authentication failed.', 'woocommerce-gateway-stripe');
1032
+		$order->update_status('failed', $status_message);
1033 1033
 
1034
-		$this->send_failed_order_email( $order->get_id() );
1034
+		$this->send_failed_order_email($order->get_id());
1035 1035
 	}
1036 1036
 }
Please login to merge, or discard this patch.