Completed
Pull Request — master (#1383)
by
unknown
02:06
created
includes/class-wc-stripe-apple-pay-registration.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @since 4.0.6
6 6
  */
7 7
 
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if ( ! defined('ABSPATH')) {
9 9
 	exit;
10 10
 }
11 11
 
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
 	public $apple_pay_verify_notice;
33 33
 
34 34
 	public function __construct() {
35
-		add_action( 'init', array( $this, 'add_domain_association_rewrite_rule' ) );
36
-		add_filter( 'query_vars', array( $this, 'whitelist_domain_association_query_param' ), 10, 1 );
37
-		add_action( 'parse_request', array( $this, 'parse_domain_association_request' ), 10, 1 );
35
+		add_action('init', array($this, 'add_domain_association_rewrite_rule'));
36
+		add_filter('query_vars', array($this, 'whitelist_domain_association_query_param'), 10, 1);
37
+		add_action('parse_request', array($this, 'parse_domain_association_request'), 10, 1);
38 38
 
39
-		add_action( 'woocommerce_stripe_updated', array( $this, 'verify_domain_if_configured' ) );
40
-		add_action( 'add_option_woocommerce_stripe_settings', array( $this, 'verify_domain_on_new_settings' ), 10, 2 );
41
-		add_action( 'update_option_woocommerce_stripe_settings', array( $this, 'verify_domain_on_updated_settings' ), 10, 2 );
42
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
39
+		add_action('woocommerce_stripe_updated', array($this, 'verify_domain_if_configured'));
40
+		add_action('add_option_woocommerce_stripe_settings', array($this, 'verify_domain_on_new_settings'), 10, 2);
41
+		add_action('update_option_woocommerce_stripe_settings', array($this, 'verify_domain_on_updated_settings'), 10, 2);
42
+		add_action('admin_notices', array($this, 'admin_notices'));
43 43
 
44
-		$this->stripe_settings         = get_option( 'woocommerce_stripe_settings', array() );
45
-		$this->apple_pay_domain_set    = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' );
44
+		$this->stripe_settings         = get_option('woocommerce_stripe_settings', array());
45
+		$this->apple_pay_domain_set    = 'yes' === $this->get_option('apple_pay_domain_set', 'no');
46 46
 		$this->apple_pay_verify_notice = '';
47 47
 	}
48 48
 
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 	 * @param string default
55 55
 	 * @return string $setting_value
56 56
 	 */
57
-	public function get_option( $setting = '', $default = '' ) {
58
-		if ( empty( $this->stripe_settings ) ) {
57
+	public function get_option($setting = '', $default = '') {
58
+		if (empty($this->stripe_settings)) {
59 59
 			return $default;
60 60
 		}
61 61
 
62
-		if ( ! empty( $this->stripe_settings[ $setting ] ) ) {
63
-			return $this->stripe_settings[ $setting ];
62
+		if ( ! empty($this->stripe_settings[$setting])) {
63
+			return $this->stripe_settings[$setting];
64 64
 		}
65 65
 
66 66
 		return $default;
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @return string Whether Apple Pay required settings are enabled.
74 74
 	 */
75 75
 	private function is_enabled() {
76
-		$stripe_enabled                 = 'yes' === $this->get_option( 'enabled', 'no' );
77
-		$payment_request_button_enabled = 'yes' === $this->get_option( 'payment_request', 'yes' );
76
+		$stripe_enabled                 = 'yes' === $this->get_option('enabled', 'no');
77
+		$payment_request_button_enabled = 'yes' === $this->get_option('payment_request', 'yes');
78 78
 
79 79
 		return $stripe_enabled && $payment_request_button_enabled;
80 80
 	}
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	 * @return string Secret key.
87 87
 	 */
88 88
 	private function get_secret_key() {
89
-		$testmode = 'yes' === $this->get_option( 'testmode', 'no' );
90
-		return $testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
89
+		$testmode = 'yes' === $this->get_option('testmode', 'no');
90
+		return $testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
91 91
 	}
92 92
 
93 93
 	/**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		$regex    = '^\.well-known\/apple-developer-merchantid-domain-association$';
98 98
 		$redirect = 'index.php?apple-developer-merchantid-domain-association=1';
99 99
 
100
-		add_rewrite_rule( $regex, $redirect, 'top' );
100
+		add_rewrite_rule($regex, $redirect, 'top');
101 101
 	}
102 102
 
103 103
 	/**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param  array $query_vars - provided public query vars.
107 107
 	 * @return array Updated public query vars.
108 108
 	 */
109
-	public function whitelist_domain_association_query_param( $query_vars ) {
109
+	public function whitelist_domain_association_query_param($query_vars) {
110 110
 		$query_vars[] = 'apple-developer-merchantid-domain-association';
111 111
 		return $query_vars;
112 112
 	}
@@ -116,17 +116,17 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @param WP WordPress environment object.
118 118
 	 */
119
-	public function parse_domain_association_request( $wp ) {
119
+	public function parse_domain_association_request($wp) {
120 120
 		if (
121
-			! isset( $wp->query_vars['apple-developer-merchantid-domain-association'] ) ||
121
+			! isset($wp->query_vars['apple-developer-merchantid-domain-association']) ||
122 122
 			'1' !== $wp->query_vars['apple-developer-merchantid-domain-association']
123 123
 		) {
124 124
 			return;
125 125
 		}
126 126
 
127 127
 		$path = WC_STRIPE_PLUGIN_PATH . '/apple-developer-merchantid-domain-association';
128
-		header( 'Content-Type: application/octet-stream' );
129
-		echo esc_html( file_get_contents( $path ) );
128
+		header('Content-Type: application/octet-stream');
129
+		echo esc_html(file_get_contents($path));
130 130
 		exit;
131 131
 	}
132 132
 
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 	 * @version 4.5.4
138 138
 	 * @param string $secret_key
139 139
 	 */
140
-	private function make_domain_registration_request( $secret_key ) {
141
-		if ( empty( $secret_key ) ) {
142
-			throw new Exception( __( 'Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe' ) );
140
+	private function make_domain_registration_request($secret_key) {
141
+		if (empty($secret_key)) {
142
+			throw new Exception(__('Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe'));
143 143
 		}
144 144
 
145 145
 		$endpoint = 'https://api.stripe.com/v1/apple_pay/domains';
@@ -157,22 +157,22 @@  discard block
 block discarded – undo
157 157
 			$endpoint,
158 158
 			array(
159 159
 				'headers' => $headers,
160
-				'body'    => http_build_query( $data ),
160
+				'body'    => http_build_query($data),
161 161
 			)
162 162
 		);
163 163
 
164
-		if ( is_wp_error( $response ) ) {
164
+		if (is_wp_error($response)) {
165 165
 			/* translators: error message */
166
-			throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) );
166
+			throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $response->get_error_message()));
167 167
 		}
168 168
 
169
-		if ( 200 !== $response['response']['code'] ) {
170
-			$parsed_response = json_decode( $response['body'] );
169
+		if (200 !== $response['response']['code']) {
170
+			$parsed_response = json_decode($response['body']);
171 171
 
172 172
 			$this->apple_pay_verify_notice = $parsed_response->error->message;
173 173
 
174 174
 			/* translators: error message */
175
-			throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $parsed_response->error->message ) );
175
+			throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $parsed_response->error->message));
176 176
 		}
177 177
 	}
178 178
 
@@ -186,27 +186,27 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @return bool Whether domain verification succeeded.
188 188
 	 */
189
-	public function register_domain_with_apple( $secret_key ) {
189
+	public function register_domain_with_apple($secret_key) {
190 190
 		try {
191
-			$this->make_domain_registration_request( $secret_key );
191
+			$this->make_domain_registration_request($secret_key);
192 192
 
193 193
 			// No errors to this point, verification success!
194 194
 			$this->stripe_settings['apple_pay_domain_set'] = 'yes';
195 195
 			$this->apple_pay_domain_set                    = true;
196 196
 
197
-			update_option( 'woocommerce_stripe_settings', $this->stripe_settings );
197
+			update_option('woocommerce_stripe_settings', $this->stripe_settings);
198 198
 
199
-			WC_Stripe_Logger::log( 'Your domain has been verified with Apple Pay!' );
199
+			WC_Stripe_Logger::log('Your domain has been verified with Apple Pay!');
200 200
 
201 201
 			return true;
202 202
 
203
-		} catch ( Exception $e ) {
203
+		} catch (Exception $e) {
204 204
 			$this->stripe_settings['apple_pay_domain_set'] = 'no';
205 205
 			$this->apple_pay_domain_set                    = false;
206 206
 
207
-			update_option( 'woocommerce_stripe_settings', $this->stripe_settings );
207
+			update_option('woocommerce_stripe_settings', $this->stripe_settings);
208 208
 
209
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
209
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
210 210
 
211 211
 			return false;
212 212
 		}
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	public function verify_domain_if_configured() {
222 222
 		$secret_key = $this->get_secret_key();
223 223
 
224
-		if ( ! $this->is_enabled() || empty( $secret_key ) ) {
224
+		if ( ! $this->is_enabled() || empty($secret_key)) {
225 225
 			return;
226 226
 		}
227 227
 
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
 		flush_rewrite_rules();
230 230
 
231 231
 		// Register the domain with Apple Pay.
232
-		$verification_complete = $this->register_domain_with_apple( $secret_key );
232
+		$verification_complete = $this->register_domain_with_apple($secret_key);
233 233
 
234 234
 		// Show/hide notes if necessary.
235
-		WC_Stripe_Inbox_Notes::notify_on_apple_pay_domain_verification( $verification_complete );
235
+		WC_Stripe_Inbox_Notes::notify_on_apple_pay_domain_verification($verification_complete);
236 236
 	}
237 237
 
238 238
 	/**
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 	 * @since 4.5.4
242 242
 	 * @version 4.5.4
243 243
 	 */
244
-	public function verify_domain_on_new_settings( $option, $settings ) {
245
-		$this->verify_domain_on_updated_settings( array(), $settings );
244
+	public function verify_domain_on_new_settings($option, $settings) {
245
+		$this->verify_domain_on_updated_settings(array(), $settings);
246 246
 	}
247 247
 
248 248
 	/**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * @since 4.5.3
252 252
 	 * @version 4.5.4
253 253
 	 */
254
-	public function verify_domain_on_updated_settings( $prev_settings, $settings ) {
254
+	public function verify_domain_on_updated_settings($prev_settings, $settings) {
255 255
 		// Grab previous state and then update cached settings.
256 256
 		$this->stripe_settings = $prev_settings;
257 257
 		$prev_secret_key       = $this->get_secret_key();
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		$this->stripe_settings = $settings;
260 260
 
261 261
 		// If Stripe or Payment Request Button wasn't enabled (or secret key was different) then might need to verify now.
262
-		if ( ! $prev_is_enabled || ( $this->get_secret_key() !== $prev_secret_key ) ) {
262
+		if ( ! $prev_is_enabled || ($this->get_secret_key() !== $prev_secret_key)) {
263 263
 			$this->verify_domain_if_configured();
264 264
 		}
265 265
 	}
@@ -270,16 +270,16 @@  discard block
 block discarded – undo
270 270
 	 * @since 4.0.6
271 271
 	 */
272 272
 	public function admin_notices() {
273
-		if ( ! $this->is_enabled() ) {
273
+		if ( ! $this->is_enabled()) {
274 274
 			return;
275 275
 		}
276 276
 
277
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
277
+		if ( ! current_user_can('manage_woocommerce')) {
278 278
 			return;
279 279
 		}
280 280
 
281
-		$empty_notice = empty( $this->apple_pay_verify_notice );
282
-		if ( $empty_notice && ( $this->apple_pay_domain_set || empty( $this->secret_key ) ) ) {
281
+		$empty_notice = empty($this->apple_pay_verify_notice);
282
+		if ($empty_notice && ($this->apple_pay_domain_set || empty($this->secret_key))) {
283 283
 			return;
284 284
 		}
285 285
 
@@ -288,28 +288,28 @@  discard block
 block discarded – undo
288 288
 		 * when setting screen is displayed. So if domain verification is not set,
289 289
 		 * something went wrong so lets notify user.
290 290
 		 */
291
-		$allowed_html                      = array(
291
+		$allowed_html = array(
292 292
 			'a' => array(
293 293
 				'href'  => array(),
294 294
 				'title' => array(),
295 295
 			),
296 296
 		);
297
-		$verification_failed_without_error = __( 'Apple Pay domain verification failed.', 'woocommerce-gateway-stripe' );
298
-		$verification_failed_with_error    = __( 'Apple Pay domain verification failed with the following error:', 'woocommerce-gateway-stripe' );
297
+		$verification_failed_without_error = __('Apple Pay domain verification failed.', 'woocommerce-gateway-stripe');
298
+		$verification_failed_with_error    = __('Apple Pay domain verification failed with the following error:', 'woocommerce-gateway-stripe');
299 299
 		$check_log_text                    = sprintf(
300 300
 			/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
301
-			esc_html__( 'Please check the %1$slogs%2$s for more details on this issue. Logging must be enabled to see recorded logs.', 'woocommerce-gateway-stripe' ),
302
-			'<a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">',
301
+			esc_html__('Please check the %1$slogs%2$s for more details on this issue. Logging must be enabled to see recorded logs.', 'woocommerce-gateway-stripe'),
302
+			'<a href="' . admin_url('admin.php?page=wc-status&tab=logs') . '">',
303 303
 			'</a>'
304 304
 		);
305 305
 
306 306
 		?>
307 307
 		<div class="error stripe-apple-pay-message">
308
-			<?php if ( $empty_notice ) : ?>
309
-				<p><?php echo esc_html( $verification_failed_without_error ); ?></p>
308
+			<?php if ($empty_notice) : ?>
309
+				<p><?php echo esc_html($verification_failed_without_error); ?></p>
310 310
 			<?php else : ?>
311
-				<p><?php echo esc_html( $verification_failed_with_error ); ?></p>
312
-				<p><i><?php echo wp_kses( make_clickable( esc_html( $this->apple_pay_verify_notice ) ), $allowed_html ); ?></i></p>
311
+				<p><?php echo esc_html($verification_failed_with_error); ?></p>
312
+				<p><i><?php echo wp_kses(make_clickable(esc_html($this->apple_pay_verify_notice)), $allowed_html); ?></i></p>
313 313
 			<?php endif; ?>
314 314
 			<p><?php echo $check_log_text; ?></p>
315 315
 		</div>
Please login to merge, or discard this patch.
includes/admin/class-wc-stripe-inbox-notes.php 1 patch
Spacing   +40 added lines, -40 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
 
@@ -18,41 +18,41 @@  discard block
 block discarded – undo
18 18
 	const POST_SETUP_SUCCESS_ACTION = 'wc_stripe_apple_pay_post_setup_success';
19 19
 
20 20
 	public function __construct() {
21
-		add_action( self::POST_SETUP_SUCCESS_ACTION, array( self::class, 'create_marketing_note' ) );
21
+		add_action(self::POST_SETUP_SUCCESS_ACTION, array(self::class, 'create_marketing_note'));
22 22
 	}
23 23
 
24 24
 	/**
25 25
 	 * Manage notes to show after Apple Pay domain verification.
26 26
 	 */
27
-	public static function notify_on_apple_pay_domain_verification( $verification_complete ) {
28
-		if ( ! class_exists( 'Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes' ) ) {
27
+	public static function notify_on_apple_pay_domain_verification($verification_complete) {
28
+		if ( ! class_exists('Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes')) {
29 29
 			return;
30 30
 		}
31 31
 
32
-		if ( ! class_exists( 'WC_Data_Store' ) ) {
32
+		if ( ! class_exists('WC_Data_Store')) {
33 33
 			return;
34 34
 		}
35 35
 
36
-		if ( $verification_complete ) {
37
-			if ( self::should_show_marketing_note() && ! wp_next_scheduled( self::POST_SETUP_SUCCESS_ACTION ) ) {
38
-				wp_schedule_single_event( time() + DAY_IN_SECONDS, self::POST_SETUP_SUCCESS_ACTION );
36
+		if ($verification_complete) {
37
+			if (self::should_show_marketing_note() && ! wp_next_scheduled(self::POST_SETUP_SUCCESS_ACTION)) {
38
+				wp_schedule_single_event(time() + DAY_IN_SECONDS, self::POST_SETUP_SUCCESS_ACTION);
39 39
 			}
40 40
 
41 41
 			// If the domain verification completed after failure note was created, make sure it's marked as actioned.
42 42
 			try {
43
-				$data_store       = WC_Data_Store::load( 'admin-note' );
44
-				$failure_note_ids = $data_store->get_notes_with_name( self::FAILURE_NOTE_NAME );
45
-				if ( ! empty( $failure_note_ids ) ) {
46
-					$note_id = array_pop( $failure_note_ids );
47
-					$note    = WC_Admin_Notes::get_note( $note_id );
48
-					if ( false !== $note && WC_Admin_Note::E_WC_ADMIN_NOTE_ACTIONED !== $note->get_status() ) {
49
-						$note->set_status( WC_Admin_Note::E_WC_ADMIN_NOTE_ACTIONED );
43
+				$data_store       = WC_Data_Store::load('admin-note');
44
+				$failure_note_ids = $data_store->get_notes_with_name(self::FAILURE_NOTE_NAME);
45
+				if ( ! empty($failure_note_ids)) {
46
+					$note_id = array_pop($failure_note_ids);
47
+					$note    = WC_Admin_Notes::get_note($note_id);
48
+					if (false !== $note && WC_Admin_Note::E_WC_ADMIN_NOTE_ACTIONED !== $note->get_status()) {
49
+						$note->set_status(WC_Admin_Note::E_WC_ADMIN_NOTE_ACTIONED);
50 50
 						$note->save();
51 51
 					}
52 52
 				}
53
-			} catch ( Exception $e ) {}  // @codingStandardsIgnoreLine.
53
+			} catch (Exception $e) {}  // @codingStandardsIgnoreLine.
54 54
 		} else {
55
-			if ( empty( $failure_note_ids ) ) {
55
+			if (empty($failure_note_ids)) {
56 56
 				self::create_failure_note();
57 57
 			}
58 58
 		}
@@ -64,27 +64,27 @@  discard block
 block discarded – undo
64 64
 	public static function should_show_marketing_note() {
65 65
 		// Display to US merchants only.
66 66
 		$base_location = wc_get_base_location();
67
-		if ( ! $base_location || 'US' !== $base_location['country'] ) {
67
+		if ( ! $base_location || 'US' !== $base_location['country']) {
68 68
 			return false;
69 69
 		}
70 70
 
71 71
 		// Make sure Apple Pay is enabled and setup is successful.
72
-		$stripe_settings       = get_option( 'woocommerce_stripe_settings', array() );
73
-		$stripe_enabled        = isset( $stripe_settings['enabled'] ) && 'yes' === $stripe_settings['enabled'];
74
-		$button_enabled        = isset( $stripe_settings['payment_request'] ) && 'yes' === $stripe_settings['payment_request'];
75
-		$verification_complete = isset( $stripe_settings['apple_pay_domain_set'] ) && 'yes' === $stripe_settings['apple_pay_domain_set'];
76
-		if ( ! $stripe_enabled || ! $button_enabled || ! $verification_complete ) {
72
+		$stripe_settings       = get_option('woocommerce_stripe_settings', array());
73
+		$stripe_enabled        = isset($stripe_settings['enabled']) && 'yes' === $stripe_settings['enabled'];
74
+		$button_enabled        = isset($stripe_settings['payment_request']) && 'yes' === $stripe_settings['payment_request'];
75
+		$verification_complete = isset($stripe_settings['apple_pay_domain_set']) && 'yes' === $stripe_settings['apple_pay_domain_set'];
76
+		if ( ! $stripe_enabled || ! $button_enabled || ! $verification_complete) {
77 77
 			return false;
78 78
 		}
79 79
 
80 80
 		// Make sure note doesn't already exist.
81 81
 		try {
82
-			$data_store       = WC_Data_Store::load( 'admin-note' );
83
-			$success_note_ids = $data_store->get_notes_with_name( self::SUCCESS_NOTE_NAME );
84
-			if ( ! empty( $success_note_ids ) ) {
82
+			$data_store       = WC_Data_Store::load('admin-note');
83
+			$success_note_ids = $data_store->get_notes_with_name(self::SUCCESS_NOTE_NAME);
84
+			if ( ! empty($success_note_ids)) {
85 85
 				return false;
86 86
 			}
87
-		} catch ( Exception $e ) {
87
+		} catch (Exception $e) {
88 88
 			return false; // If unable to check, assume it shouldn't show note.
89 89
 		}
90 90
 
@@ -96,19 +96,19 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public static function create_marketing_note() {
98 98
 		// Make sure conditions for this note still hold.
99
-		if ( ! self::should_show_marketing_note() ) {
99
+		if ( ! self::should_show_marketing_note()) {
100 100
 			return;
101 101
 		}
102 102
 
103 103
 		$note = new WC_Admin_Note();
104
-		$note->set_title( __( 'Boost sales this holiday season with Apple Pay!', 'woocommerce-gateway-stripe' ) );
105
-		$note->set_content( __( 'Now that you accept Apple Pay® with Stripe, you can increase conversion rates by letting your customers know that Apple Pay is available. Here’s a marketing guide to help you get started.', 'woocommerce-gateway-stripe' ) );
106
-		$note->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_MARKETING );
107
-		$note->set_name( self::SUCCESS_NOTE_NAME );
108
-		$note->set_source( 'woocommerce-gateway-stripe' );
104
+		$note->set_title(__('Boost sales this holiday season with Apple Pay!', 'woocommerce-gateway-stripe'));
105
+		$note->set_content(__('Now that you accept Apple Pay® with Stripe, you can increase conversion rates by letting your customers know that Apple Pay is available. Here’s a marketing guide to help you get started.', 'woocommerce-gateway-stripe'));
106
+		$note->set_type(WC_Admin_Note::E_WC_ADMIN_NOTE_MARKETING);
107
+		$note->set_name(self::SUCCESS_NOTE_NAME);
108
+		$note->set_source('woocommerce-gateway-stripe');
109 109
 		$note->add_action(
110 110
 			'marketing-guide',
111
-			__( 'See marketing guide', 'woocommerce-gateway-stripe' ),
111
+			__('See marketing guide', 'woocommerce-gateway-stripe'),
112 112
 			'https://developer.apple.com/apple-pay/marketing/'
113 113
 		);
114 114
 		$note->save();
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public static function create_failure_note() {
121 121
 		$note = new WC_Admin_Note();
122
-		$note->set_title( __( 'Apple Pay domain verification needed', 'woocommerce-gateway-stripe' ) );
123
-		$note->set_content( __( 'The WooCommerce Stripe Gateway extension attempted to perform domain verification on behalf of your store, but was unable to do so. This must be resolved before Apple Pay can be offered to your customers.', 'woocommerce-gateway-stripe' ) );
124
-		$note->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
125
-		$note->set_name( self::FAILURE_NOTE_NAME );
126
-		$note->set_source( 'woocommerce-gateway-stripe' );
122
+		$note->set_title(__('Apple Pay domain verification needed', 'woocommerce-gateway-stripe'));
123
+		$note->set_content(__('The WooCommerce Stripe Gateway extension attempted to perform domain verification on behalf of your store, but was unable to do so. This must be resolved before Apple Pay can be offered to your customers.', 'woocommerce-gateway-stripe'));
124
+		$note->set_type(WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL);
125
+		$note->set_name(self::FAILURE_NOTE_NAME);
126
+		$note->set_source('woocommerce-gateway-stripe');
127 127
 		$note->add_action(
128 128
 			'learn-more',
129
-			__( 'Learn more', 'woocommerce-gateway-stripe' ),
129
+			__('Learn more', 'woocommerce-gateway-stripe'),
130 130
 			'https://docs.woocommerce.com/document/stripe/#apple-pay'
131 131
 		);
132 132
 		$note->save();
Please login to merge, or discard this patch.
tests/phpunit/helpers/class-wc-helper-order.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @param int $order_id ID of the order to delete.
19 19
 	 */
20
-	public static function delete_order( $order_id ) {
20
+	public static function delete_order($order_id) {
21 21
 
22
-		$order = wc_get_order( $order_id );
22
+		$order = wc_get_order($order_id);
23 23
 
24 24
 		// Delete all products in the order.
25
-		foreach ( $order->get_items() as $item ) {
26
-			WC_Helper_Product::delete_product( $item['product_id'] );
25
+		foreach ($order->get_items() as $item) {
26
+			WC_Helper_Product::delete_product($item['product_id']);
27 27
 		}
28 28
 
29 29
 		WC_Helper_Shipping::delete_simple_flat_rate();
30 30
 
31 31
 		// Delete the order post.
32
-		$order->delete( true );
32
+		$order->delete(true);
33 33
 	}
34 34
 
35 35
 	/**
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @return WC_Order
47 47
 	 */
48
-	public static function create_order( $customer_id = 1, $total = 50, $product = null ) {
48
+	public static function create_order($customer_id = 1, $total = 50, $product = null) {
49 49
 
50
-		if ( ! is_a( $product, 'WC_Product' ) ) {
50
+		if ( ! is_a($product, 'WC_Product')) {
51 51
 			$product = WC_Helper_Product::create_simple_product();
52 52
 		}
53 53
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		];
62 62
 
63 63
 		$_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // Required, else wc_create_order throws an exception.
64
-		$order                  = wc_create_order( $order_data );
64
+		$order                  = wc_create_order($order_data);
65 65
 
66 66
 		// Add order products.
67 67
 		$item = new WC_Order_Item_Product();
@@ -69,54 +69,54 @@  discard block
 block discarded – undo
69 69
 			[
70 70
 				'product'  => $product,
71 71
 				'quantity' => 4,
72
-				'subtotal' => wc_get_price_excluding_tax( $product, [ 'qty' => 4 ] ),
73
-				'total'    => wc_get_price_excluding_tax( $product, [ 'qty' => 4 ] ),
72
+				'subtotal' => wc_get_price_excluding_tax($product, ['qty' => 4]),
73
+				'total'    => wc_get_price_excluding_tax($product, ['qty' => 4]),
74 74
 			]
75 75
 		);
76 76
 		$item->save();
77
-		$order->add_item( $item );
77
+		$order->add_item($item);
78 78
 
79 79
 		// Set billing address.
80
-		$order->set_billing_first_name( 'Jeroen' );
81
-		$order->set_billing_last_name( 'Sormani' );
82
-		$order->set_billing_company( 'WooCompany' );
83
-		$order->set_billing_address_1( 'WooAddress' );
84
-		$order->set_billing_address_2( '' );
85
-		$order->set_billing_city( 'WooCity' );
86
-		$order->set_billing_state( 'NY' );
87
-		$order->set_billing_postcode( '12345' );
88
-		$order->set_billing_country( 'US' );
89
-		$order->set_billing_email( '[email protected]' );
90
-		$order->set_billing_phone( '555-32123' );
80
+		$order->set_billing_first_name('Jeroen');
81
+		$order->set_billing_last_name('Sormani');
82
+		$order->set_billing_company('WooCompany');
83
+		$order->set_billing_address_1('WooAddress');
84
+		$order->set_billing_address_2('');
85
+		$order->set_billing_city('WooCity');
86
+		$order->set_billing_state('NY');
87
+		$order->set_billing_postcode('12345');
88
+		$order->set_billing_country('US');
89
+		$order->set_billing_email('[email protected]');
90
+		$order->set_billing_phone('555-32123');
91 91
 
92 92
 		// Add shipping costs.
93
-		$shipping_taxes = WC_Tax::calc_shipping_tax( '10', WC_Tax::get_shipping_tax_rates() );
94
-		$rate           = new WC_Shipping_Rate( 'flat_rate_shipping', 'Flat rate shipping', '10', $shipping_taxes, 'flat_rate' );
93
+		$shipping_taxes = WC_Tax::calc_shipping_tax('10', WC_Tax::get_shipping_tax_rates());
94
+		$rate           = new WC_Shipping_Rate('flat_rate_shipping', 'Flat rate shipping', '10', $shipping_taxes, 'flat_rate');
95 95
 		$item           = new WC_Order_Item_Shipping();
96 96
 		$item->set_props(
97 97
 			[
98 98
 				'method_title' => $rate->label,
99 99
 				'method_id'    => $rate->id,
100
-				'total'        => wc_format_decimal( $rate->cost ),
100
+				'total'        => wc_format_decimal($rate->cost),
101 101
 				'taxes'        => $rate->taxes,
102 102
 			]
103 103
 		);
104
-		foreach ( $rate->get_meta_data() as $key => $value ) {
105
-			$item->add_meta_data( $key, $value, true );
104
+		foreach ($rate->get_meta_data() as $key => $value) {
105
+			$item->add_meta_data($key, $value, true);
106 106
 		}
107
-		$order->add_item( $item );
107
+		$order->add_item($item);
108 108
 
109 109
 		// Set payment gateway.
110 110
 		$payment_gateways = WC()->payment_gateways->payment_gateways();
111
-		$order->set_payment_method( $payment_gateways['bacs'] );
111
+		$order->set_payment_method($payment_gateways['bacs']);
112 112
 
113 113
 		// Set totals.
114
-		$order->set_shipping_total( 10 );
115
-		$order->set_discount_total( 0 );
116
-		$order->set_discount_tax( 0 );
117
-		$order->set_cart_tax( 0 );
118
-		$order->set_shipping_tax( 0 );
119
-		$order->set_total( $total );
114
+		$order->set_shipping_total(10);
115
+		$order->set_discount_total(0);
116
+		$order->set_discount_tax(0);
117
+		$order->set_cart_tax(0);
118
+		$order->set_shipping_tax(0);
119
+		$order->set_total($total);
120 120
 		$order->save();
121 121
 
122 122
 		return $order;
Please login to merge, or discard this patch.
tests/phpunit/helpers/class-wc-helper-subscriptions-cart.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 		return self::$cart_contains_subscription_result;
23 23
 	}
24 24
 
25
-	public static function set_cart_contains_subscription( $result ) {
25
+	public static function set_cart_contains_subscription($result) {
26 26
 		self::$cart_contains_subscription_result = $result;
27 27
 	}
28 28
 }
Please login to merge, or discard this patch.
tests/phpunit/helpers/class-wc-helper-subscription.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@
 block discarded – undo
18 18
 	 */
19 19
 	public $related_orders;
20 20
 
21
-	public function get_related_orders( $type ) {
21
+	public function get_related_orders($type) {
22 22
 		return $this->related_orders;
23 23
 	}
24 24
 
25
-	public function set_related_orders( $array ) {
25
+	public function set_related_orders($array) {
26 26
 		$this->related_orders = $array;
27 27
 	}
28 28
 }
Please login to merge, or discard this patch.
tests/phpunit/helpers/class-wc-helper-shipping.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 			'cost'         => '10',
28 28
 		];
29 29
 
30
-		update_option( 'woocommerce_flat_rate_settings', $flat_rate_settings );
31
-		update_option( 'woocommerce_flat_rate', [] );
32
-		WC_Cache_Helper::get_transient_version( 'shipping', true );
30
+		update_option('woocommerce_flat_rate_settings', $flat_rate_settings);
31
+		update_option('woocommerce_flat_rate', []);
32
+		WC_Cache_Helper::get_transient_version('shipping', true);
33 33
 		WC()->shipping()->load_shipping_methods();
34 34
 	}
35 35
 
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 	 * @since 2.3
40 40
 	 */
41 41
 	public static function delete_simple_flat_rate() {
42
-		delete_option( 'woocommerce_flat_rate_settings' );
43
-		delete_option( 'woocommerce_flat_rate' );
44
-		WC_Cache_Helper::get_transient_version( 'shipping', true );
42
+		delete_option('woocommerce_flat_rate_settings');
43
+		delete_option('woocommerce_flat_rate');
44
+		WC_Cache_Helper::get_transient_version('shipping', true);
45 45
 		WC()->shipping()->unregister_shipping_methods();
46 46
 	}
47 47
 }
Please login to merge, or discard this patch.
tests/phpunit/helpers/class-wc-helper-token.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,17 +19,17 @@
 block discarded – undo
19 19
 	 * @param int    $user_id        ID of the token's user, defaults to get_current_user_id().
20 20
 	 * @param string $gateway        Token's Gateway ID, default to WC_Payment_Gateway_WCPay::GATEWAY_ID
21 21
 	 */
22
-	public static function create_token( $payment_method, $user_id = null, $gateway = WC_Payment_Gateway_WCPay::GATEWAY_ID ) {
22
+	public static function create_token($payment_method, $user_id = null, $gateway = WC_Payment_Gateway_WCPay::GATEWAY_ID) {
23 23
 		$token = new WC_Payment_Token_CC();
24
-		$token->set_token( $payment_method );
25
-		$token->set_gateway_id( $gateway );
26
-		$token->set_user_id( isset ( $user_id ) ? $user_id : get_current_user_id() );
27
-		$token->set_card_type( 'visa' );
28
-		$token->set_last4( '4242' );
29
-		$token->set_expiry_month( 6 );
30
-		$token->set_expiry_year( intval( gmdate( 'Y' ) ) + 1 );
24
+		$token->set_token($payment_method);
25
+		$token->set_gateway_id($gateway);
26
+		$token->set_user_id(isset ($user_id) ? $user_id : get_current_user_id());
27
+		$token->set_card_type('visa');
28
+		$token->set_last4('4242');
29
+		$token->set_expiry_month(6);
30
+		$token->set_expiry_year(intval(gmdate('Y')) + 1);
31 31
 		$token->save();
32 32
 
33
-		return WC_Payment_Tokens::get( $token->get_id() );
33
+		return WC_Payment_Tokens::get($token->get_id());
34 34
 	}
35 35
 }
Please login to merge, or discard this patch.
tests/phpunit/helpers/class-wc-helper-subscriptions.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,32 +6,32 @@  discard block
 block discarded – undo
6 6
  */
7 7
 
8 8
 // Set up subscriptions mocks.
9
-function wcs_order_contains_subscription( $order ) {
10
-	if ( ! WC_Subscriptions::$wcs_order_contains_subscription ) {
9
+function wcs_order_contains_subscription($order) {
10
+	if ( ! WC_Subscriptions::$wcs_order_contains_subscription) {
11 11
 		return;
12 12
 	}
13
-	return call_user_func(  WC_Subscriptions::$wcs_order_contains_subscription, $order );
13
+	return call_user_func(WC_Subscriptions::$wcs_order_contains_subscription, $order);
14 14
 }
15 15
 
16
-function wcs_get_subscriptions_for_order( $order ) {
17
-	if ( ! WC_Subscriptions::$wcs_get_subscriptions_for_order ) {
16
+function wcs_get_subscriptions_for_order($order) {
17
+	if ( ! WC_Subscriptions::$wcs_get_subscriptions_for_order) {
18 18
 		return;
19 19
 	}
20
-	return call_user_func(  WC_Subscriptions::$wcs_get_subscriptions_for_order, $order );
20
+	return call_user_func(WC_Subscriptions::$wcs_get_subscriptions_for_order, $order);
21 21
 }
22 22
 
23
-function wcs_is_subscription( $order ) {
24
-	if ( ! WC_Subscriptions::$wcs_is_subscription ) {
23
+function wcs_is_subscription($order) {
24
+	if ( ! WC_Subscriptions::$wcs_is_subscription) {
25 25
 		return;
26 26
 	}
27
-	return call_user_func(  WC_Subscriptions::$wcs_is_subscription, $order );
27
+	return call_user_func(WC_Subscriptions::$wcs_is_subscription, $order);
28 28
 }
29 29
 
30
-function wcs_get_subscription( $subscription ) {
31
-	if ( ! WC_Subscriptions::$wcs_get_subscription ) {
30
+function wcs_get_subscription($subscription) {
31
+	if ( ! WC_Subscriptions::$wcs_get_subscription) {
32 32
 		return;
33 33
 	}
34
-	return call_user_func(  WC_Subscriptions::$wcs_get_subscription, $subscription );
34
+	return call_user_func(WC_Subscriptions::$wcs_get_subscription, $subscription);
35 35
 }
36 36
 
37 37
 /**
@@ -75,19 +75,19 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public static $wcs_get_subscription = null;
77 77
 
78
-	public static function set_wcs_order_contains_subscription( $function ) {
78
+	public static function set_wcs_order_contains_subscription($function) {
79 79
 		self::$wcs_order_contains_subscription = $function;
80 80
 	}
81 81
 
82
-	public static function set_wcs_get_subscriptions_for_order( $function ) {
82
+	public static function set_wcs_get_subscriptions_for_order($function) {
83 83
 		self::$wcs_get_subscriptions_for_order = $function;
84 84
 	}
85 85
 
86
-	public static function set_wcs_is_subscription( $function ) {
86
+	public static function set_wcs_is_subscription($function) {
87 87
 		self::$wcs_is_subscription = $function;
88 88
 	}
89 89
 
90
-	public static function set_wcs_get_subscription( $function ) {
90
+	public static function set_wcs_get_subscription($function) {
91 91
 		self::$wcs_get_subscription = $function;
92 92
 	}
93 93
 }
Please login to merge, or discard this patch.
tests/phpunit/bootstrap.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-$_tests_dir = getenv( 'WP_TESTS_DIR' ) ?: '/tmp/wordpress-tests-lib';
3
+$_tests_dir = getenv('WP_TESTS_DIR') ?: '/tmp/wordpress-tests-lib';
4 4
 
5
-if ( PHP_VERSION_ID >= 80000 && is_dir( $_tests_dir . '/includes/phpunit7/MockObject' ) ) {
5
+if (PHP_VERSION_ID >= 80000 && is_dir($_tests_dir . '/includes/phpunit7/MockObject')) {
6 6
 	// WP Core test library includes patches for PHPUnit 7 to make it compatible with PHP8.
7 7
 	require_once $_tests_dir . '/includes/phpunit7/MockObject/Builder/NamespaceMatch.php';
8 8
 	require_once $_tests_dir . '/includes/phpunit7/MockObject/Builder/ParametersMatch.php';
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 require_once $_tests_dir . '/includes/functions.php';
14 14
 
15 15
 function _manually_load_plugin() {
16
-	$plugins_dir = dirname( dirname( dirname( __DIR__ ) ) );
16
+	$plugins_dir = dirname(dirname(dirname(__DIR__)));
17 17
 	require $plugins_dir . '/woocommerce/woocommerce.php';
18 18
 	require __DIR__ . '/setup.php';
19 19
 	require $plugins_dir . '/woocommerce-gateway-stripe/woocommerce-gateway-stripe.php';
20 20
 }
21 21
 
22
-tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
22
+tests_add_filter('muplugins_loaded', '_manually_load_plugin');
23 23
 
24 24
 require $_tests_dir . '/includes/bootstrap.php';
25 25
 
@@ -32,6 +32,6 @@  discard block
 block discarded – undo
32 32
 require_once __DIR__ . '/helpers/class-wc-helper-subscriptions-cart.php';
33 33
 
34 34
 // We use outdated PHPUnit version, which emits deprecation errors in PHP 7.4 (deprecated reflection APIs).
35
-if ( defined( 'PHP_VERSION_ID' ) && PHP_VERSION_ID >= 70400 ) {
36
-	error_reporting( error_reporting() ^ E_DEPRECATED ); // phpcs:ignore
35
+if (defined('PHP_VERSION_ID') && PHP_VERSION_ID >= 70400) {
36
+	error_reporting(error_reporting() ^ E_DEPRECATED); // phpcs:ignore
37 37
 }
Please login to merge, or discard this patch.