Completed
Push — master ( fe691d...813aaf )
by Boro
01:54
created
includes/compat/class-wc-stripe-subs-compat.php 1 patch
Spacing   +161 added lines, -161 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,21 +15,21 @@  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
 	}
35 35
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	 * @since 4.0.0
50 50
 	 * @version 4.0.0
51 51
 	 */
52
-	public function maybe_hide_save_checkbox( $display_tokenization ) {
53
-		if ( WC_Subscriptions_Cart::cart_contains_subscription() ) {
52
+	public function maybe_hide_save_checkbox($display_tokenization) {
53
+		if (WC_Subscriptions_Cart::cart_contains_subscription()) {
54 54
 			return false;
55 55
 		}
56 56
 
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 * @param  int  $order_id
63 63
 	 * @return boolean
64 64
 	 */
65
-	public function has_subscription( $order_id ) {
66
-		return ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_is_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ) );
65
+	public function has_subscription($order_id) {
66
+		return (function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order_id) || wcs_is_subscription($order_id) || wcs_order_contains_renewal($order_id)));
67 67
 	}
68 68
 
69 69
 	/**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @return bool
74 74
 	 */
75 75
 	public function is_subs_change_payment() {
76
-		return ( isset( $_GET['pay_for_order'] ) && isset( $_GET['change_payment_method'] ) );
76
+		return (isset($_GET['pay_for_order']) && isset($_GET['change_payment_method']));
77 77
 	}
78 78
 
79 79
 	/**
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function display_update_subs_payment_checkout() {
86 86
 		if (
87
-			apply_filters( 'wc_stripe_display_update_subs_payment_method_card_checkbox', false ) &&
88
-			wcs_user_has_subscription( get_current_user_id(), '', 'active' ) &&
87
+			apply_filters('wc_stripe_display_update_subs_payment_method_card_checkbox', false) &&
88
+			wcs_user_has_subscription(get_current_user_id(), '', 'active') &&
89 89
 			is_add_payment_method_page()
90 90
 		) {
91 91
 			printf(
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 					<input id="wc-%1$s-update-subs-payment-method-card" name="wc-%1$s-update-subs-payment-method-card" type="checkbox" value="true" style="width:auto;" />
94 94
 					<label for="wc-%1$s-update-subs-payment-method-card" style="display:inline;">%2$s</label>
95 95
 				</p>',
96
-				esc_attr( $this->id ),
97
-				esc_html( apply_filters( 'wc_stripe_save_to_subs_text', __( 'Update the Payment Method used for all of my active subscriptions (optional).', 'woocommerce-gateway-stripe' ) ) )
96
+				esc_attr($this->id),
97
+				esc_html(apply_filters('wc_stripe_save_to_subs_text', __('Update the Payment Method used for all of my active subscriptions (optional).', 'woocommerce-gateway-stripe')))
98 98
 			);
99 99
 		}
100 100
 	}
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
 	 * @param string $source_id
107 107
 	 * @param object $source_object
108 108
 	 */
