Completed
Pull Request — master (#1405)
by
unknown
02:14
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.
woocommerce-gateway-stripe.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
  *
16 16
  */
17 17
 
18
-if ( ! defined( 'ABSPATH' ) ) {
18
+if ( ! defined('ABSPATH')) {
19 19
 	exit;
20 20
 }
21 21
 
22 22
 /**
23 23
  * Required minimums and constants
24 24
  */
25
-define( 'WC_STRIPE_VERSION', '4.5.5' ); // WRCS: DEFINED_VERSION.
26
-define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
27
-define( 'WC_STRIPE_MIN_WC_VER', '3.0' );
28
-define( 'WC_STRIPE_FUTURE_MIN_WC_VER', '3.0' );
29
-define( 'WC_STRIPE_MAIN_FILE', __FILE__ );
30
-define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
31
-define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
25
+define('WC_STRIPE_VERSION', '4.5.5'); // WRCS: DEFINED_VERSION.
26
+define('WC_STRIPE_MIN_PHP_VER', '5.6.0');
27
+define('WC_STRIPE_MIN_WC_VER', '3.0');
28
+define('WC_STRIPE_FUTURE_MIN_WC_VER', '3.0');
29
+define('WC_STRIPE_MAIN_FILE', __FILE__);
30
+define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__))));
31
+define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__)));
32 32
 
33 33
 // phpcs:disable WordPress.Files.FileName
34 34
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
  */
41 41
 function woocommerce_stripe_missing_wc_notice() {
42 42
 	/* translators: 1. URL link. */
43
-	echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'Stripe requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-gateway-stripe' ), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>' ) . '</strong></p></div>';
43
+	echo '<div class="error"><p><strong>' . sprintf(esc_html__('Stripe requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-gateway-stripe'), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>') . '</strong></p></div>';
44 44
 }
45 45
 
46 46
 /**
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
  */
52 52
 function woocommerce_stripe_wc_not_supported() {
53 53
 	/* translators: $1. Minimum WooCommerce version. $2. Current WooCommerce version. */
54
-	echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'Stripe requires WooCommerce %1$s or greater to be installed and active. WooCommerce %2$s is no longer supported.', 'woocommerce-gateway-stripe' ), WC_STRIPE_MIN_WC_VER, WC_VERSION ) . '</strong></p></div>';
54
+	echo '<div class="error"><p><strong>' . sprintf(esc_html__('Stripe requires WooCommerce %1$s or greater to be installed and active. WooCommerce %2$s is no longer supported.', 'woocommerce-gateway-stripe'), WC_STRIPE_MIN_WC_VER, WC_VERSION) . '</strong></p></div>';
55 55
 }
56 56
 
