Completed
Pull Request — master (#1158)
by Marcin
02:39
created
includes/compat/class-wc-stripe-pre-orders-compat.php 1 patch
Spacing   +49 added lines, -49 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
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	public $saved_cards;
12 12
 
13 13
 	public function __construct() {
14
-		$this->saved_cards = WC_Stripe_Helper::get_settings( 'stripe', 'saved_cards' );
14
+		$this->saved_cards = WC_Stripe_Helper::get_settings('stripe', 'saved_cards');
15 15
 	}
16 16
 
17 17
 	/**
@@ -19,22 +19,22 @@  discard block
 block discarded – undo
19 19
 	 * @param  int  $order_id
20 20
 	 * @return boolean
21 21
 	 */
22
-	public function is_pre_order( $order_id ) {
23
-		return WC_Pre_Orders_Order::order_contains_pre_order( $order_id );
22
+	public function is_pre_order($order_id) {
23
+		return WC_Pre_Orders_Order::order_contains_pre_order($order_id);
24 24
 	}
25 25
 
26 26
 	/**
27 27
 	 * Remove order meta
28 28
 	 * @param object $order
29 29
 	 */
30
-	public function remove_order_source_before_retry( $order ) {
31
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
32
-			delete_post_meta( $order->id, '_stripe_source_id' );
30
+	public function remove_order_source_before_retry($order) {
31
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
32
+			delete_post_meta($order->id, '_stripe_source_id');
33 33
 			// For BW compat will remove in the future.
34
-			delete_post_meta( $order->id, '_stripe_card_id' );
34
+			delete_post_meta($order->id, '_stripe_card_id');
35 35
 		} else {
36
-			$order->delete_meta_data( '_stripe_source_id' );
37
-			$order->delete_meta_data( '_stripe_card_id' );
36
+			$order->delete_meta_data('_stripe_source_id');
37
+			$order->delete_meta_data('_stripe_card_id');
38 38
 			$order->save();
39 39
 		}
40 40
 	}
@@ -43,31 +43,31 @@  discard block
 block discarded – undo
43 43
 	 * Process the pre-order when pay upon release is used.
44 44
 	 * @param int $order_id
45 45
 	 */
46
-	public function process_pre_order( $order_id ) {
46
+	public function process_pre_order($order_id) {
47 47
 		try {
48
-			$order = wc_get_order( $order_id );
48
+			$order = wc_get_order($order_id);
49 49
 
50 50
 			// This will throw exception if not valid.
51
-			$this->validate_minimum_order_amount( $order );
51
+			$this->validate_minimum_order_amount($order);
52 52
 
53
-			$prepared_source = $this->prepare_source( get_current_user_id(), true );
53
+			$prepared_source = $this->prepare_source(get_current_user_id(), true);
54 54
 
55 55
 			// We need a source on file to continue.
56
-			if ( empty( $prepared_source->customer ) || empty( $prepared_source->source ) ) {
57
-				throw new WC_Stripe_Exception( __( 'Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe' ) );
56
+			if (empty($prepared_source->customer) || empty($prepared_source->source)) {
57
+				throw new WC_Stripe_Exception(__('Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe'));
58 58
 			}
59 59
 
60 60
 			// Setup the response early to allow later modifications.
61 61
 			$response = array(
62 62
 				'result'   => 'success',
63
-				'redirect' => $this->get_return_url( $order ),
63
+				'redirect' => $this->get_return_url($order),
64 64
 			);
65 65
 
66
-			$this->save_source_to_order( $order, $prepared_source );
66
+			$this->save_source_to_order($order, $prepared_source);
67 67
 
68 68
 			// Try setting up a payment intent.
69
-			$intent_secret = $this->setup_intent( $order, $prepared_source );
70
-			if ( ! empty( $intent_secret ) ) {
69
+			$intent_secret = $this->setup_intent($order, $prepared_source);
70
+			if ( ! empty($intent_secret)) {
71 71
 				$response['setup_intent_secret'] = $intent_secret;
72 72
 				return $response;
73 73
 			}
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
 			WC()->cart->empty_cart();
77 77
 
78 78
 			// Is pre ordered!
79
-			WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order );
79
+			WC_Pre_Orders_Order::mark_order_as_pre_ordered($order);
80 80
 
81 81
 			// Return thank you page redirect
82 82
 			return $response;
83
-		} catch ( WC_Stripe_Exception $e ) {
84
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
85
-			WC_Stripe_Logger::log( 'Pre Orders Error: ' . $e->getMessage() );
83
+		} catch (WC_Stripe_Exception $e) {
84
+			wc_add_notice($e->getLocalizedMessage(), 'error');
85
+			WC_Stripe_Logger::log('Pre Orders Error: ' . $e->getMessage());
86 86
 
87 87
 			return array(
88 88
 				'result'   => 'success',
89
-				'redirect' => $order->get_checkout_payment_url( true ),
89
+				'redirect' => $order->get_checkout_payment_url(true),
90 90
 			);
91 91
 		}
92 92
 	}
@@ -99,50 +99,50 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @return void
101 101
 	 */
102
-	public function process_pre_order_release_payment( $order, $retry = true ) {
102
+	public function process_pre_order_release_payment($order, $retry = true) {
103 103
 		try {
104
-			$source   = $this->prepare_order_source( $order );
105
-			$response = $this->create_and_confirm_intent_for_off_session( $order, $source );
104
+			$source   = $this->prepare_order_source($order);
105
+			$response = $this->create_and_confirm_intent_for_off_session($order, $source);
106 106
 
107
-			$is_authentication_required = $this->is_authentication_required_for_payment( $response );
107
+			$is_authentication_required = $this->is_authentication_required_for_payment($response);
108 108
 
109
-			if ( ! empty( $response->error ) && ! $is_authentication_required ) {
110
-				if ( ! $retry ) {
111
-					throw new Exception( $response->error->message );
109
+			if ( ! empty($response->error) && ! $is_authentication_required) {
110
+				if ( ! $retry) {
111
+					throw new Exception($response->error->message);
112 112
 				}
113
-				$this->remove_order_source_before_retry( $order );
114
-				$this->process_pre_order_release_payment( $order, false );
115
-			} else if ( $is_authentication_required ) {
116
-				$charge = end( $response->error->payment_intent->charges->data );
113
+				$this->remove_order_source_before_retry($order);
114
+				$this->process_pre_order_release_payment($order, false);
115
+			} else if ($is_authentication_required) {
116
+				$charge = end($response->error->payment_intent->charges->data);
117 117
 				$id = $charge->id;
118
-				$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
118
+				$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
119 119
 
120
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_transaction_id', $id ) : $order->set_transaction_id( $id );
121
-				$order->update_status( 'failed', sprintf( __( 'Stripe charge awaiting authentication by user: %s.', 'woocommerce-gateway-stripe' ), $id ) );
122
-				if ( is_callable( array( $order, 'save' ) ) ) {
120
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_transaction_id', $id) : $order->set_transaction_id($id);
121
+				$order->update_status('failed', sprintf(__('Stripe charge awaiting authentication by user: %s.', 'woocommerce-gateway-stripe'), $id));
122
+				if (is_callable(array($order, 'save'))) {
123 123
 					$order->save();
124 124
 				}
125 125
 
126 126
 				WC_Emails::instance();
127 127
 
128
-				do_action( 'wc_gateway_stripe_process_payment_authentication_required', $order );
128
+				do_action('wc_gateway_stripe_process_payment_authentication_required', $order);
129 129
 
130
-				throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
130
+				throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
131 131
 			} else {
132 132
 				// Successful
133
-				$this->process_response( end( $response->charges->data ), $order );
133
+				$this->process_response(end($response->charges->data), $order);
134 134
 			}
135
-		} catch ( Exception $e ) {
136
-			$error_message = is_callable( array( $e, 'getLocalizedMessage' ) ) ? $e->getLocalizedMessage() : $e->getMessage();
135
+		} catch (Exception $e) {
136
+			$error_message = is_callable(array($e, 'getLocalizedMessage')) ? $e->getLocalizedMessage() : $e->getMessage();
137 137
 			/* translators: error message */
138
-			$order_note = sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $error_message );
138
+			$order_note = sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $error_message);
139 139
 
140 140
 			// Mark order as failed if not already set,
141 141
 			// otherwise, make sure we add the order note so we can detect when someone fails to check out multiple times
142
-			if ( ! $order->has_status( 'failed' ) ) {
143
-				$order->update_status( 'failed', $order_note );
142
+			if ( ! $order->has_status('failed')) {
143
+				$order->update_status('failed', $order_note);
144 144
 			} else {
145
-				$order->add_order_note( $order_note );
145
+				$order->add_order_note($order_note);
146 146
 			}
147 147
 		}
148 148
 	}
Please login to merge, or discard this patch.
templates/emails/failed-renewal-authentication-requested.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@  discard block
 block discarded – undo
6 6
  * @version 4.3.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Output the email header.
15 15
  */
16
-do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
16
+do_action('woocommerce_email_header', $email_heading, $email); ?>
17 17
 
18 18
 <p>
19 19
 	<?php
@@ -27,31 +27,31 @@  discard block
 block discarded – undo
27 27
 			),
28 28
 			$order->get_order_number(),
29 29
 			$order->get_formatted_billing_full_name(),
30
-			wcs_get_human_time_diff( $retry->get_time() )
30
+			wcs_get_human_time_diff($retry->get_time())
31 31
 		)
32 32
 	);
33 33
 	?>
34 34
 </p>
35
-<p><?php esc_html_e( 'The renewal order is as follows:', 'woocommerce-gateway-stripe' ); ?></p>
35
+<p><?php esc_html_e('The renewal order is as follows:', 'woocommerce-gateway-stripe'); ?></p>
36 36
 
37 37
 <?php
38 38
 
39 39
 /**
40 40
  * Shows the order details table.
41 41
  */
42
-do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
42
+do_action('woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email);
43 43
 
44 44
 /**
45 45
 * Shows order meta data.
46 46
 */
47
-do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
47
+do_action('woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email);
48 48
 
49 49
 /**
50 50
 * Shows customer details, and email address.
51 51
 */
52
-do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
52
+do_action('woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email);
53 53
 
54 54
 /**
55 55
 * Output the email footer.
56 56
 */
57
-do_action( 'woocommerce_email_footer', $email );
57
+do_action('woocommerce_email_footer', $email);
Please login to merge, or discard this patch.
templates/emails/plain/failed-renewal-authentication-requested.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @version 4.3.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
@@ -21,29 +21,29 @@  discard block
 block discarded – undo
21 21
 	),
22 22
 	$order->get_order_number(),
23 23
 	$order->get_formatted_billing_full_name(),
24
-	wcs_get_human_time_diff( $retry->get_time() )
24
+	wcs_get_human_time_diff($retry->get_time())
25 25
 ) . "\n\n";
26
-printf( __( 'The renewal order is as follows:', 'woocommerce-gateway-stripe' ) ) . "\n\n";
26
+printf(__('The renewal order is as follows:', 'woocommerce-gateway-stripe')) . "\n\n";
27 27
 
28 28
 echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
29 29
 
30 30
 /**
31 31
  * Shows the order details table.
32 32
  */
33
-do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
33
+do_action('woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email);
34 34
 
35 35
 echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
36 36
 
37 37
 /**
38 38
 * Shows order meta data.
39 39
 */
40
-do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
40
+do_action('woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email);
41 41
 
42 42
 /**
43 43
 * Shows customer details, and email address.
44 44
 */
45
-do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
45
+do_action('woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email);
46 46
 
47 47
 echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
48 48
 
49
-echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
49
+echo apply_filters('woocommerce_email_footer_text', get_option('woocommerce_email_footer_text'));
Please login to merge, or discard this patch.
includes/compat/class-wc-stripe-email-failed-authentication-retry.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @extends     WC_Email_Failed_Order
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
 	 */
27 27
 	public function __construct() {
28 28
 		$this->id          = 'failed_authentication_requested';
29
-		$this->title       = __( 'Payment Authentication Requested Email', 'woocommerce-gateway-stripe' );
30
-		$this->description = __( 'Payment authentication requested emails are sent to chosen recipient(s) when an attempt to automatically process a subscription renewal payment fails because the transaction requires an SCA verification, the customer is requested to authenticate the payment, and a retry rule has been applied to notify the customer again within a certain time period.', 'woocommerce-gateway-stripe' );
29
+		$this->title       = __('Payment Authentication Requested Email', 'woocommerce-gateway-stripe');
30
+		$this->description = __('Payment authentication requested emails are sent to chosen recipient(s) when an attempt to automatically process a subscription renewal payment fails because the transaction requires an SCA verification, the customer is requested to authenticate the payment, and a retry rule has been applied to notify the customer again within a certain time period.', 'woocommerce-gateway-stripe');
31 31
 
32
-		$this->heading = __( 'Automatic renewal payment failed due to authentication required', 'woocommerce-gateway-stripe' );
33
-		$this->subject = __( '[{site_title}] Automatic payment failed for {order_number}. Customer asked to authenticate payment and will be notified again {retry_time}', 'woocommerce-gateway-stripe' );
32
+		$this->heading = __('Automatic renewal payment failed due to authentication required', 'woocommerce-gateway-stripe');
33
+		$this->subject = __('[{site_title}] Automatic payment failed for {order_number}. Customer asked to authenticate payment and will be notified again {retry_time}', 'woocommerce-gateway-stripe');
34 34
 
35 35
 		$this->template_html  = 'emails/failed-renewal-authentication-requested.php';
36 36
 		$this->template_plain = 'emails/plain/failed-renewal-authentication-requested.php';
37
-		$this->template_base  = plugin_dir_path( WC_STRIPE_MAIN_FILE ) . 'templates/';
37
+		$this->template_base  = plugin_dir_path(WC_STRIPE_MAIN_FILE) . 'templates/';
38 38
 
39
-		$this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
39
+		$this->recipient = $this->get_option('recipient', get_option('admin_email'));
40 40
 
41 41
 		// We want all the parent's methods, with none of its properties, so call its parent's constructor, rather than my parent constructor.
42 42
 		WC_Email::__construct();
@@ -66,26 +66,26 @@  discard block
 block discarded – undo
66 66
 	 * @param int           $order_id The order ID.
67 67
 	 * @param WC_Order|null $order Order object.
68 68
 	 */
69
-	public function trigger( $order_id, $order = null ) {
69
+	public function trigger($order_id, $order = null) {
70 70
 		$this->object = $order;
71 71
 
72 72
 		$this->find['retry-time'] = '{retry_time}';
73
-		if ( class_exists( 'WCS_Retry_Manager' ) && function_exists( 'wcs_get_human_time_diff' ) ) {
74
-			$this->retry = WCS_Retry_Manager::store()->get_last_retry_for_order( wcs_get_objects_property( $order, 'id' ) );
75
-			$this->replace['retry-time'] = wcs_get_human_time_diff( $this->retry->get_time() );
73
+		if (class_exists('WCS_Retry_Manager') && function_exists('wcs_get_human_time_diff')) {
74
+			$this->retry = WCS_Retry_Manager::store()->get_last_retry_for_order(wcs_get_objects_property($order, 'id'));
75
+			$this->replace['retry-time'] = wcs_get_human_time_diff($this->retry->get_time());
76 76
 		} else {
77
-			WC_Stripe_Logger::log( 'WCS_Retry_Manager class or does not exist. Not able to send admnin email about customer notification for authentication required for renewal payment.' );
77
+			WC_Stripe_Logger::log('WCS_Retry_Manager class or does not exist. Not able to send admnin email about customer notification for authentication required for renewal payment.');
78 78
 			return;
79 79
 		}
80 80
 
81 81
 		$this->find['order-number']    = '{order_number}';
82 82
 		$this->replace['order-number'] = $this->object->get_order_number();
83 83
 
84
-		if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
84
+		if ( ! $this->is_enabled() || ! $this->get_recipient()) {
85 85
 			return;
86 86
 		}
87 87
 
88
-		$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
88
+		$this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
89 89
 	}
90 90
 
91 91
 	/**
Please login to merge, or discard this patch.
includes/compat/class-wc-stripe-email-failed-renewal-authentication.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit; // Exit if accessed directly.
4 4
 }
5 5
 
@@ -14,20 +14,20 @@  discard block
 block discarded – undo
14 14
 	 *
15 15
 	 * @param WC_Email[] $email_classes All existing instances of WooCommerce emails.
16 16
 	 */
17
-	public function __construct( $email_classes = array() ) {
17
+	public function __construct($email_classes = array()) {
18 18
 		$this->id             = 'failed_renewal_authentication';
19
-		$this->title          = __( 'Failed Subscription Renewal SCA Authentication', 'woocommerce-gateway-stripe' );
20
-		$this->description    = __( 'Sent to a customer when a renewal fails because the transaction requires an SCA verification. The email contains renewal order information and payment links.', 'woocommerce-gateway-stripe' );
19
+		$this->title          = __('Failed Subscription Renewal SCA Authentication', 'woocommerce-gateway-stripe');
20
+		$this->description    = __('Sent to a customer when a renewal fails because the transaction requires an SCA verification. The email contains renewal order information and payment links.', 'woocommerce-gateway-stripe');
21 21
 		$this->customer_email = true;
22 22
 
23 23
 		$this->template_html  = 'emails/failed-renewal-authentication.php';
24 24
 		$this->template_plain = 'emails/plain/failed-renewal-authentication.php';
25
-		$this->template_base  = plugin_dir_path( WC_STRIPE_MAIN_FILE ) . 'templates/';
25
+		$this->template_base  = plugin_dir_path(WC_STRIPE_MAIN_FILE) . 'templates/';
26 26
 
27 27
 		// Triggers the email at the correct hook.
28
-		add_action( 'wc_gateway_stripe_process_payment_authentication_required', array( $this, 'trigger' ) );
28
+		add_action('wc_gateway_stripe_process_payment_authentication_required', array($this, 'trigger'));
29 29
 
30
-		if ( isset( $email_classes['WCS_Email_Customer_Renewal_Invoice'] ) ) {
30
+		if (isset($email_classes['WCS_Email_Customer_Renewal_Invoice'])) {
31 31
 			$this->original_email = $email_classes['WCS_Email_Customer_Renewal_Invoice'];
32 32
 		}
33 33
 
@@ -40,21 +40,21 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @param WC_Order $order The order that is being paid.
42 42
 	 */
43
-	public function trigger( $order ) {
44
-		if ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order->get_id() ) || wcs_is_subscription( $order->get_id() ) || wcs_order_contains_renewal( $order->get_id() ) ) ) {
45
-			parent::trigger( $order );
43
+	public function trigger($order) {
44
+		if (function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order->get_id()) || wcs_is_subscription($order->get_id()) || wcs_order_contains_renewal($order->get_id()))) {
45
+			parent::trigger($order);
46 46
 
47 47
 			// Prevent the renewal email from WooCommerce Subscriptions from being sent.
48
-			if ( isset( $this->original_email ) ) {
49
-				remove_action( 'woocommerce_generated_manual_renewal_order_renewal_notification', array( $this->original_email, 'trigger' ) );
50
-				remove_action( 'woocommerce_order_status_failed_renewal_notification', array( $this->original_email, 'trigger' ) );
48
+			if (isset($this->original_email)) {
49
+				remove_action('woocommerce_generated_manual_renewal_order_renewal_notification', array($this->original_email, 'trigger'));
50
+				remove_action('woocommerce_order_status_failed_renewal_notification', array($this->original_email, 'trigger'));
51 51
 			}
52 52
 
53 53
 			// Prevent the retry email from WooCommerce Subscriptions from being sent.
54
-			add_filter( 'wcs_get_retry_rule_raw', array( $this, 'prevent_retry_notification_email' ), 100, 3 );
54
+			add_filter('wcs_get_retry_rule_raw', array($this, 'prevent_retry_notification_email'), 100, 3);
55 55
 
56 56
 			// Send email to store owner indicating communication is happening with the customer to request authentication.
57
-			add_filter( 'wcs_get_retry_rule_raw', array( $this, 'set_store_owner_custom_email' ), 100, 3 );
57
+			add_filter('wcs_get_retry_rule_raw', array($this, 'set_store_owner_custom_email'), 100, 3);
58 58
 		}
59 59
 	}
60 60
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * @return string
65 65
 	 */
66 66
 	public function get_default_subject() {
67
-		return __( 'Payment authorization needed for renewal of {site_title} order {order_number}', 'woocommerce-gateway-stripe' );
67
+		return __('Payment authorization needed for renewal of {site_title} order {order_number}', 'woocommerce-gateway-stripe');
68 68
 	}
69 69
 
70 70
 	/**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @return string
74 74
 	 */
75 75
 	public function get_default_heading() {
76
-		return __( 'Payment authorization needed for renewal of order {order_number}', 'woocommerce-gateway-stripe' );
76
+		return __('Payment authorization needed for renewal of order {order_number}', 'woocommerce-gateway-stripe');
77 77
 	}
78 78
 
79 79
 	/**
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 * @param int   $order_id     The ID of the order that needs payment.
85 85
 	 * @return array
86 86
 	 */
87
-	public function prevent_retry_notification_email( $rule_array, $retry_number, $order_id ) {
88
-		if ( wcs_get_objects_property( $this->object, 'id' ) === $order_id ) {
87
+	public function prevent_retry_notification_email($rule_array, $retry_number, $order_id) {
88
+		if (wcs_get_objects_property($this->object, 'id') === $order_id) {
89 89
 			$rule_array['email_template_customer'] = '';
90 90
 		}
91 91
 
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 	 * @param int   $order_id     The ID of the order that needs payment.
101 101
 	 * @return array
102 102
 	 */
103
-	public function set_store_owner_custom_email( $rule_array, $retry_number, $order_id ) {
103
+	public function set_store_owner_custom_email($rule_array, $retry_number, $order_id) {
104 104
 		if (
105
-			wcs_get_objects_property( $this->object, 'id' ) === $order_id &&
105
+			wcs_get_objects_property($this->object, 'id') === $order_id &&
106 106
 			'' !== $rule_array['email_template_admin'] // Only send our email if a retry admin email was already going to be sent.
107 107
 		) {
108 108
 			$rule_array['email_template_admin'] = 'WC_Stripe_Email_Failed_Authentication_Retry';
Please login to merge, or discard this patch.
includes/class-wc-stripe-apple-pay-registration.php 1 patch
Spacing   +51 added lines, -51 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
 
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
 	public $apple_pay_verify_notice;
61 61
 
62 62
 	public function __construct() {
63
-		add_action( 'woocommerce_stripe_updated', array( $this, 'update_verification_file' ) );
63
+		add_action('woocommerce_stripe_updated', array($this, 'update_verification_file'));
64 64
 
65
-		$this->stripe_settings         = get_option( 'woocommerce_stripe_settings', array() );
66
-		$this->stripe_enabled          = $this->get_option( 'enabled' );
67
-		$this->payment_request         = 'yes' === $this->get_option( 'payment_request', 'yes' );
68
-		$this->apple_pay_domain_set    = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' );
65
+		$this->stripe_settings         = get_option('woocommerce_stripe_settings', array());
66
+		$this->stripe_enabled          = $this->get_option('enabled');
67
+		$this->payment_request         = 'yes' === $this->get_option('payment_request', 'yes');
68
+		$this->apple_pay_domain_set    = 'yes' === $this->get_option('apple_pay_domain_set', 'no');
69 69
 		$this->apple_pay_verify_notice = '';
70
-		$this->testmode                = 'yes' === $this->get_option( 'testmode', 'no' );
71
-		$this->secret_key              = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
70
+		$this->testmode                = 'yes' === $this->get_option('testmode', 'no');
71
+		$this->secret_key              = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
72 72
 
73
-		if ( empty( $this->stripe_settings ) ) {
73
+		if (empty($this->stripe_settings)) {
74 74
 			return;
75 75
 		}
76 76
 
77 77
 		$this->init_apple_pay();
78 78
 
79
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
79
+		add_action('admin_notices', array($this, 'admin_notices'));
80 80
 	}
81 81
 
82 82
 	/**
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
 	 * @param string default
88 88
 	 * @return string $setting_value
89 89
 	 */
90
-	public function get_option( $setting = '', $default = '' ) {
91
-		if ( empty( $this->stripe_settings ) ) {
90
+	public function get_option($setting = '', $default = '') {
91
+		if (empty($this->stripe_settings)) {
92 92
 			return $default;
93 93
 		}
94 94
 
95
-		if ( ! empty( $this->stripe_settings[ $setting ] ) ) {
96
-			return $this->stripe_settings[ $setting ];
95
+		if ( ! empty($this->stripe_settings[$setting])) {
96
+			return $this->stripe_settings[$setting];
97 97
 		}
98 98
 
99 99
 		return $default;
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	public function init_apple_pay() {
109 109
 		if (
110 110
 			is_admin() &&
111
-			isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] &&
112
-			isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'] &&
113
-			isset( $_GET['section'] ) && 'stripe' === $_GET['section'] &&
111
+			isset($_GET['page']) && 'wc-settings' === $_GET['page'] &&
112
+			isset($_GET['tab']) && 'checkout' === $_GET['tab'] &&
113
+			isset($_GET['section']) && 'stripe' === $_GET['section'] &&
114 114
 			$this->payment_request
115 115
 		) {
116 116
 			$this->process_apple_pay_verification();
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 	 * @version 3.1.0
125 125
 	 * @param string $secret_key
126 126
 	 */
127
-	private function register_apple_pay_domain( $secret_key = '' ) {
128
-		if ( empty( $secret_key ) ) {
129
-			throw new Exception( __( 'Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe' ) );
127
+	private function register_apple_pay_domain($secret_key = '') {
128
+		if (empty($secret_key)) {
129
+			throw new Exception(__('Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe'));
130 130
 		}
131 131
 
132 132
 		$endpoint = 'https://api.stripe.com/v1/apple_pay/domains';
@@ -144,22 +144,22 @@  discard block
 block discarded – undo
144 144
 			$endpoint,
145 145
 			array(
146 146
 				'headers' => $headers,
147
-				'body'    => http_build_query( $data ),
147
+				'body'    => http_build_query($data),
148 148
 			)
149 149
 		);
150 150
 
151
-		if ( is_wp_error( $response ) ) {
151
+		if (is_wp_error($response)) {
152 152
 			/* translators: error message */
153
-			throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) );
153
+			throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $response->get_error_message()));
154 154
 		}
155 155
 
156
-		if ( 200 !== $response['response']['code'] ) {
157
-			$parsed_response = json_decode( $response['body'] );
156
+		if (200 !== $response['response']['code']) {
157
+			$parsed_response = json_decode($response['body']);
158 158
 
159 159
 			$this->apple_pay_verify_notice = $parsed_response->error->message;
160 160
 
161 161
 			/* translators: error message */
162
-			throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $parsed_response->error->message ) );
162
+			throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $parsed_response->error->message));
163 163
 		}
164 164
 	}
165 165
 
@@ -172,31 +172,31 @@  discard block
 block discarded – undo
172 172
 	 * @since 4.3.0
173 173
 	 * @return bool True on success, false on failure.
174 174
 	 */
175
-	public function update_verification_file( $force = false ) {
176
-			$path     = untrailingslashit( $_SERVER['DOCUMENT_ROOT'] );
175
+	public function update_verification_file($force = false) {
176
+			$path     = untrailingslashit($_SERVER['DOCUMENT_ROOT']);
177 177
 			$dir      = '.well-known';
178 178
 			$file     = 'apple-developer-merchantid-domain-association';
179 179
 			$fullpath = $path . '/' . $dir . '/' . $file;
180 180
 
181
-			$existing_contents = @file_get_contents( $fullpath );
182
-			$new_contents = @file_get_contents( WC_STRIPE_PLUGIN_PATH . '/' . $file );
183
-			if ( ( ! $existing_contents && ! $force ) || $existing_contents === $new_contents ) {
181
+			$existing_contents = @file_get_contents($fullpath);
182
+			$new_contents = @file_get_contents(WC_STRIPE_PLUGIN_PATH . '/' . $file);
183
+			if (( ! $existing_contents && ! $force) || $existing_contents === $new_contents) {
184 184
 				return true;
185 185
 			}
186 186
 
187
-			if ( ! file_exists( $path . '/' . $dir ) ) {
188
-				if ( ! @mkdir( $path . '/' . $dir, 0755 ) ) { // @codingStandardsIgnoreLine
189
-					WC_Stripe_Logger::log( 'Error: ' . __( 'Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe' ) );
187
+			if ( ! file_exists($path . '/' . $dir)) {
188
+				if ( ! @mkdir($path . '/' . $dir, 0755)) { // @codingStandardsIgnoreLine
189
+					WC_Stripe_Logger::log('Error: ' . __('Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe'));
190 190
 					return false;
191 191
 				}
192 192
 			}
193 193
 
194
-			if ( ! @copy( WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath ) ) { // @codingStandardsIgnoreLine
195
-				WC_Stripe_Logger::log( 'Error: ' . __( 'Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe' ) );
194
+			if ( ! @copy(WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath)) { // @codingStandardsIgnoreLine
195
+				WC_Stripe_Logger::log('Error: ' . __('Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe'));
196 196
 				return false;
197 197
 			}
198 198
 
199
-			WC_Stripe_Logger::log( 'Domain association file updated.' );
199
+			WC_Stripe_Logger::log('Domain association file updated.');
200 200
 			return true;
201 201
 	}
202 202
 
@@ -207,31 +207,31 @@  discard block
 block discarded – undo
207 207
 	 * @version 3.1.0
208 208
 	 */
209 209
 	public function process_apple_pay_verification() {
210
-		if ( ! $this->update_verification_file( true ) ) {
210
+		if ( ! $this->update_verification_file(true)) {
211 211
 			$this->stripe_settings['apple_pay_domain_set'] = 'no';
212
-			update_option( 'woocommerce_stripe_settings', $this->stripe_settings );
212
+			update_option('woocommerce_stripe_settings', $this->stripe_settings);
213 213
 			return;
214 214
 		}
215 215
 
216 216
 		try {
217 217
 			// At this point then the domain association folder and file should be available.
218 218
 			// Proceed to verify/and or verify again.
219
-			$this->register_apple_pay_domain( $this->secret_key );
219
+			$this->register_apple_pay_domain($this->secret_key);
220 220
 
221 221
 			// No errors to this point, verification success!
222 222
 			$this->stripe_settings['apple_pay_domain_set'] = 'yes';
223 223
 			$this->apple_pay_domain_set                    = true;
224 224
 
225
-			update_option( 'woocommerce_stripe_settings', $this->stripe_settings );
225
+			update_option('woocommerce_stripe_settings', $this->stripe_settings);
226 226
 
227
-			WC_Stripe_Logger::log( 'Your domain has been verified with Apple Pay!' );
227
+			WC_Stripe_Logger::log('Your domain has been verified with Apple Pay!');
228 228
 
229
-		} catch ( Exception $e ) {
229
+		} catch (Exception $e) {
230 230
 			$this->stripe_settings['apple_pay_domain_set'] = 'no';
231 231
 
232
-			update_option( 'woocommerce_stripe_settings', $this->stripe_settings );
232
+			update_option('woocommerce_stripe_settings', $this->stripe_settings);
233 233
 
234
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
234
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
235 235
 		}
236 236
 	}
237 237
 
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
 	 * @since 4.0.6
242 242
 	 */
243 243
 	public function admin_notices() {
244
-		if ( ! $this->stripe_enabled ) {
244
+		if ( ! $this->stripe_enabled) {
245 245
 			return;
246 246
 		}
247 247
 
248
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
248
+		if ( ! current_user_can('manage_woocommerce')) {
249 249
 			return;
250 250
 		}
251 251
 
252
-		if ( $this->payment_request && ! empty( $this->apple_pay_verify_notice ) ) {
252
+		if ($this->payment_request && ! empty($this->apple_pay_verify_notice)) {
253 253
 			$allowed_html = array(
254 254
 				'a' => array(
255 255
 					'href'  => array(),
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 				),
258 258
 			);
259 259
 
260
-			echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses( make_clickable( $this->apple_pay_verify_notice ), $allowed_html ) . '</p></div>';
260
+			echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses(make_clickable($this->apple_pay_verify_notice), $allowed_html) . '</p></div>';
261 261
 		}
262 262
 
263 263
 		/**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
 		 * when setting screen is displayed. So if domain verification is not set,
266 266
 		 * something went wrong so lets notify user.
267 267
 		 */
268
-		if ( ! empty( $this->secret_key ) && $this->payment_request && ! $this->apple_pay_domain_set ) {
268
+		if ( ! empty($this->secret_key) && $this->payment_request && ! $this->apple_pay_domain_set) {
269 269
 			/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
270
-			echo '<div class="error stripe-apple-pay-message"><p>' . sprintf( __( 'Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe' ), '<a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">', '</a>' ) . '</p></div>';
270
+			echo '<div class="error stripe-apple-pay-message"><p>' . sprintf(__('Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe'), '<a href="' . admin_url('admin.php?page=wc-status&tab=logs') . '">', '</a>') . '</p></div>';
271 271
 		}
272 272
 	}
273 273
 }
Please login to merge, or discard this patch.
includes/payment-methods/class-wc-stripe-payment-request.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * Get this instance.
131 131
 	 *
132 132
 	 * @since 4.0.6
133
-	 * @return class
133
+	 * @return WC_Stripe_Payment_Request
134 134
 	 */
135 135
 	public static function instance() {
136 136
 		return self::$_this;
@@ -604,7 +604,6 @@  discard block
 block discarded – undo
604 604
 	 *
605 605
 	 * @since 4.3.2
606 606
 	 *
607
-	 * @param object $post
608 607
 	 *
609 608
 	 * @return bool
610 609
 	 */
Please login to merge, or discard this patch.
Spacing   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   4.0.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
@@ -64,41 +64,41 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function __construct() {
66 66
 		self::$_this            = $this;
67
-		$this->stripe_settings  = get_option( 'woocommerce_stripe_settings', array() );
68
-		$this->testmode         = ( ! empty( $this->stripe_settings['testmode'] ) && 'yes' === $this->stripe_settings['testmode'] ) ? true : false;
69
-		$this->publishable_key  = ! empty( $this->stripe_settings['publishable_key'] ) ? $this->stripe_settings['publishable_key'] : '';
70
-		$this->secret_key       = ! empty( $this->stripe_settings['secret_key'] ) ? $this->stripe_settings['secret_key'] : '';
71
-		$this->total_label      = ! empty( $this->stripe_settings['statement_descriptor'] ) ? WC_Stripe_Helper::clean_statement_descriptor( $this->stripe_settings['statement_descriptor'] ) : '';
67
+		$this->stripe_settings  = get_option('woocommerce_stripe_settings', array());
68
+		$this->testmode         = ( ! empty($this->stripe_settings['testmode']) && 'yes' === $this->stripe_settings['testmode']) ? true : false;
69
+		$this->publishable_key  = ! empty($this->stripe_settings['publishable_key']) ? $this->stripe_settings['publishable_key'] : '';
70
+		$this->secret_key       = ! empty($this->stripe_settings['secret_key']) ? $this->stripe_settings['secret_key'] : '';
71
+		$this->total_label      = ! empty($this->stripe_settings['statement_descriptor']) ? WC_Stripe_Helper::clean_statement_descriptor($this->stripe_settings['statement_descriptor']) : '';
72 72
 
73
-		if ( $this->testmode ) {
74
-			$this->publishable_key = ! empty( $this->stripe_settings['test_publishable_key'] ) ? $this->stripe_settings['test_publishable_key'] : '';
75
-			$this->secret_key      = ! empty( $this->stripe_settings['test_secret_key'] ) ? $this->stripe_settings['test_secret_key'] : '';
73
+		if ($this->testmode) {
74
+			$this->publishable_key = ! empty($this->stripe_settings['test_publishable_key']) ? $this->stripe_settings['test_publishable_key'] : '';
75
+			$this->secret_key      = ! empty($this->stripe_settings['test_secret_key']) ? $this->stripe_settings['test_secret_key'] : '';
76 76
 		}
77 77
 
78
-		$this->total_label = str_replace( "'", '', $this->total_label ) . apply_filters( 'wc_stripe_payment_request_total_label_suffix', ' (via WooCommerce)' );
78
+		$this->total_label = str_replace("'", '', $this->total_label) . apply_filters('wc_stripe_payment_request_total_label_suffix', ' (via WooCommerce)');
79 79
 
80 80
 		// Checks if Stripe Gateway is enabled.
81
-		if ( empty( $this->stripe_settings ) || ( isset( $this->stripe_settings['enabled'] ) && 'yes' !== $this->stripe_settings['enabled'] ) ) {
81
+		if (empty($this->stripe_settings) || (isset($this->stripe_settings['enabled']) && 'yes' !== $this->stripe_settings['enabled'])) {
82 82
 			return;
83 83
 		}
84 84
 
85 85
 		// Checks if Payment Request is enabled.
86
-		if ( ! isset( $this->stripe_settings['payment_request'] ) || 'yes' !== $this->stripe_settings['payment_request'] ) {
86
+		if ( ! isset($this->stripe_settings['payment_request']) || 'yes' !== $this->stripe_settings['payment_request']) {
87 87
 			return;
88 88
 		}
89 89
 
90 90
 		// Don't load for change payment method page.
91
-		if ( isset( $_GET['change_payment_method'] ) ) {
91
+		if (isset($_GET['change_payment_method'])) {
92 92
 			return;
93 93
 		}
94 94
 
95
-		$wc_default_country = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
95
+		$wc_default_country = substr(get_option('woocommerce_default_country'), 0, 2);
96 96
 
97
-		if ( ! in_array( $wc_default_country, $this->get_stripe_supported_countries() ) ) {
97
+		if ( ! in_array($wc_default_country, $this->get_stripe_supported_countries())) {
98 98
 			return;
99 99
 		}
100 100
 
101
-		add_action( 'template_redirect', array( $this, 'set_session' ) );
101
+		add_action('template_redirect', array($this, 'set_session'));
102 102
 		$this->init();
103 103
 	}
104 104
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @return array The list of countries.
110 110
 	 */
111 111
 	public function get_stripe_supported_countries() {
112
-		return apply_filters( 'wc_stripe_supported_countries', array( 'AT', 'AU', 'BE', 'BR', 'CA', 'CH', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'HK', 'IE', 'IN', 'IT', 'JP', 'LT', 'LU', 'LV', 'MX', 'NL', 'NZ', 'NO', 'PH', 'PL', 'PR', 'PT', 'RO', 'SE', 'SG', 'SK', 'US' ) );
112
+		return apply_filters('wc_stripe_supported_countries', array('AT', 'AU', 'BE', 'BR', 'CA', 'CH', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'HK', 'IE', 'IN', 'IT', 'JP', 'LT', 'LU', 'LV', 'MX', 'NL', 'NZ', 'NO', 'PH', 'PL', 'PR', 'PT', 'RO', 'SE', 'SG', 'SK', 'US'));
113 113
 	}
114 114
 
115 115
 	/**
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @return bool
120 120
 	 */
121 121
 	public function are_keys_set() {
122
-		if ( empty( $this->secret_key ) || empty( $this->publishable_key ) ) {
122
+		if (empty($this->secret_key) || empty($this->publishable_key)) {
123 123
 			return false;
124 124
 		}
125 125
 
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 	 * @since 4.0.0
144 144
 	 */
145 145
 	public function set_session() {
146
-		if ( ! is_product() || ( isset( WC()->session ) && WC()->session->has_session() ) ) {
146
+		if ( ! is_product() || (isset(WC()->session) && WC()->session->has_session())) {
147 147
 			return;
148 148
 		}
149 149
 
150
-		WC()->session->set_customer_session_cookie( true );
150
+		WC()->session->set_customer_session_cookie(true);
151 151
 	}
152 152
 
153 153
 	/**
@@ -157,40 +157,40 @@  discard block
 block discarded – undo
157 157
 	 * @version 4.0.0
158 158
 	 */
159 159
 	public function init() {
160
-		add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ) );
160
+		add_action('wp_enqueue_scripts', array($this, 'scripts'));
161 161
 
162 162
 		/*
163 163
 		 * In order to display the Payment Request button in the correct position,
164 164
 		 * a new hook was added to WooCommerce 3.0. In older versions of WooCommerce,
165 165
 		 * CSS is used to position the button.
166 166
 		 */
167
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
168
-			add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_payment_request_button_html' ), 1 );
169
-			add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_payment_request_button_separator_html' ), 2 );
167
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
168
+			add_action('woocommerce_after_add_to_cart_button', array($this, 'display_payment_request_button_html'), 1);
169
+			add_action('woocommerce_after_add_to_cart_button', array($this, 'display_payment_request_button_separator_html'), 2);
170 170
 		} else {
171
-			add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_html' ), 1 );
172
-			add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_separator_html' ), 2 );
171
+			add_action('woocommerce_after_add_to_cart_quantity', array($this, 'display_payment_request_button_html'), 1);
172
+			add_action('woocommerce_after_add_to_cart_quantity', array($this, 'display_payment_request_button_separator_html'), 2);
173 173
 		}
174 174
 
175
-		add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_payment_request_button_html' ), 1 );
176
-		add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_payment_request_button_separator_html' ), 2 );
175
+		add_action('woocommerce_proceed_to_checkout', array($this, 'display_payment_request_button_html'), 1);
176
+		add_action('woocommerce_proceed_to_checkout', array($this, 'display_payment_request_button_separator_html'), 2);
177 177
 
178
-		add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_payment_request_button_html' ), 1 );
179
-		add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_payment_request_button_separator_html' ), 2 );
178
+		add_action('woocommerce_checkout_before_customer_details', array($this, 'display_payment_request_button_html'), 1);
179
+		add_action('woocommerce_checkout_before_customer_details', array($this, 'display_payment_request_button_separator_html'), 2);
180 180
 
181
-		add_action( 'wc_ajax_wc_stripe_get_cart_details', array( $this, 'ajax_get_cart_details' ) );
182
-		add_action( 'wc_ajax_wc_stripe_get_shipping_options', array( $this, 'ajax_get_shipping_options' ) );
183
-		add_action( 'wc_ajax_wc_stripe_update_shipping_method', array( $this, 'ajax_update_shipping_method' ) );
184
-		add_action( 'wc_ajax_wc_stripe_create_order', array( $this, 'ajax_create_order' ) );
185
-		add_action( 'wc_ajax_wc_stripe_add_to_cart', array( $this, 'ajax_add_to_cart' ) );
186
-		add_action( 'wc_ajax_wc_stripe_get_selected_product_data', array( $this, 'ajax_get_selected_product_data' ) );
187
-		add_action( 'wc_ajax_wc_stripe_clear_cart', array( $this, 'ajax_clear_cart' ) );
188
-		add_action( 'wc_ajax_wc_stripe_log_errors', array( $this, 'ajax_log_errors' ) );
181
+		add_action('wc_ajax_wc_stripe_get_cart_details', array($this, 'ajax_get_cart_details'));
182
+		add_action('wc_ajax_wc_stripe_get_shipping_options', array($this, 'ajax_get_shipping_options'));
183
+		add_action('wc_ajax_wc_stripe_update_shipping_method', array($this, 'ajax_update_shipping_method'));
184
+		add_action('wc_ajax_wc_stripe_create_order', array($this, 'ajax_create_order'));
185
+		add_action('wc_ajax_wc_stripe_add_to_cart', array($this, 'ajax_add_to_cart'));
186
+		add_action('wc_ajax_wc_stripe_get_selected_product_data', array($this, 'ajax_get_selected_product_data'));
187
+		add_action('wc_ajax_wc_stripe_clear_cart', array($this, 'ajax_clear_cart'));
188
+		add_action('wc_ajax_wc_stripe_log_errors', array($this, 'ajax_log_errors'));
189 189
 
190
-		add_filter( 'woocommerce_gateway_title', array( $this, 'filter_gateway_title' ), 10, 2 );
191
-		add_filter( 'woocommerce_validate_postcode', array( $this, 'postal_code_validation' ), 10, 3 );
190
+		add_filter('woocommerce_gateway_title', array($this, 'filter_gateway_title'), 10, 2);
191
+		add_filter('woocommerce_validate_postcode', array($this, 'postal_code_validation'), 10, 3);
192 192
 
193
-		add_action( 'woocommerce_checkout_order_processed', array( $this, 'add_order_meta' ), 10, 2 );
193
+		add_action('woocommerce_checkout_order_processed', array($this, 'add_order_meta'), 10, 2);
194 194
 	}
195 195
 
196 196
 	/**
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 * @return string
202 202
 	 */
203 203
 	public function get_button_type() {
204
-		return isset( $this->stripe_settings['payment_request_button_type'] ) ? $this->stripe_settings['payment_request_button_type'] : 'default';
204
+		return isset($this->stripe_settings['payment_request_button_type']) ? $this->stripe_settings['payment_request_button_type'] : 'default';
205 205
 	}
206 206
 
207 207
 	/**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 * @return string
213 213
 	 */
214 214
 	public function get_button_theme() {
215
-		return isset( $this->stripe_settings['payment_request_button_theme'] ) ? $this->stripe_settings['payment_request_button_theme'] : 'dark';
215
+		return isset($this->stripe_settings['payment_request_button_theme']) ? $this->stripe_settings['payment_request_button_theme'] : 'dark';
216 216
 	}
217 217
 
218 218
 	/**
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 * @return string
224 224
 	 */
225 225
 	public function get_button_height() {
226
-		return isset( $this->stripe_settings['payment_request_button_height'] ) ? str_replace( 'px', '', $this->stripe_settings['payment_request_button_height'] ) : '64';
226
+		return isset($this->stripe_settings['payment_request_button_height']) ? str_replace('px', '', $this->stripe_settings['payment_request_button_height']) : '64';
227 227
 	}
228 228
 
229 229
 	/**
@@ -233,26 +233,26 @@  discard block
 block discarded – undo
233 233
 	 * @version 4.0.0
234 234
 	 */
235 235
 	public function get_product_data() {
236
-		if ( ! is_product() ) {
236
+		if ( ! is_product()) {
237 237
 			return false;
238 238
 		}
239 239
 
240 240
 		global $post;
241 241
 
242
-		$product = wc_get_product( $post->ID );
242
+		$product = wc_get_product($post->ID);
243 243
 
244
-		if ( 'variable' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ) ) {
245
-			$attributes = wc_clean( wp_unslash( $_GET ) );
244
+		if ('variable' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type())) {
245
+			$attributes = wc_clean(wp_unslash($_GET));
246 246
 
247
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
248
-				$variation_id = $product->get_matching_variation( $attributes );
247
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
248
+				$variation_id = $product->get_matching_variation($attributes);
249 249
 			} else {
250
-				$data_store   = WC_Data_Store::load( 'product' );
251
-				$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
250
+				$data_store   = WC_Data_Store::load('product');
251
+				$variation_id = $data_store->find_matching_product_variation($product, $attributes);
252 252
 			}
253 253
 
254
-			if ( ! empty( $variation_id ) ) {
255
-				$product = wc_get_product( $variation_id );
254
+			if ( ! empty($variation_id)) {
255
+				$product = wc_get_product($variation_id);
256 256
 			}
257 257
 		}
258 258
 
@@ -260,28 +260,28 @@  discard block
 block discarded – undo
260 260
 		$items = array();
261 261
 
262 262
 		$items[] = array(
263
-			'label'  => WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->name : $product->get_name(),
264
-			'amount' => WC_Stripe_Helper::get_stripe_amount( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->price : $product->get_price() ),
263
+			'label'  => WC_Stripe_Helper::is_wc_lt('3.0') ? $product->name : $product->get_name(),
264
+			'amount' => WC_Stripe_Helper::get_stripe_amount(WC_Stripe_Helper::is_wc_lt('3.0') ? $product->price : $product->get_price()),
265 265
 		);
266 266
 
267
-		if ( wc_tax_enabled() ) {
267
+		if (wc_tax_enabled()) {
268 268
 			$items[] = array(
269
-				'label'   => __( 'Tax', 'woocommerce-gateway-stripe' ),
269
+				'label'   => __('Tax', 'woocommerce-gateway-stripe'),
270 270
 				'amount'  => 0,
271 271
 				'pending' => true,
272 272
 			);
273 273
 		}
274 274
 
275
-		if ( wc_shipping_enabled() && $product->needs_shipping() ) {
275
+		if (wc_shipping_enabled() && $product->needs_shipping()) {
276 276
 			$items[] = array(
277
-				'label'   => __( 'Shipping', 'woocommerce-gateway-stripe' ),
277
+				'label'   => __('Shipping', 'woocommerce-gateway-stripe'),
278 278
 				'amount'  => 0,
279 279
 				'pending' => true,
280 280
 			);
281 281
 
282 282
 			$data['shippingOptions'] = array(
283 283
 				'id'     => 'pending',
284
-				'label'  => __( 'Pending', 'woocommerce-gateway-stripe' ),
284
+				'label'  => __('Pending', 'woocommerce-gateway-stripe'),
285 285
 				'detail' => '',
286 286
 				'amount' => 0,
287 287
 			);
@@ -289,41 +289,41 @@  discard block
 block discarded – undo
289 289
 
290 290
 		$data['displayItems'] = $items;
291 291
 		$data['total']        = array(
292
-			'label'   => apply_filters( 'wc_stripe_payment_request_total_label', $this->total_label ),
293
-			'amount'  => WC_Stripe_Helper::get_stripe_amount( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->price : $product->get_price() ),
292
+			'label'   => apply_filters('wc_stripe_payment_request_total_label', $this->total_label),
293
+			'amount'  => WC_Stripe_Helper::get_stripe_amount(WC_Stripe_Helper::is_wc_lt('3.0') ? $product->price : $product->get_price()),
294 294
 			'pending' => true,
295 295
 		);
296 296
 
297
-		$data['requestShipping'] = ( wc_shipping_enabled() && $product->needs_shipping() );
298
-		$data['currency']        = strtolower( get_woocommerce_currency() );
299
-		$data['country_code']    = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
297
+		$data['requestShipping'] = (wc_shipping_enabled() && $product->needs_shipping());
298
+		$data['currency']        = strtolower(get_woocommerce_currency());
299
+		$data['country_code']    = substr(get_option('woocommerce_default_country'), 0, 2);
300 300
 
301
-		return apply_filters( 'wc_stripe_payment_request_product_data', $data, $product );
301
+		return apply_filters('wc_stripe_payment_request_product_data', $data, $product);
302 302
 	}
303 303
 
304 304
 	/**
305 305
 	 * Filters the gateway title to reflect Payment Request type
306 306
 	 *
307 307
 	 */
308
-	public function filter_gateway_title( $title, $id ) {
308
+	public function filter_gateway_title($title, $id) {
309 309
 		global $post;
310 310
 
311
-		if ( ! is_object( $post ) ) {
311
+		if ( ! is_object($post)) {
312 312
 			return $title;
313 313
 		}
314 314
 
315
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
316
-			$method_title = get_post_meta( $post->ID, '_payment_method_title', true );
315
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
316
+			$method_title = get_post_meta($post->ID, '_payment_method_title', true);
317 317
 		} else {
318
-			$order        = wc_get_order( $post->ID );
319
-			$method_title = is_object( $order ) ? $order->get_payment_method_title() : '';
318
+			$order        = wc_get_order($post->ID);
319
+			$method_title = is_object($order) ? $order->get_payment_method_title() : '';
320 320
 		}
321 321
 
322
-		if ( 'stripe' === $id && ! empty( $method_title ) && 'Apple Pay (Stripe)' === $method_title ) {
322
+		if ('stripe' === $id && ! empty($method_title) && 'Apple Pay (Stripe)' === $method_title) {
323 323
 			return $method_title;
324 324
 		}
325 325
 
326
-		if ( 'stripe' === $id && ! empty( $method_title ) && 'Chrome Payment Request (Stripe)' === $method_title ) {
326
+		if ('stripe' === $id && ! empty($method_title) && 'Chrome Payment Request (Stripe)' === $method_title) {
327 327
 			return $method_title;
328 328
 		}
329 329
 
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
 	 * @since 3.1.4
337 337
 	 * @version 4.0.0
338 338
 	 */
339
-	public function postal_code_validation( $valid, $postcode, $country ) {
339
+	public function postal_code_validation($valid, $postcode, $country) {
340 340
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
341 341
 
342
-		if ( ! isset( $gateways['stripe'] ) ) {
342
+		if ( ! isset($gateways['stripe'])) {
343 343
 			return $valid;
344 344
 		}
345 345
 
346
-		$payment_request_type = isset( $_POST['payment_request_type'] ) ? wc_clean( $_POST['payment_request_type'] ) : '';
346
+		$payment_request_type = isset($_POST['payment_request_type']) ? wc_clean($_POST['payment_request_type']) : '';
347 347
 
348
-		if ( 'apple_pay' !== $payment_request_type ) {
348
+		if ('apple_pay' !== $payment_request_type) {
349 349
 			return $valid;
350 350
 		}
351 351
 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 		 * the order and not let it go through. The remedy for now is just to remove this validation.
356 356
 		 * Note that this only works with shipping providers that don't validate full postal codes.
357 357
 		 */
358
-		if ( 'GB' === $country || 'CA' === $country ) {
358
+		if ('GB' === $country || 'CA' === $country) {
359 359
 			return true;
360 360
 		}
361 361
 
@@ -370,29 +370,29 @@  discard block
 block discarded – undo
370 370
 	 * @param int $order_id
371 371
 	 * @param array $posted_data The posted data from checkout form.
372 372
 	 */
373
-	public function add_order_meta( $order_id, $posted_data ) {
374
-		if ( empty( $_POST['payment_request_type'] ) ) {
373
+	public function add_order_meta($order_id, $posted_data) {
374
+		if (empty($_POST['payment_request_type'])) {
375 375
 			return;
376 376
 		}
377 377
 
378
-		$order = wc_get_order( $order_id );
378
+		$order = wc_get_order($order_id);
379 379
 
380
-		$payment_request_type = wc_clean( $_POST['payment_request_type'] );
380
+		$payment_request_type = wc_clean($_POST['payment_request_type']);
381 381
 
382
-		if ( 'apple_pay' === $payment_request_type ) {
383
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
384
-				update_post_meta( $order_id, '_payment_method_title', 'Apple Pay (Stripe)' );
382
+		if ('apple_pay' === $payment_request_type) {
383
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
384
+				update_post_meta($order_id, '_payment_method_title', 'Apple Pay (Stripe)');
385 385
 			} else {
386
-				$order->set_payment_method_title( 'Apple Pay (Stripe)' );
386
+				$order->set_payment_method_title('Apple Pay (Stripe)');
387 387
 				$order->save();
388 388
 			}
389 389
 		}
390 390
 
391
-		if ( 'payment_request_api' === $payment_request_type ) {
392
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
393
-				update_post_meta( $order_id, '_payment_method_title', 'Chrome Payment Request (Stripe)' );
391
+		if ('payment_request_api' === $payment_request_type) {
392
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
393
+				update_post_meta($order_id, '_payment_method_title', 'Chrome Payment Request (Stripe)');
394 394
 			} else {
395
-				$order->set_payment_method_title( 'Chrome Payment Request (Stripe)' );
395
+				$order->set_payment_method_title('Chrome Payment Request (Stripe)');
396 396
 				$order->save();
397 397
 			}
398 398
 		}
@@ -431,20 +431,20 @@  discard block
 block discarded – undo
431 431
 	 * @return bool
432 432
 	 */
433 433
 	public function allowed_items_in_cart() {
434
-		foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
435
-			$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
434
+		foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
435
+			$_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);
436 436
 
437
-			if ( ! in_array( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $_product->product_type : $_product->get_type() ), $this->supported_product_types() ) ) {
437
+			if ( ! in_array((WC_Stripe_Helper::is_wc_lt('3.0') ? $_product->product_type : $_product->get_type()), $this->supported_product_types())) {
438 438
 				return false;
439 439
 			}
440 440
 
441 441
 			// Trial subscriptions with shipping are not supported
442
-			if ( class_exists( 'WC_Subscriptions_Order' ) && WC_Subscriptions_Cart::cart_contains_subscription() && $_product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $_product ) > 0 ) {
442
+			if (class_exists('WC_Subscriptions_Order') && WC_Subscriptions_Cart::cart_contains_subscription() && $_product->needs_shipping() && WC_Subscriptions_Product::get_trial_length($_product) > 0) {
443 443
 				return false;
444 444
 			}
445 445
 
446 446
 			// Pre Orders compatbility where we don't support charge upon release.
447
-			if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Cart::cart_contains_pre_order() && WC_Pre_Orders_Product::product_is_charged_upon_release( WC_Pre_Orders_Cart::get_pre_order_product() ) ) {
447
+			if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Cart::cart_contains_pre_order() && WC_Pre_Orders_Product::product_is_charged_upon_release(WC_Pre_Orders_Cart::get_pre_order_product())) {
448 448
 				return false;
449 449
 			}
450 450
 		}
@@ -460,73 +460,73 @@  discard block
 block discarded – undo
460 460
 	 */
461 461
 	public function scripts() {
462 462
 		// If keys are not set bail.
463
-		if ( ! $this->are_keys_set() ) {
464
-			WC_Stripe_Logger::log( 'Keys are not set correctly.' );
463
+		if ( ! $this->are_keys_set()) {
464
+			WC_Stripe_Logger::log('Keys are not set correctly.');
465 465
 			return;
466 466
 		}
467 467
 
468 468
 		// If no SSL bail.
469
-		if ( ! $this->testmode && ! is_ssl() ) {
470
-			WC_Stripe_Logger::log( 'Stripe Payment Request live mode requires SSL.' );
469
+		if ( ! $this->testmode && ! is_ssl()) {
470
+			WC_Stripe_Logger::log('Stripe Payment Request live mode requires SSL.');
471 471
 			return;
472 472
 		}
473 473
 
474
-		if ( ! is_product() && ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) ) {
474
+		if ( ! is_product() && ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order'])) {
475 475
 			return;
476 476
 		}
477 477
 
478
-		if ( is_product() && ! $this->should_show_payment_button_on_product_page() ) {
478
+		if (is_product() && ! $this->should_show_payment_button_on_product_page()) {
479 479
 			return;
480 480
 		}
481 481
 
482
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
482
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
483 483
 
484 484
 		$stripe_params = array(
485
-			'ajax_url'        => WC_AJAX::get_endpoint( '%%endpoint%%' ),
485
+			'ajax_url'        => WC_AJAX::get_endpoint('%%endpoint%%'),
486 486
 			'stripe'          => array(
487 487
 				'key'                => $this->publishable_key,
488
-				'allow_prepaid_card' => apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no',
488
+				'allow_prepaid_card' => apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no',
489 489
 			),
490 490
 			'nonce'           => array(
491
-				'payment'                   => wp_create_nonce( 'wc-stripe-payment-request' ),
492
-				'shipping'                  => wp_create_nonce( 'wc-stripe-payment-request-shipping' ),
493
-				'update_shipping'           => wp_create_nonce( 'wc-stripe-update-shipping-method' ),
494
-				'checkout'                  => wp_create_nonce( 'woocommerce-process_checkout' ),
495
-				'add_to_cart'               => wp_create_nonce( 'wc-stripe-add-to-cart' ),
496
-				'get_selected_product_data' => wp_create_nonce( 'wc-stripe-get-selected-product-data' ),
497
-				'log_errors'                => wp_create_nonce( 'wc-stripe-log-errors' ),
498
-				'clear_cart'                => wp_create_nonce( 'wc-stripe-clear-cart' ),
491
+				'payment'                   => wp_create_nonce('wc-stripe-payment-request'),
492
+				'shipping'                  => wp_create_nonce('wc-stripe-payment-request-shipping'),
493
+				'update_shipping'           => wp_create_nonce('wc-stripe-update-shipping-method'),
494
+				'checkout'                  => wp_create_nonce('woocommerce-process_checkout'),
495
+				'add_to_cart'               => wp_create_nonce('wc-stripe-add-to-cart'),
496
+				'get_selected_product_data' => wp_create_nonce('wc-stripe-get-selected-product-data'),
497
+				'log_errors'                => wp_create_nonce('wc-stripe-log-errors'),
498
+				'clear_cart'                => wp_create_nonce('wc-stripe-clear-cart'),
499 499
 			),
500 500
 			'i18n'            => array(
501
-				'no_prepaid_card'  => __( 'Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe' ),
501
+				'no_prepaid_card'  => __('Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe'),
502 502
 				/* translators: Do not translate the [option] placeholder */
503
-				'unknown_shipping' => __( 'Unknown shipping option "[option]".', 'woocommerce-gateway-stripe' ),
503
+				'unknown_shipping' => __('Unknown shipping option "[option]".', 'woocommerce-gateway-stripe'),
504 504
 			),
505 505
 			'checkout'        => array(
506 506
 				'url'            => wc_get_checkout_url(),
507
-				'currency_code'  => strtolower( get_woocommerce_currency() ),
508
-				'country_code'   => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
507
+				'currency_code'  => strtolower(get_woocommerce_currency()),
508
+				'country_code'   => substr(get_option('woocommerce_default_country'), 0, 2),
509 509
 				'needs_shipping' => WC()->cart->needs_shipping() ? 'yes' : 'no',
510 510
 			),
511 511
 			'button'          => array(
512 512
 				'type'   => $this->get_button_type(),
513 513
 				'theme'  => $this->get_button_theme(),
514 514
 				'height' => $this->get_button_height(),
515
-				'locale' => apply_filters( 'wc_stripe_payment_request_button_locale', substr( get_locale(), 0, 2 ) ), // Default format is en_US.
515
+				'locale' => apply_filters('wc_stripe_payment_request_button_locale', substr(get_locale(), 0, 2)), // Default format is en_US.
516 516
 			),
517 517
 			'is_product_page' => is_product(),
518 518
 			'product'         => $this->get_product_data(),
519 519
 		);
520 520
 
521
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
522
-		wp_register_script( 'wc_stripe_payment_request', plugins_url( 'assets/js/stripe-payment-request' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery', 'stripe' ), WC_STRIPE_VERSION, true );
521
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
522
+		wp_register_script('wc_stripe_payment_request', plugins_url('assets/js/stripe-payment-request' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery', 'stripe'), WC_STRIPE_VERSION, true);
523 523
 
524
-		wp_localize_script( 'wc_stripe_payment_request', 'wc_stripe_payment_request_params', apply_filters( 'wc_stripe_payment_request_params', $stripe_params ) );
524
+		wp_localize_script('wc_stripe_payment_request', 'wc_stripe_payment_request_params', apply_filters('wc_stripe_payment_request_params', $stripe_params));
525 525
 
526
-		wp_enqueue_script( 'wc_stripe_payment_request' );
526
+		wp_enqueue_script('wc_stripe_payment_request');
527 527
 
528 528
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
529
-		if ( isset( $gateways['stripe'] ) ) {
529
+		if (isset($gateways['stripe'])) {
530 530
 			$gateways['stripe']->payment_scripts();
531 531
 		}
532 532
 	}
@@ -542,23 +542,23 @@  discard block
 block discarded – undo
542 542
 
543 543
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
544 544
 
545
-		if ( ! isset( $gateways['stripe'] ) ) {
545
+		if ( ! isset($gateways['stripe'])) {
546 546
 			return;
547 547
 		}
548 548
 
549
-		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) {
549
+		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset($_GET['pay_for_order'])) {
550 550
 			return;
551 551
 		}
552 552
 
553
-		if ( is_checkout() && ! apply_filters( 'wc_stripe_show_payment_request_on_checkout', false, $post ) ) {
553
+		if (is_checkout() && ! apply_filters('wc_stripe_show_payment_request_on_checkout', false, $post)) {
554 554
 			return;
555 555
 		}
556 556
 
557
-		if ( is_product() && ! $this->should_show_payment_button_on_product_page() ) {
557
+		if (is_product() && ! $this->should_show_payment_button_on_product_page()) {
558 558
 			return;
559 559
 		} else {
560
-			if ( ! $this->allowed_items_in_cart() ) {
561
-				WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' );
560
+			if ( ! $this->allowed_items_in_cart()) {
561
+				WC_Stripe_Logger::log('Items in the cart has unsupported product type ( Payment Request button disabled )');
562 562
 				return;
563 563
 			}
564 564
 		}
@@ -582,28 +582,28 @@  discard block
 block discarded – undo
582 582
 
583 583
 		$gateways = WC()->payment_gateways->get_available_payment_gateways();
584 584
 
585
-		if ( ! isset( $gateways['stripe'] ) ) {
585
+		if ( ! isset($gateways['stripe'])) {
586 586
 			return;
587 587
 		}
588 588
 
589
-		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) {
589
+		if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset($_GET['pay_for_order'])) {
590 590
 			return;
591 591
 		}
592 592
 
593
-		if ( is_checkout() && ! apply_filters( 'wc_stripe_show_payment_request_on_checkout', false, $post ) ) {
593
+		if (is_checkout() && ! apply_filters('wc_stripe_show_payment_request_on_checkout', false, $post)) {
594 594
 			return;
595 595
 		}
596 596
 
597
-		if ( is_product() && ! $this->should_show_payment_button_on_product_page() ) {
597
+		if (is_product() && ! $this->should_show_payment_button_on_product_page()) {
598 598
 			return;
599 599
 		} else {
600
-			if ( ! $this->allowed_items_in_cart() ) {
601
-				WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' );
600
+			if ( ! $this->allowed_items_in_cart()) {
601
+				WC_Stripe_Logger::log('Items in the cart has unsupported product type ( Payment Request button disabled )');
602 602
 				return;
603 603
 			}
604 604
 		}
605 605
 		?>
606
-		<p id="wc-stripe-payment-request-button-separator" style="margin-top:1.5em;text-align:center;display:none;">&mdash; <?php esc_html_e( 'OR', 'woocommerce-gateway-stripe' ); ?> &mdash;</p>
606
+		<p id="wc-stripe-payment-request-button-separator" style="margin-top:1.5em;text-align:center;display:none;">&mdash; <?php esc_html_e('OR', 'woocommerce-gateway-stripe'); ?> &mdash;</p>
607 607
 		<?php
608 608
 	}
609 609
 
@@ -619,32 +619,32 @@  discard block
 block discarded – undo
619 619
 	private function should_show_payment_button_on_product_page() {
620 620
 		global $post;
621 621
 
622
-		$product = wc_get_product( $post->ID );
622
+		$product = wc_get_product($post->ID);
623 623
 
624
-		if ( apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false, $post ) ) {
624
+		if (apply_filters('wc_stripe_hide_payment_request_on_product_page', false, $post)) {
625 625
 			return false;
626 626
 		}
627 627
 
628
-		if ( ! is_object( $product ) || ! in_array( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) {
628
+		if ( ! is_object($product) || ! in_array((WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type()), $this->supported_product_types())) {
629 629
 			return false;
630 630
 		}
631 631
 
632 632
 		// Trial subscriptions with shipping are not supported
633
-		if ( class_exists( 'WC_Subscriptions_Order' ) && $product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $product ) > 0 ) {
633
+		if (class_exists('WC_Subscriptions_Order') && $product->needs_shipping() && WC_Subscriptions_Product::get_trial_length($product) > 0) {
634 634
 			return false;
635 635
 		}
636 636
 
637 637
 		// Pre Orders charge upon release not supported.
638
-		if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Product::product_is_charged_upon_release( $product ) ) {
639
-			WC_Stripe_Logger::log( 'Pre Order charge upon release is not supported. ( Payment Request button disabled )' );
638
+		if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Product::product_is_charged_upon_release($product)) {
639
+			WC_Stripe_Logger::log('Pre Order charge upon release is not supported. ( Payment Request button disabled )');
640 640
 			return false;
641 641
 		}
642 642
 
643 643
 		// File upload addon not supported
644
-		if ( class_exists( 'WC_Product_Addons_Helper' ) ) {
645
-			$product_addons = WC_Product_Addons_Helper::get_product_addons( $product->get_id() );
646
-			foreach ( $product_addons as $addon ) {
647
-				if ( 'file_upload' === $addon['type'] ) {
644
+		if (class_exists('WC_Product_Addons_Helper')) {
645
+			$product_addons = WC_Product_Addons_Helper::get_product_addons($product->get_id());
646
+			foreach ($product_addons as $addon) {
647
+				if ('file_upload' === $addon['type']) {
648 648
 					return false;
649 649
 				}
650 650
 			}
@@ -660,11 +660,11 @@  discard block
 block discarded – undo
660 660
 	 * @version 4.0.0
661 661
 	 */
662 662
 	public function ajax_log_errors() {
663
-		check_ajax_referer( 'wc-stripe-log-errors', 'security' );
663
+		check_ajax_referer('wc-stripe-log-errors', 'security');
664 664
 
665
-		$errors = wc_clean( stripslashes( $_POST['errors'] ) );
665
+		$errors = wc_clean(stripslashes($_POST['errors']));
666 666
 
667
-		WC_Stripe_Logger::log( $errors );
667
+		WC_Stripe_Logger::log($errors);
668 668
 
669 669
 		exit;
670 670
 	}
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 	 * @version 4.0.0
677 677
 	 */
678 678
 	public function ajax_clear_cart() {
679
-		check_ajax_referer( 'wc-stripe-clear-cart', 'security' );
679
+		check_ajax_referer('wc-stripe-clear-cart', 'security');
680 680
 
681 681
 		WC()->cart->empty_cart();
682 682
 		exit;
@@ -686,10 +686,10 @@  discard block
 block discarded – undo
686 686
 	 * Get cart details.
687 687
 	 */
688 688
 	public function ajax_get_cart_details() {
689
-		check_ajax_referer( 'wc-stripe-payment-request', 'security' );
689
+		check_ajax_referer('wc-stripe-payment-request', 'security');
690 690
 
691
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
692
-			define( 'WOOCOMMERCE_CART', true );
691
+		if ( ! defined('WOOCOMMERCE_CART')) {
692
+			define('WOOCOMMERCE_CART', true);
693 693
 		}
694 694
 
695 695
 		WC()->cart->calculate_totals();
@@ -700,14 +700,14 @@  discard block
 block discarded – undo
700 700
 		$data = array(
701 701
 			'shipping_required' => WC()->cart->needs_shipping(),
702 702
 			'order_data'        => array(
703
-				'currency'     => strtolower( $currency ),
704
-				'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
703
+				'currency'     => strtolower($currency),
704
+				'country_code' => substr(get_option('woocommerce_default_country'), 0, 2),
705 705
 			),
706 706
 		);
707 707
 
708 708
 		$data['order_data'] += $this->build_display_items();
709 709
 
710
-		wp_send_json( $data );
710
+		wp_send_json($data);
711 711
 	}
712 712
 
713 713
 	/**
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 	 * @see WC_Shipping::get_packages().
719 719
 	 */
720 720
 	public function ajax_get_shipping_options() {
721
-		check_ajax_referer( 'wc-stripe-payment-request-shipping', 'security' );
721
+		check_ajax_referer('wc-stripe-payment-request-shipping', 'security');
722 722
 
723 723
 		try {
724 724
 			// Set the shipping package.
@@ -734,34 +734,34 @@  discard block
 block discarded – undo
734 734
 				)
735 735
 			);
736 736
 
737
-			$this->calculate_shipping( apply_filters( 'wc_stripe_payment_request_shipping_posted_values', $posted ) );
737
+			$this->calculate_shipping(apply_filters('wc_stripe_payment_request_shipping_posted_values', $posted));
738 738
 
739 739
 			// Set the shipping options.
740 740
 			$data     = array();
741 741
 			$packages = WC()->shipping->get_packages();
742 742
 
743
-			if ( ! empty( $packages ) && WC()->customer->has_calculated_shipping() ) {
744
-				foreach ( $packages as $package_key => $package ) {
745
-					if ( empty( $package['rates'] ) ) {
746
-						throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) );
743
+			if ( ! empty($packages) && WC()->customer->has_calculated_shipping()) {
744
+				foreach ($packages as $package_key => $package) {
745
+					if (empty($package['rates'])) {
746
+						throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe'));
747 747
 					}
748 748
 
749
-					foreach ( $package['rates'] as $key => $rate ) {
749
+					foreach ($package['rates'] as $key => $rate) {
750 750
 						$data['shipping_options'][] = array(
751 751
 							'id'     => $rate->id,
752 752
 							'label'  => $rate->label,
753 753
 							'detail' => '',
754
-							'amount' => WC_Stripe_Helper::get_stripe_amount( $rate->cost ),
754
+							'amount' => WC_Stripe_Helper::get_stripe_amount($rate->cost),
755 755
 						);
756 756
 					}
757 757
 				}
758 758
 			} else {
759
-				throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) );
759
+				throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe'));
760 760
 			}
761 761
 
762
-			if ( isset( $data[0] ) ) {
762
+			if (isset($data[0])) {
763 763
 				// Auto select the first shipping method.
764
-				WC()->session->set( 'chosen_shipping_methods', array( $data[0]['id'] ) );
764
+				WC()->session->set('chosen_shipping_methods', array($data[0]['id']));
765 765
 			}
766 766
 
767 767
 			WC()->cart->calculate_totals();
@@ -769,12 +769,12 @@  discard block
 block discarded – undo
769 769
 			$data          += $this->build_display_items();
770 770
 			$data['result'] = 'success';
771 771
 
772
-			wp_send_json( $data );
773
-		} catch ( Exception $e ) {
772
+			wp_send_json($data);
773
+		} catch (Exception $e) {
774 774
 			$data          += $this->build_display_items();
775 775
 			$data['result'] = 'invalid_shipping_address';
776 776
 
777
-			wp_send_json( $data );
777
+			wp_send_json($data);
778 778
 		}
779 779
 	}
780 780
 
@@ -782,22 +782,22 @@  discard block
 block discarded – undo
782 782
 	 * Update shipping method.
783 783
 	 */
784 784
 	public function ajax_update_shipping_method() {
785
-		check_ajax_referer( 'wc-stripe-update-shipping-method', 'security' );
785
+		check_ajax_referer('wc-stripe-update-shipping-method', 'security');
786 786
 
787
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
788
-			define( 'WOOCOMMERCE_CART', true );
787
+		if ( ! defined('WOOCOMMERCE_CART')) {
788
+			define('WOOCOMMERCE_CART', true);
789 789
 		}
790 790
 
791
-		$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
792
-		$shipping_method         = filter_input( INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
791
+		$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
792
+		$shipping_method         = filter_input(INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
793 793
 
794
-		if ( is_array( $shipping_method ) ) {
795
-			foreach ( $shipping_method as $i => $value ) {
796
-				$chosen_shipping_methods[ $i ] = wc_clean( $value );
794
+		if (is_array($shipping_method)) {
795
+			foreach ($shipping_method as $i => $value) {
796
+				$chosen_shipping_methods[$i] = wc_clean($value);
797 797
 			}
798 798
 		}
799 799
 
800
-		WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods );
800
+		WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
801 801
 
802 802
 		WC()->cart->calculate_totals();
803 803
 
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 		$data          += $this->build_display_items();
806 806
 		$data['result'] = 'success';
807 807
 
808
-		wp_send_json( $data );
808
+		wp_send_json($data);
809 809
 	}
810 810
 
811 811
 	/**
@@ -816,45 +816,45 @@  discard block
 block discarded – undo
816 816
 	 * @return array $data
817 817
 	 */
818 818
 	public function ajax_get_selected_product_data() {
819
-		check_ajax_referer( 'wc-stripe-get-selected-product-data', 'security' );
819
+		check_ajax_referer('wc-stripe-get-selected-product-data', 'security');
820 820
 
821 821
 		try {
822
-			$product_id   = absint( $_POST['product_id'] );
823
-			$qty          = ! isset( $_POST['qty'] ) ? 1 : apply_filters( 'woocommerce_add_to_cart_quantity', absint( $_POST['qty'] ), $product_id );
824
-			$addon_value  = isset( $_POST['addon_value'] ) ? max( floatval( $_POST['addon_value'] ), 0 ) : 0;
825
-			$product      = wc_get_product( $product_id );
822
+			$product_id   = absint($_POST['product_id']);
823
+			$qty          = ! isset($_POST['qty']) ? 1 : apply_filters('woocommerce_add_to_cart_quantity', absint($_POST['qty']), $product_id);
824
+			$addon_value  = isset($_POST['addon_value']) ? max(floatval($_POST['addon_value']), 0) : 0;
825
+			$product      = wc_get_product($product_id);
826 826
 			$variation_id = null;
827 827
 
828
-			if ( ! is_a( $product, 'WC_Product' ) ) {
829
-				throw new Exception( sprintf( __( 'Product with the ID (%d) cannot be found.', 'woocommerce-gateway-stripe' ), $product_id ) );
828
+			if ( ! is_a($product, 'WC_Product')) {
829
+				throw new Exception(sprintf(__('Product with the ID (%d) cannot be found.', 'woocommerce-gateway-stripe'), $product_id));
830 830
 			}
831 831
 
832
-			if ( 'variable' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type() ) && isset( $_POST['attributes'] ) ) {
833
-				$attributes = wc_clean( wp_unslash( $_POST['attributes'] ) );
832
+			if ('variable' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type()) && isset($_POST['attributes'])) {
833
+				$attributes = wc_clean(wp_unslash($_POST['attributes']));
834 834
 
835
-				if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
836
-					$variation_id = $product->get_matching_variation( $attributes );
835
+				if (WC_Stripe_Helper::is_wc_lt('3.0')) {
836
+					$variation_id = $product->get_matching_variation($attributes);
837 837
 				} else {
838
-					$data_store   = WC_Data_Store::load( 'product' );
839
-					$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
838
+					$data_store   = WC_Data_Store::load('product');
839
+					$variation_id = $data_store->find_matching_product_variation($product, $attributes);
840 840
 				}
841 841
 
842
-				if ( ! empty( $variation_id ) ) {
843
-					$product = wc_get_product( $variation_id );
842
+				if ( ! empty($variation_id)) {
843
+					$product = wc_get_product($variation_id);
844 844
 				}
845 845
 			}
846 846
 
847 847
 			// Force quantity to 1 if sold individually and check for existing item in cart.
848
-			if ( $product->is_sold_individually() ) {
849
-				$qty = apply_filters( 'wc_stripe_payment_request_add_to_cart_sold_individually_quantity', 1, $qty, $product_id, $variation_id );
848
+			if ($product->is_sold_individually()) {
849
+				$qty = apply_filters('wc_stripe_payment_request_add_to_cart_sold_individually_quantity', 1, $qty, $product_id, $variation_id);
850 850
 			}
851 851
 
852
-			if ( ! $product->has_enough_stock( $qty ) ) {
852
+			if ( ! $product->has_enough_stock($qty)) {
853 853
 				/* translators: 1: product name 2: quantity in stock */
854
-				throw new Exception( sprintf( __( 'You cannot add that amount of "%1$s"; to the cart because there is not enough stock (%2$s remaining).', 'woocommerce-gateway-stripe' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity(), $product ) ) );
854
+				throw new Exception(sprintf(__('You cannot add that amount of "%1$s"; to the cart because there is not enough stock (%2$s remaining).', 'woocommerce-gateway-stripe'), $product->get_name(), wc_format_stock_quantity_for_display($product->get_stock_quantity(), $product)));
855 855
 			}
856 856
 
857
-			$total = $qty * ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->price : $product->get_price() ) + $addon_value;
857
+			$total = $qty * (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->price : $product->get_price()) + $addon_value;
858 858
 
859 859
 			$quantity_label = 1 < $qty ? ' (x' . $qty . ')' : '';
860 860
 
@@ -862,28 +862,28 @@  discard block
 block discarded – undo
862 862
 			$items = array();
863 863
 
864 864
 			$items[] = array(
865
-				'label'  => ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->name : $product->get_name() ) . $quantity_label,
866
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $total ),
865
+				'label'  => (WC_Stripe_Helper::is_wc_lt('3.0') ? $product->name : $product->get_name()) . $quantity_label,
866
+				'amount' => WC_Stripe_Helper::get_stripe_amount($total),
867 867
 			);
868 868
 
869
-			if ( wc_tax_enabled() ) {
869
+			if (wc_tax_enabled()) {
870 870
 				$items[] = array(
871
-					'label'   => __( 'Tax', 'woocommerce-gateway-stripe' ),
871
+					'label'   => __('Tax', 'woocommerce-gateway-stripe'),
872 872
 					'amount'  => 0,
873 873
 					'pending' => true,
874 874
 				);
875 875
 			}
876 876
 
877
-			if ( wc_shipping_enabled() && $product->needs_shipping() ) {
877
+			if (wc_shipping_enabled() && $product->needs_shipping()) {
878 878
 				$items[] = array(
879
-					'label'   => __( 'Shipping', 'woocommerce-gateway-stripe' ),
879
+					'label'   => __('Shipping', 'woocommerce-gateway-stripe'),
880 880
 					'amount'  => 0,
881 881
 					'pending' => true,
882 882
 				);
883 883
 
884 884
 				$data['shippingOptions'] = array(
885 885
 					'id'     => 'pending',
886
-					'label'  => __( 'Pending', 'woocommerce-gateway-stripe' ),
886
+					'label'  => __('Pending', 'woocommerce-gateway-stripe'),
887 887
 					'detail' => '',
888 888
 					'amount' => 0,
889 889
 				);
@@ -892,17 +892,17 @@  discard block
 block discarded – undo
892 892
 			$data['displayItems'] = $items;
893 893
 			$data['total']        = array(
894 894
 				'label'   => $this->total_label,
895
-				'amount'  => WC_Stripe_Helper::get_stripe_amount( $total ),
895
+				'amount'  => WC_Stripe_Helper::get_stripe_amount($total),
896 896
 				'pending' => true,
897 897
 			);
898 898
 
899
-			$data['requestShipping'] = ( wc_shipping_enabled() && $product->needs_shipping() );
900
-			$data['currency']        = strtolower( get_woocommerce_currency() );
901
-			$data['country_code']    = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
899
+			$data['requestShipping'] = (wc_shipping_enabled() && $product->needs_shipping());
900
+			$data['currency']        = strtolower(get_woocommerce_currency());
901
+			$data['country_code']    = substr(get_option('woocommerce_default_country'), 0, 2);
902 902
 
903
-			wp_send_json( $data );
904
-		} catch ( Exception $e ) {
905
-			wp_send_json( array( 'error' => wp_strip_all_tags( $e->getMessage() ) ) );
903
+			wp_send_json($data);
904
+		} catch (Exception $e) {
905
+			wp_send_json(array('error' => wp_strip_all_tags($e->getMessage())));
906 906
 		}
907 907
 	}
908 908
 
@@ -914,37 +914,37 @@  discard block
 block discarded – undo
914 914
 	 * @return array $data
915 915
 	 */
916 916
 	public function ajax_add_to_cart() {
917
-		check_ajax_referer( 'wc-stripe-add-to-cart', 'security' );
917
+		check_ajax_referer('wc-stripe-add-to-cart', 'security');
918 918
 
919
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
920
-			define( 'WOOCOMMERCE_CART', true );
919
+		if ( ! defined('WOOCOMMERCE_CART')) {
920
+			define('WOOCOMMERCE_CART', true);
921 921
 		}
922 922
 
923 923
 		WC()->shipping->reset_shipping();
924 924
 
925
-		$product_id   = absint( $_POST['product_id'] );
926
-		$qty          = ! isset( $_POST['qty'] ) ? 1 : absint( $_POST['qty'] );
927
-		$product      = wc_get_product( $product_id );
928
-		$product_type = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $product->product_type : $product->get_type();
925
+		$product_id   = absint($_POST['product_id']);
926
+		$qty          = ! isset($_POST['qty']) ? 1 : absint($_POST['qty']);
927
+		$product      = wc_get_product($product_id);
928
+		$product_type = WC_Stripe_Helper::is_wc_lt('3.0') ? $product->product_type : $product->get_type();
929 929
 
930 930
 		// First empty the cart to prevent wrong calculation.
931 931
 		WC()->cart->empty_cart();
932 932
 
933
-		if ( ( 'variable' === $product_type || 'variable-subscription' === $product_type ) && isset( $_POST['attributes'] ) ) {
934
-			$attributes = wc_clean( wp_unslash( $_POST['attributes'] ) );
933
+		if (('variable' === $product_type || 'variable-subscription' === $product_type) && isset($_POST['attributes'])) {
934
+			$attributes = wc_clean(wp_unslash($_POST['attributes']));
935 935
 
936
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
937
-				$variation_id = $product->get_matching_variation( $attributes );
936
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
937
+				$variation_id = $product->get_matching_variation($attributes);
938 938
 			} else {
939
-				$data_store   = WC_Data_Store::load( 'product' );
940
-				$variation_id = $data_store->find_matching_product_variation( $product, $attributes );
939
+				$data_store   = WC_Data_Store::load('product');
940
+				$variation_id = $data_store->find_matching_product_variation($product, $attributes);
941 941
 			}
942 942
 
943
-			WC()->cart->add_to_cart( $product->get_id(), $qty, $variation_id, $attributes );
943
+			WC()->cart->add_to_cart($product->get_id(), $qty, $variation_id, $attributes);
944 944
 		}
945 945
 
946
-		if ( 'simple' === $product_type || 'subscription' === $product_type ) {
947
-			WC()->cart->add_to_cart( $product->get_id(), $qty );
946
+		if ('simple' === $product_type || 'subscription' === $product_type) {
947
+			WC()->cart->add_to_cart($product->get_id(), $qty);
948 948
 		}
949 949
 
950 950
 		WC()->cart->calculate_totals();
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
 		$data          += $this->build_display_items();
954 954
 		$data['result'] = 'success';
955 955
 
956
-		wp_send_json( $data );
956
+		wp_send_json($data);
957 957
 	}
958 958
 
959 959
 	/**
@@ -966,31 +966,31 @@  discard block
 block discarded – undo
966 966
 	 * @version 4.0.0
967 967
 	 */
968 968
 	public function normalize_state() {
969
-		$billing_country  = ! empty( $_POST['billing_country'] ) ? wc_clean( $_POST['billing_country'] ) : '';
970
-		$shipping_country = ! empty( $_POST['shipping_country'] ) ? wc_clean( $_POST['shipping_country'] ) : '';
971
-		$billing_state    = ! empty( $_POST['billing_state'] ) ? wc_clean( $_POST['billing_state'] ) : '';
972
-		$shipping_state   = ! empty( $_POST['shipping_state'] ) ? wc_clean( $_POST['shipping_state'] ) : '';
969
+		$billing_country  = ! empty($_POST['billing_country']) ? wc_clean($_POST['billing_country']) : '';
970
+		$shipping_country = ! empty($_POST['shipping_country']) ? wc_clean($_POST['shipping_country']) : '';
971
+		$billing_state    = ! empty($_POST['billing_state']) ? wc_clean($_POST['billing_state']) : '';
972
+		$shipping_state   = ! empty($_POST['shipping_state']) ? wc_clean($_POST['shipping_state']) : '';
973 973
 
974
-		if ( $billing_state && $billing_country ) {
975
-			$valid_states = WC()->countries->get_states( $billing_country );
974
+		if ($billing_state && $billing_country) {
975
+			$valid_states = WC()->countries->get_states($billing_country);
976 976
 
977 977
 			// Valid states found for country.
978
-			if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) {
979
-				foreach ( $valid_states as $state_abbr => $state ) {
980
-					if ( preg_match( '/' . preg_quote( $state ) . '/i', $billing_state ) ) {
978
+			if ( ! empty($valid_states) && is_array($valid_states) && sizeof($valid_states) > 0) {
979
+				foreach ($valid_states as $state_abbr => $state) {
980
+					if (preg_match('/' . preg_quote($state) . '/i', $billing_state)) {
981 981
 						$_POST['billing_state'] = $state_abbr;
982 982
 					}
983 983
 				}
984 984
 			}
985 985
 		}
986 986
 
987
-		if ( $shipping_state && $shipping_country ) {
988
-			$valid_states = WC()->countries->get_states( $shipping_country );
987
+		if ($shipping_state && $shipping_country) {
988
+			$valid_states = WC()->countries->get_states($shipping_country);
989 989
 
990 990
 			// Valid states found for country.
991
-			if ( ! empty( $valid_states ) && is_array( $valid_states ) && sizeof( $valid_states ) > 0 ) {
992
-				foreach ( $valid_states as $state_abbr => $state ) {
993
-					if ( preg_match( '/' . preg_quote( $state ) . '/i', $shipping_state ) ) {
991
+			if ( ! empty($valid_states) && is_array($valid_states) && sizeof($valid_states) > 0) {
992
+				foreach ($valid_states as $state_abbr => $state) {
993
+					if (preg_match('/' . preg_quote($state) . '/i', $shipping_state)) {
994 994
 						$_POST['shipping_state'] = $state_abbr;
995 995
 					}
996 996
 				}
@@ -1005,19 +1005,19 @@  discard block
 block discarded – undo
1005 1005
 	 * @version 4.0.0
1006 1006
 	 */
1007 1007
 	public function ajax_create_order() {
1008
-		if ( WC()->cart->is_empty() ) {
1009
-			wp_send_json_error( __( 'Empty cart', 'woocommerce-gateway-stripe' ) );
1008
+		if (WC()->cart->is_empty()) {
1009
+			wp_send_json_error(__('Empty cart', 'woocommerce-gateway-stripe'));
1010 1010
 		}
1011 1011
 
1012
-		if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) {
1013
-			define( 'WOOCOMMERCE_CHECKOUT', true );
1012
+		if ( ! defined('WOOCOMMERCE_CHECKOUT')) {
1013
+			define('WOOCOMMERCE_CHECKOUT', true);
1014 1014
 		}
1015 1015
 
1016 1016
 		$this->normalize_state();
1017 1017
 
1018 1018
 		WC()->checkout()->process_checkout();
1019 1019
 
1020
-		die( 0 );
1020
+		die(0);
1021 1021
 	}
1022 1022
 
1023 1023
 	/**
@@ -1027,41 +1027,41 @@  discard block
 block discarded – undo
1027 1027
 	 * @version 4.0.0
1028 1028
 	 * @param array $address
1029 1029
 	 */
1030
-	protected function calculate_shipping( $address = array() ) {
1030
+	protected function calculate_shipping($address = array()) {
1031 1031
 		$country   = $address['country'];
1032 1032
 		$state     = $address['state'];
1033 1033
 		$postcode  = $address['postcode'];
1034 1034
 		$city      = $address['city'];
1035 1035
 		$address_1 = $address['address'];
1036 1036
 		$address_2 = $address['address_2'];
1037
-		$wc_states = WC()->countries->get_states( $country );
1037
+		$wc_states = WC()->countries->get_states($country);
1038 1038
 
1039 1039
 		/**
1040 1040
 		 * In some versions of Chrome, state can be a full name. So we need
1041 1041
 		 * to convert that to abbreviation as WC is expecting that.
1042 1042
 		 */
1043
-		if ( 2 < strlen( $state ) && ! empty( $wc_states ) ) {
1044
-			$state = array_search( ucwords( strtolower( $state ) ), $wc_states, true );
1043
+		if (2 < strlen($state) && ! empty($wc_states)) {
1044
+			$state = array_search(ucwords(strtolower($state)), $wc_states, true);
1045 1045
 		}
1046 1046
 
1047 1047
 		WC()->shipping->reset_shipping();
1048 1048
 
1049
-		if ( $postcode && WC_Validation::is_postcode( $postcode, $country ) ) {
1050
-			$postcode = wc_format_postcode( $postcode, $country );
1049
+		if ($postcode && WC_Validation::is_postcode($postcode, $country)) {
1050
+			$postcode = wc_format_postcode($postcode, $country);
1051 1051
 		}
1052 1052
 
1053
-		if ( $country ) {
1054
-			WC()->customer->set_location( $country, $state, $postcode, $city );
1055
-			WC()->customer->set_shipping_location( $country, $state, $postcode, $city );
1053
+		if ($country) {
1054
+			WC()->customer->set_location($country, $state, $postcode, $city);
1055
+			WC()->customer->set_shipping_location($country, $state, $postcode, $city);
1056 1056
 		} else {
1057
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? WC()->customer->set_to_base() : WC()->customer->set_billing_address_to_base();
1058
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? WC()->customer->set_shipping_to_base() : WC()->customer->set_shipping_address_to_base();
1057
+			WC_Stripe_Helper::is_wc_lt('3.0') ? WC()->customer->set_to_base() : WC()->customer->set_billing_address_to_base();
1058
+			WC_Stripe_Helper::is_wc_lt('3.0') ? WC()->customer->set_shipping_to_base() : WC()->customer->set_shipping_address_to_base();
1059 1059
 		}
1060 1060
 
1061
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
1062
-			WC()->customer->calculated_shipping( true );
1061
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
1062
+			WC()->customer->calculated_shipping(true);
1063 1063
 		} else {
1064
-			WC()->customer->set_calculated_shipping( true );
1064
+			WC()->customer->set_calculated_shipping(true);
1065 1065
 			WC()->customer->save();
1066 1066
 		}
1067 1067
 
@@ -1078,17 +1078,17 @@  discard block
 block discarded – undo
1078 1078
 		$packages[0]['destination']['address']   = $address_1;
1079 1079
 		$packages[0]['destination']['address_2'] = $address_2;
1080 1080
 
1081
-		foreach ( WC()->cart->get_cart() as $item ) {
1082
-			if ( $item['data']->needs_shipping() ) {
1083
-				if ( isset( $item['line_total'] ) ) {
1081
+		foreach (WC()->cart->get_cart() as $item) {
1082
+			if ($item['data']->needs_shipping()) {
1083
+				if (isset($item['line_total'])) {
1084 1084
 					$packages[0]['contents_cost'] += $item['line_total'];
1085 1085
 				}
1086 1086
 			}
1087 1087
 		}
1088 1088
 
1089
-		$packages = apply_filters( 'woocommerce_cart_shipping_packages', $packages );
1089
+		$packages = apply_filters('woocommerce_cart_shipping_packages', $packages);
1090 1090
 
1091
-		WC()->shipping->calculate_shipping( $packages );
1091
+		WC()->shipping->calculate_shipping($packages);
1092 1092
 	}
1093 1093
 
1094 1094
 	/**
@@ -1097,19 +1097,19 @@  discard block
 block discarded – undo
1097 1097
 	 * @since 3.1.0
1098 1098
 	 * @version 4.0.0
1099 1099
 	 */
1100
-	protected function build_shipping_methods( $shipping_methods ) {
1101
-		if ( empty( $shipping_methods ) ) {
1100
+	protected function build_shipping_methods($shipping_methods) {
1101
+		if (empty($shipping_methods)) {
1102 1102
 			return array();
1103 1103
 		}
1104 1104
 
1105 1105
 		$shipping = array();
1106 1106
 
1107
-		foreach ( $shipping_methods as $method ) {
1107
+		foreach ($shipping_methods as $method) {
1108 1108
 			$shipping[] = array(
1109 1109
 				'id'     => $method['id'],
1110 1110
 				'label'  => $method['label'],
1111 1111
 				'detail' => '',
1112
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $method['amount']['value'] ),
1112
+				'amount' => WC_Stripe_Helper::get_stripe_amount($method['amount']['value']),
1113 1113
 			);
1114 1114
 		}
1115 1115
 
@@ -1123,8 +1123,8 @@  discard block
 block discarded – undo
1123 1123
 	 * @version 4.0.0
1124 1124
 	 */
1125 1125
 	protected function build_display_items() {
1126
-		if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
1127
-			define( 'WOOCOMMERCE_CART', true );
1126
+		if ( ! defined('WOOCOMMERCE_CART')) {
1127
+			define('WOOCOMMERCE_CART', true);
1128 1128
 		}
1129 1129
 
1130 1130
 		$items     = array();
@@ -1132,71 +1132,71 @@  discard block
 block discarded – undo
1132 1132
 		$discounts = 0;
1133 1133
 
1134 1134
 		// Default show only subtotal instead of itemization.
1135
-		if ( ! apply_filters( 'wc_stripe_payment_request_hide_itemization', true ) ) {
1136
-			foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
1135
+		if ( ! apply_filters('wc_stripe_payment_request_hide_itemization', true)) {
1136
+			foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
1137 1137
 				$amount         = $cart_item['line_subtotal'];
1138 1138
 				$subtotal      += $cart_item['line_subtotal'];
1139 1139
 				$quantity_label = 1 < $cart_item['quantity'] ? ' (x' . $cart_item['quantity'] . ')' : '';
1140 1140
 
1141
-				$product_name = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $cart_item['data']->post->post_title : $cart_item['data']->get_name();
1141
+				$product_name = WC_Stripe_Helper::is_wc_lt('3.0') ? $cart_item['data']->post->post_title : $cart_item['data']->get_name();
1142 1142
 
1143 1143
 				$item = array(
1144 1144
 					'label'  => $product_name . $quantity_label,
1145
-					'amount' => WC_Stripe_Helper::get_stripe_amount( $amount ),
1145
+					'amount' => WC_Stripe_Helper::get_stripe_amount($amount),
1146 1146
 				);
1147 1147
 
1148 1148
 				$items[] = $item;
1149 1149
 			}
1150 1150
 		}
1151 1151
 
1152
-		if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
1153
-			$discounts = wc_format_decimal( WC()->cart->get_cart_discount_total(), WC()->cart->dp );
1152
+		if (version_compare(WC_VERSION, '3.2', '<')) {
1153
+			$discounts = wc_format_decimal(WC()->cart->get_cart_discount_total(), WC()->cart->dp);
1154 1154
 		} else {
1155
-			$applied_coupons = array_values( WC()->cart->get_coupon_discount_totals() );
1155
+			$applied_coupons = array_values(WC()->cart->get_coupon_discount_totals());
1156 1156
 
1157
-			foreach ( $applied_coupons as $amount ) {
1157
+			foreach ($applied_coupons as $amount) {
1158 1158
 				$discounts += (float) $amount;
1159 1159
 			}
1160 1160
 		}
1161 1161
 
1162
-		$discounts   = wc_format_decimal( $discounts, WC()->cart->dp );
1163
-		$tax         = wc_format_decimal( WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp );
1164
-		$shipping    = wc_format_decimal( WC()->cart->shipping_total, WC()->cart->dp );
1165
-		$items_total = wc_format_decimal( WC()->cart->cart_contents_total, WC()->cart->dp ) + $discounts;
1166
-		$order_total = version_compare( WC_VERSION, '3.2', '<' ) ? wc_format_decimal( $items_total + $tax + $shipping - $discounts, WC()->cart->dp ) : WC()->cart->get_total( false );
1162
+		$discounts   = wc_format_decimal($discounts, WC()->cart->dp);
1163
+		$tax         = wc_format_decimal(WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp);
1164
+		$shipping    = wc_format_decimal(WC()->cart->shipping_total, WC()->cart->dp);
1165
+		$items_total = wc_format_decimal(WC()->cart->cart_contents_total, WC()->cart->dp) + $discounts;
1166
+		$order_total = version_compare(WC_VERSION, '3.2', '<') ? wc_format_decimal($items_total + $tax + $shipping - $discounts, WC()->cart->dp) : WC()->cart->get_total(false);
1167 1167
 
1168
-		if ( wc_tax_enabled() ) {
1168
+		if (wc_tax_enabled()) {
1169 1169
 			$items[] = array(
1170
-				'label'  => esc_html( __( 'Tax', 'woocommerce-gateway-stripe' ) ),
1171
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $tax ),
1170
+				'label'  => esc_html(__('Tax', 'woocommerce-gateway-stripe')),
1171
+				'amount' => WC_Stripe_Helper::get_stripe_amount($tax),
1172 1172
 			);
1173 1173
 		}
1174 1174
 
1175
-		if ( WC()->cart->needs_shipping() ) {
1175
+		if (WC()->cart->needs_shipping()) {
1176 1176
 			$items[] = array(
1177
-				'label'  => esc_html( __( 'Shipping', 'woocommerce-gateway-stripe' ) ),
1178
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $shipping ),
1177
+				'label'  => esc_html(__('Shipping', 'woocommerce-gateway-stripe')),
1178
+				'amount' => WC_Stripe_Helper::get_stripe_amount($shipping),
1179 1179
 			);
1180 1180
 		}
1181 1181
 
1182
-		if ( WC()->cart->has_discount() ) {
1182
+		if (WC()->cart->has_discount()) {
1183 1183
 			$items[] = array(
1184
-				'label'  => esc_html( __( 'Discount', 'woocommerce-gateway-stripe' ) ),
1185
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $discounts ),
1184
+				'label'  => esc_html(__('Discount', 'woocommerce-gateway-stripe')),
1185
+				'amount' => WC_Stripe_Helper::get_stripe_amount($discounts),
1186 1186
 			);
1187 1187
 		}
1188 1188
 
1189
-		if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
1189
+		if (version_compare(WC_VERSION, '3.2', '<')) {
1190 1190
 			$cart_fees = WC()->cart->fees;
1191 1191
 		} else {
1192 1192
 			$cart_fees = WC()->cart->get_fees();
1193 1193
 		}
1194 1194
 
1195 1195
 		// Include fees and taxes as display items.
1196
-		foreach ( $cart_fees as $key => $fee ) {
1196
+		foreach ($cart_fees as $key => $fee) {
1197 1197
 			$items[] = array(
1198 1198
 				'label'  => $fee->name,
1199
-				'amount' => WC_Stripe_Helper::get_stripe_amount( $fee->amount ),
1199
+				'amount' => WC_Stripe_Helper::get_stripe_amount($fee->amount),
1200 1200
 			);
1201 1201
 		}
1202 1202
 
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 			'displayItems' => $items,
1205 1205
 			'total'        => array(
1206 1206
 				'label'   => $this->total_label,
1207
-				'amount'  => max( 0, apply_filters( 'woocommerce_stripe_calculated_total', WC_Stripe_Helper::get_stripe_amount( $order_total ), $order_total, WC()->cart ) ),
1207
+				'amount'  => max(0, apply_filters('woocommerce_stripe_calculated_total', WC_Stripe_Helper::get_stripe_amount($order_total), $order_total, WC()->cart)),
1208 1208
 				'pending' => false,
1209 1209
 			),
1210 1210
 		);
Please login to merge, or discard this patch.
includes/admin/stripe-eps-settings.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -7,36 +7,36 @@  discard block
 block discarded – undo
7 7
 	'wc_stripe_eps_settings',
8 8
 	array(
9 9
 		'geo_target'  => array(
10
-			'description' => __( 'Relevant Payer Geography: Austria', 'woocommerce-gateway-stripe' ),
10
+			'description' => __('Relevant Payer Geography: Austria', 'woocommerce-gateway-stripe'),
11 11
 			'type'        => 'title',
12 12
 		),
13 13
 		'activation'  => array(
14
-			'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ),
14
+			'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'),
15 15
 			'type'        => 'title',
16 16
 		),
17 17
 		'enabled'     => array(
18
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
19
-			'label'       => __( 'Enable Stripe EPS', 'woocommerce-gateway-stripe' ),
18
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
19
+			'label'       => __('Enable Stripe EPS', 'woocommerce-gateway-stripe'),
20 20
 			'type'        => 'checkbox',
21 21
 			'description' => '',
22 22
 			'default'     => 'no',
23 23
 		),
24 24
 		'title'       => array(
25
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
25
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
26 26
 			'type'        => 'text',
27
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
28
-			'default'     => __( 'EPS', 'woocommerce-gateway-stripe' ),
27
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
28
+			'default'     => __('EPS', 'woocommerce-gateway-stripe'),
29 29
 			'desc_tip'    => true,
30 30
 		),
31 31
 		'description' => array(
32
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
32
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
33 33
 			'type'        => 'text',
34
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
35
-			'default'     => __( 'You will be redirected to EPS.', 'woocommerce-gateway-stripe' ),
34
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
35
+			'default'     => __('You will be redirected to EPS.', 'woocommerce-gateway-stripe'),
36 36
 			'desc_tip'    => true,
37 37
 		),
38 38
 		'webhook'     => array(
39
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
39
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
40 40
 			'type'        => 'title',
41 41
 			/* translators: webhook URL */
42 42
 			'description' => $this->display_admin_settings_webhook_description(),
Please login to merge, or discard this patch.
includes/admin/class-wc-stripe-admin-notices.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 * @since 4.1.0
22 22
 	 */
23 23
 	public function __construct() {
24
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
25
-		add_action( 'wp_loaded', array( $this, 'hide_notices' ) );
26
-		add_action( 'woocommerce_stripe_updated', array( $this, 'stripe_updated' ) );
24
+		add_action('admin_notices', array($this, 'admin_notices'));
25
+		add_action('wp_loaded', array($this, 'hide_notices'));
26
+		add_action('woocommerce_stripe_updated', array($this, 'stripe_updated'));
27 27
 	}
28 28
 
29 29
 	/**
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 * @since 1.0.0
33 33
 	 * @version 4.0.0
34 34
 	 */
35
-	public function add_admin_notice( $slug, $class, $message, $dismissible = false ) {
36
-		$this->notices[ $slug ] = array(
35
+	public function add_admin_notice($slug, $class, $message, $dismissible = false) {
36
+		$this->notices[$slug] = array(
37 37
 			'class'       => $class,
38 38
 			'message'     => $message,
39 39
 			'dismissible' => $dismissible,
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @version 4.0.0
48 48
 	 */
49 49
 	public function admin_notices() {
50
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
50
+		if ( ! current_user_can('manage_woocommerce')) {
51 51
 			return;
52 52
 		}
53 53
 
@@ -57,17 +57,17 @@  discard block
 block discarded – undo
57 57
 		// All other payment methods.
58 58
 		$this->payment_methods_check_environment();
59 59
 
60
-		foreach ( (array) $this->notices as $notice_key => $notice ) {
61
-			echo '<div class="' . esc_attr( $notice['class'] ) . '" style="position:relative;">';
60
+		foreach ((array) $this->notices as $notice_key => $notice) {
61
+			echo '<div class="' . esc_attr($notice['class']) . '" style="position:relative;">';
62 62
 
63
-			if ( $notice['dismissible'] ) {
63
+			if ($notice['dismissible']) {
64 64
 				?>
65
-				<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-stripe-hide-notice', $notice_key ), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce' ) ); ?>" class="woocommerce-message-close notice-dismiss" style="position:relative;float:right;padding:9px 0px 9px 9px 9px;text-decoration:none;"></a>
65
+				<a href="<?php echo esc_url(wp_nonce_url(add_query_arg('wc-stripe-hide-notice', $notice_key), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce')); ?>" class="woocommerce-message-close notice-dismiss" style="position:relative;float:right;padding:9px 0px 9px 9px 9px;text-decoration:none;"></a>
66 66
 				<?php
67 67
 			}
68 68
 
69 69
 			echo '<p>';
70
-			echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array(), 'target' => array() ) ) );
70
+			echo wp_kses($notice['message'], array('a' => array('href' => array(), 'target' => array())));
71 71
 			echo '</p></div>';
72 72
 		}
73 73
 	}
@@ -100,116 +100,116 @@  discard block
 block discarded – undo
100 100
 	 * @version 4.0.0
101 101
 	 */
102 102
 	public function stripe_check_environment() {
103
-		$show_style_notice   = get_option( 'wc_stripe_show_style_notice' );
104
-		$show_ssl_notice     = get_option( 'wc_stripe_show_ssl_notice' );
105
-		$show_keys_notice    = get_option( 'wc_stripe_show_keys_notice' );
106
-		$show_3ds_notice     = get_option( 'wc_stripe_show_3ds_notice' );
107
-		$show_phpver_notice  = get_option( 'wc_stripe_show_phpver_notice' );
108
-		$show_wcver_notice   = get_option( 'wc_stripe_show_wcver_notice' );
109
-		$show_curl_notice    = get_option( 'wc_stripe_show_curl_notice' );
110
-		$show_sca_notice     = get_option( 'wc_stripe_show_sca_notice' );
111
-		$changed_keys_notice = get_option( 'wc_stripe_show_changed_keys_notice' );
112
-		$options             = get_option( 'woocommerce_stripe_settings' );
113
-		$testmode            = ( isset( $options['testmode'] ) && 'yes' === $options['testmode'] ) ? true : false;
114
-		$test_pub_key        = isset( $options['test_publishable_key'] ) ? $options['test_publishable_key'] : '';
115
-		$test_secret_key     = isset( $options['test_secret_key'] ) ? $options['test_secret_key'] : '';
116
-		$live_pub_key        = isset( $options['publishable_key'] ) ? $options['publishable_key'] : '';
117
-		$live_secret_key     = isset( $options['secret_key'] ) ? $options['secret_key'] : '';
118
-		$three_d_secure      = isset( $options['three_d_secure'] ) && 'yes' === $options['three_d_secure'];
119
-
120
-		if ( isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) {
121
-			if ( empty( $show_3ds_notice ) && $three_d_secure ) {
103
+		$show_style_notice   = get_option('wc_stripe_show_style_notice');
104
+		$show_ssl_notice     = get_option('wc_stripe_show_ssl_notice');
105
+		$show_keys_notice    = get_option('wc_stripe_show_keys_notice');
106
+		$show_3ds_notice     = get_option('wc_stripe_show_3ds_notice');
107
+		$show_phpver_notice  = get_option('wc_stripe_show_phpver_notice');
108
+		$show_wcver_notice   = get_option('wc_stripe_show_wcver_notice');
109
+		$show_curl_notice    = get_option('wc_stripe_show_curl_notice');
110
+		$show_sca_notice     = get_option('wc_stripe_show_sca_notice');
111
+		$changed_keys_notice = get_option('wc_stripe_show_changed_keys_notice');
112
+		$options             = get_option('woocommerce_stripe_settings');
113
+		$testmode            = (isset($options['testmode']) && 'yes' === $options['testmode']) ? true : false;
114
+		$test_pub_key        = isset($options['test_publishable_key']) ? $options['test_publishable_key'] : '';
115
+		$test_secret_key     = isset($options['test_secret_key']) ? $options['test_secret_key'] : '';
116
+		$live_pub_key        = isset($options['publishable_key']) ? $options['publishable_key'] : '';
117
+		$live_secret_key     = isset($options['secret_key']) ? $options['secret_key'] : '';
118
+		$three_d_secure      = isset($options['three_d_secure']) && 'yes' === $options['three_d_secure'];
119
+
120
+		if (isset($options['enabled']) && 'yes' === $options['enabled']) {
121
+			if (empty($show_3ds_notice) && $three_d_secure) {
122 122
 				$url = 'https://stripe.com/docs/payments/3d-secure#three-ds-radar';
123 123
 
124 124
 				/* translators: 1) A URL that explains Stripe Radar. */
125
-				$message = __( 'WooCommerce Stripe - We see that you had the "Require 3D secure when applicable" setting turned on. This setting is not available here anymore, because it is now replaced by Stripe Radar. You can learn more about it <a href="%s" target="_blank">here</a>.', 'woocommerce-gateway-stripe' );
125
+				$message = __('WooCommerce Stripe - We see that you had the "Require 3D secure when applicable" setting turned on. This setting is not available here anymore, because it is now replaced by Stripe Radar. You can learn more about it <a href="%s" target="_blank">here</a>.', 'woocommerce-gateway-stripe');
126 126
 
127
-				$this->add_admin_notice( '3ds', 'notice notice-warning', sprintf( $message, $url ), true );
127
+				$this->add_admin_notice('3ds', 'notice notice-warning', sprintf($message, $url), true);
128 128
 			}
129 129
 
130
-			if ( empty( $show_style_notice ) ) {
130
+			if (empty($show_style_notice)) {
131 131
 				/* translators: 1) int version 2) int version */
132
-				$message = __( 'WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://docs.woocommerce.com/document/stripe/#styling" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe' );
132
+				$message = __('WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://docs.woocommerce.com/document/stripe/#styling" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe');
133 133
 
134
-				$this->add_admin_notice( 'style', 'notice notice-warning', $message, true );
134
+				$this->add_admin_notice('style', 'notice notice-warning', $message, true);
135 135
 
136 136
 				return;
137 137
 			}
138 138
 
139
-			if ( empty( $show_phpver_notice ) ) {
140
-				if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) {
139
+			if (empty($show_phpver_notice)) {
140
+				if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) {
141 141
 					/* translators: 1) int version 2) int version */
142
-					$message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' );
142
+					$message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe');
143 143
 
144
-					$this->add_admin_notice( 'phpver', 'error', sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() ), true );
144
+					$this->add_admin_notice('phpver', 'error', sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion()), true);
145 145
 
146 146
 					return;
147 147
 				}
148 148
 			}
149 149
 
150
-			if ( empty( $show_wcver_notice ) ) {
151
-				if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) {
150
+			if (empty($show_wcver_notice)) {
151
+				if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) {
152 152
 					/* translators: 1) int version 2) int version */
153
-					$message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' );
153
+					$message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe');
154 154
 
155
-					$this->add_admin_notice( 'wcver', 'notice notice-warning', sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION ), true );
155
+					$this->add_admin_notice('wcver', 'notice notice-warning', sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION), true);
156 156
 
157 157
 					return;
158 158
 				}
159 159
 			}
160 160
 
161
-			if ( empty( $show_curl_notice ) ) {
162
-				if ( ! function_exists( 'curl_init' ) ) {
163
-					$this->add_admin_notice( 'curl', 'notice notice-warning', __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' ), true );
161
+			if (empty($show_curl_notice)) {
162
+				if ( ! function_exists('curl_init')) {
163
+					$this->add_admin_notice('curl', 'notice notice-warning', __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe'), true);
164 164
 				}
165 165
 			}
166 166
 
167
-			if ( empty( $show_keys_notice ) ) {
167
+			if (empty($show_keys_notice)) {
168 168
 				$secret = WC_Stripe_API::get_secret_key();
169 169
 
170
-				if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) {
170
+				if (empty($secret) && ! (isset($_GET['page'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'])) {
171 171
 					$setting_link = $this->get_setting_link();
172 172
 					/* translators: 1) link */
173
-					$this->add_admin_notice( 'keys', 'notice notice-warning', sprintf( __( 'Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
173
+					$this->add_admin_notice('keys', 'notice notice-warning', sprintf(__('Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
174 174
 				}
175 175
 
176 176
 				// Check if keys are entered properly per live/test mode.
177
-				if ( $testmode ) {
177
+				if ($testmode) {
178 178
 					if (
179
-						! empty( $test_pub_key ) && ! preg_match( '/^pk_test_/', $test_pub_key )
180
-						|| ( ! empty( $test_secret_key ) && ! preg_match( '/^sk_test_/', $test_secret_key )
181
-						&& ! empty( $test_secret_key ) && ! preg_match( '/^rk_test_/', $test_secret_key ) ) ) {
179
+						! empty($test_pub_key) && ! preg_match('/^pk_test_/', $test_pub_key)
180
+						|| ( ! empty($test_secret_key) && ! preg_match('/^sk_test_/', $test_secret_key)
181
+						&& ! empty($test_secret_key) && ! preg_match('/^rk_test_/', $test_secret_key)) ) {
182 182
 						$setting_link = $this->get_setting_link();
183 183
 						/* translators: 1) link */
184
-						$this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
184
+						$this->add_admin_notice('keys', 'notice notice-error', sprintf(__('Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
185 185
 					}
186 186
 				} else {
187 187
 					if (
188
-						! empty( $live_pub_key ) && ! preg_match( '/^pk_live_/', $live_pub_key )
189
-						|| ( ! empty( $live_secret_key ) && ! preg_match( '/^sk_live_/', $live_secret_key )
190
-						&& ! empty( $live_secret_key ) && ! preg_match( '/^rk_live_/', $live_secret_key ) ) ) {
188
+						! empty($live_pub_key) && ! preg_match('/^pk_live_/', $live_pub_key)
189
+						|| ( ! empty($live_secret_key) && ! preg_match('/^sk_live_/', $live_secret_key)
190
+						&& ! empty($live_secret_key) && ! preg_match('/^rk_live_/', $live_secret_key)) ) {
191 191
 						$setting_link = $this->get_setting_link();
192 192
 						/* translators: 1) link */
193
-						$this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in live mode however your test keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
193
+						$this->add_admin_notice('keys', 'notice notice-error', sprintf(__('Stripe is in live mode however your test keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
194 194
 					}
195 195
 				}
196 196
 			}
197 197
 
198
-			if ( empty( $show_ssl_notice ) ) {
198
+			if (empty($show_ssl_notice)) {
199 199
 				// Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected.
200
-				if ( ! wc_checkout_is_https() ) {
200
+				if ( ! wc_checkout_is_https()) {
201 201
 					/* translators: 1) link */
202
-					$this->add_admin_notice( 'ssl', 'notice notice-warning', sprintf( __( 'Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe' ), 'https://en.wikipedia.org/wiki/Transport_Layer_Security' ), true );
202
+					$this->add_admin_notice('ssl', 'notice notice-warning', sprintf(__('Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe'), 'https://en.wikipedia.org/wiki/Transport_Layer_Security'), true);
203 203
 				}
204 204
 			}
205 205
 
206
-			if ( empty( $show_sca_notice ) ) {
207
-				$this->add_admin_notice( 'sca', 'notice notice-success', sprintf( __( 'Stripe is now ready for Strong Customer Authentication (SCA) and 3D Secure 2! <a href="%1$s" target="_blank">Read about SCA</a>', 'woocommerce-gateway-stripe' ), 'https://woocommerce.com/posts/introducing-strong-customer-authentication-sca/' ), true );
206
+			if (empty($show_sca_notice)) {
207
+				$this->add_admin_notice('sca', 'notice notice-success', sprintf(__('Stripe is now ready for Strong Customer Authentication (SCA) and 3D Secure 2! <a href="%1$s" target="_blank">Read about SCA</a>', 'woocommerce-gateway-stripe'), 'https://woocommerce.com/posts/introducing-strong-customer-authentication-sca/'), true);
208 208
 			}
209 209
 
210
-			if ( 'yes' === $changed_keys_notice ) {
210
+			if ('yes' === $changed_keys_notice) {
211 211
 				// translators: %s is a the URL for the link.
212
-				$this->add_admin_notice( 'changed_keys', 'notice notice-warning', sprintf( __( 'The public and/or secret keys for the Stripe gateway have been changed. This might cause errors for existing customers and saved payment methods. <a href="%s" target="_blank">Click here to learn more</a>.', 'woocommerce-gateway-stripe' ), 'https://docs.woocommerce.com/document/stripe-fixing-customer-errors/' ), true );
212
+				$this->add_admin_notice('changed_keys', 'notice notice-warning', sprintf(__('The public and/or secret keys for the Stripe gateway have been changed. This might cause errors for existing customers and saved payment methods. <a href="%s" target="_blank">Click here to learn more</a>.', 'woocommerce-gateway-stripe'), 'https://docs.woocommerce.com/document/stripe-fixing-customer-errors/'), true);
213 213
 			}
214 214
 		}
215 215
 	}
@@ -222,17 +222,17 @@  discard block
 block discarded – undo
222 222
 	public function payment_methods_check_environment() {
223 223
 		$payment_methods = $this->get_payment_methods();
224 224
 
225
-		foreach ( $payment_methods as $method => $class ) {
226
-			$show_notice = get_option( 'wc_stripe_show_' . strtolower( $method ) . '_notice' );
225
+		foreach ($payment_methods as $method => $class) {
226
+			$show_notice = get_option('wc_stripe_show_' . strtolower($method) . '_notice');
227 227
 			$gateway     = new $class();
228 228
 
229
-			if ( 'yes' !== $gateway->enabled || 'no' === $show_notice ) {
229
+			if ('yes' !== $gateway->enabled || 'no' === $show_notice) {
230 230
 				continue;
231 231
 			}
232 232
 
233
-			if ( ! in_array( get_woocommerce_currency(), $gateway->get_supported_currency() ) ) {
233
+			if ( ! in_array(get_woocommerce_currency(), $gateway->get_supported_currency())) {
234 234
 				/* translators: %1$s Payment method, %2$s List of supported currencies */
235
-				$this->add_admin_notice( $method, 'notice notice-error', sprintf( __( '%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe' ), $method, implode( ', ', $gateway->get_supported_currency() ) ), true );
235
+				$this->add_admin_notice($method, 'notice notice-error', sprintf(__('%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe'), $method, implode(', ', $gateway->get_supported_currency())), true);
236 236
 			}
237 237
 		}
238 238
 	}
@@ -244,71 +244,71 @@  discard block
 block discarded – undo
244 244
 	 * @version 4.0.0
245 245
 	 */
246 246
 	public function hide_notices() {
247
-		if ( isset( $_GET['wc-stripe-hide-notice'] ) && isset( $_GET['_wc_stripe_notice_nonce'] ) ) {
248
-			if ( ! wp_verify_nonce( $_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce' ) ) {
249
-				wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe' ) );
247
+		if (isset($_GET['wc-stripe-hide-notice']) && isset($_GET['_wc_stripe_notice_nonce'])) {
248
+			if ( ! wp_verify_nonce($_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce')) {
249
+				wp_die(__('Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe'));
250 250
 			}
251 251
 
252
-			if ( ! current_user_can( 'manage_woocommerce' ) ) {
253
-				wp_die( __( 'Cheatin&#8217; huh?', 'woocommerce-gateway-stripe' ) );
252
+			if ( ! current_user_can('manage_woocommerce')) {
253
+				wp_die(__('Cheatin&#8217; huh?', 'woocommerce-gateway-stripe'));
254 254
 			}
255 255
 
256
-			$notice = wc_clean( $_GET['wc-stripe-hide-notice'] );
256
+			$notice = wc_clean($_GET['wc-stripe-hide-notice']);
257 257
 
258
-			switch ( $notice ) {
258
+			switch ($notice) {
259 259
 				case 'style':
260
-					update_option( 'wc_stripe_show_style_notice', 'no' );
260
+					update_option('wc_stripe_show_style_notice', 'no');
261 261
 					break;
262 262
 				case 'phpver':
263
-					update_option( 'wc_stripe_show_phpver_notice', 'no' );
263
+					update_option('wc_stripe_show_phpver_notice', 'no');
264 264
 					break;
265 265
 				case 'wcver':
266
-					update_option( 'wc_stripe_show_wcver_notice', 'no' );
266
+					update_option('wc_stripe_show_wcver_notice', 'no');
267 267
 					break;
268 268
 				case 'curl':
269
-					update_option( 'wc_stripe_show_curl_notice', 'no' );
269
+					update_option('wc_stripe_show_curl_notice', 'no');
270 270
 					break;
271 271
 				case 'ssl':
272
-					update_option( 'wc_stripe_show_ssl_notice', 'no' );
272
+					update_option('wc_stripe_show_ssl_notice', 'no');
273 273
 					break;
274 274
 				case 'keys':
275
-					update_option( 'wc_stripe_show_keys_notice', 'no' );
275
+					update_option('wc_stripe_show_keys_notice', 'no');
276 276
 					break;
277 277
 				case '3ds':
278
-					update_option( 'wc_stripe_show_3ds_notice', 'no' );
278
+					update_option('wc_stripe_show_3ds_notice', 'no');
279 279
 					break;
280 280
 				case 'Alipay':
281
-					update_option( 'wc_stripe_show_alipay_notice', 'no' );
281
+					update_option('wc_stripe_show_alipay_notice', 'no');
282 282
 					break;
283 283
 				case 'Bancontact':
284
-					update_option( 'wc_stripe_show_bancontact_notice', 'no' );
284
+					update_option('wc_stripe_show_bancontact_notice', 'no');
285 285
 					break;
286 286
 				case 'EPS':
287
-					update_option( 'wc_stripe_show_eps_notice', 'no' );
287
+					update_option('wc_stripe_show_eps_notice', 'no');
288 288
 					break;
289 289
 				case 'Giropay':
290
-					update_option( 'wc_stripe_show_giropay_notice', 'no' );
290
+					update_option('wc_stripe_show_giropay_notice', 'no');
291 291
 					break;
292 292
 				case 'iDeal':
293
-					update_option( 'wc_stripe_show_ideal_notice', 'no' );
293
+					update_option('wc_stripe_show_ideal_notice', 'no');
294 294
 					break;
295 295
 				case 'Multibanco':
296
-					update_option( 'wc_stripe_show_multibanco_notice', 'no' );
296
+					update_option('wc_stripe_show_multibanco_notice', 'no');
297 297
 					break;
298 298
 				case 'P24':
299
-					update_option( 'wc_stripe_show_p24_notice', 'no' );
299
+					update_option('wc_stripe_show_p24_notice', 'no');
300 300
 					break;
301 301
 				case 'SEPA':
302
-					update_option( 'wc_stripe_show_sepa_notice', 'no' );
302
+					update_option('wc_stripe_show_sepa_notice', 'no');
303 303
 					break;
304 304
 				case 'SOFORT':
305
-					update_option( 'wc_stripe_show_sofort_notice', 'no' );
305
+					update_option('wc_stripe_show_sofort_notice', 'no');
306 306
 					break;
307 307
 				case 'sca':
308
-					update_option( 'wc_stripe_show_sca_notice', 'no' );
308
+					update_option('wc_stripe_show_sca_notice', 'no');
309 309
 					break;
310 310
 				case 'changed_keys':
311
-					update_option( 'wc_stripe_show_changed_keys_notice', 'no' );
311
+					update_option('wc_stripe_show_changed_keys_notice', 'no');
312 312
 			}
313 313
 		}
314 314
 	}
@@ -321,11 +321,11 @@  discard block
 block discarded – undo
321 321
 	 * @return string Setting link
322 322
 	 */
323 323
 	public function get_setting_link() {
324
-		$use_id_as_section = function_exists( 'WC' ) ? version_compare( WC()->version, '2.6', '>=' ) : false;
324
+		$use_id_as_section = function_exists('WC') ? version_compare(WC()->version, '2.6', '>=') : false;
325 325
 
326
-		$section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' );
326
+		$section_slug = $use_id_as_section ? 'stripe' : strtolower('WC_Gateway_Stripe');
327 327
 
328
-		return admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . $section_slug );
328
+		return admin_url('admin.php?page=wc-settings&tab=checkout&section=' . $section_slug);
329 329
 	}
330 330
 
331 331
 	/**
@@ -334,16 +334,16 @@  discard block
 block discarded – undo
334 334
 	 * @since 4.3.0
335 335
 	 */
336 336
 	public function stripe_updated() {
337
-		$previous_version = get_option( 'wc_stripe_version' );
337
+		$previous_version = get_option('wc_stripe_version');
338 338
 
339 339
 		// Only show the style notice if the plugin was installed and older than 4.1.4.
340
-		if ( empty( $previous_version ) || version_compare( $previous_version, '4.1.4', 'ge' ) ) {
341
-			update_option( 'wc_stripe_show_style_notice', 'no' );
340
+		if (empty($previous_version) || version_compare($previous_version, '4.1.4', 'ge')) {
341
+			update_option('wc_stripe_show_style_notice', 'no');
342 342
 		}
343 343
 
344 344
 		// Only show the SCA notice on pre-4.3.0 installs.
345
-		if ( empty( $previous_version ) || version_compare( $previous_version, '4.3.0', 'ge' ) ) {
346
-			update_option( 'wc_stripe_show_sca_notice', 'no' );
345
+		if (empty($previous_version) || version_compare($previous_version, '4.3.0', 'ge')) {
346
+			update_option('wc_stripe_show_sca_notice', 'no');
347 347
 		}
348 348
 	}
349 349
 }
Please login to merge, or discard this patch.