109
-	public function handle_add_payment_method_success( $source_id, $source_object ) {
110
-		if ( isset( $_POST['wc-' . $this->id . '-update-subs-payment-method-card'] ) ) {
109
+	public function handle_add_payment_method_success($source_id, $source_object) {
110
+		if (isset($_POST['wc-' . $this->id . '-update-subs-payment-method-card'])) {
111 111
 			$all_subs = wcs_get_users_subscriptions();
112 112
 
113
-			if ( ! empty( $all_subs ) ) {
114
-				foreach ( $all_subs as $sub ) {
115
-					if ( 'active' === $sub->get_status() ) {
116
-						update_post_meta( $sub->get_id(), '_stripe_source_id', $source_id );
117
-						update_post_meta( $sub->get_id(), '_payment_method', $this->id );
118
-						update_post_meta( $sub->get_id(), '_payment_method_title', $this->method_title );
113
+			if ( ! empty($all_subs)) {
114
+				foreach ($all_subs as $sub) {
115
+					if ('active' === $sub->get_status()) {
116
+						update_post_meta($sub->get_id(), '_stripe_source_id', $source_id);
117
+						update_post_meta($sub->get_id(), '_payment_method', $this->id);
118
+						update_post_meta($sub->get_id(), '_payment_method_title', $this->method_title);
119 119
 					}
120 120
 				}
121 121
 			}
@@ -129,34 +129,34 @@  discard block
 block discarded – undo
129 129
 	 * @since 4.1.11 Remove 3DS check as it is not needed.
130 130
 	 * @param int $order_id
131 131
 	 */
132
-	public function change_subs_payment_method( $order_id ) {
132
+	public function change_subs_payment_method($order_id) {
133 133
 		try {
134
-			$subscription    = wc_get_order( $order_id );
135
-			$prepared_source = $this->prepare_source( get_current_user_id(), true );
134
+			$subscription    = wc_get_order($order_id);
135
+			$prepared_source = $this->prepare_source(get_current_user_id(), true);
136 136
 			$source_object   = $prepared_source->source_object;
137 137
 
138 138
 			// Check if we don't allow prepaid credit cards.
139
-			if ( ! apply_filters( 'wc_stripe_allow_prepaid_card', true ) && $this->is_prepaid_card( $source_object ) ) {
140
-				$localized_message = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
141
-				throw new WC_Stripe_Exception( print_r( $source_object, true ), $localized_message );
139
+			if ( ! apply_filters('wc_stripe_allow_prepaid_card', true) && $this->is_prepaid_card($source_object)) {
140
+				$localized_message = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
141
+				throw new WC_Stripe_Exception(print_r($source_object, true), $localized_message);
142 142
 			}
143 143
 
144
-			if ( empty( $prepared_source->source ) ) {
145
-				$localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
146
-				throw new WC_Stripe_Exception( print_r( $prepared_source, true ), $localized_message );
144
+			if (empty($prepared_source->source)) {
145
+				$localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
146
+				throw new WC_Stripe_Exception(print_r($prepared_source, true), $localized_message);
147 147
 			}
148 148
 
149
-			$this->save_source_to_order( $subscription, $prepared_source );
149
+			$this->save_source_to_order($subscription, $prepared_source);
150 150
  
151
-			do_action( 'wc_stripe_change_subs_payment_method_success', $prepared_source->source, $prepared_source );
151
+			do_action('wc_stripe_change_subs_payment_method_success', $prepared_source->source, $prepared_source);
152 152
 
153 153
 			return array(
154 154
 				'result'   => 'success',
155
-				'redirect' => $this->get_return_url( $subscription ),
155
+				'redirect' => $this->get_return_url($subscription),
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
 
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
 	 * @param  int $order_id
166 166
 	 * @return array
167 167
 	 */
168
-	public function process_payment( $order_id, $retry = true, $force_save_source = false, $previous_error = false ) {
169
-		if ( $this->has_subscription( $order_id ) ) {
170
-			if ( $this->is_subs_change_payment() ) {
171
-				return $this->change_subs_payment_method( $order_id );
168
+	public function process_payment($order_id, $retry = true, $force_save_source = false, $previous_error = false) {
169
+		if ($this->has_subscription($order_id)) {
170
+			if ($this->is_subs_change_payment()) {
171
+				return $this->change_subs_payment_method($order_id);
172 172
 			}
173 173
 
174 174
 			// Regular payment with force customer enabled
175
-			return parent::process_payment( $order_id, $retry, true, $previous_error );
175
+			return parent::process_payment($order_id, $retry, true, $previous_error);
176 176
 		} else {
177
-			return parent::process_payment( $order_id, $retry, $force_save_source, $previous_error );
177
+			return parent::process_payment($order_id, $retry, $force_save_source, $previous_error);
178 178
 		}
179 179
 	}
180 180
 
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @param $amount_to_charge float The amount to charge.
185 185
 	 * @param $renewal_order WC_Order A WC_Order object created to record the renewal payment.
186 186
 	 */
187
-	public function scheduled_subscription_payment( $amount_to_charge, $renewal_order ) {
188
-		$this->process_subscription_payment( $amount_to_charge, $renewal_order, true, false );
187
+	public function scheduled_subscription_payment($amount_to_charge, $renewal_order) {
188
+		$this->process_subscription_payment($amount_to_charge, $renewal_order, true, false);
189 189
 	}
190 190
 
191 191
 	/**
@@ -199,86 +199,86 @@  discard block
 block discarded – undo
199 199
 	 * @param bool $retry Should we retry the process?
200 200
 	 * @param object $previous_error
201 201
 	 */
202
-	public function process_subscription_payment( $amount = 0.0, $renewal_order, $retry = true, $previous_error ) {
202
+	public function process_subscription_payment($amount = 0.0, $renewal_order, $retry = true, $previous_error) {
203 203
 		try {
204
-			if ( $amount * 100 < WC_Stripe_Helper::get_minimum_amount() ) {
204
+			if ($amount * 100 < WC_Stripe_Helper::get_minimum_amount()) {
205 205
 				/* translators: minimum amount */
206
-				return new WP_Error( 'stripe_error', 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 ) ) );
206
+				return new WP_Error('stripe_error', 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)));
207 207
 			}
208 208
 
209
-			$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $renewal_order->id : $renewal_order->get_id();
209
+			$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $renewal_order->id : $renewal_order->get_id();
210 210
 
211 211
 			// Get source from order
212
-			$prepared_source = $this->prepare_order_source( $renewal_order );
212
+			$prepared_source = $this->prepare_order_source($renewal_order);
213 213
 			$source_object   = $prepared_source->source_object;
214 214
 
215
-			if ( ! $prepared_source->customer ) {
216
-				return new WP_Error( 'stripe_error', __( 'Customer not found', 'woocommerce-gateway-stripe' ) );
215
+			if ( ! $prepared_source->customer) {
216
+				return new WP_Error('stripe_error', __('Customer not found', 'woocommerce-gateway-stripe'));
217 217
 			}
218 218
 
219
-			WC_Stripe_Logger::log( "Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}" );
219
+			WC_Stripe_Logger::log("Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}");
220 220
 
221 221
 			/* If we're doing a retry and source is chargeable, we need to pass
222 222
 			 * a different idempotency key and retry for success.
223 223
 			 */
224
-			if ( is_object( $source_object ) && empty( $source_object->error ) && $this->need_update_idempotency_key( $source_object, $previous_error ) ) {
225
-				add_filter( 'wc_stripe_idempotency_key', array( $this, 'change_idempotency_key' ), 10, 2 );
224
+			if (is_object($source_object) && empty($source_object->error) && $this->need_update_idempotency_key($source_object, $previous_error)) {
225
+				add_filter('wc_stripe_idempotency_key', array($this, 'change_idempotency_key'), 10, 2);
226 226
 			}
227 227
 
228
-			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 ) ) {
228
+			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)) {
229 229
 				// Passing empty source will charge customer default.
230 230
 				$prepared_source->source = '';
231 231
 			}
232 232
 
233
-			$request            = $this->generate_payment_request( $renewal_order, $prepared_source );
233
+			$request            = $this->generate_payment_request($renewal_order, $prepared_source);
234 234
 			$request['capture'] = 'true';
235
-			$request['amount']  = WC_Stripe_Helper::get_stripe_amount( $amount, $request['currency'] );
236
-			$response           = WC_Stripe_API::request( $request );
235
+			$request['amount']  = WC_Stripe_Helper::get_stripe_amount($amount, $request['currency']);
236
+			$response           = WC_Stripe_API::request($request);
237 237
 
238
-			if ( ! empty( $response->error ) ) {
238
+			if ( ! empty($response->error)) {
239 239
 				// We want to retry.
240
-				if ( $this->is_retryable_error( $response->error ) ) {
241
-					if ( $retry ) {
240
+				if ($this->is_retryable_error($response->error)) {
241
+					if ($retry) {
242 242
 						// Don't do anymore retries after this.
243
-						if ( 5 <= $this->retry_interval ) {
244
-							return $this->process_subscription_payment( $amount, $renewal_order, false, $response->error );
243
+						if (5 <= $this->retry_interval) {
244
+							return $this->process_subscription_payment($amount, $renewal_order, false, $response->error);
245 245
 						}
246 246
 
247
-						sleep( $this->retry_interval );
247
+						sleep($this->retry_interval);
248 248
 
249 249
 						$this->retry_interval++;
250 250
 
251
-						return $this->process_subscription_payment( $amount, $renewal_order, true, $response->error );
251
+						return $this->process_subscription_payment($amount, $renewal_order, true, $response->error);
252 252
 					} else {
253
-						$localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' );
254
-						$renewal_order->add_order_note( $localized_message );
255
-						throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
253
+						$localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe');
254
+						$renewal_order->add_order_note($localized_message);
255
+						throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
256 256
 					}
257 257
 				}
258 258
 
259 259
 				$localized_messages = WC_Stripe_Helper::get_localized_messages();
260 260
 
261
-				if ( 'card_error' === $response->error->type ) {
262
-					$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
261
+				if ('card_error' === $response->error->type) {
262
+					$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
263 263
 				} else {
264
-					$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
264
+					$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
265 265
 				}
266 266
 
267
-				$renewal_order->add_order_note( $localized_message );
267
+				$renewal_order->add_order_note($localized_message);
268 268
 
269
-				throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
269
+				throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
270 270
 			}
271 271
 
272
-			do_action( 'wc_gateway_stripe_process_payment', $response, $renewal_order );
272
+			do_action('wc_gateway_stripe_process_payment', $response, $renewal_order);
273 273
 
274
-			$this->process_response( $response, $renewal_order );
275
-		} catch ( WC_Stripe_Exception $e ) {
276
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
274
+			$this->process_response($response, $renewal_order);
275
+		} catch (WC_Stripe_Exception $e) {
276
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
277 277
 
278
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $renewal_order );
278
+			do_action('wc_gateway_stripe_process_payment_error', $e, $renewal_order);
279 279
 
280 280
 			/* translators: error message */
281
-			$renewal_order->update_status( 'failed' );
281
+			$renewal_order->update_status('failed');
282 282
 		}
283 283
 	}
284 284
 
@@ -288,24 +288,24 @@  discard block
 block discarded – undo
288 288
 	 * @since 3.1.0
289 289
 	 * @version 4.0.0
290 290
 	 */
291
-	public function save_source_to_order( $order, $source ) {
292
-		parent::save_source_to_order( $order, $source );
291
+	public function save_source_to_order($order, $source) {
292
+		parent::save_source_to_order($order, $source);
293 293
 
294
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
294
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
295 295
 
296 296
 		// Also store it on the subscriptions being purchased or paid for in the order
297
-		if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) {
298
-			$subscriptions = wcs_get_subscriptions_for_order( $order_id );
299
-		} elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) {
300
-			$subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id );
297
+		if (function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($order_id)) {
298
+			$subscriptions = wcs_get_subscriptions_for_order($order_id);
299
+		} elseif (function_exists('wcs_order_contains_renewal') && wcs_order_contains_renewal($order_id)) {
300
+			$subscriptions = wcs_get_subscriptions_for_renewal_order($order_id);
301 301
 		} else {
302 302
 			$subscriptions = array();
303 303
 		}
304 304
 
305
-		foreach ( $subscriptions as $subscription ) {
306
-			$subscription_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id();
307
-			update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer );
308
-			update_post_meta( $subscription_id, '_stripe_source_id', $source->source );
305
+		foreach ($subscriptions as $subscription) {
306
+			$subscription_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->id : $subscription->get_id();
307
+			update_post_meta($subscription_id, '_stripe_customer_id', $source->customer);
308
+			update_post_meta($subscription_id, '_stripe_source_id', $source->source);
309 309
 		}
310 310
 	}
311 311
 
@@ -313,21 +313,21 @@  discard block
 block discarded – undo
313 313
 	 * Don't transfer Stripe customer/token meta to resubscribe orders.
314 314
 	 * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
315 315
 	 */
316
-	public function delete_resubscribe_meta( $resubscribe_order ) {
317
-		delete_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_customer_id' );
318
-		delete_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_source_id' );
316
+	public function delete_resubscribe_meta($resubscribe_order) {
317
+		delete_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_customer_id');
318
+		delete_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_source_id');
319 319
 		// For BW compat will remove in future
320
-		delete_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_card_id' );
321
-		$this->delete_renewal_meta( $resubscribe_order );
320
+		delete_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_card_id');
321
+		$this->delete_renewal_meta($resubscribe_order);
322 322
 	}
323 323
 
324 324
 	/**
325 325
 	 * Don't transfer Stripe fee/ID meta to renewal orders.
326 326
 	 * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
327 327
 	 */
328
-	public function delete_renewal_meta( $renewal_order ) {
329
-		WC_Stripe_Helper::delete_stripe_fee( $renewal_order );
330
-		WC_Stripe_Helper::delete_stripe_net( $renewal_order );
328
+	public function delete_renewal_meta($renewal_order) {
329
+		WC_Stripe_Helper::delete_stripe_fee($renewal_order);
330
+		WC_Stripe_Helper::delete_stripe_net($renewal_order);
331 331
 
332 332
 		return $renewal_order;
333 333
 	}
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
 	 * @param WC_Order $renewal_order The order which recorded the successful payment (to make up for the failed automatic payment).
342 342
 	 * @return void
343 343
 	 */
344
-	public function update_failing_payment_method( $subscription, $renewal_order ) {
345
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
346
-			update_post_meta( $subscription->id, '_stripe_customer_id', $renewal_order->stripe_customer_id );
347
-			update_post_meta( $subscription->id, '_stripe_source_id', $renewal_order->stripe_source_id );
344
+	public function update_failing_payment_method($subscription, $renewal_order) {
345
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
346
+			update_post_meta($subscription->id, '_stripe_customer_id', $renewal_order->stripe_customer_id);
347
+			update_post_meta($subscription->id, '_stripe_source_id', $renewal_order->stripe_source_id);
348 348
 
349 349
 		} else {
350
-			update_post_meta( $subscription->get_id(), '_stripe_customer_id', $renewal_order->get_meta( '_stripe_customer_id', true ) );
351
-			update_post_meta( $subscription->get_id(), '_stripe_source_id', $renewal_order->get_meta( '_stripe_source_id', true ) );
350
+			update_post_meta($subscription->get_id(), '_stripe_customer_id', $renewal_order->get_meta('_stripe_customer_id', true));
351
+			update_post_meta($subscription->get_id(), '_stripe_source_id', $renewal_order->get_meta('_stripe_source_id', true));
352 352
 		}
353 353
 	}
354 354
 
@@ -361,23 +361,23 @@  discard block
 block discarded – undo
361 361
 	 * @param WC_Subscription $subscription An instance of a subscription object
362 362
 	 * @return array
363 363
 	 */
364
-	public function add_subscription_payment_meta( $payment_meta, $subscription ) {
365
-		$subscription_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id();
366
-		$source_id = get_post_meta( $subscription_id, '_stripe_source_id', true );
364
+	public function add_subscription_payment_meta($payment_meta, $subscription) {
365
+		$subscription_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->id : $subscription->get_id();
366
+		$source_id = get_post_meta($subscription_id, '_stripe_source_id', true);
367 367
 
368 368
 		// For BW compat will remove in future.
369
-		if ( empty( $source_id ) ) {
370
-			$source_id = get_post_meta( $subscription_id, '_stripe_card_id', true );
369
+		if (empty($source_id)) {
370
+			$source_id = get_post_meta($subscription_id, '_stripe_card_id', true);
371 371
 
372 372
 			// Take this opportunity to update the key name.
373
-			update_post_meta( $subscription_id, '_stripe_source_id', $source_id );
374
-			delete_post_meta( $subscription_id, '_stripe_card_id', $source_id );
373
+			update_post_meta($subscription_id, '_stripe_source_id', $source_id);
374
+			delete_post_meta($subscription_id, '_stripe_card_id', $source_id);
375 375
 		}
376 376
 
377
-		$payment_meta[ $this->id ] = array(
377
+		$payment_meta[$this->id] = array(
378 378
 			'post_meta' => array(
379 379
 				'_stripe_customer_id' => array(
380
-					'value' => get_post_meta( $subscription_id, '_stripe_customer_id', true ),
380
+					'value' => get_post_meta($subscription_id, '_stripe_customer_id', true),
381 381
 					'label' => 'Stripe Customer ID',
382 382
 				),
383 383
 				'_stripe_source_id' => array(
@@ -400,22 +400,22 @@  discard block
 block discarded – undo
400 400
 	 * @param array $payment_meta associative array of meta data required for automatic payments
401 401
 	 * @return array
402 402
 	 */
403
-	public function validate_subscription_payment_meta( $payment_method_id, $payment_meta ) {
404
-		if ( $this->id === $payment_method_id ) {
403
+	public function validate_subscription_payment_meta($payment_method_id, $payment_meta) {
404
+		if ($this->id === $payment_method_id) {
405 405
 
406
-			if ( ! isset( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) || empty( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) ) {
407
-				throw new Exception( __( 'A "Stripe Customer ID" value is required.', 'woocommerce-gateway-stripe' ) );
408
-			} elseif ( 0 !== strpos( $payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_' ) ) {
409
-				throw new Exception( __( 'Invalid customer ID. A valid "Stripe Customer ID" must begin with "cus_".', 'woocommerce-gateway-stripe' ) );
406
+			if ( ! isset($payment_meta['post_meta']['_stripe_customer_id']['value']) || empty($payment_meta['post_meta']['_stripe_customer_id']['value'])) {
407
+				throw new Exception(__('A "Stripe Customer ID" value is required.', 'woocommerce-gateway-stripe'));
408
+			} elseif (0 !== strpos($payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_')) {
409
+				throw new Exception(__('Invalid customer ID. A valid "Stripe Customer ID" must begin with "cus_".', 'woocommerce-gateway-stripe'));
410 410
 			}
411 411
 
412 412
 			if (
413
-				( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] )
414
-				&& 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'card_' ) )
415
-				&& ( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] )
416
-				&& 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'src_' ) ) ) {
413
+				( ! empty($payment_meta['post_meta']['_stripe_source_id']['value'])
414
+				&& 0 !== strpos($payment_meta['post_meta']['_stripe_source_id']['value'], 'card_'))
415
+				&& ( ! empty($payment_meta['post_meta']['_stripe_source_id']['value'])
416
+				&& 0 !== strpos($payment_meta['post_meta']['_stripe_source_id']['value'], 'src_')) ) {
417 417
 
418
-				throw new Exception( __( 'Invalid source ID. A valid source "Stripe Source ID" must begin with "src_" or "card_".', 'woocommerce-gateway-stripe' ) );
418
+				throw new Exception(__('Invalid source ID. A valid source "Stripe Source ID" must begin with "src_" or "card_".', 'woocommerce-gateway-stripe'));
419 419
 			}
420 420
 		}
421 421
 	}
@@ -428,75 +428,75 @@  discard block
 block discarded – undo
428 428
 	 * @param WC_Subscription $subscription the subscription details
429 429
 	 * @return string the subscription payment method
430 430
 	 */
431
-	public function maybe_render_subscription_payment_method( $payment_method_to_display, $subscription ) {
432
-		$customer_user = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->customer_user : $subscription->get_customer_id();
431
+	public function maybe_render_subscription_payment_method($payment_method_to_display, $subscription) {
432
+		$customer_user = WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->customer_user : $subscription->get_customer_id();
433 433
 
434 434
 		// bail for other payment methods
435
-		if ( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->payment_method : $subscription->get_payment_method() ) !== $this->id || ! $customer_user ) {
435
+		if ((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->payment_method : $subscription->get_payment_method()) !== $this->id || ! $customer_user) {
436 436
 			return $payment_method_to_display;
437 437
 		}
438 438
 
439
-		$stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id() ), '_stripe_source_id', true );
439
+		$stripe_source_id = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->id : $subscription->get_id()), '_stripe_source_id', true);
440 440
 
441 441
 		// For BW compat will remove in future.
442
-		if ( empty( $stripe_source_id ) ) {
443
-			$stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true );
442
+		if (empty($stripe_source_id)) {
443
+			$stripe_source_id = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->id : $subscription->get_id()), '_stripe_card_id', true);
444 444
 
445 445
 			// Take this opportunity to update the key name.
446
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $subscription->id, '_stripe_source_id', $stripe_source_id ) : update_post_meta( $subscription->get_id(), '_stripe_source_id', $stripe_source_id );
446
+			WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($subscription->id, '_stripe_source_id', $stripe_source_id) : update_post_meta($subscription->get_id(), '_stripe_source_id', $stripe_source_id);
447 447
 		}
448 448
 
449 449
 		$stripe_customer    = new WC_Stripe_Customer();
450
-		$stripe_customer_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true );
450
+		$stripe_customer_id = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->id : $subscription->get_id()), '_stripe_customer_id', true);
451 451
 
452 452
 		// If we couldn't find a Stripe customer linked to the subscription, fallback to the user meta data.
453
-		if ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) {
453
+		if ( ! $stripe_customer_id || ! is_string($stripe_customer_id)) {
454 454
 			$user_id            = $customer_user;
455
-			$stripe_customer_id = get_user_meta( $user_id, '_stripe_customer_id', true );
456
-			$stripe_source_id   = get_user_meta( $user_id, '_stripe_source_id', true );
455
+			$stripe_customer_id = get_user_meta($user_id, '_stripe_customer_id', true);
456
+			$stripe_source_id   = get_user_meta($user_id, '_stripe_source_id', true);
457 457
 
458 458
 			// For BW compat will remove in future.
459
-			if ( empty( $stripe_source_id ) ) {
460
-				$stripe_source_id = get_user_meta( $user_id, '_stripe_card_id', true );
459
+			if (empty($stripe_source_id)) {
460
+				$stripe_source_id = get_user_meta($user_id, '_stripe_card_id', true);
461 461
 
462 462
 				// Take this opportunity to update the key name.
463
-				update_user_meta( $user_id, '_stripe_source_id', $stripe_source_id );
463
+				update_user_meta($user_id, '_stripe_source_id', $stripe_source_id);
464 464
 			}
465 465
 		}
466 466
 
467 467
 		// If we couldn't find a Stripe customer linked to the account, fallback to the order meta data.
468
-		if ( ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) && false !== $subscription->order ) {
469
-			$stripe_customer_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_customer_id', true );
470
-			$stripe_source_id   = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_source_id', true );
468
+		if (( ! $stripe_customer_id || ! is_string($stripe_customer_id)) && false !== $subscription->order) {
469
+			$stripe_customer_id = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_customer_id', true);
470
+			$stripe_source_id   = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_source_id', true);
471 471
 
472 472
 			// For BW compat will remove in future.
473
-			if ( empty( $stripe_source_id ) ) {
474
-				$stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_card_id', true );
473
+			if (empty($stripe_source_id)) {
474
+				$stripe_source_id = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_card_id', true);
475 475
 
476 476
 				// Take this opportunity to update the key name.
477
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $subscription->order->id, '_stripe_source_id', $stripe_source_id ) : update_post_meta( $subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id );
477
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($subscription->order->id, '_stripe_source_id', $stripe_source_id) : update_post_meta($subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id);
478 478
 			}
479 479
 		}
480 480
 
481
-		$stripe_customer->set_id( $stripe_customer_id );
481
+		$stripe_customer->set_id($stripe_customer_id);
482 482
 
483 483
 		$sources                   = $stripe_customer->get_sources();
484
-		$payment_method_to_display = __( 'N/A', 'woocommerce-gateway-stripe' );
484
+		$payment_method_to_display = __('N/A', 'woocommerce-gateway-stripe');
485 485
 
486
-		if ( $sources ) {
486
+		if ($sources) {
487 487
 			$card = false;
488 488
 
489
-			foreach ( $sources as $source ) {
490
-				if ( isset( $source->type ) && 'card' === $source->type ) {
489
+			foreach ($sources as $source) {
490
+				if (isset($source->type) && 'card' === $source->type) {
491 491
 					$card = $source->card;
492
-				} elseif ( isset( $source->object ) && 'card' === $source->object ) {
492
+				} elseif (isset($source->object) && 'card' === $source->object) {
493 493
 					$card = $source;
494 494
 				}
495 495
 
496
-				if ( $source->id === $stripe_source_id ) {
497
-					if ( $card ) {
496
+				if ($source->id === $stripe_source_id) {
497
+					if ($card) {
498 498
 						/* translators: 1) card brand 2) last 4 digits */
499
-						$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 );
499
+						$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);
500 500
 					}
501 501
 
502 502
 					break;
Please login to merge, or discard this patch.
woocommerce-gateway-stripe.php 1 patch
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  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
 
@@ -29,29 +29,29 @@  discard block
 block discarded – undo
29 29
  */
30 30
 function woocommerce_stripe_missing_wc_notice() {
31 31
 	/* translators: 1. URL link. */
32
-	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>';
32
+	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>';
33 33
 }
34 34
 
35
-add_action( 'plugins_loaded', 'woocommerce_gateway_stripe_init' );
35
+add_action('plugins_loaded', 'woocommerce_gateway_stripe_init');
36 36
 
37 37
 function woocommerce_gateway_stripe_init() {
38
-	load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
38
+	load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages');
39 39
 
40
-	if ( ! class_exists( 'WooCommerce' ) ) {
41
-		add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' );
40
+	if ( ! class_exists('WooCommerce')) {
41
+		add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice');
42 42
 		return;
43 43
 	}
44 44
 
45
-	if ( ! class_exists( 'WC_Stripe' ) ) :
45
+	if ( ! class_exists('WC_Stripe')) :
46 46
 		/**
47 47
 		 * Required minimums and constants
48 48
 		 */
49
-		define( 'WC_STRIPE_VERSION', '4.1.10' );
50
-		define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
51
-		define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' );
52
-		define( 'WC_STRIPE_MAIN_FILE', __FILE__ );
53
-		define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
54
-		define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
49
+		define('WC_STRIPE_VERSION', '4.1.10');
50
+		define('WC_STRIPE_MIN_PHP_VER', '5.6.0');
51
+		define('WC_STRIPE_MIN_WC_VER', '2.6.0');
52
+		define('WC_STRIPE_MAIN_FILE', __FILE__);
53
+		define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__))));
54
+		define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__)));
55 55
 
56 56
 		class WC_Stripe {
57 57
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			 * @return Singleton The *Singleton* instance.
72 72
 			 */
73 73
 			public static function get_instance() {
74
-				if ( null === self::$instance ) {
74
+				if (null === self::$instance) {
75 75
 					self::$instance = new self();
76 76
 				}
77 77
 				return self::$instance;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 			 * *Singleton* via the `new` operator from outside of this class.
99 99
 			 */
100 100
 			private function __construct() {
101
-				add_action( 'admin_init', array( $this, 'install' ) );
101
+				add_action('admin_init', array($this, 'install'));
102 102
 				$this->init();
103 103
 			}
104 104
 
@@ -109,48 +109,48 @@  discard block
 block discarded – undo
109 109
 			 * @version 4.0.0
110 110
 			 */
111 111
 			public function init() {
112
-				if ( is_admin() ) {
113
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php';
112
+				if (is_admin()) {
113
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php';
114 114
 				}
115 115
 
116
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php';
117
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php';
118
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php';
119
-				include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php';
120
-				require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
121
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php';
122
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php';
123
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php';
124
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
125
-				require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php';
126
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
127
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
128
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
129
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
130
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
131
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
132
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
133
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
134
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
135
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
136
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php';
137
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
138
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php';
139
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php';
140
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php';
141
-
142
-				if ( is_admin() ) {
143
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php';
116
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-exception.php';
117
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-logger.php';
118
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-helper.php';
119
+				include_once dirname(__FILE__) . '/includes/class-wc-stripe-api.php';
120
+				require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
121
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php';
122
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php';
123
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php';
124
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
125
+				require_once dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php';
126
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
127
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
128
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
129
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
130
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
131
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
132
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
133
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
134
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
135
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
136
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php';
137
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
138
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php';
139
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php';
140
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-customer.php';
141
+
142
+				if (is_admin()) {
143
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php';
144 144
 				}
145 145
 
146 146
 				// REMOVE IN THE FUTURE.
147
-				require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
147
+				require_once dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
148 148
 
149
-				add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) );
150
-				add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
149
+				add_filter('woocommerce_payment_gateways', array($this, 'add_gateways'));
150
+				add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
151 151
 
152
-				if ( version_compare( WC_VERSION, '3.4', '<' ) ) {
153
-					add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) );
152
+				if (version_compare(WC_VERSION, '3.4', '<')) {
153
+					add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin'));
154 154
 				}
155 155
 			}
156 156
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 			 * @version 4.0.0
162 162
 			 */
163 163
 			public function update_plugin_version() {
164
-				delete_option( 'wc_stripe_version' );
165
-				update_option( 'wc_stripe_version', WC_STRIPE_VERSION );
164
+				delete_option('wc_stripe_version');
165
+				update_option('wc_stripe_version', WC_STRIPE_VERSION);
166 166
 			}
167 167
 
168 168
 			/**
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
 			 * @version 3.1.0
173 173
 			 */
174 174
 			public function install() {
175
-				if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) {
175
+				if ( ! is_plugin_active(plugin_basename(__FILE__))) {
176 176
 					return;
177 177
 				}
178 178
 
179
-				if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) {
180
-					do_action( 'woocommerce_stripe_updated' );
179
+				if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) {
180
+					do_action('woocommerce_stripe_updated');
181 181
 
182
-					if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) {
183
-						define( 'WC_STRIPE_INSTALLING', true );
182
+					if ( ! defined('WC_STRIPE_INSTALLING')) {
183
+						define('WC_STRIPE_INSTALLING', true);
184 184
 					}
185 185
 
186 186
 					$this->update_plugin_version();
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 			 * @since 1.0.0
194 194
 			 * @version 4.0.0
195 195
 			 */
196
-			public function plugin_action_links( $links ) {
196
+			public function plugin_action_links($links) {
197 197
 				$plugin_links = array(
198
-					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
199
-					'<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>',
200
-					'<a href="https://woocommerce.com/contact-us/">' . esc_html__( 'Support', 'woocommerce-gateway-stripe' ) . '</a>',
198
+					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>',
199
+					'<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__('Docs', 'woocommerce-gateway-stripe') . '</a>',
200
+					'<a href="https://woocommerce.com/contact-us/">' . esc_html__('Support', 'woocommerce-gateway-stripe') . '</a>',
201 201
 				);
202
-				return array_merge( $plugin_links, $links );
202
+				return array_merge($plugin_links, $links);
203 203
 			}
204 204
 
205 205
 			/**
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 			 * @since 1.0.0
209 209
 			 * @version 4.0.0
210 210
 			 */
211
-			public function add_gateways( $methods ) {
212
-				if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) {
211
+			public function add_gateways($methods) {
212
+				if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) {
213 213
 					$methods[] = 'WC_Stripe_Subs_Compat';
214 214
 					$methods[] = 'WC_Stripe_Sepa_Subs_Compat';
215 215
 				} else {
@@ -235,28 +235,28 @@  discard block
 block discarded – undo
235 235
 			 * @since 4.0.0
236 236
 			 * @version 4.0.0
237 237
 			 */
238
-			public function filter_gateway_order_admin( $sections ) {
239
-				unset( $sections['stripe'] );
240
-				unset( $sections['stripe_bancontact'] );
241
-				unset( $sections['stripe_sofort'] );
242
-				unset( $sections['stripe_giropay'] );
243
-				unset( $sections['stripe_eps'] );
244
-				unset( $sections['stripe_ideal'] );
245
-				unset( $sections['stripe_p24'] );
246
-				unset( $sections['stripe_alipay'] );
247
-				unset( $sections['stripe_sepa'] );
248
-				unset( $sections['stripe_multibanco'] );
238
+			public function filter_gateway_order_admin($sections) {
239
+				unset($sections['stripe']);
240
+				unset($sections['stripe_bancontact']);
241
+				unset($sections['stripe_sofort']);
242
+				unset($sections['stripe_giropay']);
243
+				unset($sections['stripe_eps']);
244
+				unset($sections['stripe_ideal']);
245
+				unset($sections['stripe_p24']);
246
+				unset($sections['stripe_alipay']);
247
+				unset($sections['stripe_sepa']);
248
+				unset($sections['stripe_multibanco']);
249 249
 
250 250
 				$sections['stripe']            = 'Stripe';
251
-				$sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' );
252
-				$sections['stripe_sofort']     = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' );
253
-				$sections['stripe_giropay']    = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' );
254
-				$sections['stripe_eps']        = __( 'Stripe EPS', 'woocommerce-gateway-stripe' );
255
-				$sections['stripe_ideal']      = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' );
256
-				$sections['stripe_p24']        = __( 'Stripe P24', 'woocommerce-gateway-stripe' );
257
-				$sections['stripe_alipay']     = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' );
258
-				$sections['stripe_sepa']       = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' );
259
-				$sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' );
251
+				$sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe');
252
+				$sections['stripe_sofort']     = __('Stripe SOFORT', 'woocommerce-gateway-stripe');
253
+				$sections['stripe_giropay']    = __('Stripe Giropay', 'woocommerce-gateway-stripe');
254
+				$sections['stripe_eps']        = __('Stripe EPS', 'woocommerce-gateway-stripe');
255
+				$sections['stripe_ideal']      = __('Stripe iDeal', 'woocommerce-gateway-stripe');
256
+				$sections['stripe_p24']        = __('Stripe P24', 'woocommerce-gateway-stripe');
257
+				$sections['stripe_alipay']     = __('Stripe Alipay', 'woocommerce-gateway-stripe');
258
+				$sections['stripe_sepa']       = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe');
259
+				$sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe');
260 260
 
261 261
 				return $sections;
262 262
 			}
Please login to merge, or discard this patch.