57 57
 function wc_stripe() {
58 58
 
59 59
 	static $plugin;
60 60
 
61
-	if ( ! isset( $plugin ) ) {
61
+	if ( ! isset($plugin)) {
62 62
 
63 63
 		class WC_Stripe {
64 64
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 			 * @return Singleton The *Singleton* instance.
74 74
 			 */
75 75
 			public static function get_instance() {
76
-				if ( null === self::$instance ) {
76
+				if (null === self::$instance) {
77 77
 					self::$instance = new self();
78 78
 				}
79 79
 				return self::$instance;
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 			 * *Singleton* via the `new` operator from outside of this class.
115 115
 			 */
116 116
 			public function __construct() {
117
-				add_action( 'admin_init', array( $this, 'install' ) );
117
+				add_action('admin_init', array($this, 'install'));
118 118
 
119 119
 				$this->init();
120 120
 
121 121
 				$this->api     = new WC_Stripe_Connect_API();
122
-				$this->connect = new WC_Stripe_Connect( $this->api );
122
+				$this->connect = new WC_Stripe_Connect($this->api);
123 123
 
124
-				add_action( 'rest_api_init', array( $this, 'register_connect_routes' ) );
124
+				add_action('rest_api_init', array($this, 'register_connect_routes'));
125 125
 			}
126 126
 
127 127
 			/**
@@ -131,57 +131,57 @@  discard block
 block discarded – undo
131 131
 			 * @version 4.0.0
132 132
 			 */
133 133
 			public function init() {
134
-				if ( is_admin() ) {
135
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php';
134
+				if (is_admin()) {
135
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php';
136 136
 				}
137 137
 
138
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php';
139
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php';
140
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php';
141
-				include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php';
142
-				require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
143
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php';
144
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php';
145
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php';
146
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
147
-				require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php';
148
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
149
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
150
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
151
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
152
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
153
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
154
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
155
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
156
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
157
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
158
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php';
159
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
160
-				require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect.php';
161
-				require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect-api.php';
162
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php';
163
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php';
164
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php';
165
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-intent-controller.php';
166
-				require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-inbox-notes.php';
167
-
168
-				if ( is_admin() ) {
169
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php';
138
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-exception.php';
139
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-logger.php';
140
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-helper.php';
141
+				include_once dirname(__FILE__) . '/includes/class-wc-stripe-api.php';
142
+				require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
143
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php';
144
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php';
145
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php';
146
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
147
+				require_once dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php';
148
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
149
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
150
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
151
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
152
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
153
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
154
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
155
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
156
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
157
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
158
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php';
159
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
160
+				require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect.php';
161
+				require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect-api.php';
162
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php';
163
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php';
164
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-customer.php';
165
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-intent-controller.php';
166
+				require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-inbox-notes.php';
167
+
168
+				if (is_admin()) {
169
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php';
170 170
 				}
171 171
 
172 172
 				// REMOVE IN THE FUTURE.
173
-				require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
173
+				require_once dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
174 174
 
175
-				add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) );
176
-				add_filter( 'pre_update_option_woocommerce_stripe_settings', array( $this, 'gateway_settings_update' ), 10, 2 );
177
-				add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
178
-				add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
175
+				add_filter('woocommerce_payment_gateways', array($this, 'add_gateways'));
176
+				add_filter('pre_update_option_woocommerce_stripe_settings', array($this, 'gateway_settings_update'), 10, 2);
177
+				add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
178
+				add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2);
179 179
 
180 180
 				// Modify emails emails.
181
-				add_filter( 'woocommerce_email_classes', array( $this, 'add_emails' ), 20 );
181
+				add_filter('woocommerce_email_classes', array($this, 'add_emails'), 20);
182 182
 
183
-				if ( version_compare( WC_VERSION, '3.4', '<' ) ) {
184
-					add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) );
183
+				if (version_compare(WC_VERSION, '3.4', '<')) {
184
+					add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin'));
185 185
 				}
186 186
 			}
187 187
 
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 			 * @version 4.0.0
193 193
 			 */
194 194
 			public function update_plugin_version() {
195
-				delete_option( 'wc_stripe_version' );
196
-				update_option( 'wc_stripe_version', WC_STRIPE_VERSION );
195
+				delete_option('wc_stripe_version');
196
+				update_option('wc_stripe_version', WC_STRIPE_VERSION);
197 197
 			}
198 198
 
199 199
 			/**
@@ -203,15 +203,15 @@  discard block
 block discarded – undo
203 203
 			 * @version 3.1.0
204 204
 			 */
205 205
 			public function install() {
206
-				if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) {
206
+				if ( ! is_plugin_active(plugin_basename(__FILE__))) {
207 207
 					return;
208 208
 				}
209 209
 
210
-				if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) {
211
-					do_action( 'woocommerce_stripe_updated' );
210
+				if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) {
211
+					do_action('woocommerce_stripe_updated');
212 212
 
213
-					if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) {
214
-						define( 'WC_STRIPE_INSTALLING', true );
213
+					if ( ! defined('WC_STRIPE_INSTALLING')) {
214
+						define('WC_STRIPE_INSTALLING', true);
215 215
 					}
216 216
 
217 217
 					$this->update_plugin_version();
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
 			 * @since 1.0.0
225 225
 			 * @version 4.0.0
226 226
 			 */
227
-			public function plugin_action_links( $links ) {
227
+			public function plugin_action_links($links) {
228 228
 				$plugin_links = array(
229
-					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
229
+					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>',
230 230
 				);
231
-				return array_merge( $plugin_links, $links );
231
+				return array_merge($plugin_links, $links);
232 232
 			}
233 233
 
234 234
 			/**
@@ -239,13 +239,13 @@  discard block
 block discarded – undo
239 239
 			 * @param  string $file  Name of current file.
240 240
 			 * @return array  $links Update list of plugin links.
241 241
 			 */
242
-			public function plugin_row_meta( $links, $file ) {
243
-				if ( plugin_basename( __FILE__ ) === $file ) {
242
+			public function plugin_row_meta($links, $file) {
243
+				if (plugin_basename(__FILE__) === $file) {
244 244
 					$row_meta = array(
245
-						'docs'    => '<a href="' . esc_url( apply_filters( 'woocommerce_gateway_stripe_docs_url', 'https://docs.woocommerce.com/document/stripe/' ) ) . '" title="' . esc_attr( __( 'View Documentation', 'woocommerce-gateway-stripe' ) ) . '">' . __( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>',
246
-						'support' => '<a href="' . esc_url( apply_filters( 'woocommerce_gateway_stripe_support_url', 'https://woocommerce.com/my-account/create-a-ticket?select=18627' ) ) . '" title="' . esc_attr( __( 'Open a support request at WooCommerce.com', 'woocommerce-gateway-stripe' ) ) . '">' . __( 'Support', 'woocommerce-gateway-stripe' ) . '</a>',
245
+						'docs'    => '<a href="' . esc_url(apply_filters('woocommerce_gateway_stripe_docs_url', 'https://docs.woocommerce.com/document/stripe/')) . '" title="' . esc_attr(__('View Documentation', 'woocommerce-gateway-stripe')) . '">' . __('Docs', 'woocommerce-gateway-stripe') . '</a>',
246
+						'support' => '<a href="' . esc_url(apply_filters('woocommerce_gateway_stripe_support_url', 'https://woocommerce.com/my-account/create-a-ticket?select=18627')) . '" title="' . esc_attr(__('Open a support request at WooCommerce.com', 'woocommerce-gateway-stripe')) . '">' . __('Support', 'woocommerce-gateway-stripe') . '</a>',
247 247
 					);
248
-					return array_merge( $links, $row_meta );
248
+					return array_merge($links, $row_meta);
249 249
 				}
250 250
 				return (array) $links;
251 251
 			}
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 			 * @since 1.0.0
257 257
 			 * @version 4.0.0
258 258
 			 */
259
-			public function add_gateways( $methods ) {
260
-				if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) {
259
+			public function add_gateways($methods) {
260
+				if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) {
261 261
 					$methods[] = 'WC_Stripe_Subs_Compat';
262 262
 					$methods[] = 'WC_Stripe_Sepa_Subs_Compat';
263 263
 				} else {
@@ -283,28 +283,28 @@  discard block
 block discarded – undo
283 283
 			 * @since 4.0.0
284 284
 			 * @version 4.0.0
285 285
 			 */
286
-			public function filter_gateway_order_admin( $sections ) {
287
-				unset( $sections['stripe'] );
288
-				unset( $sections['stripe_bancontact'] );
289
-				unset( $sections['stripe_sofort'] );
290
-				unset( $sections['stripe_giropay'] );
291
-				unset( $sections['stripe_eps'] );
292
-				unset( $sections['stripe_ideal'] );
293
-				unset( $sections['stripe_p24'] );
294
-				unset( $sections['stripe_alipay'] );
295
-				unset( $sections['stripe_sepa'] );
296
-				unset( $sections['stripe_multibanco'] );
286
+			public function filter_gateway_order_admin($sections) {
287
+				unset($sections['stripe']);
288
+				unset($sections['stripe_bancontact']);
289
+				unset($sections['stripe_sofort']);
290
+				unset($sections['stripe_giropay']);
291
+				unset($sections['stripe_eps']);
292
+				unset($sections['stripe_ideal']);
293
+				unset($sections['stripe_p24']);
294
+				unset($sections['stripe_alipay']);
295
+				unset($sections['stripe_sepa']);
296
+				unset($sections['stripe_multibanco']);
297 297
 
298 298
 				$sections['stripe']            = 'Stripe';
299
-				$sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' );
300
-				$sections['stripe_sofort']     = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' );
301
-				$sections['stripe_giropay']    = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' );
302
-				$sections['stripe_eps']        = __( 'Stripe EPS', 'woocommerce-gateway-stripe' );
303
-				$sections['stripe_ideal']      = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' );
304
-				$sections['stripe_p24']        = __( 'Stripe P24', 'woocommerce-gateway-stripe' );
305
-				$sections['stripe_alipay']     = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' );
306
-				$sections['stripe_sepa']       = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' );
307
-				$sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' );
299
+				$sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe');
300
+				$sections['stripe_sofort']     = __('Stripe SOFORT', 'woocommerce-gateway-stripe');
301
+				$sections['stripe_giropay']    = __('Stripe Giropay', 'woocommerce-gateway-stripe');
302
+				$sections['stripe_eps']        = __('Stripe EPS', 'woocommerce-gateway-stripe');
303
+				$sections['stripe_ideal']      = __('Stripe iDeal', 'woocommerce-gateway-stripe');
304
+				$sections['stripe_p24']        = __('Stripe P24', 'woocommerce-gateway-stripe');
305
+				$sections['stripe_alipay']     = __('Stripe Alipay', 'woocommerce-gateway-stripe');
306
+				$sections['stripe_sepa']       = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe');
307
+				$sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe');
308 308
 
309 309
 				return $sections;
310 310
 			}
@@ -319,12 +319,12 @@  discard block
 block discarded – undo
319 319
 			 * @param array|bool $old_settings Existing settings, if any.
320 320
 			 * @return array New value but with defaults initially filled in for missing settings.
321 321
 			 */
322
-			public function gateway_settings_update( $settings, $old_settings ) {
323
-				if ( false === $old_settings ) {
322
+			public function gateway_settings_update($settings, $old_settings) {
323
+				if (false === $old_settings) {
324 324
 					$gateway  = new WC_Gateway_Stripe();
325 325
 					$fields   = $gateway->get_form_fields();
326
-					$defaults = array_merge( array_fill_keys( array_keys( $fields ), '' ), wp_list_pluck( $fields, 'default' ) );
327
-					return array_merge( $defaults, $settings );
326
+					$defaults = array_merge(array_fill_keys(array_keys($fields), ''), wp_list_pluck($fields, 'default'));
327
+					return array_merge($defaults, $settings);
328 328
 				}
329 329
 				return $settings;
330 330
 			}
@@ -335,16 +335,16 @@  discard block
 block discarded – undo
335 335
 			 * @param WC_Email[] $email_classes All existing emails.
336 336
 			 * @return WC_Email[]
337 337
 			 */
338
-			public function add_emails( $email_classes ) {
338
+			public function add_emails($email_classes) {
339 339
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication.php';
340 340
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-renewal-authentication.php';
341 341
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-preorder-authentication.php';
342 342
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication-retry.php';
343 343
 
344 344
 				// Add all emails, generated by the gateway.
345
-				$email_classes['WC_Stripe_Email_Failed_Renewal_Authentication']  = new WC_Stripe_Email_Failed_Renewal_Authentication( $email_classes );
346
-				$email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication( $email_classes );
347
-				$email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry( $email_classes );
345
+				$email_classes['WC_Stripe_Email_Failed_Renewal_Authentication']  = new WC_Stripe_Email_Failed_Renewal_Authentication($email_classes);
346
+				$email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication($email_classes);
347
+				$email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry($email_classes);
348 348
 
349 349
 				return $email_classes;
350 350
 			}
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/connect/class-wc-stripe-connect-rest-oauth-init-controller.php';
359 359
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/connect/class-wc-stripe-connect-rest-oauth-connect-controller.php';
360 360
 
361
-				$oauth_init    = new WC_Stripe_Connect_REST_Oauth_Init_Controller( $this->connect, $this->api );
362
-				$oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller( $this->connect, $this->api );
361
+				$oauth_init    = new WC_Stripe_Connect_REST_Oauth_Init_Controller($this->connect, $this->api);
362
+				$oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller($this->connect, $this->api);
363 363
 
364 364
 				$oauth_init->register_routes();
365 365
 				$oauth_connect->register_routes();
@@ -373,18 +373,18 @@  discard block
 block discarded – undo
373 373
 	return $plugin;
374 374
 }
375 375
 
376
-add_action( 'plugins_loaded', 'woocommerce_gateway_stripe_init' );
376
+add_action('plugins_loaded', 'woocommerce_gateway_stripe_init');
377 377
 
378 378
 function woocommerce_gateway_stripe_init() {
379
-	load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
379
+	load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages');
380 380
 
381
-	if ( ! class_exists( 'WooCommerce' ) ) {
382
-		add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' );
381
+	if ( ! class_exists('WooCommerce')) {
382
+		add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice');
383 383
 		return;
384 384
 	}
385 385
 
386
-	if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) {
387
-		add_action( 'admin_notices', 'woocommerce_stripe_wc_not_supported' );
386
+	if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) {
387
+		add_action('admin_notices', 'woocommerce_stripe_wc_not_supported');
388 388
 		return;
389 389
 	}
390 390
 
Please login to merge, or discard this patch.
includes/compat/class-wc-stripe-subs-compat.php 1 patch
Spacing   +212 added lines, -212 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
 
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 	public function __construct() {
16 16
 		parent::__construct();
17 17
 
18
-		if ( class_exists( 'WC_Subscriptions_Order' ) ) {
19
-			add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 );
20
-			add_action( 'wcs_resubscribe_order_created', array( $this, 'delete_resubscribe_meta' ), 10 );
21
-			add_action( 'wcs_renewal_order_created', array( $this, 'delete_renewal_meta' ), 10 );
22
-			add_action( 'woocommerce_subscription_failing_payment_method_updated_stripe', array( $this, 'update_failing_payment_method' ), 10, 2 );
23
-			add_action( 'wc_stripe_cards_payment_fields', array( $this, 'display_update_subs_payment_checkout' ) );
24
-			add_action( 'wc_stripe_add_payment_method_' . $this->id . '_success', array( $this, 'handle_add_payment_method_success' ), 10, 2 );
18
+		if (class_exists('WC_Subscriptions_Order')) {
19
+			add_action('woocommerce_scheduled_subscription_payment_' . $this->id, array($this, 'scheduled_subscription_payment'), 10, 2);
20
+			add_action('wcs_resubscribe_order_created', array($this, 'delete_resubscribe_meta'), 10);
21
+			add_action('wcs_renewal_order_created', array($this, 'delete_renewal_meta'), 10);
22
+			add_action('woocommerce_subscription_failing_payment_method_updated_stripe', array($this, 'update_failing_payment_method'), 10, 2);
23
+			add_action('wc_stripe_cards_payment_fields', array($this, 'display_update_subs_payment_checkout'));
24
+			add_action('wc_stripe_add_payment_method_' . $this->id . '_success', array($this, 'handle_add_payment_method_success'), 10, 2);
25 25
 
26 26
 			// display the credit card used for a subscription in the "My Subscriptions" table
27
-			add_filter( 'woocommerce_my_subscriptions_payment_method', array( $this, 'maybe_render_subscription_payment_method' ), 10, 2 );
27
+			add_filter('woocommerce_my_subscriptions_payment_method', array($this, 'maybe_render_subscription_payment_method'), 10, 2);
28 28
 
29 29
 			// allow store managers to manually set Stripe as the payment method on a subscription
30
-			add_filter( 'woocommerce_subscription_payment_meta', array( $this, 'add_subscription_payment_meta' ), 10, 2 );
31
-			add_filter( 'woocommerce_subscription_validate_payment_meta', array( $this, 'validate_subscription_payment_meta' ), 10, 2 );
32
-			add_filter( 'wc_stripe_display_save_payment_method_checkbox', array( $this, 'maybe_hide_save_checkbox' ) );
30
+			add_filter('woocommerce_subscription_payment_meta', array($this, 'add_subscription_payment_meta'), 10, 2);
31
+			add_filter('woocommerce_subscription_validate_payment_meta', array($this, 'validate_subscription_payment_meta'), 10, 2);
32
+			add_filter('wc_stripe_display_save_payment_method_checkbox', array($this, 'maybe_hide_save_checkbox'));
33 33
 
34 34
 			// upon changing payment method, first redirect to confirmation screen if necessary
35
-			add_filter( 'woocommerce_subscriptions_process_payment_for_change_method_via_pay_shortcode', array( $this, 'process_payment_for_change_method' ), 10, 2 );
35
+			add_filter('woocommerce_subscriptions_process_payment_for_change_method_via_pay_shortcode', array($this, 'process_payment_for_change_method'), 10, 2);
36 36
 
37 37
 			/*
38 38
 			 * WC subscriptions hooks into the "template_redirect" hook with priority 100.
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 			 * See: https://github.com/woocommerce/woocommerce-subscriptions/blob/99a75687e109b64cbc07af6e5518458a6305f366/includes/class-wcs-cart-renewal.php#L165
41 41
 			 * If we are in the "You just need to authorize SCA" flow, we don't want that redirection to happen.
42 42
 			 */
43
-			add_action( 'template_redirect', array( $this, 'remove_order_pay_var' ), 99 );
44
-			add_action( 'template_redirect', array( $this, 'restore_order_pay_var' ), 101 );
43
+			add_action('template_redirect', array($this, 'remove_order_pay_var'), 99);
44
+			add_action('template_redirect', array($this, 'restore_order_pay_var'), 101);
45 45
 		}
46 46
 	}
47 47
 
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 	 * @since 4.0.0
53 53
 	 * @version 4.0.0
54 54
 	 */
55
-	public function maybe_hide_save_checkbox( $display_tokenization ) {
56
-		if ( WC_Subscriptions_Cart::cart_contains_subscription() ) {
55
+	public function maybe_hide_save_checkbox($display_tokenization) {
56
+		if (WC_Subscriptions_Cart::cart_contains_subscription()) {
57 57
 			return false;
58 58
 		}
59 59
 
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 	 * @param  int  $order_id
66 66
 	 * @return boolean
67 67
 	 */
68
-	public function has_subscription( $order_id ) {
69
-		return ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_is_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ) );
68
+	public function has_subscription($order_id) {
69
+		return (function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order_id) || wcs_is_subscription($order_id) || wcs_order_contains_renewal($order_id)));
70 70
 	}
71 71
 
72 72
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @return bool
77 77
 	 */
78 78
 	public function is_subs_change_payment() {
79
-		return ( isset( $_GET['pay_for_order'] ) && isset( $_GET['change_payment_method'] ) );
79
+		return (isset($_GET['pay_for_order']) && isset($_GET['change_payment_method']));
80 80
 	}
81 81
 
82 82
 	/**
@@ -86,20 +86,20 @@  discard block
 block discarded – undo
86 86
 	 * @since 4.1.11
87 87
 	 */
88 88
 	public function display_update_subs_payment_checkout() {
89
-		$subs_statuses = apply_filters( 'wc_stripe_update_subs_payment_method_card_statuses', array( 'active' ) );
89
+		$subs_statuses = apply_filters('wc_stripe_update_subs_payment_method_card_statuses', array('active'));
90 90
 		if (
91
-			apply_filters( 'wc_stripe_display_update_subs_payment_method_card_checkbox', true ) &&
92
-			wcs_user_has_subscription( get_current_user_id(), '', $subs_statuses ) &&
91
+			apply_filters('wc_stripe_display_update_subs_payment_method_card_checkbox', true) &&
92
+			wcs_user_has_subscription(get_current_user_id(), '', $subs_statuses) &&
93 93
 			is_add_payment_method_page()
94 94
 		) {
95
-			$label = esc_html( apply_filters( 'wc_stripe_save_to_subs_text', __( 'Update the Payment Method used for all of my active subscriptions.', 'woocommerce-gateway-stripe' ) ) );
96
-			$id    = sprintf( 'wc-%1$s-update-subs-payment-method-card', $this->id );
95
+			$label = esc_html(apply_filters('wc_stripe_save_to_subs_text', __('Update the Payment Method used for all of my active subscriptions.', 'woocommerce-gateway-stripe')));
96
+			$id    = sprintf('wc-%1$s-update-subs-payment-method-card', $this->id);
97 97
 			woocommerce_form_field(
98 98
 				$id,
99 99
 				array(
100 100
 					'type'    => 'checkbox',
101 101
 					'label'   => $label,
102
-					'default' => apply_filters( 'wc_stripe_save_to_subs_checked', false ),
102
+					'default' => apply_filters('wc_stripe_save_to_subs_checked', false),
103 103
 				)
104 104
 			);
105 105
 		}
@@ -112,19 +112,19 @@  discard block
 block discarded – undo
112 112
 	 * @param string $source_id
113 113
 	 * @param object $source_object
114 114
 	 */
115
-	public function handle_add_payment_method_success( $source_id, $source_object ) {
116
-		if ( isset( $_POST[ 'wc-' . $this->id . '-update-subs-payment-method-card' ] ) ) {
115
+	public function handle_add_payment_method_success($source_id, $source_object) {
116
+		if (isset($_POST['wc-' . $this->id . '-update-subs-payment-method-card'])) {
117 117
 			$all_subs        = wcs_get_users_subscriptions();
118
-			$subs_statuses   = apply_filters( 'wc_stripe_update_subs_payment_method_card_statuses', array( 'active' ) );
119
-			$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
120
-
121
-			if ( ! empty( $all_subs ) ) {
122
-				foreach ( $all_subs as $sub ) {
123
-					if ( $sub->has_status( $subs_statuses ) ) {
124
-						update_post_meta( $sub->get_id(), '_stripe_source_id', $source_id );
125
-						update_post_meta( $sub->get_id(), '_stripe_customer_id', $stripe_customer->get_id() );
126
-						update_post_meta( $sub->get_id(), '_payment_method', $this->id );
127
-						update_post_meta( $sub->get_id(), '_payment_method_title', $this->method_title );
118
+			$subs_statuses   = apply_filters('wc_stripe_update_subs_payment_method_card_statuses', array('active'));
119
+			$stripe_customer = new WC_Stripe_Customer(get_current_user_id());
120
+
121
+			if ( ! empty($all_subs)) {
122
+				foreach ($all_subs as $sub) {
123
+					if ($sub->has_status($subs_statuses)) {
124
+						update_post_meta($sub->get_id(), '_stripe_source_id', $source_id);
125
+						update_post_meta($sub->get_id(), '_stripe_customer_id', $stripe_customer->get_id());
126
+						update_post_meta($sub->get_id(), '_payment_method', $this->id);
127
+						update_post_meta($sub->get_id(), '_payment_method_title', $this->method_title);
128 128
 					}
129 129
 				}
130 130
 			}
@@ -138,25 +138,25 @@  discard block
 block discarded – undo
138 138
 	 * @since 4.1.11 Remove 3DS check as it is not needed.
139 139
 	 * @param int $order_id
140 140
 	 */
141
-	public function change_subs_payment_method( $order_id ) {
141
+	public function change_subs_payment_method($order_id) {
142 142
 		try {
143
-			$subscription    = wc_get_order( $order_id );
144
-			$prepared_source = $this->prepare_source( get_current_user_id(), true );
143
+			$subscription    = wc_get_order($order_id);
144
+			$prepared_source = $this->prepare_source(get_current_user_id(), true);
145 145
 
146
-			$this->maybe_disallow_prepaid_card( $prepared_source );
147
-			$this->check_source( $prepared_source );
148
-			$this->save_source_to_order( $subscription, $prepared_source );
146
+			$this->maybe_disallow_prepaid_card($prepared_source);
147
+			$this->check_source($prepared_source);
148
+			$this->save_source_to_order($subscription, $prepared_source);
149 149
 
150
-			do_action( 'wc_stripe_change_subs_payment_method_success', $prepared_source->source, $prepared_source );
150
+			do_action('wc_stripe_change_subs_payment_method_success', $prepared_source->source, $prepared_source);
151 151
 
152 152
 			return array(
153 153
 				'result'          => 'success',
154
-				'redirect'        => $this->get_return_url( $subscription ),
154
+				'redirect'        => $this->get_return_url($subscription),
155 155
 				'prepared_source' => $prepared_source,
156 156
 			);
157
-		} catch ( WC_Stripe_Exception $e ) {
158
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
159
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
157
+		} catch (WC_Stripe_Exception $e) {
158
+			wc_add_notice($e->getLocalizedMessage(), 'error');
159
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
160 160
 		}
161 161
 	}
162 162
 
@@ -168,22 +168,22 @@  discard block
 block discarded – undo
168 168
 	 * @param WC_Subscription $subscription The subscription for which the payment method is changing.
169 169
 	 * @return array
170 170
 	 */
171
-	public function process_payment_for_change_method( $result, $subscription ) {
172
-		if ( 'success' !== $result['result'] ) {
171
+	public function process_payment_for_change_method($result, $subscription) {
172
+		if ('success' !== $result['result']) {
173 173
 			return $result;
174 174
 		}
175 175
 
176 176
 		try {
177
-			$intent_secret = $this->setup_intent( $subscription, $result['prepared_source'] );
177
+			$intent_secret = $this->setup_intent($subscription, $result['prepared_source']);
178 178
 
179 179
 			// If confirmation on the client is required, redirect to confirmation screen first.
180
-			if ( ! empty( $intent_secret ) ) {
180
+			if ( ! empty($intent_secret)) {
181 181
 				$redirect_url = add_query_arg(
182 182
 					array(
183 183
 						'change_payment_method'  => $subscription->get_id(),
184 184
 						'_wpnonce'               => wp_create_nonce(),
185 185
 						'wc-stripe-confirmation' => 1,
186
-						'wc-stripe-redirect'     => rawurlencode( $result['redirect'] ),
186
+						'wc-stripe-redirect'     => rawurlencode($result['redirect']),
187 187
 					),
188 188
 					$subscription->get_checkout_payment_url()
189 189
 				);
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 					'redirect' => $redirect_url,
194 194
 				);
195 195
 			}
196
-		} catch ( WC_Stripe_Exception $e ) {
197
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
198
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
196
+		} catch (WC_Stripe_Exception $e) {
197
+			wc_add_notice($e->getLocalizedMessage(), 'error');
198
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
199 199
 		}
200 200
 
201 201
 		return $result;
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
 	 * @param  int $order_id
207 207
 	 * @return array
208 208
 	 */
209
-	public function process_payment( $order_id, $retry = true, $force_save_source = false, $previous_error = false, $use_order_source = false ) {
210
-		if ( $this->has_subscription( $order_id ) ) {
211
-			if ( $this->is_subs_change_payment() ) {
212
-				return $this->change_subs_payment_method( $order_id );
209
+	public function process_payment($order_id, $retry = true, $force_save_source = false, $previous_error = false, $use_order_source = false) {
210
+		if ($this->has_subscription($order_id)) {
211
+			if ($this->is_subs_change_payment()) {
212
+				return $this->change_subs_payment_method($order_id);
213 213
 			}
214 214
 
215 215
 			// Regular payment with force customer enabled
216
-			return parent::process_payment( $order_id, $retry, true, $previous_error, $use_order_source );
216
+			return parent::process_payment($order_id, $retry, true, $previous_error, $use_order_source);
217 217
 		} else {
218
-			return parent::process_payment( $order_id, $retry, $force_save_source, $previous_error, $use_order_source );
218
+			return parent::process_payment($order_id, $retry, $force_save_source, $previous_error, $use_order_source);
219 219
 		}
220 220
 	}
221 221
 
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 	 * @param object   $prepared_source The source that is used for the payment.
228 228
 	 * @return array                    The arguments for the request.
229 229
 	 */
230
-	public function generate_create_intent_request( $order, $prepared_source ) {
231
-		$request = parent::generate_create_intent_request( $order, $prepared_source );
230
+	public function generate_create_intent_request($order, $prepared_source) {
231
+		$request = parent::generate_create_intent_request($order, $prepared_source);
232 232
 
233 233
 		// Non-subscription orders do not need any additional parameters.
234
-		if ( ! $this->has_subscription( $order ) ) {
234
+		if ( ! $this->has_subscription($order)) {
235 235
 			return $request;
236 236
 		}
237 237
 
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 	 * @param $amount_to_charge float The amount to charge.
248 248
 	 * @param $renewal_order WC_Order A WC_Order object created to record the renewal payment.
249 249
 	 */
250
-	public function scheduled_subscription_payment( $amount_to_charge, $renewal_order ) {
251
-		$this->process_subscription_payment( $amount_to_charge, $renewal_order, true, false );
250
+	public function scheduled_subscription_payment($amount_to_charge, $renewal_order) {
251
+		$this->process_subscription_payment($amount_to_charge, $renewal_order, true, false);
252 252
 	}
253 253
 
254 254
 	/**
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 	 * @param bool $retry Should we retry the process?
263 263
 	 * @param object $previous_error
264 264
 	 */
265
-	public function process_subscription_payment( $amount, $renewal_order, $retry = true, $previous_error = false ) {
265
+	public function process_subscription_payment($amount, $renewal_order, $retry = true, $previous_error = false) {
266 266
 		try {
267
-			if ( $amount * 100 < WC_Stripe_Helper::get_minimum_amount() ) {
267
+			if ($amount * 100 < WC_Stripe_Helper::get_minimum_amount()) {
268 268
 				/* translators: minimum amount */
269
-				$message = 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 ) );
269
+				$message = 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));
270 270
 				throw new WC_Stripe_Exception(
271 271
 					'Error while processing renewal order ' . $renewal_order->get_id() . ' : ' . $message,
272 272
 					$message
@@ -275,141 +275,141 @@  discard block
 block discarded – undo
275 275
 
276 276
 			$order_id = $renewal_order->get_id();
277 277
 
278
-			$this->ensure_subscription_has_customer_id( $order_id );
278
+			$this->ensure_subscription_has_customer_id($order_id);
279 279
 
280 280
 			// Unlike regular off-session subscription payments, early renewals are treated as on-session payments, involving the customer.
281
-			if ( isset( $_REQUEST['process_early_renewal'] ) ) { // wpcs: csrf ok.
282
-				$response = parent::process_payment( $order_id, true, false, $previous_error, true );
281
+			if (isset($_REQUEST['process_early_renewal'])) { // wpcs: csrf ok.
282
+				$response = parent::process_payment($order_id, true, false, $previous_error, true);
283 283
 
284
-				if( 'success' === $response['result'] && isset( $response['payment_intent_secret'] ) ) {
284
+				if ('success' === $response['result'] && isset($response['payment_intent_secret'])) {
285 285
 					$verification_url = add_query_arg(
286 286
 						array(
287 287
 							'order'         => $order_id,
288
-							'nonce'         => wp_create_nonce( 'wc_stripe_confirm_pi' ),
289
-							'redirect_to'   => remove_query_arg( array( 'process_early_renewal', 'subscription_id', 'wcs_nonce' ) ),
288
+							'nonce'         => wp_create_nonce('wc_stripe_confirm_pi'),
289
+							'redirect_to'   => remove_query_arg(array('process_early_renewal', 'subscription_id', 'wcs_nonce')),
290 290
 							'early_renewal' => true,
291 291
 						),
292
-						WC_AJAX::get_endpoint( 'wc_stripe_verify_intent' )
292
+						WC_AJAX::get_endpoint('wc_stripe_verify_intent')
293 293
 					);
294 294
 
295
-					echo wp_json_encode( array(
295
+					echo wp_json_encode(array(
296 296
 						'stripe_sca_required' => true,
297 297
 						'intent_secret'       => $response['payment_intent_secret'],
298 298
 						'redirect_url'        => $verification_url,
299
-					) );
299
+					));
300 300
 
301 301
 					exit;
302 302
 				}
303 303
 
304 304
 				// Hijack all other redirects in order to do the redirection in JavaScript.
305
-				add_action( 'wp_redirect', array( $this, 'redirect_after_early_renewal' ), 100 );
305
+				add_action('wp_redirect', array($this, 'redirect_after_early_renewal'), 100);
306 306
 
307 307
 				return;
308 308
 			}
309 309
 
310 310
 			// Check for an existing intent, which is associated with the order.
311
-			if ( $this->has_authentication_already_failed( $renewal_order ) ) {
311
+			if ($this->has_authentication_already_failed($renewal_order)) {
312 312
 				return;
313 313
 			}
314 314
 
315 315
 			// Get source from order
316
-			$prepared_source = $this->prepare_order_source( $renewal_order );
316
+			$prepared_source = $this->prepare_order_source($renewal_order);
317 317
 			$source_object   = $prepared_source->source_object;
318 318
 
319
-			if ( ! $prepared_source->customer ) {
319
+			if ( ! $prepared_source->customer) {
320 320
 				throw new WC_Stripe_Exception(
321 321
 					'Failed to process renewal for order ' . $renewal_order->get_id() . '. Stripe customer id is missing in the order',
322
-					__( 'Customer not found', 'woocommerce-gateway-stripe' )
322
+					__('Customer not found', 'woocommerce-gateway-stripe')
323 323
 				);
324 324
 			}
325 325
 
326
-			WC_Stripe_Logger::log( "Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}" );
326
+			WC_Stripe_Logger::log("Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}");
327 327
 
328 328
 			/* If we're doing a retry and source is chargeable, we need to pass
329 329
 			 * a different idempotency key and retry for success.
330 330
 			 */
331
-			if ( is_object( $source_object ) && empty( $source_object->error ) && $this->need_update_idempotency_key( $source_object, $previous_error ) ) {
332
-				add_filter( 'wc_stripe_idempotency_key', array( $this, 'change_idempotency_key' ), 10, 2 );
331
+			if (is_object($source_object) && empty($source_object->error) && $this->need_update_idempotency_key($source_object, $previous_error)) {
332
+				add_filter('wc_stripe_idempotency_key', array($this, 'change_idempotency_key'), 10, 2);
333 333
 			}
334 334
 
335
-			if ( ( $this->is_no_such_source_error( $previous_error ) || $this->is_no_linked_source_error( $previous_error ) ) && apply_filters( 'wc_stripe_use_default_customer_source', true ) ) {
335
+			if (($this->is_no_such_source_error($previous_error) || $this->is_no_linked_source_error($previous_error)) && apply_filters('wc_stripe_use_default_customer_source', true)) {
336 336
 				// Passing empty source will charge customer default.
337 337
 				$prepared_source->source = '';
338 338
 			}
339 339
 
340
-			$this->lock_order_payment( $renewal_order );
340
+			$this->lock_order_payment($renewal_order);
341 341
 
342
-			$response                   = $this->create_and_confirm_intent_for_off_session( $renewal_order, $prepared_source, $amount );
343
-			$is_authentication_required = $this->is_authentication_required_for_payment( $response );
342
+			$response                   = $this->create_and_confirm_intent_for_off_session($renewal_order, $prepared_source, $amount);
343
+			$is_authentication_required = $this->is_authentication_required_for_payment($response);
344 344
 
345 345
 			// It's only a failed payment if it's an error and it's not of the type 'authentication_required'.
346 346
 			// If it's 'authentication_required', then we should email the user and ask them to authenticate.
347
-			if ( ! empty( $response->error ) && ! $is_authentication_required ) {
347
+			if ( ! empty($response->error) && ! $is_authentication_required) {
348 348
 				// We want to retry.
349
-				if ( $this->is_retryable_error( $response->error ) ) {
350
-					if ( $retry ) {
349
+				if ($this->is_retryable_error($response->error)) {
350
+					if ($retry) {
351 351
 						// Don't do anymore retries after this.
352
-						if ( 5 <= $this->retry_interval ) {
353
-							return $this->process_subscription_payment( $amount, $renewal_order, false, $response->error );
352
+						if (5 <= $this->retry_interval) {
353
+							return $this->process_subscription_payment($amount, $renewal_order, false, $response->error);
354 354
 						}
355 355
 
356
-						sleep( $this->retry_interval );
356
+						sleep($this->retry_interval);
357 357
 
358 358
 						$this->retry_interval++;
359 359
 
360
-						return $this->process_subscription_payment( $amount, $renewal_order, true, $response->error );
360
+						return $this->process_subscription_payment($amount, $renewal_order, true, $response->error);
361 361
 					} else {
362
-						$localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' );
363
-						$renewal_order->add_order_note( $localized_message );
364
-						throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
362
+						$localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe');
363
+						$renewal_order->add_order_note($localized_message);
364
+						throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
365 365
 					}
366 366
 				}
367 367
 
368 368
 				$localized_messages = WC_Stripe_Helper::get_localized_messages();
369 369
 
370
-				if ( 'card_error' === $response->error->type ) {
371
-					$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
370
+				if ('card_error' === $response->error->type) {
371
+					$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
372 372
 				} else {
373
-					$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
373
+					$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
374 374
 				}
375 375
 
376
-				$renewal_order->add_order_note( $localized_message );
376
+				$renewal_order->add_order_note($localized_message);
377 377
 
378
-				throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
378
+				throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
379 379
 			}
380 380
 
381 381
 			// Either the charge was successfully captured, or it requires further authentication.
382 382
 
383
-			if ( $is_authentication_required ) {
384
-				do_action( 'wc_gateway_stripe_process_payment_authentication_required', $renewal_order, $response );
383
+			if ($is_authentication_required) {
384
+				do_action('wc_gateway_stripe_process_payment_authentication_required', $renewal_order, $response);
385 385
 
386
-				$error_message = __( 'This transaction requires authentication.', 'woocommerce-gateway-stripe' );
387
-				$renewal_order->add_order_note( $error_message );
386
+				$error_message = __('This transaction requires authentication.', 'woocommerce-gateway-stripe');
387
+				$renewal_order->add_order_note($error_message);
388 388
 
389
-				$charge = end( $response->error->payment_intent->charges->data );
389
+				$charge = end($response->error->payment_intent->charges->data);
390 390
 				$id = $charge->id;
391 391
 				$order_id = $renewal_order->get_id();
392 392
 
393
-				$renewal_order->set_transaction_id( $id );
394
-				$renewal_order->update_status( 'failed', sprintf( __( 'Stripe charge awaiting authentication by user: %s.', 'woocommerce-gateway-stripe' ), $id ) );
395
-				if ( is_callable( array( $renewal_order, 'save' ) ) ) {
393
+				$renewal_order->set_transaction_id($id);
394
+				$renewal_order->update_status('failed', sprintf(__('Stripe charge awaiting authentication by user: %s.', 'woocommerce-gateway-stripe'), $id));
395
+				if (is_callable(array($renewal_order, 'save'))) {
396 396
 					$renewal_order->save();
397 397
 				}
398 398
 			} else {
399 399
 				// The charge was successfully captured
400
-				do_action( 'wc_gateway_stripe_process_payment', $response, $renewal_order );
400
+				do_action('wc_gateway_stripe_process_payment', $response, $renewal_order);
401 401
 
402
-				$this->process_response( end( $response->charges->data ), $renewal_order );
402
+				$this->process_response(end($response->charges->data), $renewal_order);
403 403
 			}
404 404
 
405
-			$this->unlock_order_payment( $renewal_order );
406
-		} catch ( WC_Stripe_Exception $e ) {
407
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
405
+			$this->unlock_order_payment($renewal_order);
406
+		} catch (WC_Stripe_Exception $e) {
407
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
408 408
 
409
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $renewal_order );
409
+			do_action('wc_gateway_stripe_process_payment_error', $e, $renewal_order);
410 410
 
411 411
 			/* translators: error message */
412
-			$renewal_order->update_status( 'failed' );
412
+			$renewal_order->update_status('failed');
413 413
 		}
414 414
 	}
415 415
 
@@ -419,24 +419,24 @@  discard block
 block discarded – undo
419 419
 	 * @since 3.1.0
420 420
 	 * @version 4.0.0
421 421
 	 */
422
-	public function save_source_to_order( $order, $source ) {
423
-		parent::save_source_to_order( $order, $source );
422
+	public function save_source_to_order($order, $source) {
423
+		parent::save_source_to_order($order, $source);
424 424
 
425 425
 		$order_id = $order->get_id();
426 426
 
427 427
 		// Also store it on the subscriptions being purchased or paid for in the order
428
-		if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) {
429
-			$subscriptions = wcs_get_subscriptions_for_order( $order_id );
430
-		} elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) {
431
-			$subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id );
428
+		if (function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($order_id)) {
429
+			$subscriptions = wcs_get_subscriptions_for_order($order_id);
430
+		} elseif (function_exists('wcs_order_contains_renewal') && wcs_order_contains_renewal($order_id)) {
431
+			$subscriptions = wcs_get_subscriptions_for_renewal_order($order_id);
432 432
 		} else {
433 433
 			$subscriptions = array();
434 434
 		}
435 435
 
436
-		foreach ( $subscriptions as $subscription ) {
436
+		foreach ($subscriptions as $subscription) {
437 437
 			$subscription_id = $subscription->get_id();
438
-			update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer );
439
-			update_post_meta( $subscription_id, '_stripe_source_id', $source->source );
438
+			update_post_meta($subscription_id, '_stripe_customer_id', $source->customer);
439
+			update_post_meta($subscription_id, '_stripe_source_id', $source->source);
440 440
 		}
441 441
 	}
442 442
 
@@ -444,26 +444,26 @@  discard block
 block discarded – undo
444 444
 	 * Don't transfer Stripe customer/token meta to resubscribe orders.
445 445
 	 * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
446 446
 	 */
447
-	public function delete_resubscribe_meta( $resubscribe_order ) {
448
-		delete_post_meta( $resubscribe_order->get_id(), '_stripe_customer_id' );
449
-		delete_post_meta( $resubscribe_order->get_id(), '_stripe_source_id' );
447
+	public function delete_resubscribe_meta($resubscribe_order) {
448
+		delete_post_meta($resubscribe_order->get_id(), '_stripe_customer_id');
449
+		delete_post_meta($resubscribe_order->get_id(), '_stripe_source_id');
450 450
 		// For BW compat will remove in future
451
-		delete_post_meta( $resubscribe_order->get_id(), '_stripe_card_id' );
451
+		delete_post_meta($resubscribe_order->get_id(), '_stripe_card_id');
452 452
 		// delete payment intent ID
453
-		delete_post_meta( $resubscribe_order->get_id(), '_stripe_intent_id' );
454
-		$this->delete_renewal_meta( $resubscribe_order );
453
+		delete_post_meta($resubscribe_order->get_id(), '_stripe_intent_id');
454
+		$this->delete_renewal_meta($resubscribe_order);
455 455
 	}
456 456
 
457 457
 	/**
458 458
 	 * Don't transfer Stripe fee/ID meta to renewal orders.
459 459
 	 * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
460 460
 	 */
461
-	public function delete_renewal_meta( $renewal_order ) {
462
-		WC_Stripe_Helper::delete_stripe_fee( $renewal_order );
463
-		WC_Stripe_Helper::delete_stripe_net( $renewal_order );
461
+	public function delete_renewal_meta($renewal_order) {
462
+		WC_Stripe_Helper::delete_stripe_fee($renewal_order);
463
+		WC_Stripe_Helper::delete_stripe_net($renewal_order);
464 464
 
465 465
 		// delete payment intent ID
466
-		delete_post_meta( $renewal_order->get_id(), '_stripe_intent_id' );
466
+		delete_post_meta($renewal_order->get_id(), '_stripe_intent_id');
467 467
 
468 468
 		return $renewal_order;
469 469
 	}
@@ -477,9 +477,9 @@  discard block
 block discarded – undo
477 477
 	 * @param WC_Order $renewal_order The order which recorded the successful payment (to make up for the failed automatic payment).
478 478
 	 * @return void
479 479
 	 */
480
-	public function update_failing_payment_method( $subscription, $renewal_order ) {
481
-		update_post_meta( $subscription->get_id(), '_stripe_customer_id', $renewal_order->get_meta( '_stripe_customer_id', true ) );
482
-		update_post_meta( $subscription->get_id(), '_stripe_source_id', $renewal_order->get_meta( '_stripe_source_id', true ) );
480
+	public function update_failing_payment_method($subscription, $renewal_order) {
481
+		update_post_meta($subscription->get_id(), '_stripe_customer_id', $renewal_order->get_meta('_stripe_customer_id', true));
482
+		update_post_meta($subscription->get_id(), '_stripe_source_id', $renewal_order->get_meta('_stripe_source_id', true));
483 483
 	}
484 484
 
485 485
 	/**
@@ -491,23 +491,23 @@  discard block
 block discarded – undo
491 491
 	 * @param WC_Subscription $subscription An instance of a subscription object
492 492
 	 * @return array
493 493
 	 */
494
-	public function add_subscription_payment_meta( $payment_meta, $subscription ) {
494
+	public function add_subscription_payment_meta($payment_meta, $subscription) {
495 495
 		$subscription_id = $subscription->get_id();
496
-		$source_id       = get_post_meta( $subscription_id, '_stripe_source_id', true );
496
+		$source_id       = get_post_meta($subscription_id, '_stripe_source_id', true);
497 497
 
498 498
 		// For BW compat will remove in future.
499
-		if ( empty( $source_id ) ) {
500
-			$source_id = get_post_meta( $subscription_id, '_stripe_card_id', true );
499
+		if (empty($source_id)) {
500
+			$source_id = get_post_meta($subscription_id, '_stripe_card_id', true);
501 501
 
502 502
 			// Take this opportunity to update the key name.
503
-			update_post_meta( $subscription_id, '_stripe_source_id', $source_id );
504
-			delete_post_meta( $subscription_id, '_stripe_card_id', $source_id );
503
+			update_post_meta($subscription_id, '_stripe_source_id', $source_id);
504
+			delete_post_meta($subscription_id, '_stripe_card_id', $source_id);
505 505
 		}
506 506
 
507
-		$payment_meta[ $this->id ] = array(
507
+		$payment_meta[$this->id] = array(
508 508
 			'post_meta' => array(
509 509
 				'_stripe_customer_id' => array(
510
-					'value' => get_post_meta( $subscription_id, '_stripe_customer_id', true ),
510
+					'value' => get_post_meta($subscription_id, '_stripe_customer_id', true),
511 511
 					'label' => 'Stripe Customer ID',
512 512
 				),
513 513
 				'_stripe_source_id'   => array(
@@ -530,27 +530,27 @@  discard block
 block discarded – undo
530 530
 	 * @param array $payment_meta associative array of meta data required for automatic payments
531 531
 	 * @return array
532 532
 	 */
533
-	public function validate_subscription_payment_meta( $payment_method_id, $payment_meta ) {
534
-		if ( $this->id === $payment_method_id ) {
533
+	public function validate_subscription_payment_meta($payment_method_id, $payment_meta) {
534
+		if ($this->id === $payment_method_id) {
535 535
 
536
-			if ( ! isset( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) || empty( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) ) {
536
+			if ( ! isset($payment_meta['post_meta']['_stripe_customer_id']['value']) || empty($payment_meta['post_meta']['_stripe_customer_id']['value'])) {
537 537
 
538 538
 				// Allow empty stripe customer id during subscription renewal. It will be added when processing payment if required.
539
-				if ( ! isset( $_POST['wc_order_action'] ) || 'wcs_process_renewal' !== $_POST['wc_order_action'] ) {
540
-					throw new Exception( __( 'A "Stripe Customer ID" value is required.', 'woocommerce-gateway-stripe' ) );
539
+				if ( ! isset($_POST['wc_order_action']) || 'wcs_process_renewal' !== $_POST['wc_order_action']) {
540
+					throw new Exception(__('A "Stripe Customer ID" value is required.', 'woocommerce-gateway-stripe'));
541 541
 				}
542
-			} elseif ( 0 !== strpos( $payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_' ) ) {
543
-				throw new Exception( __( 'Invalid customer ID. A valid "Stripe Customer ID" must begin with "cus_".', 'woocommerce-gateway-stripe' ) );
542
+			} elseif (0 !== strpos($payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_')) {
543
+				throw new Exception(__('Invalid customer ID. A valid "Stripe Customer ID" must begin with "cus_".', 'woocommerce-gateway-stripe'));
544 544
 			}
545 545
 
546 546
 			if (
547
-				! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) && (
548
-					0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'card_' )
549
-					&& 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'src_' )
550
-					&& 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'pm_' )
547
+				! empty($payment_meta['post_meta']['_stripe_source_id']['value']) && (
548
+					0 !== strpos($payment_meta['post_meta']['_stripe_source_id']['value'], 'card_')
549
+					&& 0 !== strpos($payment_meta['post_meta']['_stripe_source_id']['value'], 'src_')
550
+					&& 0 !== strpos($payment_meta['post_meta']['_stripe_source_id']['value'], 'pm_')
551 551
 				)
552 552
 			) {
553
-				throw new Exception( __( 'Invalid source ID. A valid source "Stripe Source ID" must begin with "src_", "pm_", or "card_".', 'woocommerce-gateway-stripe' ) );
553
+				throw new Exception(__('Invalid source ID. A valid source "Stripe Source ID" must begin with "src_", "pm_", or "card_".', 'woocommerce-gateway-stripe'));
554 554
 			}
555 555
 		}
556 556
 	}
@@ -563,75 +563,75 @@  discard block
 block discarded – undo
563 563
 	 * @param WC_Subscription $subscription the subscription details
564 564
 	 * @return string the subscription payment method
565 565
 	 */
566
-	public function maybe_render_subscription_payment_method( $payment_method_to_display, $subscription ) {
566
+	public function maybe_render_subscription_payment_method($payment_method_to_display, $subscription) {
567 567
 		$customer_user = $subscription->get_customer_id();
568 568
 
569 569
 		// bail for other payment methods
570
-		if ( $subscription->get_payment_method() !== $this->id || ! $customer_user ) {
570
+		if ($subscription->get_payment_method() !== $this->id || ! $customer_user) {
571 571
 			return $payment_method_to_display;
572 572
 		}
573 573
 
574
-		$stripe_source_id = get_post_meta( $subscription->get_id(), '_stripe_source_id', true );
574
+		$stripe_source_id = get_post_meta($subscription->get_id(), '_stripe_source_id', true);
575 575
 
576 576
 		// For BW compat will remove in future.
577
-		if ( empty( $stripe_source_id ) ) {
578
-			$stripe_source_id = get_post_meta( $subscription->get_id(), '_stripe_card_id', true );
577
+		if (empty($stripe_source_id)) {
578
+			$stripe_source_id = get_post_meta($subscription->get_id(), '_stripe_card_id', true);
579 579
 
580 580
 			// Take this opportunity to update the key name.
581
-			update_post_meta( $subscription->get_id(), '_stripe_source_id', $stripe_source_id );
581
+			update_post_meta($subscription->get_id(), '_stripe_source_id', $stripe_source_id);
582 582
 		}
583 583
 
584 584
 		$stripe_customer    = new WC_Stripe_Customer();
585
-		$stripe_customer_id = get_post_meta( $subscription->get_id(), '_stripe_customer_id', true );
585
+		$stripe_customer_id = get_post_meta($subscription->get_id(), '_stripe_customer_id', true);
586 586
 
587 587
 		// If we couldn't find a Stripe customer linked to the subscription, fallback to the user meta data.
588
-		if ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) {
588
+		if ( ! $stripe_customer_id || ! is_string($stripe_customer_id)) {
589 589
 			$user_id            = $customer_user;
590
-			$stripe_customer_id = get_user_option( '_stripe_customer_id', $user_id );
591
-			$stripe_source_id   = get_user_option( '_stripe_source_id', $user_id );
590
+			$stripe_customer_id = get_user_option('_stripe_customer_id', $user_id);
591
+			$stripe_source_id   = get_user_option('_stripe_source_id', $user_id);
592 592
 
593 593
 			// For BW compat will remove in future.
594
-			if ( empty( $stripe_source_id ) ) {
595
-				$stripe_source_id = get_user_option( '_stripe_card_id', $user_id );
594
+			if (empty($stripe_source_id)) {
595
+				$stripe_source_id = get_user_option('_stripe_card_id', $user_id);
596 596
 
597 597
 				// Take this opportunity to update the key name.
598
-				update_user_option( $user_id, '_stripe_source_id', $stripe_source_id, false );
598
+				update_user_option($user_id, '_stripe_source_id', $stripe_source_id, false);
599 599
 			}
600 600
 		}
601 601
 
602 602
 		// If we couldn't find a Stripe customer linked to the account, fallback to the order meta data.
603
-		if ( ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) && false !== $subscription->order ) {
604
-			$stripe_customer_id = get_post_meta( $subscription->get_parent_id(), '_stripe_customer_id', true );
605
-			$stripe_source_id   = get_post_meta( $subscription->get_parent_id(), '_stripe_source_id', true );
603
+		if (( ! $stripe_customer_id || ! is_string($stripe_customer_id)) && false !== $subscription->order) {
604
+			$stripe_customer_id = get_post_meta($subscription->get_parent_id(), '_stripe_customer_id', true);
605
+			$stripe_source_id   = get_post_meta($subscription->get_parent_id(), '_stripe_source_id', true);
606 606
 
607 607
 			// For BW compat will remove in future.
608
-			if ( empty( $stripe_source_id ) ) {
609
-				$stripe_source_id = get_post_meta( $subscription->get_parent_id(), '_stripe_card_id', true );
608
+			if (empty($stripe_source_id)) {
609
+				$stripe_source_id = get_post_meta($subscription->get_parent_id(), '_stripe_card_id', true);
610 610
 
611 611
 				// Take this opportunity to update the key name.
612
-				update_post_meta( $subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id );
612
+				update_post_meta($subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id);
613 613
 			}
614 614
 		}
615 615
 
616
-		$stripe_customer->set_id( $stripe_customer_id );
616
+		$stripe_customer->set_id($stripe_customer_id);
617 617
 
618 618
 		$sources                   = $stripe_customer->get_sources();
619
-		$payment_method_to_display = __( 'N/A', 'woocommerce-gateway-stripe' );
619
+		$payment_method_to_display = __('N/A', 'woocommerce-gateway-stripe');
620 620
 
621
-		if ( $sources ) {
621
+		if ($sources) {
622 622
 			$card = false;
623 623
 
624
-			foreach ( $sources as $source ) {
625
-				if ( isset( $source->type ) && 'card' === $source->type ) {
624
+			foreach ($sources as $source) {
625
+				if (isset($source->type) && 'card' === $source->type) {
626 626
 					$card = $source->card;
627
-				} elseif ( isset( $source->object ) && 'card' === $source->object ) {
627
+				} elseif (isset($source->object) && 'card' === $source->object) {
628 628
 					$card = $source;
629 629
 				}
630 630
 
631
-				if ( $source->id === $stripe_source_id ) {
632
-					if ( $card ) {
631
+				if ($source->id === $stripe_source_id) {
632
+					if ($card) {
633 633
 						/* translators: 1) card brand 2) last 4 digits */
634
-						$payment_method_to_display = sprintf( __( 'Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe' ), ( isset( $card->brand ) ? $card->brand : __( 'N/A', 'woocommerce-gateway-stripe' ) ), $card->last4 );
634
+						$payment_method_to_display = sprintf(__('Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe'), (isset($card->brand) ? $card->brand : __('N/A', 'woocommerce-gateway-stripe')), $card->last4);
635 635
 					}
636 636
 
637 637
 					break;
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 	 */
649 649
 	public function remove_order_pay_var() {
650 650
 		global $wp;
651
-		if ( isset( $_GET['wc-stripe-confirmation'] ) ) {
651
+		if (isset($_GET['wc-stripe-confirmation'])) {
652 652
 			$this->order_pay_var = $wp->query_vars['order-pay'];
653 653
 			$wp->query_vars['order-pay'] = null;
654 654
 		}
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 	 */
660 660
 	public function restore_order_pay_var() {
661 661
 		global $wp;
662
-		if ( isset( $this->order_pay_var ) ) {
662
+		if (isset($this->order_pay_var)) {
663 663
 			$wp->query_vars['order-pay'] = $this->order_pay_var;
664 664
 		}
665 665
 	}
@@ -670,13 +670,13 @@  discard block
 block discarded – undo
670 670
 	 * @param WC_Order $renewal_order The renewal order.
671 671
 	 * @return boolean
672 672
 	 */
673
-	public function has_authentication_already_failed( $renewal_order ) {
674
-		$existing_intent = $this->get_intent_from_order( $renewal_order );
673
+	public function has_authentication_already_failed($renewal_order) {
674
+		$existing_intent = $this->get_intent_from_order($renewal_order);
675 675
 
676 676
 		if (
677 677
 			! $existing_intent
678 678
 			|| 'requires_payment_method' !== $existing_intent->status
679
-			|| empty( $existing_intent->last_payment_error )
679
+			|| empty($existing_intent->last_payment_error)
680 680
 			|| 'authentication_required' !== $existing_intent->last_payment_error->code
681 681
 		) {
682 682
 			return false;
@@ -690,12 +690,12 @@  discard block
 block discarded – undo
690 690
 		 *
691 691
 		 * @param WC_Order $renewal_order The order that is being renewed.
692 692
 		 */
693
-		do_action( 'wc_gateway_stripe_process_payment_authentication_required', $renewal_order );
693
+		do_action('wc_gateway_stripe_process_payment_authentication_required', $renewal_order);
694 694
 
695 695
 		// Fail the payment attempt (order would be currently pending because of retry rules).
696
-		$charge    = end( $existing_intent->charges->data );
696
+		$charge    = end($existing_intent->charges->data);
697 697
 		$charge_id = $charge->id;
698
-		$renewal_order->update_status( 'failed', sprintf( __( 'Stripe charge awaiting authentication by user: %s.', 'woocommerce-gateway-stripe' ), $charge_id ) );
698
+		$renewal_order->update_status('failed', sprintf(__('Stripe charge awaiting authentication by user: %s.', 'woocommerce-gateway-stripe'), $charge_id));
699 699
 
700 700
 		return true;
701 701
 	}
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 	 * @param string $url The URL that Subscriptions attempts a redirect to.
707 707
 	 * @return void
708 708
 	 */
709
-	public function redirect_after_early_renewal( $url ) {
709
+	public function redirect_after_early_renewal($url) {
710 710
 		echo wp_json_encode(
711 711
 			array(
712 712
 				'stripe_sca_required' => false,
@@ -723,12 +723,12 @@  discard block
 block discarded – undo
723 723
 	 * @param WC_Order $order The renewal order.
724 724
 	 * @param stdClass $intent The Payment Intent object.
725 725
 	 */
726
-	protected function handle_intent_verification_success( $order, $intent ) {
727
-		parent::handle_intent_verification_success( $order, $intent );
726
+	protected function handle_intent_verification_success($order, $intent) {
727
+		parent::handle_intent_verification_success($order, $intent);
728 728
 
729
-		if ( isset( $_GET['early_renewal'] ) ) { // wpcs: csrf ok.
730
-			wcs_update_dates_after_early_renewal( wcs_get_subscription( $order->get_meta( '_subscription_renewal' ) ), $order );
731
-			wc_add_notice( __( 'Your early renewal order was successful.', 'woocommerce-gateway-stripe' ), 'success' );
729
+		if (isset($_GET['early_renewal'])) { // wpcs: csrf ok.
730
+			wcs_update_dates_after_early_renewal(wcs_get_subscription($order->get_meta('_subscription_renewal')), $order);
731
+			wc_add_notice(__('Your early renewal order was successful.', 'woocommerce-gateway-stripe'), 'success');
732 732
 		}
733 733
 	}
734 734
 
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 	 * @param WC_Order $order The renewal order.
739 739
 	 * @param stdClass $intent The Payment Intent object (unused).
740 740
 	 */
741
-	protected function handle_intent_verification_failure( $order, $intent ) {
742
-		if ( isset( $_GET['early_renewal'] ) ) {
743
-			$order->delete( true );
744
-			wc_add_notice( __( 'Payment authorization for the renewal order was unsuccessful, please try again.', 'woocommerce-gateway-stripe' ), 'error' );
745
-			$renewal_url = wcs_get_early_renewal_url( wcs_get_subscription( $order->get_meta( '_subscription_renewal' ) ) );
746
-			wp_redirect( $renewal_url ); exit;
741
+	protected function handle_intent_verification_failure($order, $intent) {
742
+		if (isset($_GET['early_renewal'])) {
743
+			$order->delete(true);
744
+			wc_add_notice(__('Payment authorization for the renewal order was unsuccessful, please try again.', 'woocommerce-gateway-stripe'), 'error');
745
+			$renewal_url = wcs_get_early_renewal_url(wcs_get_subscription($order->get_meta('_subscription_renewal')));
746
+			wp_redirect($renewal_url); exit;
747 747
 		}
748 748
 	}
749 749
 }
Please login to merge, or discard this patch.
includes/class-wc-gateway-stripe.php 1 patch
Spacing   +327 added lines, -327 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	public function __construct() {
86 86
 		$this->retry_interval = 1;
87 87
 		$this->id             = 'stripe';
88
-		$this->method_title   = __( 'Stripe', 'woocommerce-gateway-stripe' );
88
+		$this->method_title   = __('Stripe', 'woocommerce-gateway-stripe');
89 89
 		/* translators: 1) link to Stripe register page 2) link to Stripe api keys page */
90
-		$this->method_description = __( 'Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification.', 'woocommerce-gateway-stripe' );
90
+		$this->method_description = __('Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification.', 'woocommerce-gateway-stripe');
91 91
 		$this->has_fields         = true;
92 92
 		$this->supports           = array(
93 93
 			'products',
@@ -114,41 +114,41 @@  discard block
 block discarded – undo
114 114
 		$this->init_settings();
115 115
 
116 116
 		// Get setting values.
117
-		$this->title                = $this->get_option( 'title' );
118
-		$this->description          = $this->get_option( 'description' );
119
-		$this->enabled              = $this->get_option( 'enabled' );
120
-		$this->testmode             = 'yes' === $this->get_option( 'testmode' );
121
-		$this->inline_cc_form       = 'yes' === $this->get_option( 'inline_cc_form' );
122
-		$this->capture              = 'yes' === $this->get_option( 'capture', 'yes' );
123
-		$this->statement_descriptor = WC_Stripe_Helper::clean_statement_descriptor( $this->get_option( 'statement_descriptor' ) );
124
-		$this->saved_cards          = 'yes' === $this->get_option( 'saved_cards' );
125
-		$this->secret_key           = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
126
-		$this->publishable_key      = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' );
127
-		$this->payment_request      = 'yes' === $this->get_option( 'payment_request', 'yes' );
128
-
129
-		WC_Stripe_API::set_secret_key( $this->secret_key );
117
+		$this->title                = $this->get_option('title');
118
+		$this->description          = $this->get_option('description');
119
+		$this->enabled              = $this->get_option('enabled');
120
+		$this->testmode             = 'yes' === $this->get_option('testmode');
121
+		$this->inline_cc_form       = 'yes' === $this->get_option('inline_cc_form');
122
+		$this->capture              = 'yes' === $this->get_option('capture', 'yes');
123
+		$this->statement_descriptor = WC_Stripe_Helper::clean_statement_descriptor($this->get_option('statement_descriptor'));
124
+		$this->saved_cards          = 'yes' === $this->get_option('saved_cards');
125
+		$this->secret_key           = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
126
+		$this->publishable_key      = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key');
127
+		$this->payment_request      = 'yes' === $this->get_option('payment_request', 'yes');
128
+
129
+		WC_Stripe_API::set_secret_key($this->secret_key);
130 130
 
131 131
 		// Hooks.
132
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
133
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
134
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
135
-		add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_fee' ) );
136
-		add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_payout' ), 20 );
137
-		add_action( 'woocommerce_customer_save_address', array( $this, 'show_update_card_notice' ), 10, 2 );
138
-		add_action( 'before_woocommerce_pay', array( $this, 'prepare_order_pay_page' ) );
139
-		add_action( 'after_woocommerce_pay', array( $this, 'restore_order_pay_page' ), 99 );
140
-		add_action( 'woocommerce_account_view-order_endpoint', array( $this, 'check_intent_status_on_order_page' ), 1 );
141
-		add_filter( 'woocommerce_payment_successful_result', array( $this, 'modify_successful_payment_result' ), 99999, 2 );
142
-		add_action( 'set_logged_in_cookie', array( $this, 'set_cookie_on_current_request' ) );
143
-		add_filter( 'woocommerce_get_checkout_payment_url', array( $this, 'get_checkout_payment_url' ), 10, 2 );
132
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
133
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'));
134
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
135
+		add_action('woocommerce_admin_order_totals_after_total', array($this, 'display_order_fee'));
136
+		add_action('woocommerce_admin_order_totals_after_total', array($this, 'display_order_payout'), 20);
137
+		add_action('woocommerce_customer_save_address', array($this, 'show_update_card_notice'), 10, 2);
138
+		add_action('before_woocommerce_pay', array($this, 'prepare_order_pay_page'));
139
+		add_action('after_woocommerce_pay', array($this, 'restore_order_pay_page'), 99);
140
+		add_action('woocommerce_account_view-order_endpoint', array($this, 'check_intent_status_on_order_page'), 1);
141
+		add_filter('woocommerce_payment_successful_result', array($this, 'modify_successful_payment_result'), 99999, 2);
142
+		add_action('set_logged_in_cookie', array($this, 'set_cookie_on_current_request'));
143
+		add_filter('woocommerce_get_checkout_payment_url', array($this, 'get_checkout_payment_url'), 10, 2);
144 144
 
145 145
 		// Note: display error is in the parent class.
146
-		add_action( 'admin_notices', array( $this, 'display_errors' ), 9999 );
146
+		add_action('admin_notices', array($this, 'display_errors'), 9999);
147 147
 
148
-		if ( WC_Stripe_Helper::is_pre_orders_exists() ) {
148
+		if (WC_Stripe_Helper::is_pre_orders_exists()) {
149 149
 			$this->pre_orders = new WC_Stripe_Pre_Orders_Compat();
150 150
 
151
-			add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this->pre_orders, 'process_pre_order_release_payment' ) );
151
+			add_action('wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array($this->pre_orders, 'process_pre_order_release_payment'));
152 152
 		}
153 153
 	}
154 154
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @since 4.0.2
159 159
 	 */
160 160
 	public function is_available() {
161
-		if ( is_add_payment_method_page() && ! $this->saved_cards ) {
161
+		if (is_add_payment_method_page() && ! $this->saved_cards) {
162 162
 			return false;
163 163
 		}
164 164
 
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
 	 * @param int    $user_id      The ID of the current user.
173 173
 	 * @param string $load_address The address to load.
174 174
 	 */
175
-	public function show_update_card_notice( $user_id, $load_address ) {
176
-		if ( ! $this->saved_cards || ! WC_Stripe_Payment_Tokens::customer_has_saved_methods( $user_id ) || 'billing' !== $load_address ) {
175
+	public function show_update_card_notice($user_id, $load_address) {
176
+		if ( ! $this->saved_cards || ! WC_Stripe_Payment_Tokens::customer_has_saved_methods($user_id) || 'billing' !== $load_address) {
177 177
 			return;
178 178
 		}
179 179
 
180 180
 		/* translators: 1) Opening anchor tag 2) closing anchor tag */
181
-		wc_add_notice( sprintf( __( 'If your billing address has been changed for saved payment methods, be sure to remove any %1$ssaved payment methods%2$s on file and re-add them.', 'woocommerce-gateway-stripe' ), '<a href="' . esc_url( wc_get_endpoint_url( 'payment-methods' ) ) . '" class="wc-stripe-update-card-notice" style="text-decoration:underline;">', '</a>' ), 'notice' );
181
+		wc_add_notice(sprintf(__('If your billing address has been changed for saved payment methods, be sure to remove any %1$ssaved payment methods%2$s on file and re-add them.', 'woocommerce-gateway-stripe'), '<a href="' . esc_url(wc_get_endpoint_url('payment-methods')) . '" class="wc-stripe-update-card-notice" style="text-decoration:underline;">', '</a>'), 'notice');
182 182
 	}
183 183
 
184 184
 	/**
@@ -193,24 +193,24 @@  discard block
 block discarded – undo
193 193
 
194 194
 		$icons_str = '';
195 195
 
196
-		$icons_str .= isset( $icons['visa'] ) ? $icons['visa'] : '';
197
-		$icons_str .= isset( $icons['amex'] ) ? $icons['amex'] : '';
198
-		$icons_str .= isset( $icons['mastercard'] ) ? $icons['mastercard'] : '';
196
+		$icons_str .= isset($icons['visa']) ? $icons['visa'] : '';
197
+		$icons_str .= isset($icons['amex']) ? $icons['amex'] : '';
198
+		$icons_str .= isset($icons['mastercard']) ? $icons['mastercard'] : '';
199 199
 
200
-		if ( 'USD' === get_woocommerce_currency() ) {
201
-			$icons_str .= isset( $icons['discover'] ) ? $icons['discover'] : '';
202
-			$icons_str .= isset( $icons['jcb'] ) ? $icons['jcb'] : '';
203
-			$icons_str .= isset( $icons['diners'] ) ? $icons['diners'] : '';
200
+		if ('USD' === get_woocommerce_currency()) {
201
+			$icons_str .= isset($icons['discover']) ? $icons['discover'] : '';
202
+			$icons_str .= isset($icons['jcb']) ? $icons['jcb'] : '';
203
+			$icons_str .= isset($icons['diners']) ? $icons['diners'] : '';
204 204
 		}
205 205
 
206
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
206
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
207 207
 	}
208 208
 
209 209
 	/**
210 210
 	 * Initialise Gateway Settings Form Fields
211 211
 	 */
212 212
 	public function init_form_fields() {
213
-		$this->form_fields = require( dirname( __FILE__ ) . '/admin/stripe-settings.php' );
213
+		$this->form_fields = require(dirname(__FILE__) . '/admin/stripe-settings.php');
214 214
 	}
215 215
 
216 216
 	/**
@@ -219,27 +219,27 @@  discard block
 block discarded – undo
219 219
 	public function payment_fields() {
220 220
 		global $wp;
221 221
 		$user                 = wp_get_current_user();
222
-		$display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards;
222
+		$display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards;
223 223
 		$total                = WC()->cart->total;
224 224
 		$user_email           = '';
225 225
 		$description          = $this->get_description();
226
-		$description          = ! empty( $description ) ? $description : '';
226
+		$description          = ! empty($description) ? $description : '';
227 227
 		$firstname            = '';
228 228
 		$lastname             = '';
229 229
 
230 230
 		// If paying from order, we need to get total from order not cart.
231
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { // wpcs: csrf ok.
232
-			$order      = wc_get_order( wc_clean( $wp->query_vars['order-pay'] ) ); // wpcs: csrf ok, sanitization ok.
231
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { // wpcs: csrf ok.
232
+			$order      = wc_get_order(wc_clean($wp->query_vars['order-pay'])); // wpcs: csrf ok, sanitization ok.
233 233
 			$total      = $order->get_total();
234 234
 			$user_email = $order->get_billing_email();
235 235
 		} else {
236
-			if ( $user->ID ) {
237
-				$user_email = get_user_meta( $user->ID, 'billing_email', true );
236
+			if ($user->ID) {
237
+				$user_email = get_user_meta($user->ID, 'billing_email', true);
238 238
 				$user_email = $user_email ? $user_email : $user->user_email;
239 239
 			}
240 240
 		}
241 241
 
242
-		if ( is_add_payment_method_page() ) {
242
+		if (is_add_payment_method_page()) {
243 243
 			$firstname       = $user->user_firstname;
244 244
 			$lastname        = $user->user_lastname;
245 245
 		}
@@ -248,33 +248,33 @@  discard block
 block discarded – undo
248 248
 
249 249
 		echo '<div
250 250
 			id="stripe-payment-data"
251
-			data-email="' . esc_attr( $user_email ) . '"
252
-			data-full-name="' . esc_attr( $firstname . ' ' . $lastname ) . '"
253
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '"
251
+			data-email="' . esc_attr($user_email) . '"
252
+			data-full-name="' . esc_attr($firstname . ' ' . $lastname) . '"
253
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '"
254 254
 		>';
255 255
 
256
-		if ( $this->testmode ) {
256
+		if ($this->testmode) {
257 257
 			/* translators: link to Stripe testing page */
258
-			$description .= ' ' . sprintf( __( 'TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the <a href="%s" target="_blank">Testing Stripe documentation</a> for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' );
258
+			$description .= ' ' . sprintf(__('TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the <a href="%s" target="_blank">Testing Stripe documentation</a> for more card numbers.', 'woocommerce-gateway-stripe'), 'https://stripe.com/docs/testing');
259 259
 		}
260 260
 
261
-		$description = trim( $description );
261
+		$description = trim($description);
262 262
 
263
-		echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id ); // wpcs: xss ok.
263
+		echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id); // wpcs: xss ok.
264 264
 
265
-		if ( $display_tokenization ) {
265
+		if ($display_tokenization) {
266 266
 			$this->tokenization_script();
267 267
 			$this->saved_payment_methods();
268 268
 		}
269 269
 
270 270
 		$this->elements_form();
271 271
 
272
-		if ( apply_filters( 'wc_stripe_display_save_payment_method_checkbox', $display_tokenization ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) { // wpcs: csrf ok.
272
+		if (apply_filters('wc_stripe_display_save_payment_method_checkbox', $display_tokenization) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) { // wpcs: csrf ok.
273 273
 
274 274
 			$this->save_payment_method_checkbox();
275 275
 		}
276 276
 
277
-		do_action( 'wc_stripe_cards_payment_fields', $this->id );
277
+		do_action('wc_stripe_cards_payment_fields', $this->id);
278 278
 
279 279
 		echo '</div>';
280 280
 
@@ -289,12 +289,12 @@  discard block
 block discarded – undo
289 289
 	 */
290 290
 	public function elements_form() {
291 291
 		?>
292
-		<fieldset id="wc-<?php echo esc_attr( $this->id ); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
293
-			<?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?>
292
+		<fieldset id="wc-<?php echo esc_attr($this->id); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
293
+			<?php do_action('woocommerce_credit_card_form_start', $this->id); ?>
294 294
 
295
-			<?php if ( $this->inline_cc_form ) { ?>
295
+			<?php if ($this->inline_cc_form) { ?>
296 296
 				<label for="card-element">
297
-					<?php esc_html_e( 'Credit or debit card', 'woocommerce-gateway-stripe' ); ?>
297
+					<?php esc_html_e('Credit or debit card', 'woocommerce-gateway-stripe'); ?>
298 298
 				</label>
299 299
 
300 300
 				<div id="stripe-card-element" class="wc-stripe-elements-field">
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 				</div>
303 303
 			<?php } else { ?>
304 304
 				<div class="form-row form-row-wide">
305
-					<label for="stripe-card-element"><?php esc_html_e( 'Card Number', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
305
+					<label for="stripe-card-element"><?php esc_html_e('Card Number', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
306 306
 					<div class="stripe-card-group">
307 307
 						<div id="stripe-card-element" class="wc-stripe-elements-field">
308 308
 						<!-- a Stripe Element will be inserted here. -->
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 				</div>
314 314
 
315 315
 				<div class="form-row form-row-first">
316
-					<label for="stripe-exp-element"><?php esc_html_e( 'Expiry Date', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
316
+					<label for="stripe-exp-element"><?php esc_html_e('Expiry Date', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
317 317
 
318 318
 					<div id="stripe-exp-element" class="wc-stripe-elements-field">
319 319
 					<!-- a Stripe Element will be inserted here. -->
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 				</div>
322 322
 
323 323
 				<div class="form-row form-row-last">
324
-					<label for="stripe-cvc-element"><?php esc_html_e( 'Card Code (CVC)', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
324
+					<label for="stripe-cvc-element"><?php esc_html_e('Card Code (CVC)', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
325 325
 				<div id="stripe-cvc-element" class="wc-stripe-elements-field">
326 326
 				<!-- a Stripe Element will be inserted here. -->
327 327
 				</div>
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 			<!-- Used to display form errors -->
333 333
 			<div class="stripe-source-errors" role="alert"></div>
334 334
 			<br />
335
-			<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
335
+			<?php do_action('woocommerce_credit_card_form_end', $this->id); ?>
336 336
 			<div class="clear"></div>
337 337
 		</fieldset>
338 338
 		<?php
@@ -345,13 +345,13 @@  discard block
 block discarded – undo
345 345
 	 * @version 3.1.0
346 346
 	 */
347 347
 	public function admin_scripts() {
348
-		if ( 'woocommerce_page_wc-settings' !== get_current_screen()->id ) {
348
+		if ('woocommerce_page_wc-settings' !== get_current_screen()->id) {
349 349
 			return;
350 350
 		}
351 351
 
352
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
352
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
353 353
 
354
-		wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true );
354
+		wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true);
355 355
 	}
356 356
 
357 357
 	/**
@@ -368,54 +368,54 @@  discard block
 block discarded – undo
368 368
 			! is_product()
369 369
 			&& ! is_cart()
370 370
 			&& ! is_checkout()
371
-			&& ! isset( $_GET['pay_for_order'] ) // wpcs: csrf ok.
371
+			&& ! isset($_GET['pay_for_order']) // wpcs: csrf ok.
372 372
 			&& ! is_add_payment_method_page()
373
-			&& ! isset( $_GET['change_payment_method'] ) // wpcs: csrf ok.
374
-			&& ! ( ! empty( get_query_var( 'view-subscription' ) ) && is_callable( 'WCS_Early_Renewal_Manager::is_early_renewal_via_modal_enabled' ) && WCS_Early_Renewal_Manager::is_early_renewal_via_modal_enabled() )
375
-			|| ( is_order_received_page() )
373
+			&& ! isset($_GET['change_payment_method']) // wpcs: csrf ok.
374
+			&& ! ( ! empty(get_query_var('view-subscription')) && is_callable('WCS_Early_Renewal_Manager::is_early_renewal_via_modal_enabled') && WCS_Early_Renewal_Manager::is_early_renewal_via_modal_enabled())
375
+			|| (is_order_received_page())
376 376
 		) {
377 377
 			return;
378 378
 		}
379 379
 
380 380
 		// If Stripe is not enabled bail.
381
-		if ( 'no' === $this->enabled ) {
381
+		if ('no' === $this->enabled) {
382 382
 			return;
383 383
 		}
384 384
 
385 385
 		// If keys are not set bail.
386
-		if ( ! $this->are_keys_set() ) {
387
-			WC_Stripe_Logger::log( 'Keys are not set correctly.' );
386
+		if ( ! $this->are_keys_set()) {
387
+			WC_Stripe_Logger::log('Keys are not set correctly.');
388 388
 			return;
389 389
 		}
390 390
 
391 391
 		// If no SSL bail.
392
-		if ( ! $this->testmode && ! is_ssl() ) {
393
-			WC_Stripe_Logger::log( 'Stripe live mode requires SSL.' );
392
+		if ( ! $this->testmode && ! is_ssl()) {
393
+			WC_Stripe_Logger::log('Stripe live mode requires SSL.');
394 394
 			return;
395 395
 		}
396 396
 
397 397
 		$current_theme = wp_get_theme();
398 398
 
399
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
399
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
400 400
 
401
-		wp_register_style( 'stripe_styles', plugins_url( 'assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION );
402
-		wp_enqueue_style( 'stripe_styles' );
401
+		wp_register_style('stripe_styles', plugins_url('assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION);
402
+		wp_enqueue_style('stripe_styles');
403 403
 
404
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
405
-		wp_register_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripe' ), WC_STRIPE_VERSION, true );
404
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
405
+		wp_register_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripe'), WC_STRIPE_VERSION, true);
406 406
 
407 407
 		$stripe_params = array(
408 408
 			'key'                  => $this->publishable_key,
409
-			'i18n_terms'           => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ),
410
-			'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ),
409
+			'i18n_terms'           => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'),
410
+			'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'),
411 411
 		);
412 412
 
413 413
 		// If we're on the pay page we need to pass stripe.js the address of the order.
414
-		if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) { // wpcs: csrf ok.
415
-			$order_id = wc_clean( $wp->query_vars['order-pay'] ); // wpcs: csrf ok, sanitization ok, xss ok.
416
-			$order    = wc_get_order( $order_id );
414
+		if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) { // wpcs: csrf ok.
415
+			$order_id = wc_clean($wp->query_vars['order-pay']); // wpcs: csrf ok, sanitization ok, xss ok.
416
+			$order    = wc_get_order($order_id);
417 417
 
418
-			if ( is_a( $order, 'WC_Order' ) ) {
418
+			if (is_a($order, 'WC_Order')) {
419 419
 				$stripe_params['billing_first_name'] = $order->get_billing_first_name();
420 420
 				$stripe_params['billing_last_name']  = $order->get_billing_last_name();
421 421
 				$stripe_params['billing_address_1']  = $order->get_billing_address_1();
@@ -430,40 +430,40 @@  discard block
 block discarded – undo
430 430
 		$sepa_elements_options = apply_filters(
431 431
 			'wc_stripe_sepa_elements_options',
432 432
 			array(
433
-				'supportedCountries' => array( 'SEPA' ),
433
+				'supportedCountries' => array('SEPA'),
434 434
 				'placeholderCountry' => WC()->countries->get_base_country(),
435
-				'style'              => array( 'base' => array( 'fontSize' => '15px' ) ),
435
+				'style'              => array('base' => array('fontSize' => '15px')),
436 436
 			)
437 437
 		);
438 438
 
439
-		$stripe_params['no_prepaid_card_msg']       = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
440
-		$stripe_params['no_sepa_owner_msg']         = __( 'Please enter your IBAN account name.', 'woocommerce-gateway-stripe' );
441
-		$stripe_params['no_sepa_iban_msg']          = __( 'Please enter your IBAN account number.', 'woocommerce-gateway-stripe' );
442
-		$stripe_params['payment_intent_error']      = __( 'We couldn\'t initiate the payment. Please try again.', 'woocommerce-gateway-stripe' );
443
-		$stripe_params['sepa_mandate_notification'] = apply_filters( 'wc_stripe_sepa_mandate_notification', 'email' );
444
-		$stripe_params['allow_prepaid_card']        = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no';
439
+		$stripe_params['no_prepaid_card_msg']       = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
440
+		$stripe_params['no_sepa_owner_msg']         = __('Please enter your IBAN account name.', 'woocommerce-gateway-stripe');
441
+		$stripe_params['no_sepa_iban_msg']          = __('Please enter your IBAN account number.', 'woocommerce-gateway-stripe');
442
+		$stripe_params['payment_intent_error']      = __('We couldn\'t initiate the payment. Please try again.', 'woocommerce-gateway-stripe');
443
+		$stripe_params['sepa_mandate_notification'] = apply_filters('wc_stripe_sepa_mandate_notification', 'email');
444
+		$stripe_params['allow_prepaid_card']        = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no';
445 445
 		$stripe_params['inline_cc_form']            = $this->inline_cc_form ? 'yes' : 'no';
446
-		$stripe_params['is_checkout']               = ( is_checkout() && empty( $_GET['pay_for_order'] ) ) ? 'yes' : 'no'; // wpcs: csrf ok.
446
+		$stripe_params['is_checkout']               = (is_checkout() && empty($_GET['pay_for_order'])) ? 'yes' : 'no'; // wpcs: csrf ok.
447 447
 		$stripe_params['return_url']                = $this->get_stripe_return_url();
448
-		$stripe_params['ajaxurl']                   = WC_AJAX::get_endpoint( '%%endpoint%%' );
449
-		$stripe_params['stripe_nonce']              = wp_create_nonce( '_wc_stripe_nonce' );
448
+		$stripe_params['ajaxurl']                   = WC_AJAX::get_endpoint('%%endpoint%%');
449
+		$stripe_params['stripe_nonce']              = wp_create_nonce('_wc_stripe_nonce');
450 450
 		$stripe_params['statement_descriptor']      = $this->statement_descriptor;
451
-		$stripe_params['elements_options']          = apply_filters( 'wc_stripe_elements_options', array() );
451
+		$stripe_params['elements_options']          = apply_filters('wc_stripe_elements_options', array());
452 452
 		$stripe_params['sepa_elements_options']     = $sepa_elements_options;
453
-		$stripe_params['invalid_owner_name']        = __( 'Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe' );
454
-		$stripe_params['is_change_payment_page']    = isset( $_GET['change_payment_method'] ) ? 'yes' : 'no'; // wpcs: csrf ok.
455
-		$stripe_params['is_add_payment_page']       = is_wc_endpoint_url( 'add-payment-method' ) ? 'yes' : 'no';
456
-		$stripe_params['is_pay_for_order_page']     = is_wc_endpoint_url( 'order-pay' ) ? 'yes' : 'no';
457
-		$stripe_params['elements_styling']          = apply_filters( 'wc_stripe_elements_styling', false );
458
-		$stripe_params['elements_classes']          = apply_filters( 'wc_stripe_elements_classes', false );
453
+		$stripe_params['invalid_owner_name']        = __('Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe');
454
+		$stripe_params['is_change_payment_page']    = isset($_GET['change_payment_method']) ? 'yes' : 'no'; // wpcs: csrf ok.
455
+		$stripe_params['is_add_payment_page']       = is_wc_endpoint_url('add-payment-method') ? 'yes' : 'no';
456
+		$stripe_params['is_pay_for_order_page']     = is_wc_endpoint_url('order-pay') ? 'yes' : 'no';
457
+		$stripe_params['elements_styling']          = apply_filters('wc_stripe_elements_styling', false);
458
+		$stripe_params['elements_classes']          = apply_filters('wc_stripe_elements_classes', false);
459 459
 
460 460
 		// Merge localized messages to be use in JS.
461
-		$stripe_params = array_merge( $stripe_params, WC_Stripe_Helper::get_localized_messages() );
461
+		$stripe_params = array_merge($stripe_params, WC_Stripe_Helper::get_localized_messages());
462 462
 
463
-		wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
463
+		wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
464 464
 
465 465
 		$this->tokenization_script();
466
-		wp_enqueue_script( 'woocommerce_stripe' );
466
+		wp_enqueue_script('woocommerce_stripe');
467 467
 	}
468 468
 
469 469
 	/**
@@ -474,14 +474,14 @@  discard block
 block discarded – undo
474 474
 	 * @param object $prepared_source The object with source details.
475 475
 	 * @throws WC_Stripe_Exception An exception if the card is prepaid, but prepaid cards are not allowed.
476 476
 	 */
477
-	public function maybe_disallow_prepaid_card( $prepared_source ) {
477
+	public function maybe_disallow_prepaid_card($prepared_source) {
478 478
 		// Check if we don't allow prepaid credit cards.
479
-		if ( apply_filters( 'wc_stripe_allow_prepaid_card', true ) || ! $this->is_prepaid_card( $prepared_source->source_object ) ) {
479
+		if (apply_filters('wc_stripe_allow_prepaid_card', true) || ! $this->is_prepaid_card($prepared_source->source_object)) {
480 480
 			return;
481 481
 		}
482 482
 
483
-		$localized_message = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
484
-		throw new WC_Stripe_Exception( print_r( $prepared_source->source_object, true ), $localized_message );
483
+		$localized_message = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
484
+		throw new WC_Stripe_Exception(print_r($prepared_source->source_object, true), $localized_message);
485 485
 	}
486 486
 
487 487
 	/**
@@ -491,10 +491,10 @@  discard block
 block discarded – undo
491 491
 	 * @param  object $prepared_source The source that should be verified.
492 492
 	 * @throws WC_Stripe_Exception     An exception if the source ID is missing.
493 493
 	 */
494
-	public function check_source( $prepared_source ) {
495
-		if ( empty( $prepared_source->source ) ) {
496
-			$localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
497
-			throw new WC_Stripe_Exception( print_r( $prepared_source, true ), $localized_message );
494
+	public function check_source($prepared_source) {
495
+		if (empty($prepared_source->source)) {
496
+			$localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
497
+			throw new WC_Stripe_Exception(print_r($prepared_source, true), $localized_message);
498 498
 		}
499 499
 	}
500 500
 
@@ -506,13 +506,13 @@  discard block
 block discarded – undo
506 506
 	 * @param WC_Order $order The order those payment is being processed.
507 507
 	 * @return bool           A flag that indicates that the customer does not exist and should be removed.
508 508
 	 */
509
-	public function maybe_remove_non_existent_customer( $error, $order ) {
510
-		if ( ! $this->is_no_such_customer_error( $error ) ) {
509
+	public function maybe_remove_non_existent_customer($error, $order) {
510
+		if ( ! $this->is_no_such_customer_error($error)) {
511 511
 			return false;
512 512
 		}
513 513
 
514
-		delete_user_option( $order->get_customer_id(), '_stripe_customer_id' );
515
-		$order->delete_meta_data( '_stripe_customer_id' );
514
+		delete_user_option($order->get_customer_id(), '_stripe_customer_id');
515
+		$order->delete_meta_data('_stripe_customer_id');
516 516
 		$order->save();
517 517
 
518 518
 		return true;
@@ -527,15 +527,15 @@  discard block
 block discarded – undo
527 527
 	 * @param boolean  $force_save_source Whether the payment source must be saved, like when dealing with a Subscription setup.
528 528
 	 * @return array                      Redirection data for `process_payment`.
529 529
 	 */
530
-	public function complete_free_order( $order, $prepared_source, $force_save_source ) {
531
-		if ( $force_save_source ) {
532
-			$intent_secret = $this->setup_intent( $order, $prepared_source );
530
+	public function complete_free_order($order, $prepared_source, $force_save_source) {
531
+		if ($force_save_source) {
532
+			$intent_secret = $this->setup_intent($order, $prepared_source);
533 533
 
534
-			if ( ! empty( $intent_secret ) ) {
534
+			if ( ! empty($intent_secret)) {
535 535
 				// `get_return_url()` must be called immediately before returning a value.
536 536
 				return array(
537 537
 					'result'              => 'success',
538
-					'redirect'            => $this->get_return_url( $order ),
538
+					'redirect'            => $this->get_return_url($order),
539 539
 					'setup_intent_secret' => $intent_secret,
540 540
 				);
541 541
 			}
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 		// Return thank you page redirect.
550 550
 		return array(
551 551
 			'result'   => 'success',
552
-			'redirect' => $this->get_return_url( $order ),
552
+			'redirect' => $this->get_return_url($order),
553 553
 		);
554 554
 	}
555 555
 
@@ -567,81 +567,81 @@  discard block
 block discarded – undo
567 567
 	 * @throws Exception If payment will not be accepted.
568 568
 	 * @return array|void
569 569
 	 */
570
-	public function process_payment( $order_id, $retry = true, $force_save_source = false, $previous_error = false, $use_order_source = false ) {
570
+	public function process_payment($order_id, $retry = true, $force_save_source = false, $previous_error = false, $use_order_source = false) {
571 571
 		try {
572
-			$order = wc_get_order( $order_id );
572
+			$order = wc_get_order($order_id);
573 573
 
574 574
 			// ToDo: `process_pre_order` saves the source to the order for a later payment.
575 575
 			// This might not work well with PaymentIntents.
576
-			if ( $this->maybe_process_pre_orders( $order_id ) ) {
577
-				return $this->pre_orders->process_pre_order( $order_id );
576
+			if ($this->maybe_process_pre_orders($order_id)) {
577
+				return $this->pre_orders->process_pre_order($order_id);
578 578
 			}
579 579
 
580 580
 			// Check whether there is an existing intent.
581
-			$intent = $this->get_intent_from_order( $order );
582
-			if ( isset( $intent->object ) && 'setup_intent' === $intent->object ) {
581
+			$intent = $this->get_intent_from_order($order);
582
+			if (isset($intent->object) && 'setup_intent' === $intent->object) {
583 583
 				$intent = false; // This function can only deal with *payment* intents
584 584
 			}
585 585
 
586 586
 			$stripe_customer_id = null;
587
-			if ( $intent && ! empty( $intent->customer ) ) {
587
+			if ($intent && ! empty($intent->customer)) {
588 588
 				$stripe_customer_id = $intent->customer;
589 589
 			}
590 590
 
591 591
 			// For some payments the source should already be present in the order.
592
-			if ( $use_order_source ) {
593
-				$prepared_source = $this->prepare_order_source( $order );
592
+			if ($use_order_source) {
593
+				$prepared_source = $this->prepare_order_source($order);
594 594
 			} else {
595
-				$prepared_source = $this->prepare_source( get_current_user_id(), $force_save_source, $stripe_customer_id );
595
+				$prepared_source = $this->prepare_source(get_current_user_id(), $force_save_source, $stripe_customer_id);
596 596
 			}
597 597
 
598
-			$this->maybe_disallow_prepaid_card( $prepared_source );
599
-			$this->check_source( $prepared_source );
600
-			$this->save_source_to_order( $order, $prepared_source );
598
+			$this->maybe_disallow_prepaid_card($prepared_source);
599
+			$this->check_source($prepared_source);
600
+			$this->save_source_to_order($order, $prepared_source);
601 601
 
602
-			if ( 0 >= $order->get_total() ) {
603
-				return $this->complete_free_order( $order, $prepared_source, $force_save_source );
602
+			if (0 >= $order->get_total()) {
603
+				return $this->complete_free_order($order, $prepared_source, $force_save_source);
604 604
 			}
605 605
 
606 606
 			// This will throw exception if not valid.
607
-			$this->validate_minimum_order_amount( $order );
607
+			$this->validate_minimum_order_amount($order);
608 608
 
609
-			WC_Stripe_Logger::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
609
+			WC_Stripe_Logger::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}");
610 610
 
611
-			if ( $intent ) {
612
-				$intent = $this->update_existing_intent( $intent, $order, $prepared_source );
611
+			if ($intent) {
612
+				$intent = $this->update_existing_intent($intent, $order, $prepared_source);
613 613
 			} else {
614
-				$intent = $this->create_intent( $order, $prepared_source );
614
+				$intent = $this->create_intent($order, $prepared_source);
615 615
 			}
616 616
 
617 617
 			// Confirm the intent after locking the order to make sure webhooks will not interfere.
618
-			if ( empty( $intent->error ) ) {
619
-				$this->lock_order_payment( $order, $intent );
620
-				$intent = $this->confirm_intent( $intent, $order, $prepared_source );
618
+			if (empty($intent->error)) {
619
+				$this->lock_order_payment($order, $intent);
620
+				$intent = $this->confirm_intent($intent, $order, $prepared_source);
621 621
 			}
622 622
 
623
-			if ( ! empty( $intent->error ) ) {
624
-				$this->maybe_remove_non_existent_customer( $intent->error, $order );
623
+			if ( ! empty($intent->error)) {
624
+				$this->maybe_remove_non_existent_customer($intent->error, $order);
625 625
 
626 626
 				// We want to retry.
627
-				if ( $this->is_retryable_error( $intent->error ) ) {
628
-					return $this->retry_after_error( $intent, $order, $retry, $force_save_source, $previous_error, $use_order_source );
627
+				if ($this->is_retryable_error($intent->error)) {
628
+					return $this->retry_after_error($intent, $order, $retry, $force_save_source, $previous_error, $use_order_source);
629 629
 				}
630 630
 
631
-				$this->unlock_order_payment( $order );
632
-				$this->throw_localized_message( $intent, $order );
631
+				$this->unlock_order_payment($order);
632
+				$this->throw_localized_message($intent, $order);
633 633
 			}
634 634
 
635
-			if ( ! empty( $intent ) ) {
635
+			if ( ! empty($intent)) {
636 636
 				// Use the last charge within the intent to proceed.
637
-				$response = end( $intent->charges->data );
637
+				$response = end($intent->charges->data);
638 638
 
639 639
 				// If the intent requires a 3DS flow, redirect to it.
640
-				if ( 'requires_action' === $intent->status ) {
641
-					$this->unlock_order_payment( $order );
640
+				if ('requires_action' === $intent->status) {
641
+					$this->unlock_order_payment($order);
642 642
 
643
-					if ( is_wc_endpoint_url( 'order-pay' ) ) {
644
-						$redirect_url = add_query_arg( 'wc-stripe-confirmation', 1, $order->get_checkout_payment_url( false ) );
643
+					if (is_wc_endpoint_url('order-pay')) {
644
+						$redirect_url = add_query_arg('wc-stripe-confirmation', 1, $order->get_checkout_payment_url(false));
645 645
 
646 646
 						return array(
647 647
 							'result'   => 'success',
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 
657 657
 						return array(
658 658
 							'result'                => 'success',
659
-							'redirect'              => $this->get_return_url( $order ),
659
+							'redirect'              => $this->get_return_url($order),
660 660
 							'payment_intent_secret' => $intent->client_secret,
661 661
 						);
662 662
 					}
@@ -664,30 +664,30 @@  discard block
 block discarded – undo
664 664
 			}
665 665
 
666 666
 			// Process valid response.
667
-			$this->process_response( $response, $order );
667
+			$this->process_response($response, $order);
668 668
 
669 669
 			// Remove cart.
670
-			if ( isset( WC()->cart ) ) {
670
+			if (isset(WC()->cart)) {
671 671
 				WC()->cart->empty_cart();
672 672
 			}
673 673
 
674 674
 			// Unlock the order.
675
-			$this->unlock_order_payment( $order );
675
+			$this->unlock_order_payment($order);
676 676
 
677 677
 			// Return thank you page redirect.
678 678
 			return array(
679 679
 				'result'   => 'success',
680
-				'redirect' => $this->get_return_url( $order ),
680
+				'redirect' => $this->get_return_url($order),
681 681
 			);
682 682
 
683
-		} catch ( WC_Stripe_Exception $e ) {
684
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
685
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
683
+		} catch (WC_Stripe_Exception $e) {
684
+			wc_add_notice($e->getLocalizedMessage(), 'error');
685
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
686 686
 
687
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
687
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
688 688
 
689 689
 			/* translators: error message */
690
-			$order->update_status( 'failed' );
690
+			$order->update_status('failed');
691 691
 
692 692
 			return array(
693 693
 				'result'   => 'fail',
@@ -703,17 +703,17 @@  discard block
 block discarded – undo
703 703
 	 *
704 704
 	 * @param int $order_id The ID of the order.
705 705
 	 */
706
-	public function display_order_fee( $order_id ) {
707
-		if ( apply_filters( 'wc_stripe_hide_display_order_fee', false, $order_id ) ) {
706
+	public function display_order_fee($order_id) {
707
+		if (apply_filters('wc_stripe_hide_display_order_fee', false, $order_id)) {
708 708
 			return;
709 709
 		}
710 710
 
711
-		$order = wc_get_order( $order_id );
711
+		$order = wc_get_order($order_id);
712 712
 
713
-		$fee      = WC_Stripe_Helper::get_stripe_fee( $order );
714
-		$currency = WC_Stripe_Helper::get_stripe_currency( $order );
713
+		$fee      = WC_Stripe_Helper::get_stripe_fee($order);
714
+		$currency = WC_Stripe_Helper::get_stripe_currency($order);
715 715
 
716
-		if ( ! $fee || ! $currency ) {
716
+		if ( ! $fee || ! $currency) {
717 717
 			return;
718 718
 		}
719 719
 
@@ -721,12 +721,12 @@  discard block
 block discarded – undo
721 721
 
722 722
 		<tr>
723 723
 			<td class="label stripe-fee">
724
-				<?php echo wc_help_tip( __( 'This represents the fee Stripe collects for the transaction.', 'woocommerce-gateway-stripe' ) ); // wpcs: xss ok. ?>
725
-				<?php esc_html_e( 'Stripe Fee:', 'woocommerce-gateway-stripe' ); ?>
724
+				<?php echo wc_help_tip(__('This represents the fee Stripe collects for the transaction.', 'woocommerce-gateway-stripe')); // wpcs: xss ok. ?>
725
+				<?php esc_html_e('Stripe Fee:', 'woocommerce-gateway-stripe'); ?>
726 726
 			</td>
727 727
 			<td width="1%"></td>
728 728
 			<td class="total">
729
-				-&nbsp;<?php echo wc_price( $fee, array( 'currency' => $currency ) ); // wpcs: xss ok. ?>
729
+				-&nbsp;<?php echo wc_price($fee, array('currency' => $currency)); // wpcs: xss ok. ?>
730 730
 			</td>
731 731
 		</tr>
732 732
 
@@ -740,17 +740,17 @@  discard block
 block discarded – undo
740 740
 	 *
741 741
 	 * @param int $order_id The ID of the order.
742 742
 	 */
743
-	public function display_order_payout( $order_id ) {
744
-		if ( apply_filters( 'wc_stripe_hide_display_order_payout', false, $order_id ) ) {
743
+	public function display_order_payout($order_id) {
744
+		if (apply_filters('wc_stripe_hide_display_order_payout', false, $order_id)) {
745 745
 			return;
746 746
 		}
747 747
 
748
-		$order = wc_get_order( $order_id );
748
+		$order = wc_get_order($order_id);
749 749
 
750
-		$net      = WC_Stripe_Helper::get_stripe_net( $order );
751
-		$currency = WC_Stripe_Helper::get_stripe_currency( $order );
750
+		$net      = WC_Stripe_Helper::get_stripe_net($order);
751
+		$currency = WC_Stripe_Helper::get_stripe_currency($order);
752 752
 
753
-		if ( ! $net || ! $currency ) {
753
+		if ( ! $net || ! $currency) {
754 754
 			return;
755 755
 		}
756 756
 
@@ -758,12 +758,12 @@  discard block
 block discarded – undo
758 758
 
759 759
 		<tr>
760 760
 			<td class="label stripe-payout">
761
-				<?php echo wc_help_tip( __( 'This represents the net total that will be credited to your Stripe bank account. This may be in the currency that is set in your Stripe account.', 'woocommerce-gateway-stripe' ) ); // wpcs: xss ok. ?>
762
-				<?php esc_html_e( 'Stripe Payout:', 'woocommerce-gateway-stripe' ); ?>
761
+				<?php echo wc_help_tip(__('This represents the net total that will be credited to your Stripe bank account. This may be in the currency that is set in your Stripe account.', 'woocommerce-gateway-stripe')); // wpcs: xss ok. ?>
762
+				<?php esc_html_e('Stripe Payout:', 'woocommerce-gateway-stripe'); ?>
763 763
 			</td>
764 764
 			<td width="1%"></td>
765 765
 			<td class="total">
766
-				<?php echo wc_price( $net, array( 'currency' => $currency ) ); // wpcs: xss ok. ?>
766
+				<?php echo wc_price($net, array('currency' => $currency)); // wpcs: xss ok. ?>
767 767
 			</td>
768 768
 		</tr>
769 769
 
@@ -779,13 +779,13 @@  discard block
 block discarded – undo
779 779
 	 *
780 780
 	 * @return string The localized error message.
781 781
 	 */
782
-	public function get_localized_error_message_from_response( $response ) {
782
+	public function get_localized_error_message_from_response($response) {
783 783
 		$localized_messages = WC_Stripe_Helper::get_localized_messages();
784 784
 
785
-		if ( 'card_error' === $response->error->type ) {
786
-			$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
785
+		if ('card_error' === $response->error->type) {
786
+			$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
787 787
 		} else {
788
-			$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
788
+			$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
789 789
 		}
790 790
 
791 791
 		return $localized_message;
@@ -799,12 +799,12 @@  discard block
 block discarded – undo
799 799
 	 * @param  WC_Order $order     The order to add a note to.
800 800
 	 * @throws WC_Stripe_Exception An exception with the right message.
801 801
 	 */
802
-	public function throw_localized_message( $response, $order ) {
803
-		$localized_message = $this->get_localized_error_message_from_response( $response );
802
+	public function throw_localized_message($response, $order) {
803
+		$localized_message = $this->get_localized_error_message_from_response($response);
804 804
 
805
-		$order->add_order_note( $localized_message );
805
+		$order->add_order_note($localized_message);
806 806
 
807
-		throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
807
+		throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
808 808
 	}
809 809
 
810 810
 	/**
@@ -820,22 +820,22 @@  discard block
 block discarded – undo
820 820
 	 * @throws WC_Stripe_Exception        If the payment is not accepted.
821 821
 	 * @return array|void
822 822
 	 */
823
-	public function retry_after_error( $response, $order, $retry, $force_save_source, $previous_error, $use_order_source ) {
824
-		if ( ! $retry ) {
825
-			$localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' );
826
-			$order->add_order_note( $localized_message );
827
-			throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.
823
+	public function retry_after_error($response, $order, $retry, $force_save_source, $previous_error, $use_order_source) {
824
+		if ( ! $retry) {
825
+			$localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe');
826
+			$order->add_order_note($localized_message);
827
+			throw new WC_Stripe_Exception(print_r($response, true), $localized_message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.
828 828
 		}
829 829
 
830 830
 		// Don't do anymore retries after this.
831
-		if ( 5 <= $this->retry_interval ) {
832
-			return $this->process_payment( $order->get_id(), false, $force_save_source, $response->error, $previous_error );
831
+		if (5 <= $this->retry_interval) {
832
+			return $this->process_payment($order->get_id(), false, $force_save_source, $response->error, $previous_error);
833 833
 		}
834 834
 
835
-		sleep( $this->retry_interval );
835
+		sleep($this->retry_interval);
836 836
 		$this->retry_interval++;
837 837
 
838
-		return $this->process_payment( $order->get_id(), true, $force_save_source, $response->error, $previous_error, $use_order_source );
838
+		return $this->process_payment($order->get_id(), true, $force_save_source, $response->error, $previous_error, $use_order_source);
839 839
 	}
840 840
 
841 841
 	/**
@@ -845,35 +845,35 @@  discard block
 block discarded – undo
845 845
 	 * @since 4.2
846 846
 	 */
847 847
 	public function prepare_order_pay_page() {
848
-		if ( ! is_wc_endpoint_url( 'order-pay' ) || ! isset( $_GET['wc-stripe-confirmation'] ) ) { // wpcs: csrf ok.
848
+		if ( ! is_wc_endpoint_url('order-pay') || ! isset($_GET['wc-stripe-confirmation'])) { // wpcs: csrf ok.
849 849
 			return;
850 850
 		}
851 851
 
852 852
 		try {
853 853
 			$this->prepare_intent_for_order_pay_page();
854
-		} catch ( WC_Stripe_Exception $e ) {
854
+		} catch (WC_Stripe_Exception $e) {
855 855
 			// Just show the full order pay page if there was a problem preparing the Payment Intent
856 856
 			return;
857 857
 		}
858 858
 
859
-		add_filter( 'woocommerce_checkout_show_terms', '__return_false' );
860
-		add_filter( 'woocommerce_pay_order_button_html', '__return_false' );
861
-		add_filter( 'woocommerce_available_payment_gateways', '__return_empty_array' );
862
-		add_filter( 'woocommerce_no_available_payment_methods_message', array( $this, 'change_no_available_methods_message' ) );
863
-		add_action( 'woocommerce_pay_order_after_submit', array( $this, 'render_intent_inputs' ) );
864
-		add_action( 'after_woocommerce_pay', array( $this, 'render_intent_inputs' ), 101 );
859
+		add_filter('woocommerce_checkout_show_terms', '__return_false');
860
+		add_filter('woocommerce_pay_order_button_html', '__return_false');
861
+		add_filter('woocommerce_available_payment_gateways', '__return_empty_array');
862
+		add_filter('woocommerce_no_available_payment_methods_message', array($this, 'change_no_available_methods_message'));
863
+		add_action('woocommerce_pay_order_after_submit', array($this, 'render_intent_inputs'));
864
+		add_action('after_woocommerce_pay', array($this, 'render_intent_inputs'), 101);
865 865
 	}
866 866
 
867 867
 	/**
868 868
 	 * Removes hooks modifying "Pay for order" page (i.e. so that later hooks can operate on available payment gateways).
869 869
 	 */
870 870
 	public function restore_order_pay_page() {
871
-		remove_filter( 'woocommerce_checkout_show_terms', '__return_false' );
872
-		remove_filter( 'woocommerce_pay_order_button_html', '__return_false' );
873
-		remove_filter( 'woocommerce_available_payment_gateways', '__return_empty_array' );
874
-		remove_filter( 'woocommerce_no_available_payment_methods_message', array( $this, 'change_no_available_methods_message' ) );
875
-		remove_action( 'woocommerce_pay_order_after_submit', array( $this, 'render_intent_inputs' ) );
876
-		remove_action( 'after_woocommerce_pay', array( $this, 'render_intent_inputs' ), 101 );
871
+		remove_filter('woocommerce_checkout_show_terms', '__return_false');
872
+		remove_filter('woocommerce_pay_order_button_html', '__return_false');
873
+		remove_filter('woocommerce_available_payment_gateways', '__return_empty_array');
874
+		remove_filter('woocommerce_no_available_payment_methods_message', array($this, 'change_no_available_methods_message'));
875
+		remove_action('woocommerce_pay_order_after_submit', array($this, 'render_intent_inputs'));
876
+		remove_action('after_woocommerce_pay', array($this, 'render_intent_inputs'), 101);
877 877
 	}
878 878
 
879 879
 	/**
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 	 * @return string the new message.
885 885
 	 */
886 886
 	public function change_no_available_methods_message() {
887
-		return __( "Almost there!\n\nYour order has already been created, the only thing that still needs to be done is for you to authorize the payment with your bank.", 'woocommerce-gateway-stripe' );
887
+		return __("Almost there!\n\nYour order has already been created, the only thing that still needs to be done is for you to authorize the payment with your bank.", 'woocommerce-gateway-stripe');
888 888
 	}
889 889
 
890 890
 	/**
@@ -895,19 +895,19 @@  discard block
 block discarded – undo
895 895
 	 * @throws WC_Stripe_Exception
896 896
 	 * @since 4.3
897 897
 	 */
898
-	public function prepare_intent_for_order_pay_page( $order = null ) {
899
-		if ( ! isset( $order ) || empty( $order ) ) {
900
-			$order = wc_get_order( absint( get_query_var( 'order-pay' ) ) );
898
+	public function prepare_intent_for_order_pay_page($order = null) {
899
+		if ( ! isset($order) || empty($order)) {
900
+			$order = wc_get_order(absint(get_query_var('order-pay')));
901 901
 		}
902
-		$intent = $this->get_intent_from_order( $order );
902
+		$intent = $this->get_intent_from_order($order);
903 903
 
904
-		if ( ! $intent ) {
905
-			throw new WC_Stripe_Exception( 'Intent not found', __( 'Intent not found for order #' . $order->get_id(), 'woocommerce-gateway-stripe' ) );
904
+		if ( ! $intent) {
905
+			throw new WC_Stripe_Exception('Intent not found', __('Intent not found for order #' . $order->get_id(), 'woocommerce-gateway-stripe'));
906 906
 		}
907 907
 
908
-		if ( 'requires_payment_method' === $intent->status && isset( $intent->last_payment_error )
909
-		     && 'authentication_required' === $intent->last_payment_error->code ) {
910
-			$level3_data = $this->get_level3_data_from_order( $order );
908
+		if ('requires_payment_method' === $intent->status && isset($intent->last_payment_error)
909
+		     && 'authentication_required' === $intent->last_payment_error->code) {
910
+			$level3_data = $this->get_level3_data_from_order($order);
911 911
 			$intent      = WC_Stripe_API::request_with_level3_data(
912 912
 				array(
913 913
 					'payment_method' => $intent->last_payment_error->source->id,
@@ -917,8 +917,8 @@  discard block
 block discarded – undo
917 917
 				$order
918 918
 			);
919 919
 
920
-			if ( isset( $intent->error ) ) {
921
-				throw new WC_Stripe_Exception( print_r( $intent, true ), $intent->error->message );
920
+			if (isset($intent->error)) {
921
+				throw new WC_Stripe_Exception(print_r($intent, true), $intent->error->message);
922 922
 			}
923 923
 		}
924 924
 
@@ -933,31 +933,31 @@  discard block
 block discarded – undo
933 933
 	 * @throws WC_Stripe_Exception
934 934
 	 * @since 4.2
935 935
 	 */
936
-	public function render_intent_inputs( $order = null ) {
937
-		if ( ! isset( $order ) || empty( $order ) ) {
938
-			$order = wc_get_order( absint( get_query_var( 'order-pay' ) ) );
936
+	public function render_intent_inputs($order = null) {
937
+		if ( ! isset($order) || empty($order)) {
938
+			$order = wc_get_order(absint(get_query_var('order-pay')));
939 939
 		}
940
-		if ( ! isset( $this->order_pay_intent ) ) {
941
-			$this->prepare_intent_for_order_pay_page( $order );
940
+		if ( ! isset($this->order_pay_intent)) {
941
+			$this->prepare_intent_for_order_pay_page($order);
942 942
 		}
943 943
 
944
-		$redirect_url = rawurlencode( $this->get_return_url( $order ) );
944
+		$redirect_url = rawurlencode($this->get_return_url($order));
945 945
 
946
-		if ( isset( $_GET['wc-stripe-redirect'] ) ) {
946
+		if (isset($_GET['wc-stripe-redirect'])) {
947 947
 			$redirect_url = $_GET['wc-stripe-redirect'];
948 948
 		}
949 949
 
950 950
 		$verification_url = add_query_arg(
951 951
 			array(
952 952
 				'order'       => $order->get_id(),
953
-				'nonce'       => wp_create_nonce( 'wc_stripe_confirm_pi' ),
953
+				'nonce'       => wp_create_nonce('wc_stripe_confirm_pi'),
954 954
 				'redirect_to' => $redirect_url,
955 955
 			),
956
-			WC_AJAX::get_endpoint( 'wc_stripe_verify_intent' )
956
+			WC_AJAX::get_endpoint('wc_stripe_verify_intent')
957 957
 		);
958 958
 
959
-		echo '<input type="hidden" id="stripe-intent-id" value="' . esc_attr( $this->order_pay_intent->client_secret ) . '" />';
960
-		echo '<input type="hidden" id="stripe-intent-return" value="' . esc_attr( $verification_url ) . '" />';
959
+		echo '<input type="hidden" id="stripe-intent-id" value="' . esc_attr($this->order_pay_intent->client_secret) . '" />';
960
+		echo '<input type="hidden" id="stripe-intent-return" value="' . esc_attr($verification_url) . '" />';
961 961
 	}
962 962
 
963 963
 	/**
@@ -967,11 +967,11 @@  discard block
 block discarded – undo
967 967
 	 * @param WC_Payment_Token $token Payment Token.
968 968
 	 * @return string                 Generated payment method HTML
969 969
 	 */
970
-	public function get_saved_payment_method_option_html( $token ) {
971
-		$html          = parent::get_saved_payment_method_option_html( $token );
970
+	public function get_saved_payment_method_option_html($token) {
971
+		$html          = parent::get_saved_payment_method_option_html($token);
972 972
 		$error_wrapper = '<div class="stripe-source-errors" role="alert"></div>';
973 973
 
974
-		return preg_replace( '~</(\w+)>\s*$~', "$error_wrapper</$1>", $html );
974
+		return preg_replace('~</(\w+)>\s*$~', "$error_wrapper</$1>", $html);
975 975
 	}
976 976
 
977 977
 	/**
@@ -981,18 +981,18 @@  discard block
 block discarded – undo
981 981
 	 * @since 4.2.0
982 982
 	 * @param int $order_id The ID that will be used for the thank you page.
983 983
 	 */
984
-	public function check_intent_status_on_order_page( $order_id ) {
985
-		if ( empty( $order_id ) || absint( $order_id ) <= 0 ) {
984
+	public function check_intent_status_on_order_page($order_id) {
985
+		if (empty($order_id) || absint($order_id) <= 0) {
986 986
 			return;
987 987
 		}
988 988
 
989
-		$order = wc_get_order( absint( $order_id ) );
989
+		$order = wc_get_order(absint($order_id));
990 990
 
991
-		if ( ! $order ) {
991
+		if ( ! $order) {
992 992
 			return;
993 993
 		}
994 994
 
995
-		$this->verify_intent_after_checkout( $order );
995
+		$this->verify_intent_after_checkout($order);
996 996
 	}
997 997
 
998 998
 	/**
@@ -1006,8 +1006,8 @@  discard block
 block discarded – undo
1006 1006
 	 * @param int   $order_id The ID of the order which is being paid for.
1007 1007
 	 * @return array
1008 1008
 	 */
1009
-	public function modify_successful_payment_result( $result, $order_id ) {
1010
-		if ( ! isset( $result['payment_intent_secret'] ) && ! isset( $result['setup_intent_secret'] ) ) {
1009
+	public function modify_successful_payment_result($result, $order_id) {
1010
+		if ( ! isset($result['payment_intent_secret']) && ! isset($result['setup_intent_secret'])) {
1011 1011
 			// Only redirects with intents need to be modified.
1012 1012
 			return $result;
1013 1013
 		}
@@ -1016,16 +1016,16 @@  discard block
 block discarded – undo
1016 1016
 		$verification_url = add_query_arg(
1017 1017
 			array(
1018 1018
 				'order'       => $order_id,
1019
-				'nonce'       => wp_create_nonce( 'wc_stripe_confirm_pi' ),
1020
-				'redirect_to' => rawurlencode( $result['redirect'] ),
1019
+				'nonce'       => wp_create_nonce('wc_stripe_confirm_pi'),
1020
+				'redirect_to' => rawurlencode($result['redirect']),
1021 1021
 			),
1022
-			WC_AJAX::get_endpoint( 'wc_stripe_verify_intent' )
1022
+			WC_AJAX::get_endpoint('wc_stripe_verify_intent')
1023 1023
 		);
1024 1024
 
1025
-		if ( isset( $result['payment_intent_secret'] ) ) {
1026
-			$redirect = sprintf( '#confirm-pi-%s:%s', $result['payment_intent_secret'], rawurlencode( $verification_url ) );
1027
-		} else if ( isset( $result['setup_intent_secret'] ) ) {
1028
-			$redirect = sprintf( '#confirm-si-%s:%s', $result['setup_intent_secret'], rawurlencode( $verification_url ) );
1025
+		if (isset($result['payment_intent_secret'])) {
1026
+			$redirect = sprintf('#confirm-pi-%s:%s', $result['payment_intent_secret'], rawurlencode($verification_url));
1027
+		} else if (isset($result['setup_intent_secret'])) {
1028
+			$redirect = sprintf('#confirm-si-%s:%s', $result['setup_intent_secret'], rawurlencode($verification_url));
1029 1029
 		}
1030 1030
 
1031 1031
 		return array(
@@ -1037,8 +1037,8 @@  discard block
 block discarded – undo
1037 1037
 	/**
1038 1038
 	 * Proceed with current request using new login session (to ensure consistent nonce).
1039 1039
 	 */
1040
-	public function set_cookie_on_current_request( $cookie ) {
1041
-		$_COOKIE[ LOGGED_IN_COOKIE ] = $cookie;
1040
+	public function set_cookie_on_current_request($cookie) {
1041
+		$_COOKIE[LOGGED_IN_COOKIE] = $cookie;
1042 1042
 	}
1043 1043
 
1044 1044
 	/**
@@ -1048,48 +1048,48 @@  discard block
 block discarded – undo
1048 1048
 	 * @since 4.2.0
1049 1049
 	 * @param WC_Order $order The order which is in a transitional state.
1050 1050
 	 */
1051
-	public function verify_intent_after_checkout( $order ) {
1051
+	public function verify_intent_after_checkout($order) {
1052 1052
 		$payment_method = $order->get_payment_method();
1053
-		if ( $payment_method !== $this->id ) {
1053
+		if ($payment_method !== $this->id) {
1054 1054
 			// If this is not the payment method, an intent would not be available.
1055 1055
 			return;
1056 1056
 		}
1057 1057
 
1058
-		$intent = $this->get_intent_from_order( $order );
1059
-		if ( ! $intent ) {
1058
+		$intent = $this->get_intent_from_order($order);
1059
+		if ( ! $intent) {
1060 1060
 			// No intent, redirect to the order received page for further actions.
1061 1061
 			return;
1062 1062
 		}
1063 1063
 
1064 1064
 		// A webhook might have modified or locked the order while the intent was retreived. This ensures we are reading the right status.
1065
-		clean_post_cache( $order->get_id() );
1066
-		$order = wc_get_order( $order->get_id() );
1065
+		clean_post_cache($order->get_id());
1066
+		$order = wc_get_order($order->get_id());
1067 1067
 
1068
-		if ( ! $order->has_status( array( 'pending', 'failed' ) ) ) {
1068
+		if ( ! $order->has_status(array('pending', 'failed'))) {
1069 1069
 			// If payment has already been completed, this function is redundant.
1070 1070
 			return;
1071 1071
 		}
1072 1072
 
1073
-		if ( $this->lock_order_payment( $order, $intent ) ) {
1073
+		if ($this->lock_order_payment($order, $intent)) {
1074 1074
 			return;
1075 1075
 		}
1076 1076
 
1077
-		if ( 'setup_intent' === $intent->object && 'succeeded' === $intent->status ) {
1077
+		if ('setup_intent' === $intent->object && 'succeeded' === $intent->status) {
1078 1078
 			WC()->cart->empty_cart();
1079
-			if ( WC_Stripe_Helper::is_pre_orders_exists() && WC_Pre_Orders_Order::order_contains_pre_order( $order ) ) {
1080
-				WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order );
1079
+			if (WC_Stripe_Helper::is_pre_orders_exists() && WC_Pre_Orders_Order::order_contains_pre_order($order)) {
1080
+				WC_Pre_Orders_Order::mark_order_as_pre_ordered($order);
1081 1081
 			} else {
1082 1082
 				$order->payment_complete();
1083 1083
 			}
1084
-		} else if ( 'succeeded' === $intent->status || 'requires_capture' === $intent->status ) {
1084
+		} else if ('succeeded' === $intent->status || 'requires_capture' === $intent->status) {
1085 1085
 			// Proceed with the payment completion.
1086
-			$this->handle_intent_verification_success( $order, $intent );
1087
-		} else if ( 'requires_payment_method' === $intent->status ) {
1086
+			$this->handle_intent_verification_success($order, $intent);
1087
+		} else if ('requires_payment_method' === $intent->status) {
1088 1088
 			// `requires_payment_method` means that SCA got denied for the current payment method.
1089
-			$this->handle_intent_verification_failure( $order, $intent );
1089
+			$this->handle_intent_verification_failure($order, $intent);
1090 1090
 		}
1091 1091
 
1092
-		$this->unlock_order_payment( $order );
1092
+		$this->unlock_order_payment($order);
1093 1093
 	}
1094 1094
 
1095 1095
 	/**
@@ -1099,8 +1099,8 @@  discard block
 block discarded – undo
1099 1099
 	 * @param WC_Order $order The order whose verification succeeded.
1100 1100
 	 * @param stdClass $intent The Payment Intent object.
1101 1101
 	 */
1102
-	protected function handle_intent_verification_success( $order, $intent ) {
1103
-		$this->process_response( end( $intent->charges->data ), $order );
1102
+	protected function handle_intent_verification_success($order, $intent) {
1103
+		$this->process_response(end($intent->charges->data), $order);
1104 1104
 	}
1105 1105
 
1106 1106
 	/**
@@ -1110,8 +1110,8 @@  discard block
 block discarded – undo
1110 1110
 	 * @param WC_Order $order The order whose verification failed.
1111 1111
 	 * @param stdClass $intent The Payment Intent object.
1112 1112
 	 */
1113
-	protected function handle_intent_verification_failure( $order, $intent ) {
1114
-		$this->failed_sca_auth( $order, $intent );
1113
+	protected function handle_intent_verification_failure($order, $intent) {
1114
+		$this->failed_sca_auth($order, $intent);
1115 1115
 	}
1116 1116
 
1117 1117
 	/**
@@ -1121,18 +1121,18 @@  discard block
 block discarded – undo
1121 1121
 	 * @param WC_Order $order  The order which should be checked.
1122 1122
 	 * @param object   $intent The intent, associated with the order.
1123 1123
 	 */
1124
-	public function failed_sca_auth( $order, $intent ) {
1124
+	public function failed_sca_auth($order, $intent) {
1125 1125
 		// If the order has already failed, do not repeat the same message.
1126
-		if ( $order->has_status( 'failed' ) ) {
1126
+		if ($order->has_status('failed')) {
1127 1127
 			return;
1128 1128
 		}
1129 1129
 
1130 1130
 		// Load the right message and update the status.
1131
-		$status_message = isset( $intent->last_payment_error )
1131
+		$status_message = isset($intent->last_payment_error)
1132 1132
 			/* translators: 1) The error message that was received from Stripe. */
1133
-			? sprintf( __( 'Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe' ), $intent->last_payment_error->message )
1134
-			: __( 'Stripe SCA authentication failed.', 'woocommerce-gateway-stripe' );
1135
-		$order->update_status( 'failed', $status_message );
1133
+			? sprintf(__('Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe'), $intent->last_payment_error->message)
1134
+			: __('Stripe SCA authentication failed.', 'woocommerce-gateway-stripe');
1135
+		$order->update_status('failed', $status_message);
1136 1136
 	}
1137 1137
 
1138 1138
 	/**
@@ -1143,10 +1143,10 @@  discard block
 block discarded – undo
1143 1143
 	 *
1144 1144
 	 * @return string Checkout URL for the given order.
1145 1145
 	 */
1146
-	public function get_checkout_payment_url( $pay_url, $order ) {
1146
+	public function get_checkout_payment_url($pay_url, $order) {
1147 1147
 		global $wp;
1148
-		if ( isset( $_GET['wc-stripe-confirmation'] ) && isset( $wp->query_vars['order-pay'] ) && $wp->query_vars['order-pay'] == $order->get_id() ) {
1149
-			$pay_url = add_query_arg( 'wc-stripe-confirmation', 1, $pay_url );
1148
+		if (isset($_GET['wc-stripe-confirmation']) && isset($wp->query_vars['order-pay']) && $wp->query_vars['order-pay'] == $order->get_id()) {
1149
+			$pay_url = add_query_arg('wc-stripe-confirmation', 1, $pay_url);
1150 1150
 		}
1151 1151
 		return $pay_url;
1152 1152
 	}
@@ -1156,63 +1156,63 @@  discard block
 block discarded – undo
1156 1156
 	 */
1157 1157
 	public function process_admin_options() {
1158 1158
 		// Load all old values before the new settings get saved.
1159
-		$old_publishable_key      = $this->get_option( 'publishable_key' );
1160
-		$old_secret_key           = $this->get_option( 'secret_key' );
1161
-		$old_test_publishable_key = $this->get_option( 'test_publishable_key' );
1162
-		$old_test_secret_key      = $this->get_option( 'test_secret_key' );
1159
+		$old_publishable_key      = $this->get_option('publishable_key');
1160
+		$old_secret_key           = $this->get_option('secret_key');
1161
+		$old_test_publishable_key = $this->get_option('test_publishable_key');
1162
+		$old_test_secret_key      = $this->get_option('test_secret_key');
1163 1163
 
1164 1164
 		parent::process_admin_options();
1165 1165
 
1166 1166
 		// Load all old values after the new settings have been saved.
1167
-		$new_publishable_key      = $this->get_option( 'publishable_key' );
1168
-		$new_secret_key           = $this->get_option( 'secret_key' );
1169
-		$new_test_publishable_key = $this->get_option( 'test_publishable_key' );
1170
-		$new_test_secret_key      = $this->get_option( 'test_secret_key' );
1167
+		$new_publishable_key      = $this->get_option('publishable_key');
1168
+		$new_secret_key           = $this->get_option('secret_key');
1169
+		$new_test_publishable_key = $this->get_option('test_publishable_key');
1170
+		$new_test_secret_key      = $this->get_option('test_secret_key');
1171 1171
 
1172 1172
 		// Checks whether a value has transitioned from a non-empty value to a new one.
1173
-		$has_changed = function( $old_value, $new_value ) {
1174
-			return ! empty( $old_value ) && ( $old_value !== $new_value );
1173
+		$has_changed = function($old_value, $new_value) {
1174
+			return ! empty($old_value) && ($old_value !== $new_value);
1175 1175
 		};
1176 1176
 
1177 1177
 		// Look for updates.
1178 1178
 		if (
1179
-			$has_changed( $old_publishable_key, $new_publishable_key )
1180
-			|| $has_changed( $old_secret_key, $new_secret_key )
1181
-			|| $has_changed( $old_test_publishable_key, $new_test_publishable_key )
1182
-			|| $has_changed( $old_test_secret_key, $new_test_secret_key )
1179
+			$has_changed($old_publishable_key, $new_publishable_key)
1180
+			|| $has_changed($old_secret_key, $new_secret_key)
1181
+			|| $has_changed($old_test_publishable_key, $new_test_publishable_key)
1182
+			|| $has_changed($old_test_secret_key, $new_test_secret_key)
1183 1183
 		) {
1184
-			update_option( 'wc_stripe_show_changed_keys_notice', 'yes' );
1184
+			update_option('wc_stripe_show_changed_keys_notice', 'yes');
1185 1185
 		}
1186 1186
 	}
1187 1187
 
1188
-	public function validate_publishable_key_field( $key, $value ) {
1189
-		$value = $this->validate_text_field( $key, $value );
1190
-		if ( ! empty( $value ) && ! preg_match( '/^pk_live_/', $value ) ) {
1191
-			throw new Exception( __( 'The "Live Publishable Key" should start with "pk_live", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1188
+	public function validate_publishable_key_field($key, $value) {
1189
+		$value = $this->validate_text_field($key, $value);
1190
+		if ( ! empty($value) && ! preg_match('/^pk_live_/', $value)) {
1191
+			throw new Exception(__('The "Live Publishable Key" should start with "pk_live", enter the correct key.', 'woocommerce-gateway-stripe'));
1192 1192
 		}
1193 1193
 		return $value;
1194 1194
 	}
1195 1195
 
1196
-	public function validate_secret_key_field( $key, $value ) {
1197
-		$value = $this->validate_text_field( $key, $value );
1198
-		if ( ! empty( $value ) && ! preg_match( '/^[rs]k_live_/', $value ) ) {
1199
-			throw new Exception( __( 'The "Live Secret Key" should start with "sk_live" or "rk_live", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1196
+	public function validate_secret_key_field($key, $value) {
1197
+		$value = $this->validate_text_field($key, $value);
1198
+		if ( ! empty($value) && ! preg_match('/^[rs]k_live_/', $value)) {
1199
+			throw new Exception(__('The "Live Secret Key" should start with "sk_live" or "rk_live", enter the correct key.', 'woocommerce-gateway-stripe'));
1200 1200
 		}
1201 1201
 		return $value;
1202 1202
 	}
1203 1203
 
1204
-	public function validate_test_publishable_key_field( $key, $value ) {
1205
-		$value = $this->validate_text_field( $key, $value );
1206
-		if ( ! empty( $value ) && ! preg_match( '/^pk_test_/', $value ) ) {
1207
-			throw new Exception( __( 'The "Test Publishable Key" should start with "pk_test", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1204
+	public function validate_test_publishable_key_field($key, $value) {
1205
+		$value = $this->validate_text_field($key, $value);
1206
+		if ( ! empty($value) && ! preg_match('/^pk_test_/', $value)) {
1207
+			throw new Exception(__('The "Test Publishable Key" should start with "pk_test", enter the correct key.', 'woocommerce-gateway-stripe'));
1208 1208
 		}
1209 1209
 		return $value;
1210 1210
 	}
1211 1211
 
1212
-	public function validate_test_secret_key_field( $key, $value ) {
1213
-		$value = $this->validate_text_field( $key, $value );
1214
-		if ( ! empty( $value ) && ! preg_match( '/^[rs]k_test_/', $value ) ) {
1215
-			throw new Exception( __( 'The "Test Secret Key" should start with "sk_test" or "rk_test", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1212
+	public function validate_test_secret_key_field($key, $value) {
1213
+		$value = $this->validate_text_field($key, $value);
1214
+		if ( ! empty($value) && ! preg_match('/^[rs]k_test_/', $value)) {
1215
+			throw new Exception(__('The "Test Secret Key" should start with "sk_test" or "rk_test", enter the correct key.', 'woocommerce-gateway-stripe'));
1216 1216
 		}
1217 1217
 		return $value;
1218 1218
 	}
Please login to merge, or discard this patch.