Completed
Pull Request — master (#1224)
by
unknown
01:49
created
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/abstracts/abstract-wc-stripe-payment-gateway.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 * Displays the admin settings webhook description.
18 18
 	 *
19 19
 	 * @since 4.1.0
20
-	 * @return mixed
20
+	 * @return string
21 21
 	 */
22 22
 	public function display_admin_settings_webhook_description() {
23 23
 		/* translators: 1) webhook url */
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 	 *
557 557
 	 * @since 4.0.8
558 558
 	 * @param string $source_id
559
-	 * @return bool
559
+	 * @return integer
560 560
 	 */
561 561
 	public function is_type_legacy_card( $source_id ) {
562 562
 		return ( preg_match( '/^card_/', $source_id ) );
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@
 block discarded – undo
163 163
 				&& preg_match( '/^[rs]k_test_/', $this->secret_key );
164 164
 		} else {
165 165
 			return preg_match( '/^pk_live_/', $this->publishable_key )
166
-			    && preg_match( '/^[rs]k_live_/', $this->secret_key );
166
+				&& preg_match( '/^[rs]k_live_/', $this->secret_key );
167 167
 		}
168 168
 	}
169 169
 
Please login to merge, or discard this patch.
Spacing   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function display_admin_settings_webhook_description() {
23 23
 		/* translators: 1) webhook url */
24
-		$description = sprintf( __( 'You must add the following webhook endpoint <strong style="background-color:#ddd;">&nbsp;%s&nbsp;</strong> to your <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Stripe account settings</a> (if there isn\'t one already enabled). This will enable you to receive notifications on the charge statuses.', 'woocommerce-gateway-stripe' ), WC_Stripe_Helper::get_webhook_url() );
24
+		$description = sprintf(__('You must add the following webhook endpoint <strong style="background-color:#ddd;">&nbsp;%s&nbsp;</strong> to your <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Stripe account settings</a> (if there isn\'t one already enabled). This will enable you to receive notifications on the charge statuses.', 'woocommerce-gateway-stripe'), WC_Stripe_Helper::get_webhook_url());
25 25
 
26 26
 		$webhook_status = $this->get_webhook_status_message();
27 27
 
@@ -43,35 +43,35 @@  discard block
 block discarded – undo
43 43
 		$date_format = 'Y-m-d H:i:s e';
44 44
 
45 45
 		// Case 1 (Nominal case): Most recent = success
46
-		if ( $last_success_at > $last_failure_at ) {
46
+		if ($last_success_at > $last_failure_at) {
47 47
 			$message = sprintf(
48 48
 				/* translators: 1) date and time of last webhook received, e.g. 2020-06-28 10:30:50 UTC */
49
-				__( 'The most recent webhook, timestamped %s, was processed succesfully.', 'woocommerce-gateway-stripe' ),
50
-				date( $date_format, $last_success_at )
49
+				__('The most recent webhook, timestamped %s, was processed succesfully.', 'woocommerce-gateway-stripe'),
50
+				date($date_format, $last_success_at)
51 51
 			);
52 52
 			return $message;
53 53
 		}
54 54
 
55 55
 		// Case 2: No webhooks received yet
56
-		if ( ( 0 == $last_success_at ) && ( 0 == $last_failure_at ) ) {
56
+		if ((0 == $last_success_at) && (0 == $last_failure_at)) {
57 57
 			$message = sprintf(
58 58
 				/* translators: 1) date and time webhook monitoring began, e.g. 2020-06-28 10:30:50 UTC */
59
-				__( 'No webhooks have been received since monitoring began at %s.', 'woocommerce-gateway-stripe' ),
60
-				date( $date_format, $monitoring_began_at )
59
+				__('No webhooks have been received since monitoring began at %s.', 'woocommerce-gateway-stripe'),
60
+				date($date_format, $monitoring_began_at)
61 61
 			);
62 62
 			return $message;
63 63
 		}
64 64
 
65 65
 		// Case 3: Failure after success
66
-		if ( $last_success_at > 0 ) {
66
+		if ($last_success_at > 0) {
67 67
 			$message = sprintf(
68 68
 				/* translators: 1) date and time of last failed webhook e.g. 2020-06-28 10:30:50 UTC */
69 69
 				/* translators: 2) reason webhook failed */
70 70
 				/* translators: 3) date and time of last successful webhook e.g. 2020-05-28 10:30:50 UTC */
71
-				__( 'Warning: The most recent webhook, received at %s, could not be processed. Reason: %s. (The last webhook to process successfully was timestamped %s.)', 'woocommerce-gateway-stripe' ),
72
-				date( $date_format, $last_failure_at ),
71
+				__('Warning: The most recent webhook, received at %s, could not be processed. Reason: %s. (The last webhook to process successfully was timestamped %s.)', 'woocommerce-gateway-stripe'),
72
+				date($date_format, $last_failure_at),
73 73
 				$last_error,
74
-				date( $date_format, $last_success_at )
74
+				date($date_format, $last_success_at)
75 75
 			);
76 76
 			return $message;
77 77
 		}
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 			/* translators: 1) date and time of last failed webhook e.g. 2020-06-28 10:30:50 UTC */
82 82
 			/* translators: 2) reason webhook failed */
83 83
 			/* translators: 3) date and time webhook monitoring began e.g. 2020-05-28 10:30:50 UTC */
84
-			__( 'Warning: The most recent webhook, received at %s, could not be processed. Reason: %s. (No webhooks have been processed successfully since monitoring began at %s.)', 'woocommerce-gateway-stripe' ),
85
-			date( $date_format, $last_failure_at ),
84
+			__('Warning: The most recent webhook, received at %s, could not be processed. Reason: %s. (No webhooks have been processed successfully since monitoring began at %s.)', 'woocommerce-gateway-stripe'),
85
+			date($date_format, $last_failure_at),
86 86
 			$last_error,
87
-			date( $date_format, $monitoring_began_at )
87
+			date($date_format, $monitoring_began_at)
88 88
 		);
89 89
 		return $message;
90 90
 	}
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 				<input id="wc-%1$s-new-payment-method" name="wc-%1$s-new-payment-method" type="checkbox" value="true" style="width:auto;" />
101 101
 				<label for="wc-%1$s-new-payment-method" style="display:inline;">%2$s</label>
102 102
 			</p>',
103
-			esc_attr( $this->id ),
104
-			esc_html( apply_filters( 'wc_stripe_save_to_account_text', __( 'Save payment information to my account for future purchases.', 'woocommerce-gateway-stripe' ) ) )
103
+			esc_attr($this->id),
104
+			esc_html(apply_filters('wc_stripe_save_to_account_text', __('Save payment information to my account for future purchases.', 'woocommerce-gateway-stripe')))
105 105
 		);
106 106
 	}
107 107
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * @since 4.0.5
113 113
 	 * @param array $error
114 114
 	 */
115
-	public function is_retryable_error( $error ) {
115
+	public function is_retryable_error($error) {
116 116
 		return (
117 117
 			'invalid_request_error' === $error->type ||
118 118
 			'idempotency_error' === $error->type ||
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
 	 * @since 4.1.0
130 130
 	 * @param array $error
131 131
 	 */
132
-	public function is_same_idempotency_error( $error ) {
132
+	public function is_same_idempotency_error($error) {
133 133
 		return (
134 134
 			$error &&
135 135
 			'idempotency_error' === $error->type &&
136
-			preg_match( '/Keys for idempotent requests can only be used with the same parameters they were first used with./i', $error->message )
136
+			preg_match('/Keys for idempotent requests can only be used with the same parameters they were first used with./i', $error->message)
137 137
 		);
138 138
 	}
139 139
 
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 	 * @since 4.1.0
145 145
 	 * @param array $error
146 146
 	 */
147
-	public function is_no_such_customer_error( $error ) {
147
+	public function is_no_such_customer_error($error) {
148 148
 		return (
149 149
 			$error &&
150 150
 			'invalid_request_error' === $error->type &&
151
-			preg_match( '/No such customer/i', $error->message )
151
+			preg_match('/No such customer/i', $error->message)
152 152
 		);
153 153
 	}
154 154
 
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 * @since 4.1.0
160 160
 	 * @param array $error
161 161
 	 */
162
-	public function is_no_such_token_error( $error ) {
162
+	public function is_no_such_token_error($error) {
163 163
 		return (
164 164
 			$error &&
165 165
 			'invalid_request_error' === $error->type &&
166
-			preg_match( '/No such token/i', $error->message )
166
+			preg_match('/No such token/i', $error->message)
167 167
 		);
168 168
 	}
169 169
 
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 	 * @since 4.1.0
175 175
 	 * @param array $error
176 176
 	 */
177
-	public function is_no_such_source_error( $error ) {
177
+	public function is_no_such_source_error($error) {
178 178
 		return (
179 179
 			$error &&
180 180
 			'invalid_request_error' === $error->type &&
181
-			preg_match( '/No such source/i', $error->message )
181
+			preg_match('/No such source/i', $error->message)
182 182
 		);
183 183
 	}
184 184
 
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
 	 * @since 4.1.0
190 190
 	 * @param array $error
191 191
 	 */
192
-	public function is_no_linked_source_error( $error ) {
192
+	public function is_no_linked_source_error($error) {
193 193
 		return (
194 194
 			$error &&
195 195
 			'invalid_request_error' === $error->type &&
196
-			preg_match( '/does not have a linked source with ID/i', $error->message )
196
+			preg_match('/does not have a linked source with ID/i', $error->message)
197 197
 		);
198 198
 	}
199 199
 
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
 	 * @param object $error
207 207
 	 * @return bool
208 208
 	 */
209
-	public function need_update_idempotency_key( $source_object, $error ) {
209
+	public function need_update_idempotency_key($source_object, $error) {
210 210
 		return (
211 211
 			$error &&
212 212
 			1 < $this->retry_interval &&
213
-			! empty( $source_object ) &&
213
+			! empty($source_object) &&
214 214
 			'chargeable' === $source_object->status &&
215
-			self::is_same_idempotency_error( $error )
215
+			self::is_same_idempotency_error($error)
216 216
 		);
217 217
 	}
218 218
 
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
 		// NOTE: updates to this function should be added to are_keys_set()
227 227
 		// in includes/payment-methods/class-wc-stripe-payment-request.php
228 228
 
229
-		if ( $this->testmode ) {
230
-			return preg_match( '/^pk_test_/', $this->publishable_key )
231
-				&& preg_match( '/^[rs]k_test_/', $this->secret_key );
229
+		if ($this->testmode) {
230
+			return preg_match('/^pk_test_/', $this->publishable_key)
231
+				&& preg_match('/^[rs]k_test_/', $this->secret_key);
232 232
 		} else {
233
-			return preg_match( '/^pk_live_/', $this->publishable_key )
234
-			    && preg_match( '/^[rs]k_live_/', $this->secret_key );
233
+			return preg_match('/^pk_live_/', $this->publishable_key)
234
+			    && preg_match('/^[rs]k_live_/', $this->secret_key);
235 235
 		}
236 236
 	}
237 237
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 * @since 4.1.3
242 242
 	 */
243 243
 	public function is_available() {
244
-		if ( 'yes' === $this->enabled ) {
244
+		if ('yes' === $this->enabled) {
245 245
 			return $this->are_keys_set();
246 246
 		}
247 247
 
@@ -256,12 +256,12 @@  discard block
 block discarded – undo
256 256
 	 * @param int $order_id
257 257
 	 * @return bool
258 258
 	 */
259
-	public function maybe_process_pre_orders( $order_id ) {
259
+	public function maybe_process_pre_orders($order_id) {
260 260
 		return (
261 261
 			WC_Stripe_Helper::is_pre_orders_exists() &&
262
-			$this->pre_orders->is_pre_order( $order_id ) &&
263
-			WC_Pre_Orders_Order::order_requires_payment_tokenization( $order_id ) &&
264
-			! is_wc_endpoint_url( 'order-pay' )
262
+			$this->pre_orders->is_pre_order($order_id) &&
263
+			WC_Pre_Orders_Order::order_requires_payment_tokenization($order_id) &&
264
+			! is_wc_endpoint_url('order-pay')
265 265
 		);
266 266
 	}
267 267
 
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
 	 * @version 4.0.0
306 306
 	 * @param object $order
307 307
 	 */
308
-	public function validate_minimum_order_amount( $order ) {
309
-		if ( $order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount() ) {
308
+	public function validate_minimum_order_amount($order) {
309
+		if ($order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount()) {
310 310
 			/* translators: 1) dollar amount */
311
-			throw new WC_Stripe_Exception( 'Did not meet minimum amount', sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe_Helper::get_minimum_amount() / 100 ) ) );
311
+			throw new WC_Stripe_Exception('Did not meet minimum amount', sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe_Helper::get_minimum_amount() / 100)));
312 312
 		}
313 313
 	}
314 314
 
@@ -318,14 +318,14 @@  discard block
 block discarded – undo
318 318
 	 * @since 4.0.0
319 319
 	 * @version 4.0.0
320 320
 	 */
321
-	public function get_transaction_url( $order ) {
322
-		if ( $this->testmode ) {
321
+	public function get_transaction_url($order) {
322
+		if ($this->testmode) {
323 323
 			$this->view_transaction_url = 'https://dashboard.stripe.com/test/payments/%s';
324 324
 		} else {
325 325
 			$this->view_transaction_url = 'https://dashboard.stripe.com/payments/%s';
326 326
 		}
327 327
 
328
-		return parent::get_transaction_url( $order );
328
+		return parent::get_transaction_url($order);
329 329
 	}
330 330
 
331 331
 	/**
@@ -334,12 +334,12 @@  discard block
 block discarded – undo
334 334
 	 * @since 4.0.0
335 335
 	 * @version 4.0.0
336 336
 	 */
337
-	public function get_stripe_customer_id( $order ) {
338
-		$customer = get_user_option( '_stripe_customer_id', $order->get_customer_id() );
337
+	public function get_stripe_customer_id($order) {
338
+		$customer = get_user_option('_stripe_customer_id', $order->get_customer_id());
339 339
 
340
-		if ( empty( $customer ) ) {
340
+		if (empty($customer)) {
341 341
 			// Try to get it via the order.
342
-			return $order->get_meta( '_stripe_customer_id', true );
342
+			return $order->get_meta('_stripe_customer_id', true);
343 343
 		} else {
344 344
 			return $customer;
345 345
 		}
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 	 * @param object $order
356 356
 	 * @param int $id Stripe session id.
357 357
 	 */
358
-	public function get_stripe_return_url( $order = null, $id = null ) {
359
-		if ( is_object( $order ) ) {
360
-			if ( empty( $id ) ) {
358
+	public function get_stripe_return_url($order = null, $id = null) {
359
+		if (is_object($order)) {
360
+			if (empty($id)) {
361 361
 				$id = uniqid();
362 362
 			}
363 363
 
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 				'order_id'       => $order_id,
369 369
 			);
370 370
 
371
-			return wp_sanitize_redirect( esc_url_raw( add_query_arg( $args, $this->get_return_url( $order ) ) ) );
371
+			return wp_sanitize_redirect(esc_url_raw(add_query_arg($args, $this->get_return_url($order))));
372 372
 		}
373 373
 
374
-		return wp_sanitize_redirect( esc_url_raw( add_query_arg( array( 'utm_nooverride' => '1' ), $this->get_return_url() ) ) );
374
+		return wp_sanitize_redirect(esc_url_raw(add_query_arg(array('utm_nooverride' => '1'), $this->get_return_url())));
375 375
 	}
376 376
 
377 377
 	/**
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 	 * @param  int  $order_id
380 380
 	 * @return boolean
381 381
 	 */
382
-	public function has_subscription( $order_id ) {
383
-		return ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_is_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ) );
382
+	public function has_subscription($order_id) {
383
+		return (function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order_id) || wcs_is_subscription($order_id) || wcs_order_contains_renewal($order_id)));
384 384
 	}
385 385
 
386 386
 	/**
@@ -392,34 +392,34 @@  discard block
 block discarded – undo
392 392
 	 * @param  object $prepared_source
393 393
 	 * @return array()
394 394
 	 */
395
-	public function generate_payment_request( $order, $prepared_source ) {
396
-		$settings              = get_option( 'woocommerce_stripe_settings', array() );
397
-		$statement_descriptor  = ! empty( $settings['statement_descriptor'] ) ? str_replace( "'", '', $settings['statement_descriptor'] ) : '';
398
-		$capture               = ! empty( $settings['capture'] ) && 'yes' === $settings['capture'] ? true : false;
395
+	public function generate_payment_request($order, $prepared_source) {
396
+		$settings              = get_option('woocommerce_stripe_settings', array());
397
+		$statement_descriptor  = ! empty($settings['statement_descriptor']) ? str_replace("'", '', $settings['statement_descriptor']) : '';
398
+		$capture               = ! empty($settings['capture']) && 'yes' === $settings['capture'] ? true : false;
399 399
 		$post_data             = array();
400
-		$post_data['currency'] = strtolower( $order->get_currency() );
401
-		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $post_data['currency'] );
400
+		$post_data['currency'] = strtolower($order->get_currency());
401
+		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $post_data['currency']);
402 402
 		/* translators: 1) blog name 2) order number */
403
-		$post_data['description'] = sprintf( __( '%1$s - Order %2$s', 'woocommerce-gateway-stripe' ), wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $order->get_order_number() );
403
+		$post_data['description'] = sprintf(__('%1$s - Order %2$s', 'woocommerce-gateway-stripe'), wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES), $order->get_order_number());
404 404
 		$billing_email            = $order->get_billing_email();
405 405
 		$billing_first_name       = $order->get_billing_first_name();
406 406
 		$billing_last_name        = $order->get_billing_last_name();
407 407
 
408
-		if ( ! empty( $billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) {
408
+		if ( ! empty($billing_email) && apply_filters('wc_stripe_send_stripe_receipt', false)) {
409 409
 			$post_data['receipt_email'] = $billing_email;
410 410
 		}
411 411
 
412
-		switch ( $order->get_payment_method() ) {
412
+		switch ($order->get_payment_method()) {
413 413
 			case 'stripe':
414
-				if ( ! empty( $statement_descriptor ) ) {
415
-					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor );
414
+				if ( ! empty($statement_descriptor)) {
415
+					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor);
416 416
 				}
417 417
 
418 418
 				$post_data['capture'] = $capture ? 'true' : 'false';
419 419
 				break;
420 420
 			case 'stripe_sepa':
421
-				if ( ! empty( $statement_descriptor ) ) {
422
-					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor );
421
+				if ( ! empty($statement_descriptor)) {
422
+					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor);
423 423
 				}
424 424
 				break;
425 425
 		}
@@ -427,25 +427,25 @@  discard block
 block discarded – undo
427 427
 		$post_data['expand[]'] = 'balance_transaction';
428 428
 
429 429
 		$metadata = array(
430
-			__( 'customer_name', 'woocommerce-gateway-stripe' ) => sanitize_text_field( $billing_first_name ) . ' ' . sanitize_text_field( $billing_last_name ),
431
-			__( 'customer_email', 'woocommerce-gateway-stripe' ) => sanitize_email( $billing_email ),
430
+			__('customer_name', 'woocommerce-gateway-stripe') => sanitize_text_field($billing_first_name) . ' ' . sanitize_text_field($billing_last_name),
431
+			__('customer_email', 'woocommerce-gateway-stripe') => sanitize_email($billing_email),
432 432
 			'order_id' => $order->get_order_number(),
433 433
 		);
434 434
 
435
-		if ( $this->has_subscription( $order->get_id() ) ) {
435
+		if ($this->has_subscription($order->get_id())) {
436 436
 			$metadata += array(
437 437
 				'payment_type' => 'recurring',
438
-				'site_url'     => esc_url( get_site_url() ),
438
+				'site_url'     => esc_url(get_site_url()),
439 439
 			);
440 440
 		}
441 441
 
442
-		$post_data['metadata'] = apply_filters( 'wc_stripe_payment_metadata', $metadata, $order, $prepared_source );
442
+		$post_data['metadata'] = apply_filters('wc_stripe_payment_metadata', $metadata, $order, $prepared_source);
443 443
 
444
-		if ( $prepared_source->customer ) {
444
+		if ($prepared_source->customer) {
445 445
 			$post_data['customer'] = $prepared_source->customer;
446 446
 		}
447 447
 
448
-		if ( $prepared_source->source ) {
448
+		if ($prepared_source->source) {
449 449
 			$post_data['source'] = $prepared_source->source;
450 450
 		}
451 451
 
@@ -457,72 +457,72 @@  discard block
 block discarded – undo
457 457
 		 * @param WC_Order $order
458 458
 		 * @param object $source
459 459
 		 */
460
-		return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order, $prepared_source );
460
+		return apply_filters('wc_stripe_generate_payment_request', $post_data, $order, $prepared_source);
461 461
 	}
462 462
 
463 463
 	/**
464 464
 	 * Store extra meta data for an order from a Stripe Response.
465 465
 	 */
466
-	public function process_response( $response, $order ) {
467
-		WC_Stripe_Logger::log( 'Processing response: ' . print_r( $response, true ) );
466
+	public function process_response($response, $order) {
467
+		WC_Stripe_Logger::log('Processing response: ' . print_r($response, true));
468 468
 
469 469
 		$order_id = $order->get_id();
470
-		$captured = ( isset( $response->captured ) && $response->captured ) ? 'yes' : 'no';
470
+		$captured = (isset($response->captured) && $response->captured) ? 'yes' : 'no';
471 471
 
472 472
 		// Store charge data.
473
-		$order->update_meta_data( '_stripe_charge_captured', $captured );
473
+		$order->update_meta_data('_stripe_charge_captured', $captured);
474 474
 
475
-		if ( isset( $response->balance_transaction ) ) {
476
-			$this->update_fees( $order, is_string( $response->balance_transaction ) ? $response->balance_transaction : $response->balance_transaction->id );
475
+		if (isset($response->balance_transaction)) {
476
+			$this->update_fees($order, is_string($response->balance_transaction) ? $response->balance_transaction : $response->balance_transaction->id);
477 477
 		}
478 478
 
479
-		if ( 'yes' === $captured ) {
479
+		if ('yes' === $captured) {
480 480
 			/**
481 481
 			 * Charge can be captured but in a pending state. Payment methods
482 482
 			 * that are asynchronous may take couple days to clear. Webhook will
483 483
 			 * take care of the status changes.
484 484
 			 */
485
-			if ( 'pending' === $response->status ) {
486
-				$order_stock_reduced = $order->get_meta( '_order_stock_reduced', true );
485
+			if ('pending' === $response->status) {
486
+				$order_stock_reduced = $order->get_meta('_order_stock_reduced', true);
487 487
 
488
-				if ( ! $order_stock_reduced ) {
489
-					wc_reduce_stock_levels( $order_id );
488
+				if ( ! $order_stock_reduced) {
489
+					wc_reduce_stock_levels($order_id);
490 490
 				}
491 491
 
492
-				$order->set_transaction_id( $response->id );
492
+				$order->set_transaction_id($response->id);
493 493
 				/* translators: transaction id */
494
-				$order->update_status( 'on-hold', sprintf( __( 'Stripe charge awaiting payment: %s.', 'woocommerce-gateway-stripe' ), $response->id ) );
494
+				$order->update_status('on-hold', sprintf(__('Stripe charge awaiting payment: %s.', 'woocommerce-gateway-stripe'), $response->id));
495 495
 			}
496 496
 
497
-			if ( 'succeeded' === $response->status ) {
498
-				$order->payment_complete( $response->id );
497
+			if ('succeeded' === $response->status) {
498
+				$order->payment_complete($response->id);
499 499
 
500 500
 				/* translators: transaction id */
501
-				$message = sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $response->id );
502
-				$order->add_order_note( $message );
501
+				$message = sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $response->id);
502
+				$order->add_order_note($message);
503 503
 			}
504 504
 
505
-			if ( 'failed' === $response->status ) {
506
-				$localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
507
-				$order->add_order_note( $localized_message );
508
-				throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
505
+			if ('failed' === $response->status) {
506
+				$localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
507
+				$order->add_order_note($localized_message);
508
+				throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
509 509
 			}
510 510
 		} else {
511
-			$order->set_transaction_id( $response->id );
511
+			$order->set_transaction_id($response->id);
512 512
 
513
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
514
-				wc_reduce_stock_levels( $order_id );
513
+			if ($order->has_status(array('pending', 'failed'))) {
514
+				wc_reduce_stock_levels($order_id);
515 515
 			}
516 516
 
517 517
 			/* translators: transaction id */
518
-			$order->update_status( 'on-hold', sprintf( __( 'Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe' ), $response->id ) );
518
+			$order->update_status('on-hold', sprintf(__('Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe'), $response->id));
519 519
 		}
520 520
 
521
-		if ( is_callable( array( $order, 'save' ) ) ) {
521
+		if (is_callable(array($order, 'save'))) {
522 522
 			$order->save();
523 523
 		}
524 524
 
525
-		do_action( 'wc_gateway_stripe_process_response', $response, $order );
525
+		do_action('wc_gateway_stripe_process_response', $response, $order);
526 526
 
527 527
 		return $response;
528 528
 	}
@@ -535,10 +535,10 @@  discard block
 block discarded – undo
535 535
 	 * @param int $order_id
536 536
 	 * @return null
537 537
 	 */
538
-	public function send_failed_order_email( $order_id ) {
538
+	public function send_failed_order_email($order_id) {
539 539
 		$emails = WC()->mailer()->get_emails();
540
-		if ( ! empty( $emails ) && ! empty( $order_id ) ) {
541
-			$emails['WC_Email_Failed_Order']->trigger( $order_id );
540
+		if ( ! empty($emails) && ! empty($order_id)) {
541
+			$emails['WC_Email_Failed_Order']->trigger($order_id);
542 542
 		}
543 543
 	}
544 544
 
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 	 * @param object $order
551 551
 	 * @return object $details
552 552
 	 */
553
-	public function get_owner_details( $order ) {
553
+	public function get_owner_details($order) {
554 554
 		$billing_first_name = $order->get_billing_first_name();
555 555
 		$billing_last_name  = $order->get_billing_last_name();
556 556
 
@@ -560,15 +560,15 @@  discard block
 block discarded – undo
560 560
 		$email = $order->get_billing_email();
561 561
 		$phone = $order->get_billing_phone();
562 562
 
563
-		if ( ! empty( $phone ) ) {
563
+		if ( ! empty($phone)) {
564 564
 			$details['phone'] = $phone;
565 565
 		}
566 566
 
567
-		if ( ! empty( $name ) ) {
567
+		if ( ! empty($name)) {
568 568
 			$details['name'] = $name;
569 569
 		}
570 570
 
571
-		if ( ! empty( $email ) ) {
571
+		if ( ! empty($email)) {
572 572
 			$details['email'] = $email;
573 573
 		}
574 574
 
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 		$details['address']['postal_code'] = $order->get_billing_postcode();
580 580
 		$details['address']['country']     = $order->get_billing_country();
581 581
 
582
-		return (object) apply_filters( 'wc_stripe_owner_details', $details, $order );
582
+		return (object) apply_filters('wc_stripe_owner_details', $details, $order);
583 583
 	}
584 584
 
585 585
 	/**
@@ -588,15 +588,15 @@  discard block
 block discarded – undo
588 588
 	 * @since 4.0.3
589 589
 	 * @param string $source_id The source ID to get source object for.
590 590
 	 */
591
-	public function get_source_object( $source_id = '' ) {
592
-		if ( empty( $source_id ) ) {
591
+	public function get_source_object($source_id = '') {
592
+		if (empty($source_id)) {
593 593
 			return '';
594 594
 		}
595 595
 
596
-		$source_object = WC_Stripe_API::retrieve( 'sources/' . $source_id );
596
+		$source_object = WC_Stripe_API::retrieve('sources/' . $source_id);
597 597
 
598
-		if ( ! empty( $source_object->error ) ) {
599
-			throw new WC_Stripe_Exception( print_r( $source_object, true ), $source_object->error->message );
598
+		if ( ! empty($source_object->error)) {
599
+			throw new WC_Stripe_Exception(print_r($source_object, true), $source_object->error->message);
600 600
 		}
601 601
 
602 602
 		return $source_object;
@@ -609,10 +609,10 @@  discard block
 block discarded – undo
609 609
 	 * @param object $source_object
610 610
 	 * @return bool
611 611
 	 */
612
-	public function is_prepaid_card( $source_object ) {
612
+	public function is_prepaid_card($source_object) {
613 613
 		return (
614 614
 			$source_object
615
-			&& ( 'token' === $source_object->object || 'source' === $source_object->object )
615
+			&& ('token' === $source_object->object || 'source' === $source_object->object)
616 616
 			&& 'prepaid' === $source_object->card->funding
617 617
 		);
618 618
 	}
@@ -624,8 +624,8 @@  discard block
 block discarded – undo
624 624
 	 * @param string $source_id
625 625
 	 * @return bool
626 626
 	 */
627
-	public function is_type_legacy_card( $source_id ) {
628
-		return ( preg_match( '/^card_/', $source_id ) );
627
+	public function is_type_legacy_card($source_id) {
628
+		return (preg_match('/^card_/', $source_id));
629 629
 	}
630 630
 
631 631
 	/**
@@ -635,9 +635,9 @@  discard block
 block discarded – undo
635 635
 	 * @return bool
636 636
 	 */
637 637
 	public function is_using_saved_payment_method() {
638
-		$payment_method = isset( $_POST['payment_method'] ) ? wc_clean( $_POST['payment_method'] ) : 'stripe';
638
+		$payment_method = isset($_POST['payment_method']) ? wc_clean($_POST['payment_method']) : 'stripe';
639 639
 
640
-		return ( isset( $_POST[ 'wc-' . $payment_method . '-payment-token' ] ) && 'new' !== $_POST[ 'wc-' . $payment_method . '-payment-token' ] );
640
+		return (isset($_POST['wc-' . $payment_method . '-payment-token']) && 'new' !== $_POST['wc-' . $payment_method . '-payment-token']);
641 641
 	}
642 642
 
643 643
 	/**
@@ -653,64 +653,64 @@  discard block
 block discarded – undo
653 653
 	 * @throws Exception When card was not added or for and invalid card.
654 654
 	 * @return object
655 655
 	 */
656
-	public function prepare_source( $user_id, $force_save_source = false, $existing_customer_id = null ) {
657
-		$customer = new WC_Stripe_Customer( $user_id );
658
-		if ( ! empty( $existing_customer_id ) ) {
659
-			$customer->set_id( $existing_customer_id );
656
+	public function prepare_source($user_id, $force_save_source = false, $existing_customer_id = null) {
657
+		$customer = new WC_Stripe_Customer($user_id);
658
+		if ( ! empty($existing_customer_id)) {
659
+			$customer->set_id($existing_customer_id);
660 660
 		}
661 661
 
662
-		$force_save_source = apply_filters( 'wc_stripe_force_save_source', $force_save_source, $customer );
662
+		$force_save_source = apply_filters('wc_stripe_force_save_source', $force_save_source, $customer);
663 663
 		$source_object     = '';
664 664
 		$source_id         = '';
665 665
 		$wc_token_id       = false;
666
-		$payment_method    = isset( $_POST['payment_method'] ) ? wc_clean( $_POST['payment_method'] ) : 'stripe';
666
+		$payment_method    = isset($_POST['payment_method']) ? wc_clean($_POST['payment_method']) : 'stripe';
667 667
 		$is_token          = false;
668 668
 
669 669
 		// New CC info was entered and we have a new source to process.
670
-		if ( ! empty( $_POST['stripe_source'] ) ) {
671
-			$source_object = self::get_source_object( wc_clean( $_POST['stripe_source'] ) );
670
+		if ( ! empty($_POST['stripe_source'])) {
671
+			$source_object = self::get_source_object(wc_clean($_POST['stripe_source']));
672 672
 			$source_id     = $source_object->id;
673 673
 
674 674
 			// This checks to see if customer opted to save the payment method to file.
675
-			$maybe_saved_card = isset( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] ) && ! empty( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] );
675
+			$maybe_saved_card = isset($_POST['wc-' . $payment_method . '-new-payment-method']) && ! empty($_POST['wc-' . $payment_method . '-new-payment-method']);
676 676
 
677 677
 			/**
678 678
 			 * This is true if the user wants to store the card to their account.
679 679
 			 * Criteria to save to file is they are logged in, they opted to save or product requirements and the source is
680 680
 			 * actually reusable. Either that or force_save_source is true.
681 681
 			 */
682
-			if ( ( $user_id && $this->saved_cards && $maybe_saved_card && 'reusable' === $source_object->usage ) || $force_save_source ) {
683
-				$response = $customer->add_source( $source_object->id );
682
+			if (($user_id && $this->saved_cards && $maybe_saved_card && 'reusable' === $source_object->usage) || $force_save_source) {
683
+				$response = $customer->add_source($source_object->id);
684 684
 
685
-				if ( ! empty( $response->error ) ) {
686
-					throw new WC_Stripe_Exception( print_r( $response, true ), $this->get_localized_error_message_from_response( $response ) );
685
+				if ( ! empty($response->error)) {
686
+					throw new WC_Stripe_Exception(print_r($response, true), $this->get_localized_error_message_from_response($response));
687 687
 				}
688 688
 			}
689
-		} elseif ( $this->is_using_saved_payment_method() ) {
689
+		} elseif ($this->is_using_saved_payment_method()) {
690 690
 			// Use an existing token, and then process the payment.
691
-			$wc_token_id = wc_clean( $_POST[ 'wc-' . $payment_method . '-payment-token' ] );
692
-			$wc_token    = WC_Payment_Tokens::get( $wc_token_id );
691
+			$wc_token_id = wc_clean($_POST['wc-' . $payment_method . '-payment-token']);
692
+			$wc_token    = WC_Payment_Tokens::get($wc_token_id);
693 693
 
694
-			if ( ! $wc_token || $wc_token->get_user_id() !== get_current_user_id() ) {
695
-				WC()->session->set( 'refresh_totals', true );
696
-				throw new WC_Stripe_Exception( 'Invalid payment method', __( 'Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe' ) );
694
+			if ( ! $wc_token || $wc_token->get_user_id() !== get_current_user_id()) {
695
+				WC()->session->set('refresh_totals', true);
696
+				throw new WC_Stripe_Exception('Invalid payment method', __('Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe'));
697 697
 			}
698 698
 
699 699
 			$source_id = $wc_token->get_token();
700 700
 
701
-			if ( $this->is_type_legacy_card( $source_id ) ) {
701
+			if ($this->is_type_legacy_card($source_id)) {
702 702
 				$is_token = true;
703 703
 			}
704
-		} elseif ( isset( $_POST['stripe_token'] ) && 'new' !== $_POST['stripe_token'] ) {
705
-			$stripe_token     = wc_clean( $_POST['stripe_token'] );
706
-			$maybe_saved_card = isset( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] ) && ! empty( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] );
704
+		} elseif (isset($_POST['stripe_token']) && 'new' !== $_POST['stripe_token']) {
705
+			$stripe_token     = wc_clean($_POST['stripe_token']);
706
+			$maybe_saved_card = isset($_POST['wc-' . $payment_method . '-new-payment-method']) && ! empty($_POST['wc-' . $payment_method . '-new-payment-method']);
707 707
 
708 708
 			// This is true if the user wants to store the card to their account.
709
-			if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_save_source ) {
710
-				$response = $customer->add_source( $stripe_token );
709
+			if (($user_id && $this->saved_cards && $maybe_saved_card) || $force_save_source) {
710
+				$response = $customer->add_source($stripe_token);
711 711
 
712
-				if ( ! empty( $response->error ) ) {
713
-					throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
712
+				if ( ! empty($response->error)) {
713
+					throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
714 714
 				}
715 715
 				$source_id    = $response;
716 716
 			} else {
@@ -720,15 +720,15 @@  discard block
 block discarded – undo
720 720
 		}
721 721
 
722 722
 		$customer_id = $customer->get_id();
723
-		if ( ! $customer_id ) {
724
-			$customer->set_id( $customer->create_customer() );
723
+		if ( ! $customer_id) {
724
+			$customer->set_id($customer->create_customer());
725 725
 			$customer_id = $customer->get_id();
726 726
 		} else {
727 727
 			$customer_id = $customer->update_customer();
728 728
 		}
729 729
 
730
-		if ( empty( $source_object ) && ! $is_token ) {
731
-			$source_object = self::get_source_object( $source_id );
730
+		if (empty($source_object) && ! $is_token) {
731
+			$source_object = self::get_source_object($source_id);
732 732
 		}
733 733
 
734 734
 		return (object) array(
@@ -752,39 +752,39 @@  discard block
 block discarded – undo
752 752
 	 * @param object $order
753 753
 	 * @return object
754 754
 	 */
755
-	public function prepare_order_source( $order = null ) {
755
+	public function prepare_order_source($order = null) {
756 756
 		$stripe_customer = new WC_Stripe_Customer();
757 757
 		$stripe_source   = false;
758 758
 		$token_id        = false;
759 759
 		$source_object   = false;
760 760
 
761
-		if ( $order ) {
761
+		if ($order) {
762 762
 			$order_id = $order->get_id();
763 763
 
764
-			$stripe_customer_id = get_post_meta( $order_id, '_stripe_customer_id', true );
764
+			$stripe_customer_id = get_post_meta($order_id, '_stripe_customer_id', true);
765 765
 
766
-			if ( $stripe_customer_id ) {
767
-				$stripe_customer->set_id( $stripe_customer_id );
766
+			if ($stripe_customer_id) {
767
+				$stripe_customer->set_id($stripe_customer_id);
768 768
 			}
769 769
 
770
-			$source_id = $order->get_meta( '_stripe_source_id', true );
770
+			$source_id = $order->get_meta('_stripe_source_id', true);
771 771
 
772 772
 			// Since 4.0.0, we changed card to source so we need to account for that.
773
-			if ( empty( $source_id ) ) {
774
-				$source_id = $order->get_meta( '_stripe_card_id', true );
773
+			if (empty($source_id)) {
774
+				$source_id = $order->get_meta('_stripe_card_id', true);
775 775
 
776 776
 				// Take this opportunity to update the key name.
777
-				$order->update_meta_data( '_stripe_source_id', $source_id );
777
+				$order->update_meta_data('_stripe_source_id', $source_id);
778 778
 
779
-				if ( is_callable( array( $order, 'save' ) ) ) {
779
+				if (is_callable(array($order, 'save'))) {
780 780
 					$order->save();
781 781
 				}
782 782
 			}
783 783
 
784
-			if ( $source_id ) {
784
+			if ($source_id) {
785 785
 				$stripe_source = $source_id;
786
-				$source_object = WC_Stripe_API::retrieve( 'sources/' . $source_id );
787
-			} elseif ( apply_filters( 'wc_stripe_use_default_customer_source', true ) ) {
786
+				$source_object = WC_Stripe_API::retrieve('sources/' . $source_id);
787
+			} elseif (apply_filters('wc_stripe_use_default_customer_source', true)) {
788 788
 				/*
789 789
 				 * We can attempt to charge the customer's default source
790 790
 				 * by sending empty source id.
@@ -809,17 +809,17 @@  discard block
 block discarded – undo
809 809
 	 * @param WC_Order $order For to which the source applies.
810 810
 	 * @param stdClass $source Source information.
811 811
 	 */
812
-	public function save_source_to_order( $order, $source ) {
812
+	public function save_source_to_order($order, $source) {
813 813
 		// Store source in the order.
814
-		if ( $source->customer ) {
815
-			$order->update_meta_data( '_stripe_customer_id', $source->customer );
814
+		if ($source->customer) {
815
+			$order->update_meta_data('_stripe_customer_id', $source->customer);
816 816
 		}
817 817
 
818
-		if ( $source->source ) {
819
-			$order->update_meta_data( '_stripe_source_id', $source->source );
818
+		if ($source->source) {
819
+			$order->update_meta_data('_stripe_source_id', $source->source);
820 820
 		}
821 821
 
822
-		if ( is_callable( array( $order, 'save' ) ) ) {
822
+		if (is_callable(array($order, 'save'))) {
823 823
 			$order->save();
824 824
 		}
825 825
 	}
@@ -833,36 +833,36 @@  discard block
 block discarded – undo
833 833
 	 * @param object $order The order object
834 834
 	 * @param int $balance_transaction_id
835 835
 	 */
836
-	public function update_fees( $order, $balance_transaction_id ) {
837
-		$balance_transaction = WC_Stripe_API::retrieve( 'balance/history/' . $balance_transaction_id );
836
+	public function update_fees($order, $balance_transaction_id) {
837
+		$balance_transaction = WC_Stripe_API::retrieve('balance/history/' . $balance_transaction_id);
838 838
 
839
-		if ( empty( $balance_transaction->error ) ) {
840
-			if ( isset( $balance_transaction ) && isset( $balance_transaction->fee ) ) {
839
+		if (empty($balance_transaction->error)) {
840
+			if (isset($balance_transaction) && isset($balance_transaction->fee)) {
841 841
 				// Fees and Net needs to both come from Stripe to be accurate as the returned
842 842
 				// values are in the local currency of the Stripe account, not from WC.
843
-				$fee_refund = ! empty( $balance_transaction->fee ) ? WC_Stripe_Helper::format_balance_fee( $balance_transaction, 'fee' ) : 0;
844
-				$net_refund = ! empty( $balance_transaction->net ) ? WC_Stripe_Helper::format_balance_fee( $balance_transaction, 'net' ) : 0;
843
+				$fee_refund = ! empty($balance_transaction->fee) ? WC_Stripe_Helper::format_balance_fee($balance_transaction, 'fee') : 0;
844
+				$net_refund = ! empty($balance_transaction->net) ? WC_Stripe_Helper::format_balance_fee($balance_transaction, 'net') : 0;
845 845
 
846 846
 				// Current data fee & net.
847
-				$fee_current = WC_Stripe_Helper::get_stripe_fee( $order );
848
-				$net_current = WC_Stripe_Helper::get_stripe_net( $order );
847
+				$fee_current = WC_Stripe_Helper::get_stripe_fee($order);
848
+				$net_current = WC_Stripe_Helper::get_stripe_net($order);
849 849
 
850 850
 				// Calculation.
851 851
 				$fee = (float) $fee_current + (float) $fee_refund;
852 852
 				$net = (float) $net_current + (float) $net_refund;
853 853
 
854
-				WC_Stripe_Helper::update_stripe_fee( $order, $fee );
855
-				WC_Stripe_Helper::update_stripe_net( $order, $net );
854
+				WC_Stripe_Helper::update_stripe_fee($order, $fee);
855
+				WC_Stripe_Helper::update_stripe_net($order, $net);
856 856
 
857
-				$currency = ! empty( $balance_transaction->currency ) ? strtoupper( $balance_transaction->currency ) : null;
858
-				WC_Stripe_Helper::update_stripe_currency( $order, $currency );
857
+				$currency = ! empty($balance_transaction->currency) ? strtoupper($balance_transaction->currency) : null;
858
+				WC_Stripe_Helper::update_stripe_currency($order, $currency);
859 859
 
860
-				if ( is_callable( array( $order, 'save' ) ) ) {
860
+				if (is_callable(array($order, 'save'))) {
861 861
 					$order->save();
862 862
 				}
863 863
 			}
864 864
 		} else {
865
-			WC_Stripe_Logger::log( 'Unable to update fees/net meta for order: ' . $order->get_id() );
865
+			WC_Stripe_Logger::log('Unable to update fees/net meta for order: ' . $order->get_id());
866 866
 		}
867 867
 	}
868 868
 
@@ -875,93 +875,93 @@  discard block
 block discarded – undo
875 875
 	 * @param  float $amount
876 876
 	 * @return bool
877 877
 	 */
878
-	public function process_refund( $order_id, $amount = null, $reason = '' ) {
879
-		$order = wc_get_order( $order_id );
878
+	public function process_refund($order_id, $amount = null, $reason = '') {
879
+		$order = wc_get_order($order_id);
880 880
 
881
-		if ( ! $order ) {
881
+		if ( ! $order) {
882 882
 			return false;
883 883
 		}
884 884
 
885 885
 		$request = array();
886 886
 
887 887
 		$order_currency = $order->get_currency();
888
-		$captured       = $order->get_meta( '_stripe_charge_captured', true );
888
+		$captured       = $order->get_meta('_stripe_charge_captured', true);
889 889
 		$charge_id      = $order->get_transaction_id();
890 890
 
891
-		if ( ! $charge_id ) {
891
+		if ( ! $charge_id) {
892 892
 			return false;
893 893
 		}
894 894
 
895
-		if ( ! is_null( $amount ) ) {
896
-			$request['amount'] = WC_Stripe_Helper::get_stripe_amount( $amount, $order_currency );
895
+		if ( ! is_null($amount)) {
896
+			$request['amount'] = WC_Stripe_Helper::get_stripe_amount($amount, $order_currency);
897 897
 		}
898 898
 
899 899
 		// If order is only authorized, don't pass amount.
900
-		if ( 'yes' !== $captured ) {
901
-			unset( $request['amount'] );
900
+		if ('yes' !== $captured) {
901
+			unset($request['amount']);
902 902
 		}
903 903
 
904
-		if ( $reason ) {
904
+		if ($reason) {
905 905
 			$request['metadata'] = array(
906 906
 				'reason' => $reason,
907 907
 			);
908 908
 		}
909 909
 
910 910
 		$request['charge'] = $charge_id;
911
-		WC_Stripe_Logger::log( "Info: Beginning refund for order {$charge_id} for the amount of {$amount}" );
911
+		WC_Stripe_Logger::log("Info: Beginning refund for order {$charge_id} for the amount of {$amount}");
912 912
 
913
-		$request = apply_filters( 'wc_stripe_refund_request', $request, $order );
913
+		$request = apply_filters('wc_stripe_refund_request', $request, $order);
914 914
 
915
-		$intent = $this->get_intent_from_order( $order );
915
+		$intent = $this->get_intent_from_order($order);
916 916
 		$intent_cancelled = false;
917
-		if ( $intent ) {
917
+		if ($intent) {
918 918
 			// If the order has a Payment Intent pending capture, then the Intent itself must be refunded (cancelled), not the Charge
919
-			if ( ! empty( $intent->error ) ) {
919
+			if ( ! empty($intent->error)) {
920 920
 				$response = $intent;
921 921
 				$intent_cancelled = true;
922
-			} elseif ( 'requires_capture' === $intent->status ) {
922
+			} elseif ('requires_capture' === $intent->status) {
923 923
 				$result = WC_Stripe_API::request(
924 924
 					array(),
925 925
 					'payment_intents/' . $intent->id . '/cancel'
926 926
 				);
927 927
 				$intent_cancelled = true;
928 928
 
929
-				if ( ! empty( $result->error ) ) {
929
+				if ( ! empty($result->error)) {
930 930
 					$response = $result;
931 931
 				} else {
932
-					$charge = end( $result->charges->data );
933
-					$response = end( $charge->refunds->data );
932
+					$charge = end($result->charges->data);
933
+					$response = end($charge->refunds->data);
934 934
 				}
935 935
 			}
936 936
 		}
937 937
 
938
-		if ( ! $intent_cancelled ) {
939
-			$response = WC_Stripe_API::request( $request, 'refunds' );
938
+		if ( ! $intent_cancelled) {
939
+			$response = WC_Stripe_API::request($request, 'refunds');
940 940
 		}
941 941
 
942
-		if ( ! empty( $response->error ) ) {
943
-			WC_Stripe_Logger::log( 'Error: ' . $response->error->message );
942
+		if ( ! empty($response->error)) {
943
+			WC_Stripe_Logger::log('Error: ' . $response->error->message);
944 944
 
945 945
 			return $response;
946 946
 
947
-		} elseif ( ! empty( $response->id ) ) {
948
-			$order->update_meta_data( '_stripe_refund_id', $response->id );
947
+		} elseif ( ! empty($response->id)) {
948
+			$order->update_meta_data('_stripe_refund_id', $response->id);
949 949
 
950
-			$amount = wc_price( $response->amount / 100 );
950
+			$amount = wc_price($response->amount / 100);
951 951
 
952
-			if ( in_array( strtolower( $order->get_currency() ), WC_Stripe_Helper::no_decimal_currencies() ) ) {
953
-				$amount = wc_price( $response->amount );
952
+			if (in_array(strtolower($order->get_currency()), WC_Stripe_Helper::no_decimal_currencies())) {
953
+				$amount = wc_price($response->amount);
954 954
 			}
955 955
 
956
-			if ( isset( $response->balance_transaction ) ) {
957
-				$this->update_fees( $order, $response->balance_transaction );
956
+			if (isset($response->balance_transaction)) {
957
+				$this->update_fees($order, $response->balance_transaction);
958 958
 			}
959 959
 
960 960
 			/* translators: 1) dollar amount 2) transaction id 3) refund message */
961
-			$refund_message = ( isset( $captured ) && 'yes' === $captured ) ? sprintf( __( 'Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe' ), $amount, $response->id, $reason ) : __( 'Pre-Authorization Released', 'woocommerce-gateway-stripe' );
961
+			$refund_message = (isset($captured) && 'yes' === $captured) ? sprintf(__('Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe'), $amount, $response->id, $reason) : __('Pre-Authorization Released', 'woocommerce-gateway-stripe');
962 962
 
963
-			$order->add_order_note( $refund_message );
964
-			WC_Stripe_Logger::log( 'Success: ' . html_entity_decode( wp_strip_all_tags( $refund_message ) ) );
963
+			$order->add_order_note($refund_message);
964
+			WC_Stripe_Logger::log('Success: ' . html_entity_decode(wp_strip_all_tags($refund_message)));
965 965
 
966 966
 			return true;
967 967
 		}
@@ -976,46 +976,46 @@  discard block
 block discarded – undo
976 976
 	 */
977 977
 	public function add_payment_method() {
978 978
 		$error     = false;
979
-		$error_msg = __( 'There was a problem adding the payment method.', 'woocommerce-gateway-stripe' );
979
+		$error_msg = __('There was a problem adding the payment method.', 'woocommerce-gateway-stripe');
980 980
 		$source_id = '';
981 981
 
982
-		if ( empty( $_POST['stripe_source'] ) && empty( $_POST['stripe_token'] ) || ! is_user_logged_in() ) {
982
+		if (empty($_POST['stripe_source']) && empty($_POST['stripe_token']) || ! is_user_logged_in()) {
983 983
 			$error = true;
984 984
 		}
985 985
 
986
-		$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
986
+		$stripe_customer = new WC_Stripe_Customer(get_current_user_id());
987 987
 
988
-		$source = ! empty( $_POST['stripe_source'] ) ? wc_clean( $_POST['stripe_source'] ) : '';
988
+		$source = ! empty($_POST['stripe_source']) ? wc_clean($_POST['stripe_source']) : '';
989 989
 
990
-		$source_object = WC_Stripe_API::retrieve( 'sources/' . $source );
990
+		$source_object = WC_Stripe_API::retrieve('sources/' . $source);
991 991
 
992
-		if ( isset( $source_object ) ) {
993
-			if ( ! empty( $source_object->error ) ) {
992
+		if (isset($source_object)) {
993
+			if ( ! empty($source_object->error)) {
994 994
 				$error = true;
995 995
 			}
996 996
 
997 997
 			$source_id = $source_object->id;
998
-		} elseif ( isset( $_POST['stripe_token'] ) ) {
999
-			$source_id = wc_clean( $_POST['stripe_token'] );
998
+		} elseif (isset($_POST['stripe_token'])) {
999
+			$source_id = wc_clean($_POST['stripe_token']);
1000 1000
 		}
1001 1001
 
1002
-		$response = $stripe_customer->add_source( $source_id );
1002
+		$response = $stripe_customer->add_source($source_id);
1003 1003
 
1004
-		if ( ! $response || is_wp_error( $response ) || ! empty( $response->error ) ) {
1004
+		if ( ! $response || is_wp_error($response) || ! empty($response->error)) {
1005 1005
 			$error = true;
1006 1006
 		}
1007 1007
 
1008
-		if ( $error ) {
1009
-			wc_add_notice( $error_msg, 'error' );
1010
-			WC_Stripe_Logger::log( 'Add payment method Error: ' . $error_msg );
1008
+		if ($error) {
1009
+			wc_add_notice($error_msg, 'error');
1010
+			WC_Stripe_Logger::log('Add payment method Error: ' . $error_msg);
1011 1011
 			return;
1012 1012
 		}
1013 1013
 
1014
-		do_action( 'wc_stripe_add_payment_method_' . $_POST['payment_method'] . '_success', $source_id, $source_object );
1014
+		do_action('wc_stripe_add_payment_method_' . $_POST['payment_method'] . '_success', $source_id, $source_object);
1015 1015
 
1016 1016
 		return array(
1017 1017
 			'result'   => 'success',
1018
-			'redirect' => wc_get_endpoint_url( 'payment-methods' ),
1018
+			'redirect' => wc_get_endpoint_url('payment-methods'),
1019 1019
 		);
1020 1020
 	}
1021 1021
 
@@ -1032,10 +1032,10 @@  discard block
 block discarded – undo
1032 1032
 		 * Stripe expects Norwegian to only be passed NO.
1033 1033
 		 * But WP has different dialects.
1034 1034
 		 */
1035
-		if ( 'NO' === substr( $locale, 3, 2 ) ) {
1035
+		if ('NO' === substr($locale, 3, 2)) {
1036 1036
 			$locale = 'no';
1037 1037
 		} else {
1038
-			$locale = substr( get_locale(), 0, 2 );
1038
+			$locale = substr(get_locale(), 0, 2);
1039 1039
 		}
1040 1040
 
1041 1041
 		return $locale;
@@ -1049,9 +1049,9 @@  discard block
 block discarded – undo
1049 1049
 	 * @param string $idempotency_key
1050 1050
 	 * @param array $request
1051 1051
 	 */
1052
-	public function change_idempotency_key( $idempotency_key, $request ) {
1053
-		$customer = ! empty( $request['customer'] ) ? $request['customer'] : '';
1054
-		$source   = ! empty( $request['source'] ) ? $request['source'] : $customer;
1052
+	public function change_idempotency_key($idempotency_key, $request) {
1053
+		$customer = ! empty($request['customer']) ? $request['customer'] : '';
1054
+		$source   = ! empty($request['source']) ? $request['source'] : $customer;
1055 1055
 		$count    = $this->retry_interval;
1056 1056
 
1057 1057
 		return $request['metadata']['order_id'] . '-' . $count . '-' . $source;
@@ -1065,8 +1065,8 @@  discard block
 block discarded – undo
1065 1065
 	 * @since 4.0.6
1066 1066
 	 * @param array $headers
1067 1067
 	 */
1068
-	public function is_original_request( $headers ) {
1069
-		if ( $headers['original-request'] === $headers['request-id'] ) {
1068
+	public function is_original_request($headers) {
1069
+		if ($headers['original-request'] === $headers['request-id']) {
1070 1070
 			return true;
1071 1071
 		}
1072 1072
 
@@ -1080,27 +1080,27 @@  discard block
 block discarded – undo
1080 1080
 	 * @param object   $prepared_source The source that is used for the payment.
1081 1081
 	 * @return array                    The arguments for the request.
1082 1082
 	 */
1083
-	public function generate_create_intent_request( $order, $prepared_source ) {
1083
+	public function generate_create_intent_request($order, $prepared_source) {
1084 1084
 		// The request for a charge contains metadata for the intent.
1085
-		$full_request = $this->generate_payment_request( $order, $prepared_source );
1085
+		$full_request = $this->generate_payment_request($order, $prepared_source);
1086 1086
 
1087 1087
 		$request = array(
1088 1088
 			'source'               => $prepared_source->source,
1089
-			'amount'               => WC_Stripe_Helper::get_stripe_amount( $order->get_total() ),
1090
-			'currency'             => strtolower( $order->get_currency() ),
1089
+			'amount'               => WC_Stripe_Helper::get_stripe_amount($order->get_total()),
1090
+			'currency'             => strtolower($order->get_currency()),
1091 1091
 			'description'          => $full_request['description'],
1092 1092
 			'metadata'             => $full_request['metadata'],
1093
-			'capture_method'       => ( 'true' === $full_request['capture'] ) ? 'automatic' : 'manual',
1093
+			'capture_method'       => ('true' === $full_request['capture']) ? 'automatic' : 'manual',
1094 1094
 			'payment_method_types' => array(
1095 1095
 				'card',
1096 1096
 			),
1097 1097
 		);
1098 1098
 
1099
-		if ( $prepared_source->customer ) {
1099
+		if ($prepared_source->customer) {
1100 1100
 			$request['customer'] = $prepared_source->customer;
1101 1101
 		}
1102 1102
 
1103
-		if ( isset( $full_request['statement_descriptor'] ) ) {
1103
+		if (isset($full_request['statement_descriptor'])) {
1104 1104
 			$request['statement_descriptor'] = $full_request['statement_descriptor'];
1105 1105
 		}
1106 1106
 
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 		 * @param WC_Order $order
1113 1113
 		 * @param object $source
1114 1114
 		 */
1115
-		return apply_filters( 'wc_stripe_generate_create_intent_request', $request, $order, $prepared_source );
1115
+		return apply_filters('wc_stripe_generate_create_intent_request', $request, $order, $prepared_source);
1116 1116
 	}
1117 1117
 
1118 1118
 	/**
@@ -1121,21 +1121,21 @@  discard block
 block discarded – undo
1121 1121
 	 * @param WC_Order $order The order that is being paid for.
1122 1122
 	 * @return array          The level 3 data to send to Stripe.
1123 1123
 	 */
1124
-	public function get_level3_data_from_order( $order ) {
1124
+	public function get_level3_data_from_order($order) {
1125 1125
 		// Get the order items. Don't need their keys, only their values.
1126 1126
 		// Order item IDs are used as keys in the original order items array.
1127
-		$order_items = array_values( $order->get_items() );
1127
+		$order_items = array_values($order->get_items());
1128 1128
 		$currency    = $order->get_currency();
1129 1129
 
1130
-		$stripe_line_items = array_map(function( $item ) use ( $currency ) {
1130
+		$stripe_line_items = array_map(function($item) use ($currency) {
1131 1131
 			$product_id          = $item->get_variation_id()
1132 1132
 				? $item->get_variation_id()
1133 1133
 				: $item->get_product_id();
1134
-			$product_description = substr( $item->get_name(), 0, 26 );
1134
+			$product_description = substr($item->get_name(), 0, 26);
1135 1135
 			$quantity            = $item->get_quantity();
1136
-			$unit_cost           = WC_Stripe_Helper::get_stripe_amount( ( $item->get_subtotal() / $quantity ), $currency );
1137
-			$tax_amount          = WC_Stripe_Helper::get_stripe_amount( $item->get_total_tax(), $currency );
1138
-			$discount_amount     = WC_Stripe_Helper::get_stripe_amount( $item->get_subtotal() - $item->get_total(), $currency );
1136
+			$unit_cost           = WC_Stripe_Helper::get_stripe_amount(($item->get_subtotal() / $quantity), $currency);
1137
+			$tax_amount          = WC_Stripe_Helper::get_stripe_amount($item->get_total_tax(), $currency);
1138
+			$discount_amount     = WC_Stripe_Helper::get_stripe_amount($item->get_subtotal() - $item->get_total(), $currency);
1139 1139
 
1140 1140
 			return (object) array(
1141 1141
 				'product_code'        => (string) $product_id, // Up to 12 characters that uniquely identify the product.
@@ -1149,19 +1149,19 @@  discard block
 block discarded – undo
1149 1149
 
1150 1150
 		$level3_data = array(
1151 1151
 			'merchant_reference'   => $order->get_id(), // An alphanumeric string of up to  characters in length. This unique value is assigned by the merchant to identify the order. Also known as an “Order ID”.
1152
-			'shipping_amount'      => WC_Stripe_Helper::get_stripe_amount( (float) $order->get_shipping_total() + (float) $order->get_shipping_tax(), $currency), // The shipping cost, in cents, as a non-negative integer.
1152
+			'shipping_amount'      => WC_Stripe_Helper::get_stripe_amount((float) $order->get_shipping_total() + (float) $order->get_shipping_tax(), $currency), // The shipping cost, in cents, as a non-negative integer.
1153 1153
 			'line_items'           => $stripe_line_items,
1154 1154
 		);
1155 1155
 
1156 1156
 		// The customer’s U.S. shipping ZIP code.
1157 1157
 		$shipping_address_zip = $order->get_shipping_postcode();
1158
-		if ( $this->is_valid_us_zip_code( $shipping_address_zip ) ) {
1158
+		if ($this->is_valid_us_zip_code($shipping_address_zip)) {
1159 1159
 			$level3_data['shipping_address_zip'] = $shipping_address_zip;
1160 1160
 		}
1161 1161
 
1162 1162
 		// The merchant’s U.S. shipping ZIP code.
1163
-		$store_postcode = get_option( 'woocommerce_store_postcode' );
1164
-		if ( $this->is_valid_us_zip_code( $store_postcode ) ) {
1163
+		$store_postcode = get_option('woocommerce_store_postcode');
1164
+		if ($this->is_valid_us_zip_code($store_postcode)) {
1165 1165
 			$level3_data['shipping_from_zip'] = $store_postcode;
1166 1166
 		}
1167 1167
 
@@ -1175,20 +1175,20 @@  discard block
 block discarded – undo
1175 1175
 	 * @param object   $prepared_source The source that is used for the payment.
1176 1176
 	 * @return object                   An intent or an error.
1177 1177
 	 */
1178
-	public function create_intent( $order, $prepared_source ) {
1179
-		$request = $this->generate_create_intent_request( $order, $prepared_source );
1178
+	public function create_intent($order, $prepared_source) {
1179
+		$request = $this->generate_create_intent_request($order, $prepared_source);
1180 1180
 
1181 1181
 		// Create an intent that awaits an action.
1182
-		$intent = WC_Stripe_API::request( $request, 'payment_intents' );
1183
-		if ( ! empty( $intent->error ) ) {
1182
+		$intent = WC_Stripe_API::request($request, 'payment_intents');
1183
+		if ( ! empty($intent->error)) {
1184 1184
 			return $intent;
1185 1185
 		}
1186 1186
 
1187 1187
 		$order_id = $order->get_id();
1188
-		WC_Stripe_Logger::log( "Stripe PaymentIntent $intent->id initiated for order $order_id" );
1188
+		WC_Stripe_Logger::log("Stripe PaymentIntent $intent->id initiated for order $order_id");
1189 1189
 
1190 1190
 		// Save the intent ID to the order.
1191
-		$this->save_intent_to_order( $order, $intent );
1191
+		$this->save_intent_to_order($order, $intent);
1192 1192
 
1193 1193
 		return $intent;
1194 1194
 	}
@@ -1201,27 +1201,27 @@  discard block
 block discarded – undo
1201 1201
 	 * @param object   $prepared_source Currently selected source.
1202 1202
 	 * @return object                   An updated intent.
1203 1203
 	 */
1204
-	public function update_existing_intent( $intent, $order, $prepared_source ) {
1204
+	public function update_existing_intent($intent, $order, $prepared_source) {
1205 1205
 		$request = array();
1206 1206
 
1207
-		if ( $prepared_source->source !== $intent->source ) {
1207
+		if ($prepared_source->source !== $intent->source) {
1208 1208
 			$request['source'] = $prepared_source->source;
1209 1209
 		}
1210 1210
 
1211
-		$new_amount = WC_Stripe_Helper::get_stripe_amount( $order->get_total() );
1212
-		if ( $intent->amount !== $new_amount ) {
1211
+		$new_amount = WC_Stripe_Helper::get_stripe_amount($order->get_total());
1212
+		if ($intent->amount !== $new_amount) {
1213 1213
 			$request['amount'] = $new_amount;
1214 1214
 		}
1215 1215
 
1216
-		if ( $prepared_source->customer && $intent->customer !== $prepared_source->customer ) {
1216
+		if ($prepared_source->customer && $intent->customer !== $prepared_source->customer) {
1217 1217
 			$request['customer'] = $prepared_source->customer;
1218 1218
 		}
1219 1219
 
1220
-		if ( empty( $request ) ) {
1220
+		if (empty($request)) {
1221 1221
 			return $intent;
1222 1222
 		}
1223 1223
 
1224
-		$level3_data = $this->get_level3_data_from_order( $order );
1224
+		$level3_data = $this->get_level3_data_from_order($order);
1225 1225
 		return WC_Stripe_API::request_with_level3_data(
1226 1226
 			$request,
1227 1227
 			"payment_intents/$intent->id",
@@ -1239,8 +1239,8 @@  discard block
 block discarded – undo
1239 1239
 	 * @param object   $prepared_source The source that is being charged.
1240 1240
 	 * @return object                   Either an error or the updated intent.
1241 1241
 	 */
1242
-	public function confirm_intent( $intent, $order, $prepared_source ) {
1243
-		if ( 'requires_confirmation' !== $intent->status ) {
1242
+	public function confirm_intent($intent, $order, $prepared_source) {
1243
+		if ('requires_confirmation' !== $intent->status) {
1244 1244
 			return $intent;
1245 1245
 		}
1246 1246
 
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 			'source' => $prepared_source->source,
1250 1250
 		);
1251 1251
 
1252
-		$level3_data = $this->get_level3_data_from_order( $order );
1252
+		$level3_data = $this->get_level3_data_from_order($order);
1253 1253
 		$confirmed_intent = WC_Stripe_API::request_with_level3_data(
1254 1254
 			$confirm_request,
1255 1255
 			"payment_intents/$intent->id/confirm",
@@ -1257,16 +1257,16 @@  discard block
 block discarded – undo
1257 1257
 			$order
1258 1258
 		);
1259 1259
 
1260
-		if ( ! empty( $confirmed_intent->error ) ) {
1260
+		if ( ! empty($confirmed_intent->error)) {
1261 1261
 			return $confirmed_intent;
1262 1262
 		}
1263 1263
 
1264 1264
 		// Save a note about the status of the intent.
1265 1265
 		$order_id = $order->get_id();
1266
-		if ( 'succeeded' === $confirmed_intent->status ) {
1267
-			WC_Stripe_Logger::log( "Stripe PaymentIntent $intent->id succeeded for order $order_id" );
1268
-		} elseif ( 'requires_action' === $confirmed_intent->status ) {
1269
-			WC_Stripe_Logger::log( "Stripe PaymentIntent $intent->id requires authentication for order $order_id" );
1266
+		if ('succeeded' === $confirmed_intent->status) {
1267
+			WC_Stripe_Logger::log("Stripe PaymentIntent $intent->id succeeded for order $order_id");
1268
+		} elseif ('requires_action' === $confirmed_intent->status) {
1269
+			WC_Stripe_Logger::log("Stripe PaymentIntent $intent->id requires authentication for order $order_id");
1270 1270
 		}
1271 1271
 
1272 1272
 		return $confirmed_intent;
@@ -1279,10 +1279,10 @@  discard block
 block discarded – undo
1279 1279
 	 * @param WC_Order $order For to which the source applies.
1280 1280
 	 * @param stdClass $intent Payment intent information.
1281 1281
 	 */
1282
-	public function save_intent_to_order( $order, $intent ) {
1283
-		$order->update_meta_data( '_stripe_intent_id', $intent->id );
1282
+	public function save_intent_to_order($order, $intent) {
1283
+		$order->update_meta_data('_stripe_intent_id', $intent->id);
1284 1284
 
1285
-		if ( is_callable( array( $order, 'save' ) ) ) {
1285
+		if (is_callable(array($order, 'save'))) {
1286 1286
 			$order->save();
1287 1287
 		}
1288 1288
 	}
@@ -1294,18 +1294,18 @@  discard block
 block discarded – undo
1294 1294
 	 * @param WC_Order $order The order to retrieve an intent for.
1295 1295
 	 * @return obect|bool     Either the intent object or `false`.
1296 1296
 	 */
1297
-	public function get_intent_from_order( $order ) {
1298
-		$intent_id = $order->get_meta( '_stripe_intent_id' );
1297
+	public function get_intent_from_order($order) {
1298
+		$intent_id = $order->get_meta('_stripe_intent_id');
1299 1299
 
1300
-		if ( $intent_id ) {
1301
-			return $this->get_intent( 'payment_intents', $intent_id );
1300
+		if ($intent_id) {
1301
+			return $this->get_intent('payment_intents', $intent_id);
1302 1302
 		}
1303 1303
 
1304 1304
 		// The order doesn't have a payment intent, but it may have a setup intent.
1305
-		$intent_id = $order->get_meta( '_stripe_setup_intent' );
1305
+		$intent_id = $order->get_meta('_stripe_setup_intent');
1306 1306
 
1307
-		if ( $intent_id ) {
1308
-			return $this->get_intent( 'setup_intents', $intent_id );
1307
+		if ($intent_id) {
1308
+			return $this->get_intent('setup_intents', $intent_id);
1309 1309
 		}
1310 1310
 
1311 1311
 		return false;
@@ -1319,15 +1319,15 @@  discard block
 block discarded – undo
1319 1319
 	 * @return object|bool 			Either the intent object or `false`.
1320 1320
 	 * @throws Exception 			Throws exception for unknown $intent_type.
1321 1321
 	 */
1322
-	private function get_intent( $intent_type, $intent_id ) {
1323
-		if ( ! in_array( $intent_type, [ 'payment_intents', 'setup_intents' ] ) ) {
1324
-			throw new Exception( "Failed to get intent of type $intent_type. Type is not allowed" );
1322
+	private function get_intent($intent_type, $intent_id) {
1323
+		if ( ! in_array($intent_type, ['payment_intents', 'setup_intents'])) {
1324
+			throw new Exception("Failed to get intent of type $intent_type. Type is not allowed");
1325 1325
 		}
1326 1326
 
1327
-		$response = WC_Stripe_API::request( array(), "$intent_type/$intent_id", 'GET' );
1327
+		$response = WC_Stripe_API::request(array(), "$intent_type/$intent_id", 'GET');
1328 1328
 
1329
-		if ( $response && isset( $response->{ 'error' } ) ) {
1330
-			$error_response_message = print_r( $response, true );
1329
+		if ($response && isset($response->{ 'error' } )) {
1330
+			$error_response_message = print_r($response, true);
1331 1331
 			WC_Stripe_Logger::log("Failed to get Stripe intent $intent_type/$intent_id.");
1332 1332
 			WC_Stripe_Logger::log("Response: $error_response_message");
1333 1333
 			return false;
@@ -1344,18 +1344,18 @@  discard block
 block discarded – undo
1344 1344
 	 * @param stdClass $intent The intent that is being processed.
1345 1345
 	 * @return bool            A flag that indicates whether the order is already locked.
1346 1346
 	 */
1347
-	public function lock_order_payment( $order, $intent = null ) {
1347
+	public function lock_order_payment($order, $intent = null) {
1348 1348
 		$order_id       = $order->get_id();
1349 1349
 		$transient_name = 'wc_stripe_processing_intent_' . $order_id;
1350
-		$processing     = get_transient( $transient_name );
1350
+		$processing     = get_transient($transient_name);
1351 1351
 
1352 1352
 		// Block the process if the same intent is already being handled.
1353
-		if ( "-1" === $processing || ( isset( $intent->id ) && $processing === $intent->id ) ) {
1353
+		if ("-1" === $processing || (isset($intent->id) && $processing === $intent->id)) {
1354 1354
 			return true;
1355 1355
 		}
1356 1356
 
1357 1357
 		// Save the new intent as a transient, eventually overwriting another one.
1358
-		set_transient( $transient_name, empty( $intent ) ? '-1' : $intent->id, 5 * MINUTE_IN_SECONDS );
1358
+		set_transient($transient_name, empty($intent) ? '-1' : $intent->id, 5 * MINUTE_IN_SECONDS);
1359 1359
 
1360 1360
 		return false;
1361 1361
 	}
@@ -1366,9 +1366,9 @@  discard block
 block discarded – undo
1366 1366
 	 * @since 4.2
1367 1367
 	 * @param WC_Order $order The order that is being unlocked.
1368 1368
 	 */
1369
-	public function unlock_order_payment( $order ) {
1369
+	public function unlock_order_payment($order) {
1370 1370
 		$order_id = $order->get_id();
1371
-		delete_transient( 'wc_stripe_processing_intent_' . $order_id );
1371
+		delete_transient('wc_stripe_processing_intent_' . $order_id);
1372 1372
 	}
1373 1373
 
1374 1374
 	/**
@@ -1378,9 +1378,9 @@  discard block
 block discarded – undo
1378 1378
 	 * @param object $response The response from Stripe.
1379 1379
 	 * @return boolean Whether or not it's a 'authentication_required' error
1380 1380
 	 */
1381
-	public function is_authentication_required_for_payment( $response ) {
1382
-		return ( ! empty( $response->error ) && 'authentication_required' === $response->error->code )
1383
-			|| ( ! empty( $response->last_payment_error ) && 'authentication_required' === $response->last_payment_error->code );
1381
+	public function is_authentication_required_for_payment($response) {
1382
+		return ( ! empty($response->error) && 'authentication_required' === $response->error->code)
1383
+			|| ( ! empty($response->last_payment_error) && 'authentication_required' === $response->last_payment_error->code);
1384 1384
 	}
1385 1385
 
1386 1386
 	/**
@@ -1390,18 +1390,18 @@  discard block
 block discarded – undo
1390 1390
 	 * @param object   $prepared_source The source, entered/chosen by the customer.
1391 1391
 	 * @return string                   The client secret of the intent, used for confirmation in JS.
1392 1392
 	 */
1393
-	public function setup_intent( $order, $prepared_source ) {
1393
+	public function setup_intent($order, $prepared_source) {
1394 1394
 		$order_id     = $order->get_id();
1395
-		$setup_intent = WC_Stripe_API::request( array(
1395
+		$setup_intent = WC_Stripe_API::request(array(
1396 1396
 			'payment_method' => $prepared_source->source,
1397 1397
 			'customer'       => $prepared_source->customer,
1398 1398
 			'confirm'        => 'true',
1399
-		), 'setup_intents' );
1399
+		), 'setup_intents');
1400 1400
 
1401
-		if ( is_wp_error( $setup_intent ) ) {
1402
-			WC_Stripe_Logger::log( "Unable to create SetupIntent for Order #$order_id: " . print_r( $setup_intent, true ) );
1403
-		} elseif ( 'requires_action' === $setup_intent->status ) {
1404
-			$order->update_meta_data( '_stripe_setup_intent', $setup_intent->id );
1401
+		if (is_wp_error($setup_intent)) {
1402
+			WC_Stripe_Logger::log("Unable to create SetupIntent for Order #$order_id: " . print_r($setup_intent, true));
1403
+		} elseif ('requires_action' === $setup_intent->status) {
1404
+			$order->update_meta_data('_stripe_setup_intent', $setup_intent->id);
1405 1405
 			$order->save();
1406 1406
 
1407 1407
 			return $setup_intent->client_secret;
@@ -1416,12 +1416,12 @@  discard block
 block discarded – undo
1416 1416
 	 * @param float    $amount          The amount to charge. If not specified, it will be read from the order.
1417 1417
 	 * @return object                   An intent or an error.
1418 1418
 	 */
1419
-	public function create_and_confirm_intent_for_off_session( $order, $prepared_source, $amount = NULL ) {
1419
+	public function create_and_confirm_intent_for_off_session($order, $prepared_source, $amount = NULL) {
1420 1420
 		// The request for a charge contains metadata for the intent.
1421
-		$full_request = $this->generate_payment_request( $order, $prepared_source );
1421
+		$full_request = $this->generate_payment_request($order, $prepared_source);
1422 1422
 
1423 1423
 		$request = array(
1424
-			'amount'               => $amount ? WC_Stripe_Helper::get_stripe_amount( $amount, $full_request['currency'] ) : $full_request['amount'],
1424
+			'amount'               => $amount ? WC_Stripe_Helper::get_stripe_amount($amount, $full_request['currency']) : $full_request['amount'],
1425 1425
 			'currency'             => $full_request['currency'],
1426 1426
 			'description'          => $full_request['description'],
1427 1427
 			'metadata'             => $full_request['metadata'],
@@ -1433,44 +1433,44 @@  discard block
 block discarded – undo
1433 1433
 			'confirmation_method'  => 'automatic',
1434 1434
 		);
1435 1435
 
1436
-		if ( isset( $full_request['statement_descriptor'] ) ) {
1436
+		if (isset($full_request['statement_descriptor'])) {
1437 1437
 			$request['statement_descriptor'] = $full_request['statement_descriptor'];
1438 1438
 		}
1439 1439
 
1440
-		if ( isset( $full_request['customer'] ) ) {
1440
+		if (isset($full_request['customer'])) {
1441 1441
 			$request['customer'] = $full_request['customer'];
1442 1442
 		}
1443 1443
 
1444
-		if ( isset( $full_request['source'] ) ) {
1444
+		if (isset($full_request['source'])) {
1445 1445
 			$request['source'] = $full_request['source'];
1446 1446
 		}
1447 1447
 
1448
-		$level3_data = $this->get_level3_data_from_order( $order );
1448
+		$level3_data = $this->get_level3_data_from_order($order);
1449 1449
 		$intent = WC_Stripe_API::request_with_level3_data(
1450 1450
 			$request,
1451 1451
 			'payment_intents',
1452 1452
 			$level3_data,
1453 1453
 			$order
1454 1454
 		);
1455
-		$is_authentication_required = $this->is_authentication_required_for_payment( $intent );
1455
+		$is_authentication_required = $this->is_authentication_required_for_payment($intent);
1456 1456
 
1457
-		if ( ! empty( $intent->error ) && ! $is_authentication_required ) {
1457
+		if ( ! empty($intent->error) && ! $is_authentication_required) {
1458 1458
 			return $intent;
1459 1459
 		}
1460 1460
 
1461
-		$intent_id      = ( ! empty( $intent->error )
1461
+		$intent_id = ( ! empty($intent->error)
1462 1462
 			? $intent->error->payment_intent->id
1463 1463
 			: $intent->id
1464 1464
 		);
1465
-		$payment_intent = ( ! empty( $intent->error )
1465
+		$payment_intent = ( ! empty($intent->error)
1466 1466
 			? $intent->error->payment_intent
1467 1467
 			: $intent
1468 1468
 		);
1469
-		$order_id       = $order->get_id();
1470
-		WC_Stripe_Logger::log( "Stripe PaymentIntent $intent_id initiated for order $order_id" );
1469
+		$order_id = $order->get_id();
1470
+		WC_Stripe_Logger::log("Stripe PaymentIntent $intent_id initiated for order $order_id");
1471 1471
 
1472 1472
 		// Save the intent ID to the order.
1473
-		$this->save_intent_to_order( $order, $payment_intent );
1473
+		$this->save_intent_to_order($order, $payment_intent);
1474 1474
 
1475 1475
 		return $intent;
1476 1476
 	}
@@ -1481,13 +1481,13 @@  discard block
 block discarded – undo
1481 1481
 	 * Fix renewal for existing subscriptions affected by https://github.com/woocommerce/woocommerce-gateway-stripe/issues/1072.
1482 1482
 	 * @param int $order_id subscription renewal order id.
1483 1483
 	 */
1484
-	public function ensure_subscription_has_customer_id( $order_id ) {
1485
-		$subscriptions_ids = wcs_get_subscriptions_for_order( $order_id, array( 'order_type' => 'any' ) );
1486
-		foreach( $subscriptions_ids as $subscription_id => $subscription ) {
1487
-			if ( ! metadata_exists( 'post', $subscription_id, '_stripe_customer_id' ) ) {
1488
-				$stripe_customer = new WC_Stripe_Customer( $subscription->get_user_id() );
1489
-				update_post_meta( $subscription_id, '_stripe_customer_id', $stripe_customer->get_id() );
1490
-				update_post_meta( $order_id, '_stripe_customer_id', $stripe_customer->get_id() );
1484
+	public function ensure_subscription_has_customer_id($order_id) {
1485
+		$subscriptions_ids = wcs_get_subscriptions_for_order($order_id, array('order_type' => 'any'));
1486
+		foreach ($subscriptions_ids as $subscription_id => $subscription) {
1487
+			if ( ! metadata_exists('post', $subscription_id, '_stripe_customer_id')) {
1488
+				$stripe_customer = new WC_Stripe_Customer($subscription->get_user_id());
1489
+				update_post_meta($subscription_id, '_stripe_customer_id', $stripe_customer->get_id());
1490
+				update_post_meta($order_id, '_stripe_customer_id', $stripe_customer->get_id());
1491 1491
 			}
1492 1492
 		}
1493 1493
 	}
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
 	 * @param string $zip The ZIP code to verify.
1498 1498
 	 * @return boolean
1499 1499
 	 */
1500
-	public function is_valid_us_zip_code( $zip ) {
1501
-		return ! empty( $zip ) && preg_match( '/^\d{5,5}(-\d{4,4})?$/', $zip );
1500
+	public function is_valid_us_zip_code($zip) {
1501
+		return ! empty($zip) && preg_match('/^\d{5,5}(-\d{4,4})?$/', $zip);
1502 1502
 	}
1503 1503
 }
Please login to merge, or discard this patch.
includes/class-wc-stripe-helper.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@
 block discarded – undo
231 231
 	 * List of currencies supported by Stripe that has no decimals
232 232
 	 * https://stripe.com/docs/currencies#zero-decimal from https://stripe.com/docs/currencies#presentment-currencies
233 233
 	 *
234
-	 * @return array $currencies
234
+	 * @return string[] $currencies
235 235
 	 */
236 236
 	public static function no_decimal_currencies() {
237 237
 		return array(
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 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,12 +22,12 @@  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
-		return $order->get_meta( self::META_NAME_STRIPE_CURRENCY, true );
30
+		return $order->get_meta(self::META_NAME_STRIPE_CURRENCY, true);
31 31
 	}
32 32
 
33 33
 	/**
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 	 * @param object $order
38 38
 	 * @param string $currency
39 39
 	 */
40
-	public static function update_stripe_currency( $order = null, $currency ) {
41
-		if ( is_null( $order ) ) {
40
+	public static function update_stripe_currency($order = null, $currency) {
41
+		if (is_null($order)) {
42 42
 			return false;
43 43
 		}
44 44
 
45
-		$order->update_meta_data( self::META_NAME_STRIPE_CURRENCY, $currency );
45
+		$order->update_meta_data(self::META_NAME_STRIPE_CURRENCY, $currency);
46 46
 	}
47 47
 
48 48
 	/**
@@ -52,20 +52,20 @@  discard block
 block discarded – undo
52 52
 	 * @param object $order
53 53
 	 * @return string $amount
54 54
 	 */
55
-	public static function get_stripe_fee( $order = null ) {
56
-		if ( is_null( $order ) ) {
55
+	public static function get_stripe_fee($order = null) {
56
+		if (is_null($order)) {
57 57
 			return false;
58 58
 		}
59 59
 
60
-		$amount = $order->get_meta( self::META_NAME_FEE, true );
60
+		$amount = $order->get_meta(self::META_NAME_FEE, true);
61 61
 
62 62
 		// If not found let's check for legacy name.
63
-		if ( empty( $amount ) ) {
64
-			$amount = $order->get_meta( self::LEGACY_META_NAME_FEE, true );
63
+		if (empty($amount)) {
64
+			$amount = $order->get_meta(self::LEGACY_META_NAME_FEE, true);
65 65
 
66 66
 			// If found update to new name.
67
-			if ( $amount ) {
68
-				self::update_stripe_fee( $order, $amount );
67
+			if ($amount) {
68
+				self::update_stripe_fee($order, $amount);
69 69
 			}
70 70
 		}
71 71
 
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 	 * @param object $order
80 80
 	 * @param float $amount
81 81
 	 */
82
-	public static function update_stripe_fee( $order = null, $amount = 0.0 ) {
83
-		if ( is_null( $order ) ) {
82
+	public static function update_stripe_fee($order = null, $amount = 0.0) {
83
+		if (is_null($order)) {
84 84
 			return false;
85 85
 		}
86 86
 
87
-		$order->update_meta_data( self::META_NAME_FEE, $amount );
87
+		$order->update_meta_data(self::META_NAME_FEE, $amount);
88 88
 	}
89 89
 
90 90
 	/**
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 	 * @since 4.1.0
94 94
 	 * @param object $order
95 95
 	 */
96
-	public static function delete_stripe_fee( $order = null ) {
97
-		if ( is_null( $order ) ) {
96
+	public static function delete_stripe_fee($order = null) {
97
+		if (is_null($order)) {
98 98
 			return false;
99 99
 		}
100 100
 
101 101
 		$order_id = $order->get_id();
102 102
 
103
-		delete_post_meta( $order_id, self::META_NAME_FEE );
104
-		delete_post_meta( $order_id, self::LEGACY_META_NAME_FEE );
103
+		delete_post_meta($order_id, self::META_NAME_FEE);
104
+		delete_post_meta($order_id, self::LEGACY_META_NAME_FEE);
105 105
 	}
106 106
 
107 107
 	/**
@@ -111,20 +111,20 @@  discard block
 block discarded – undo
111 111
 	 * @param object $order
112 112
 	 * @return string $amount
113 113
 	 */
114
-	public static function get_stripe_net( $order = null ) {
115
-		if ( is_null( $order ) ) {
114
+	public static function get_stripe_net($order = null) {
115
+		if (is_null($order)) {
116 116
 			return false;
117 117
 		}
118 118
 
119
-		$amount = $order->get_meta( self::META_NAME_NET, true );
119
+		$amount = $order->get_meta(self::META_NAME_NET, true);
120 120
 
121 121
 		// If not found let's check for legacy name.
122
-		if ( empty( $amount ) ) {
123
-			$amount = $order->get_meta( self::LEGACY_META_NAME_NET, true );
122
+		if (empty($amount)) {
123
+			$amount = $order->get_meta(self::LEGACY_META_NAME_NET, true);
124 124
 
125 125
 			// If found update to new name.
126
-			if ( $amount ) {
127
-				self::update_stripe_net( $order, $amount );
126
+			if ($amount) {
127
+				self::update_stripe_net($order, $amount);
128 128
 			}
129 129
 		}
130 130
 
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
 	 * @param object $order
139 139
 	 * @param float $amount
140 140
 	 */
141
-	public static function update_stripe_net( $order = null, $amount = 0.0 ) {
142
-		if ( is_null( $order ) ) {
141
+	public static function update_stripe_net($order = null, $amount = 0.0) {
142
+		if (is_null($order)) {
143 143
 			return false;
144 144
 		}
145 145
 
146
-		$order->update_meta_data( self::META_NAME_NET, $amount );
146
+		$order->update_meta_data(self::META_NAME_NET, $amount);
147 147
 	}
148 148
 
149 149
 	/**
@@ -152,15 +152,15 @@  discard block
 block discarded – undo
152 152
 	 * @since 4.1.0
153 153
 	 * @param object $order
154 154
 	 */
155
-	public static function delete_stripe_net( $order = null ) {
156
-		if ( is_null( $order ) ) {
155
+	public static function delete_stripe_net($order = null) {
156
+		if (is_null($order)) {
157 157
 			return false;
158 158
 		}
159 159
 
160 160
 		$order_id = $order->get_id();
161 161
 
162
-		delete_post_meta( $order_id, self::META_NAME_NET );
163
-		delete_post_meta( $order_id, self::LEGACY_META_NAME_NET );
162
+		delete_post_meta($order_id, self::META_NAME_NET);
163
+		delete_post_meta($order_id, self::LEGACY_META_NAME_NET);
164 164
 	}
165 165
 
166 166
 	/**
@@ -171,15 +171,15 @@  discard block
 block discarded – undo
171 171
 	 *
172 172
 	 * @return float|int
173 173
 	 */
174
-	public static function get_stripe_amount( $total, $currency = '' ) {
175
-		if ( ! $currency ) {
174
+	public static function get_stripe_amount($total, $currency = '') {
175
+		if ( ! $currency) {
176 176
 			$currency = get_woocommerce_currency();
177 177
 		}
178 178
 
179
-		if ( in_array( strtolower( $currency ), self::no_decimal_currencies() ) ) {
180
-			return absint( $total );
179
+		if (in_array(strtolower($currency), self::no_decimal_currencies())) {
180
+			return absint($total);
181 181
 		} else {
182
-			return absint( wc_format_decimal( ( (float) $total * 100 ), wc_get_price_decimals() ) ); // In cents.
182
+			return absint(wc_format_decimal(((float) $total * 100), wc_get_price_decimals())); // In cents.
183 183
 		}
184 184
 	}
185 185
 
@@ -194,24 +194,24 @@  discard block
 block discarded – undo
194 194
 		return apply_filters(
195 195
 			'wc_stripe_localized_messages',
196 196
 			array(
197
-				'invalid_number'           => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ),
198
-				'invalid_expiry_month'     => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ),
199
-				'invalid_expiry_year'      => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ),
200
-				'invalid_cvc'              => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ),
201
-				'incorrect_number'         => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ),
202
-				'incomplete_number'        => __( 'The card number is incomplete.', 'woocommerce-gateway-stripe' ),
203
-				'incomplete_cvc'           => __( 'The card\'s security code is incomplete.', 'woocommerce-gateway-stripe' ),
204
-				'incomplete_expiry'        => __( 'The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe' ),
205
-				'expired_card'             => __( 'The card has expired.', 'woocommerce-gateway-stripe' ),
206
-				'incorrect_cvc'            => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ),
207
-				'incorrect_zip'            => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ),
208
-				'invalid_expiry_year_past' => __( 'The card\'s expiration year is in the past', 'woocommerce-gateway-stripe' ),
209
-				'card_declined'            => __( 'The card was declined.', 'woocommerce-gateway-stripe' ),
210
-				'missing'                  => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ),
211
-				'processing_error'         => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ),
212
-				'invalid_request_error'    => __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ),
213
-				'invalid_sofort_country'   => __( 'The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe' ),
214
-				'email_invalid'            => __( 'Invalid email address, please correct and try again.', 'woocommerce-gateway-stripe' ),
197
+				'invalid_number'           => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'),
198
+				'invalid_expiry_month'     => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'),
199
+				'invalid_expiry_year'      => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'),
200
+				'invalid_cvc'              => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'),
201
+				'incorrect_number'         => __('The card number is incorrect.', 'woocommerce-gateway-stripe'),
202
+				'incomplete_number'        => __('The card number is incomplete.', 'woocommerce-gateway-stripe'),
203
+				'incomplete_cvc'           => __('The card\'s security code is incomplete.', 'woocommerce-gateway-stripe'),
204
+				'incomplete_expiry'        => __('The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe'),
205
+				'expired_card'             => __('The card has expired.', 'woocommerce-gateway-stripe'),
206
+				'incorrect_cvc'            => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'),
207
+				'incorrect_zip'            => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'),
208
+				'invalid_expiry_year_past' => __('The card\'s expiration year is in the past', 'woocommerce-gateway-stripe'),
209
+				'card_declined'            => __('The card was declined.', 'woocommerce-gateway-stripe'),
210
+				'missing'                  => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'),
211
+				'processing_error'         => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'),
212
+				'invalid_request_error'    => __('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe'),
213
+				'invalid_sofort_country'   => __('The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe'),
214
+				'email_invalid'            => __('Invalid email address, please correct and try again.', 'woocommerce-gateway-stripe'),
215 215
 			)
216 216
 		);
217 217
 	}
@@ -252,24 +252,24 @@  discard block
 block discarded – undo
252 252
 	 * @param string $type Type of number to format
253 253
 	 * @return string
254 254
 	 */
255
-	public static function format_balance_fee( $balance_transaction, $type = 'fee' ) {
256
-		if ( ! is_object( $balance_transaction ) ) {
255
+	public static function format_balance_fee($balance_transaction, $type = 'fee') {
256
+		if ( ! is_object($balance_transaction)) {
257 257
 			return;
258 258
 		}
259 259
 
260
-		if ( in_array( strtolower( $balance_transaction->currency ), self::no_decimal_currencies() ) ) {
261
-			if ( 'fee' === $type ) {
260
+		if (in_array(strtolower($balance_transaction->currency), self::no_decimal_currencies())) {
261
+			if ('fee' === $type) {
262 262
 				return $balance_transaction->fee;
263 263
 			}
264 264
 
265 265
 			return $balance_transaction->net;
266 266
 		}
267 267
 
268
-		if ( 'fee' === $type ) {
269
-			return number_format( $balance_transaction->fee / 100, 2, '.', '' );
268
+		if ('fee' === $type) {
269
+			return number_format($balance_transaction->fee / 100, 2, '.', '');
270 270
 		}
271 271
 
272
-		return number_format( $balance_transaction->net / 100, 2, '.', '' );
272
+		return number_format($balance_transaction->net / 100, 2, '.', '');
273 273
 	}
274 274
 
275 275
 	/**
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 */
278 278
 	public static function get_minimum_amount() {
279 279
 		// Check order amount
280
-		switch ( get_woocommerce_currency() ) {
280
+		switch (get_woocommerce_currency()) {
281 281
 			case 'USD':
282 282
 			case 'CAD':
283 283
 			case 'EUR':
@@ -322,14 +322,14 @@  discard block
 block discarded – undo
322 322
 	 * @param string $method The payment method to get the settings from.
323 323
 	 * @param string $setting The name of the setting to get.
324 324
 	 */
325
-	public static function get_settings( $method = null, $setting = null ) {
326
-		$all_settings = null === $method ? get_option( 'woocommerce_stripe_settings', array() ) : get_option( 'woocommerce_stripe_' . $method . '_settings', array() );
325
+	public static function get_settings($method = null, $setting = null) {
326
+		$all_settings = null === $method ? get_option('woocommerce_stripe_settings', array()) : get_option('woocommerce_stripe_' . $method . '_settings', array());
327 327
 
328
-		if ( null === $setting ) {
328
+		if (null === $setting) {
329 329
 			return $all_settings;
330 330
 		}
331 331
 
332
-		return isset( $all_settings[ $setting ] ) ? $all_settings[ $setting ] : '';
332
+		return isset($all_settings[$setting]) ? $all_settings[$setting] : '';
333 333
 	}
334 334
 
335 335
 	/**
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	 * @return bool
340 340
 	 */
341 341
 	public static function is_pre_orders_exists() {
342
-		return class_exists( 'WC_Pre_Orders_Order' );
342
+		return class_exists('WC_Pre_Orders_Order');
343 343
 	}
344 344
 
345 345
 	/**
@@ -349,8 +349,8 @@  discard block
 block discarded – undo
349 349
 	 * @param string $version Version to check against.
350 350
 	 * @return bool
351 351
 	 */
352
-	public static function is_wc_lt( $version ) {
353
-		return version_compare( WC_VERSION, $version, '<' );
352
+	public static function is_wc_lt($version) {
353
+		return version_compare(WC_VERSION, $version, '<');
354 354
 	}
355 355
 
356 356
 	/**
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 * @return string
364 364
 	 */
365 365
 	public static function get_webhook_url() {
366
-		return add_query_arg( 'wc-api', 'wc_stripe', trailingslashit( get_home_url() ) );
366
+		return add_query_arg('wc-api', 'wc_stripe', trailingslashit(get_home_url()));
367 367
 	}
368 368
 
369 369
 	/**
@@ -373,13 +373,13 @@  discard block
 block discarded – undo
373 373
 	 * @version 4.0.0
374 374
 	 * @param string $source_id
375 375
 	 */
376
-	public static function get_order_by_source_id( $source_id ) {
376
+	public static function get_order_by_source_id($source_id) {
377 377
 		global $wpdb;
378 378
 
379
-		$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' ) );
379
+		$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'));
380 380
 
381
-		if ( ! empty( $order_id ) ) {
382
-			return wc_get_order( $order_id );
381
+		if ( ! empty($order_id)) {
382
+			return wc_get_order($order_id);
383 383
 		}
384 384
 
385 385
 		return false;
@@ -392,17 +392,17 @@  discard block
 block discarded – undo
392 392
 	 * @since 4.1.16 Return false if charge_id is empty.
393 393
 	 * @param string $charge_id
394 394
 	 */
395
-	public static function get_order_by_charge_id( $charge_id ) {
395
+	public static function get_order_by_charge_id($charge_id) {
396 396
 		global $wpdb;
397 397
 
398
-		if ( empty( $charge_id ) ) {
398
+		if (empty($charge_id)) {
399 399
 			return false;
400 400
 		}
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", $charge_id, '_transaction_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", $charge_id, '_transaction_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,13 +415,13 @@  discard block
 block discarded – undo
415 415
 	 * @param string $intent_id The ID of the intent.
416 416
 	 * @return WC_Order|bool Either an order or false when not found.
417 417
 	 */
418
-	public static function get_order_by_intent_id( $intent_id ) {
418
+	public static function get_order_by_intent_id($intent_id) {
419 419
 		global $wpdb;
420 420
 
421
-		$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' ) );
421
+		$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'));
422 422
 
423
-		if ( ! empty( $order_id ) ) {
424
-			return wc_get_order( $order_id );
423
+		if ( ! empty($order_id)) {
424
+			return wc_get_order($order_id);
425 425
 		}
426 426
 
427 427
 		return false;
@@ -434,13 +434,13 @@  discard block
 block discarded – undo
434 434
 	 * @param string $intent_id The ID of the intent.
435 435
 	 * @return WC_Order|bool Either an order or false when not found.
436 436
 	 */
437
-	public static function get_order_by_setup_intent_id( $intent_id ) {
437
+	public static function get_order_by_setup_intent_id($intent_id) {
438 438
 		global $wpdb;
439 439
 
440
-		$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_setup_intent' ) );
440
+		$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_setup_intent'));
441 441
 
442
-		if ( ! empty( $order_id ) ) {
443
-			return wc_get_order( $order_id );
442
+		if ( ! empty($order_id)) {
443
+			return wc_get_order($order_id);
444 444
 		}
445 445
 
446 446
 		return false;
@@ -456,13 +456,13 @@  discard block
 block discarded – undo
456 456
 	 * @param string $statement_descriptor
457 457
 	 * @return string $statement_descriptor Sanitized statement descriptor
458 458
 	 */
459
-	public static function clean_statement_descriptor( $statement_descriptor = '' ) {
460
-		$disallowed_characters = array( '<', '>', '"', "'" );
459
+	public static function clean_statement_descriptor($statement_descriptor = '') {
460
+		$disallowed_characters = array('<', '>', '"', "'");
461 461
 
462 462
 		// Remove special characters.
463
-		$statement_descriptor = str_replace( $disallowed_characters, '', $statement_descriptor );
463
+		$statement_descriptor = str_replace($disallowed_characters, '', $statement_descriptor);
464 464
 
465
-		$statement_descriptor = substr( trim( $statement_descriptor ), 0, 22 );
465
+		$statement_descriptor = substr(trim($statement_descriptor), 0, 22);
466 466
 
467 467
 		return $statement_descriptor;
468 468
 	}
Please login to merge, or discard this patch.
templates/emails/plain/failed-renewal-authentication.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 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
 echo $email_heading . "\n\n";
7 7
 
8 8
 // translators: %1$s: name of the blog, %2$s: link to checkout payment url, note: no full stop due to url at the end
9
-printf( esc_html_x( 'The automatic payment to renew your subscription with %1$s has failed. To reactivate the subscription, please login and authorize the renewal from your account page: %2$s', 'In failed renewal authentication email', 'woocommerce-gateway-stripe' ), esc_html( get_bloginfo( 'name' ) ), esc_attr( $authorization_url ) );
9
+printf(esc_html_x('The automatic payment to renew your subscription with %1$s has failed. To reactivate the subscription, please login and authorize the renewal from your account page: %2$s', 'In failed renewal authentication email', 'woocommerce-gateway-stripe'), esc_html(get_bloginfo('name')), esc_attr($authorization_url));
10 10
 
11 11
 echo "\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n";
12 12
 
13
-do_action( 'woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email );
13
+do_action('woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email);
14 14
 
15 15
 echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
16 16
 
17
-echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
17
+echo apply_filters('woocommerce_email_footer_text', get_option('woocommerce_email_footer_text'));
Please login to merge, or discard this patch.
templates/emails/failed-renewal-authentication.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit; // Exit if accessed directly
4 4
 }
5 5
 ?>
6 6
 
7
-<?php do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
7
+<?php do_action('woocommerce_email_header', $email_heading, $email); ?>
8 8
 
9 9
 <p>
10 10
 	<?php
11 11
 	// translators: %1$s: name of the blog, %2$s: link to payment re-authentication URL, note: no full stop due to url at the end
12
-	echo wp_kses( sprintf( _x( 'The automatic payment to renew your subscription with %1$s has failed. To reactivate the subscription, please login and authorize the renewal from your account page: %2$s', 'In failed renewal authentication email', 'woocommerce-gateway-stripe' ), esc_html( get_bloginfo( 'name' ) ), '<a href="' . esc_url( $authorization_url ) . '">' . esc_html__( 'Authorize the payment &raquo;', 'woocommerce-gateway-stripe' ) . '</a>' ), array( 'a' => array( 'href' => true ) ) ); ?>
12
+	echo wp_kses(sprintf(_x('The automatic payment to renew your subscription with %1$s has failed. To reactivate the subscription, please login and authorize the renewal from your account page: %2$s', 'In failed renewal authentication email', 'woocommerce-gateway-stripe'), esc_html(get_bloginfo('name')), '<a href="' . esc_url($authorization_url) . '">' . esc_html__('Authorize the payment &raquo;', 'woocommerce-gateway-stripe') . '</a>'), array('a' => array('href' => true))); ?>
13 13
 </p>
14 14
 
15
-<?php do_action( 'woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email ); ?>
15
+<?php do_action('woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email); ?>
16 16
 
17
-<?php do_action( 'woocommerce_email_footer', $email ); ?>
17
+<?php do_action('woocommerce_email_footer', $email); ?>
Please login to merge, or discard this patch.
includes/compat/class-wc-stripe-email-failed-authentication.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit; // Exit if accessed directly.
4 4
 }
5 5
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 				'email_heading'     => $this->get_heading(),
31 31
 				'sent_to_admin'     => false,
32 32
 				'plain_text'        => false,
33
-				'authorization_url' => $this->get_authorization_url( $this->object ),
33
+				'authorization_url' => $this->get_authorization_url($this->object),
34 34
 				'email'             => $this,
35 35
 			),
36 36
 			'',
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 				'email_heading'     => $this->get_heading(),
54 54
 				'sent_to_admin'     => false,
55 55
 				'plain_text'        => true,
56
-				'authorization_url' => $this->get_authorization_url( $this->object ),
56
+				'authorization_url' => $this->get_authorization_url($this->object),
57 57
 				'email'             => $this,
58 58
 			),
59 59
 			'',
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	 * @param WC_Order $order The order whose payment needs authentication.
69 69
 	 * @return string
70 70
 	 */
71
-	public function get_authorization_url( $order ) {
72
-		return add_query_arg( 'wc-stripe-confirmation', 1, $order->get_checkout_payment_url( false ) );
71
+	public function get_authorization_url($order) {
72
+		return add_query_arg('wc-stripe-confirmation', 1, $order->get_checkout_payment_url(false));
73 73
 	}
74 74
 
75 75
 	/**
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 
82 82
 		$this->form_fields = array(
83 83
 			'enabled'    => array(
84
-				'title'   => _x( 'Enable/Disable', 'an email notification', 'woocommerce-gateway-stripe' ),
84
+				'title'   => _x('Enable/Disable', 'an email notification', 'woocommerce-gateway-stripe'),
85 85
 				'type'    => 'checkbox',
86
-				'label'   => __( 'Enable this email notification', 'woocommerce-gateway-stripe' ),
86
+				'label'   => __('Enable this email notification', 'woocommerce-gateway-stripe'),
87 87
 				'default' => 'yes',
88 88
 			),
89 89
 
@@ -98,29 +98,29 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @param WC_Order $order The renewal order whose payment failed.
100 100
 	 */
101
-	public function trigger( $order ) {
102
-		if ( ! $this->is_enabled() ) {
101
+	public function trigger($order) {
102
+		if ( ! $this->is_enabled()) {
103 103
 			return;
104 104
 		}
105 105
 
106 106
 		$this->object = $order;
107 107
 
108
-		if ( method_exists( $order, 'get_billing_email' ) ) {
108
+		if (method_exists($order, 'get_billing_email')) {
109 109
 			$this->recipient = $order->get_billing_email();
110 110
 		} else {
111 111
 			$this->recipient = $order->billing_email;
112 112
 		}
113 113
 
114 114
 		$this->find['order_date'] = '{order_date}';
115
-		if ( function_exists( 'wc_format_datetime' ) ) { // WC 3.0+
116
-			$this->replace['order_date'] = wc_format_datetime( $order->get_date_created() );
115
+		if (function_exists('wc_format_datetime')) { // WC 3.0+
116
+			$this->replace['order_date'] = wc_format_datetime($order->get_date_created());
117 117
 		} else { // WC < 3.0
118
-			$this->replace['order_date'] = $order->date_created->date_i18n( wc_date_format() );
118
+			$this->replace['order_date'] = $order->date_created->date_i18n(wc_date_format());
119 119
 		}
120 120
 
121 121
 		$this->find['order_number']    = '{order_number}';
122 122
 		$this->replace['order_number'] = $order->get_order_number();
123 123
 
124
-		$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
124
+		$this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
125 125
 	}
126 126
 }
Please login to merge, or discard this patch.
includes/compat/class-wc-stripe-email-failed-preorder-authentication.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit; // Exit if accessed directly.
4 4
 }
5 5
 
@@ -21,20 +21,20 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WC_Email[] $email_classes All existing instances of WooCommerce emails.
23 23
 	 */
24
-	public function __construct( $email_classes = array() ) {
24
+	public function __construct($email_classes = array()) {
25 25
 		$this->id             = 'failed_preorder_sca_authentication';
26
-		$this->title          = __( 'Pre-order Payment Action Needed', 'woocommerce-gateway-stripe' );
27
-		$this->description    = __( 'This is an order notification sent to the customer once a pre-order is complete, but additional payment steps are required.', 'woocommerce-gateway-stripe' );
26
+		$this->title          = __('Pre-order Payment Action Needed', 'woocommerce-gateway-stripe');
27
+		$this->description    = __('This is an order notification sent to the customer once a pre-order is complete, but additional payment steps are required.', 'woocommerce-gateway-stripe');
28 28
 		$this->customer_email = true;
29 29
 
30 30
 		$this->template_html  = 'emails/failed-preorder-authentication.php';
31 31
 		$this->template_plain = 'emails/plain/failed-preorder-authentication.php';
32
-		$this->template_base  = plugin_dir_path( WC_STRIPE_MAIN_FILE ) . 'templates/';
32
+		$this->template_base  = plugin_dir_path(WC_STRIPE_MAIN_FILE) . 'templates/';
33 33
 
34 34
 		// Use the "authentication required" hook to add the correct, later hook.
35
-		add_action( 'wc_gateway_stripe_process_payment_authentication_required', array( $this, 'trigger' ) );
35
+		add_action('wc_gateway_stripe_process_payment_authentication_required', array($this, 'trigger'));
36 36
 
37
-		if ( isset( $email_classes['WC_Pre_Orders_Email_Pre_Order_Available'] ) ) {
37
+		if (isset($email_classes['WC_Pre_Orders_Email_Pre_Order_Available'])) {
38 38
 			$this->original_email = $email_classes['WC_Pre_Orders_Email_Pre_Order_Available'];
39 39
 		}
40 40
 
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @param WC_Order $order The order whose payment is failing.
50 50
 	 */
51
-	public function trigger( $order ) {
52
-		if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Order::order_contains_pre_order( $order->get_id() ) ) {
53
-			if ( isset( $this->original_email ) ) {
54
-				remove_action( 'wc_pre_order_status_completed_notification', array( $this->original_email, 'trigger' ), 10, 2 );
51
+	public function trigger($order) {
52
+		if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Order::order_contains_pre_order($order->get_id())) {
53
+			if (isset($this->original_email)) {
54
+				remove_action('wc_pre_order_status_completed_notification', array($this->original_email, 'trigger'), 10, 2);
55 55
 			}
56 56
 
57
-			add_action( 'wc_pre_orders_pre_order_completed', array( $this, 'send_email' ), 10, 2 );
57
+			add_action('wc_pre_orders_pre_order_completed', array($this, 'send_email'), 10, 2);
58 58
 		}
59 59
 	}
60 60
 
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
 	 * @param WC_Order $order The order that is being paid.
65 65
 	 * @param string   $message The message, which should be added to the email.
66 66
 	 */
67
-	public function send_email( $order, $message ) {
67
+	public function send_email($order, $message) {
68 68
 		$this->custom_message = $message;
69 69
 
70
-		parent::trigger( $order );
70
+		parent::trigger($order);
71 71
 
72 72
 		// Restore the action of the original email for other bulk actions.
73
-		if ( isset( $this->original_email ) ) {
74
-			add_action( 'wc_pre_order_status_completed_notification', array( $this->original_email, 'trigger' ), 10, 2 );
73
+		if (isset($this->original_email)) {
74
+			add_action('wc_pre_order_status_completed_notification', array($this->original_email, 'trigger'), 10, 2);
75 75
 		}
76 76
 	}
77 77
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @return string
82 82
 	 */
83 83
 	public function get_default_subject() {
84
-		return __( 'Payment authorization needed for pre-order {order_number}', 'woocommerce-gateway-stripe' );
84
+		return __('Payment authorization needed for pre-order {order_number}', 'woocommerce-gateway-stripe');
85 85
 	}
86 86
 
87 87
 	/**
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @return string
91 91
 	 */
92 92
 	public function get_default_heading() {
93
-		return __( 'Payment authorization needed for pre-order {order_number}', 'woocommerce-gateway-stripe' );
93
+		return __('Payment authorization needed for pre-order {order_number}', 'woocommerce-gateway-stripe');
94 94
 	}
95 95
 
96 96
 	/**
Please login to merge, or discard this patch.
templates/emails/plain/failed-preorder-authentication.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
 
8 8
 printf(
9 9
 	// translators: %s is a link to the payment re-authentication URL.
10
-	_x( 'Your pre-order is now available, but payment cannot be completed automatically. Please complete the payment now: %s', 'woocommerce-gateway-stripe' ),
10
+	_x('Your pre-order is now available, but payment cannot be completed automatically. Please complete the payment now: %s', 'woocommerce-gateway-stripe'),
11 11
 	$authorization_url
12 12
 );
13 13
 
14
-if ( $email->get_custom_message() ) :
14
+if ($email->get_custom_message()) :
15 15
 
16 16
 	echo "----------\n\n";
17
-	echo wptexturize( $email->get_custom_message() ) . "\n\n";
17
+	echo wptexturize($email->get_custom_message()) . "\n\n";
18 18
 	echo "----------\n\n";
19 19
 
20 20
 endif;
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 
23 23
 echo "\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n";
24 24
 
25
-do_action( 'woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email );
25
+do_action('woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email);
26 26
 
27 27
 echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
28 28
 
29
-echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
29
+echo apply_filters('woocommerce_email_footer_text', get_option('woocommerce_email_footer_text'));
Please login to merge, or discard this patch.
templates/emails/failed-renewal-authentication-requested.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@  discard block
 block discarded – undo
6 6
  * @version 4.3.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Output the email header.
15 15
  */
16
-do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
16
+do_action('woocommerce_email_header', $email_heading, $email); ?>
17 17
 
18 18
 <p>
19 19
 	<?php
@@ -27,31 +27,31 @@  discard block
 block discarded – undo
27 27
 			),
28 28
 			$order->get_order_number(),
29 29
 			$order->get_formatted_billing_full_name(),
30
-			wcs_get_human_time_diff( $retry->get_time() )
30
+			wcs_get_human_time_diff($retry->get_time())
31 31
 		)
32 32
 	);
33 33
 	?>
34 34
 </p>
35
-<p><?php esc_html_e( 'The renewal order is as follows:', 'woocommerce-gateway-stripe' ); ?></p>
35
+<p><?php esc_html_e('The renewal order is as follows:', 'woocommerce-gateway-stripe'); ?></p>
36 36
 
37 37
 <?php
38 38
 
39 39
 /**
40 40
  * Shows the order details table.
41 41
  */
42
-do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
42
+do_action('woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email);
43 43
 
44 44
 /**
45 45
 * Shows order meta data.
46 46
 */
47
-do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
47
+do_action('woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email);
48 48
 
49 49
 /**
50 50
 * Shows customer details, and email address.
51 51
 */
52
-do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
52
+do_action('woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email);
53 53
 
54 54
 /**
55 55
 * Output the email footer.
56 56
 */
57
-do_action( 'woocommerce_email_footer', $email );
57
+do_action('woocommerce_email_footer', $email);
Please login to merge, or discard this patch.