Completed
Push — master ( a1581a...b80e00 )
by Roy
26s
created
includes/admin/stripe-p24-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_p24_settings',
8 8
 	array(
9 9
 		'geo_target'  => array(
10
-			'description' => __( 'Relevant Payer Geography: Poland', 'woocommerce-gateway-stripe' ),
10
+			'description' => __('Relevant Payer Geography: Poland', '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 P24', 'woocommerce-gateway-stripe' ),
18
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
19
+			'label'       => __('Enable Stripe P24', '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'     => __( 'Przelewy24 (P24)', 'woocommerce-gateway-stripe' ),
27
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
28
+			'default'     => __('Przelewy24 (P24)', '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 P24.', '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 P24.', '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/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 Enpoints', 'woocommerce-gateway-stripe' ),
39
+			'title'       => __('Webhook Enpoints', '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-privacy.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! class_exists( 'WC_Abstract_Privacy' ) ) {
2
+if ( ! class_exists('WC_Abstract_Privacy')) {
3 3
 	return;
4 4
 }
5 5
 
@@ -9,20 +9,20 @@  discard block
 block discarded – undo
9 9
 	 *
10 10
 	 */
11 11
 	public function __construct() {
12
-		parent::__construct( __( 'Stripe', 'woocommerce-gateway-stripe' ) );
12
+		parent::__construct(__('Stripe', 'woocommerce-gateway-stripe'));
13 13
 
14
-		$this->add_exporter( 'woocommerce-gateway-stripe-order-data', __( 'WooCommerce Stripe Order Data', 'woocommerce-gateway-stripe' ), array( $this, 'order_data_exporter' ) );
14
+		$this->add_exporter('woocommerce-gateway-stripe-order-data', __('WooCommerce Stripe Order Data', 'woocommerce-gateway-stripe'), array($this, 'order_data_exporter'));
15 15
 
16
-		if ( function_exists( 'wcs_get_subscriptions' ) ) {
17
-			$this->add_exporter( 'woocommerce-gateway-stripe-subscriptions-data', __( 'WooCommerce Stripe Subscriptions Data', 'woocommerce-gateway-stripe' ), array( $this, 'subscriptions_data_exporter' ) );
16
+		if (function_exists('wcs_get_subscriptions')) {
17
+			$this->add_exporter('woocommerce-gateway-stripe-subscriptions-data', __('WooCommerce Stripe Subscriptions Data', 'woocommerce-gateway-stripe'), array($this, 'subscriptions_data_exporter'));
18 18
 		}
19 19
 
20
-		$this->add_exporter( 'woocommerce-gateway-stripe-customer-data', __( 'WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe' ), array( $this, 'customer_data_exporter' ) );
20
+		$this->add_exporter('woocommerce-gateway-stripe-customer-data', __('WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe'), array($this, 'customer_data_exporter'));
21 21
 
22
-		$this->add_eraser( 'woocommerce-gateway-stripe-customer-data', __( 'WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe' ), array( $this, 'customer_data_eraser' ) );
23
-		$this->add_eraser( 'woocommerce-gateway-stripe-order-data', __( 'WooCommerce Stripe Data', 'woocommerce-gateway-stripe' ), array( $this, 'order_data_eraser' ) );
22
+		$this->add_eraser('woocommerce-gateway-stripe-customer-data', __('WooCommerce Stripe Customer Data', 'woocommerce-gateway-stripe'), array($this, 'customer_data_eraser'));
23
+		$this->add_eraser('woocommerce-gateway-stripe-order-data', __('WooCommerce Stripe Data', 'woocommerce-gateway-stripe'), array($this, 'order_data_eraser'));
24 24
 
25
-		add_filter( 'woocommerce_get_settings_account', array( $this, 'account_settings' ) );
25
+		add_filter('woocommerce_get_settings_account', array($this, 'account_settings'));
26 26
 	}
27 27
 
28 28
 	/**
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
 	 * @param array $settings
32 32
 	 * @return array $settings Updated
33 33
 	 */
34
-	public function account_settings( $settings ) {
34
+	public function account_settings($settings) {
35 35
 		$insert_setting = array(
36 36
 			array(
37
-				'title'       => __( 'Retain Stripe Data', 'woocommerce-gateway-stripe' ),
38
-				'desc_tip'    => __( 'Retains any Stripe data such as Stripe customer ID, source ID.', 'woocommerce-gateway-stripe' ),
37
+				'title'       => __('Retain Stripe Data', 'woocommerce-gateway-stripe'),
38
+				'desc_tip'    => __('Retains any Stripe data such as Stripe customer ID, source ID.', 'woocommerce-gateway-stripe'),
39 39
 				'id'          => 'woocommerce_gateway_stripe_retention',
40 40
 				'type'        => 'relative_date_selector',
41
-				'placeholder' => __( 'N/A', 'woocommerce-gateway-stripe' ),
41
+				'placeholder' => __('N/A', 'woocommerce-gateway-stripe'),
42 42
 				'default'     => '',
43 43
 				'autoload'    => false,
44 44
 			),
45 45
 		);
46 46
 
47
-		array_splice( $settings, ( count( $settings ) - 1 ), 0, $insert_setting );
47
+		array_splice($settings, (count($settings) - 1), 0, $insert_setting);
48 48
 
49 49
 		return $settings;
50 50
 	}
@@ -57,22 +57,22 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @return array WP_Post
59 59
 	 */
60
-	protected function get_stripe_orders( $email_address, $page ) {
61
-		$user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
60
+	protected function get_stripe_orders($email_address, $page) {
61
+		$user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data.
62 62
 
63 63
 		$order_query = array(
64
-			'payment_method' => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ),
64
+			'payment_method' => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'),
65 65
 			'limit'          => 10,
66 66
 			'page'           => $page,
67 67
 		);
68 68
 
69
-		if ( $user instanceof WP_User ) {
69
+		if ($user instanceof WP_User) {
70 70
 			$order_query['customer_id'] = (int) $user->ID;
71 71
 		} else {
72 72
 			$order_query['billing_email'] = $email_address;
73 73
 		}
74 74
 
75
-		return wc_get_orders( $order_query );
75
+		return wc_get_orders($order_query);
76 76
 	}
77 77
 
78 78
 	/**
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function get_privacy_message() {
83 83
 		/* translators: %s URL to docs */
84
-		return wpautop( sprintf( __( 'By using this extension, you may be storing personal data or sharing data with an external service. <a href="%s" target="_blank">Learn more about how this works, including what you may want to include in your privacy policy.</a>', 'woocommerce-gateway-stripe' ), 'https://docs.woocommerce.com/document/privacy-payments/#woocommerce-gateway-stripe' ) );
84
+		return wpautop(sprintf(__('By using this extension, you may be storing personal data or sharing data with an external service. <a href="%s" target="_blank">Learn more about how this works, including what you may want to include in your privacy policy.</a>', 'woocommerce-gateway-stripe'), 'https://docs.woocommerce.com/document/privacy-payments/#woocommerce-gateway-stripe'));
85 85
 	}
86 86
 
87 87
 	/**
@@ -92,34 +92,34 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return array
94 94
 	 */
95
-	public function order_data_exporter( $email_address, $page = 1 ) {
95
+	public function order_data_exporter($email_address, $page = 1) {
96 96
 		$done           = false;
97 97
 		$data_to_export = array();
98 98
 
99
-		$orders = $this->get_stripe_orders( $email_address, (int) $page );
99
+		$orders = $this->get_stripe_orders($email_address, (int) $page);
100 100
 
101 101
 		$done = true;
102 102
 
103
-		if ( 0 < count( $orders ) ) {
104
-			foreach ( $orders as $order ) {
103
+		if (0 < count($orders)) {
104
+			foreach ($orders as $order) {
105 105
 				$data_to_export[] = array(
106 106
 					'group_id'    => 'woocommerce_orders',
107
-					'group_label' => __( 'Orders', 'woocommerce-gateway-stripe' ),
107
+					'group_label' => __('Orders', 'woocommerce-gateway-stripe'),
108 108
 					'item_id'     => 'order-' . $order->get_id(),
109 109
 					'data'        => array(
110 110
 						array(
111
-							'name'  => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ),
112
-							'value' => get_post_meta( $order->get_id(), '_stripe_source_id', true ),
111
+							'name'  => __('Stripe payment id', 'woocommerce-gateway-stripe'),
112
+							'value' => get_post_meta($order->get_id(), '_stripe_source_id', true),
113 113
 						),
114 114
 						array(
115
-							'name'  => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ),
116
-							'value' => get_post_meta( $order->get_id(), '_stripe_customer_id', true ),
115
+							'name'  => __('Stripe customer id', 'woocommerce-gateway-stripe'),
116
+							'value' => get_post_meta($order->get_id(), '_stripe_customer_id', true),
117 117
 						),
118 118
 					),
119 119
 				);
120 120
 			}
121 121
 
122
-			$done = 10 > count( $orders );
122
+			$done = 10 > count($orders);
123 123
 		}
124 124
 
125 125
 		return array(
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @return array
138 138
 	 */
139
-	public function subscriptions_data_exporter( $email_address, $page = 1 ) {
139
+	public function subscriptions_data_exporter($email_address, $page = 1) {
140 140
 		$done           = false;
141 141
 		$page           = (int) $page;
142 142
 		$data_to_export = array();
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			'relation' => 'AND',
146 146
 			array(
147 147
 				'key'     => '_payment_method',
148
-				'value'   => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ),
148
+				'value'   => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'),
149 149
 				'compare' => 'IN',
150 150
 			),
151 151
 			array(
@@ -161,30 +161,30 @@  discard block
 block discarded – undo
161 161
 			'meta_query'     => $meta_query,
162 162
 		);
163 163
 
164
-		$subscriptions = wcs_get_subscriptions( $subscription_query );
164
+		$subscriptions = wcs_get_subscriptions($subscription_query);
165 165
 
166 166
 		$done = true;
167 167
 
168
-		if ( 0 < count( $subscriptions ) ) {
169
-			foreach ( $subscriptions as $subscription ) {
168
+		if (0 < count($subscriptions)) {
169
+			foreach ($subscriptions as $subscription) {
170 170
 				$data_to_export[] = array(
171 171
 					'group_id'    => 'woocommerce_subscriptions',
172
-					'group_label' => __( 'Subscriptions', 'woocommerce-gateway-stripe' ),
172
+					'group_label' => __('Subscriptions', 'woocommerce-gateway-stripe'),
173 173
 					'item_id'     => 'subscription-' . $subscription->get_id(),
174 174
 					'data'        => array(
175 175
 						array(
176
-							'name'  => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ),
177
-							'value' => get_post_meta( $subscription->get_id(), '_stripe_source_id', true ),
176
+							'name'  => __('Stripe payment id', 'woocommerce-gateway-stripe'),
177
+							'value' => get_post_meta($subscription->get_id(), '_stripe_source_id', true),
178 178
 						),
179 179
 						array(
180
-							'name'  => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ),
181
-							'value' => get_post_meta( $subscription->get_id(), '_stripe_customer_id', true ),
180
+							'name'  => __('Stripe customer id', 'woocommerce-gateway-stripe'),
181
+							'value' => get_post_meta($subscription->get_id(), '_stripe_customer_id', true),
182 182
 						),
183 183
 					),
184 184
 				);
185 185
 			}
186 186
 
187
-			$done = 10 > count( $subscriptions );
187
+			$done = 10 > count($subscriptions);
188 188
 		}
189 189
 
190 190
 		return array(
@@ -200,24 +200,24 @@  discard block
 block discarded – undo
200 200
 	 * @param int    $page  Page.
201 201
 	 * @return array An array of personal data in name value pairs
202 202
 	 */
203
-	public function customer_data_exporter( $email_address, $page ) {
204
-		$user           = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
203
+	public function customer_data_exporter($email_address, $page) {
204
+		$user           = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data.
205 205
 		$data_to_export = array();
206 206
 
207
-		if ( $user instanceof WP_User ) {
208
-			$stripe_user = new WC_Stripe_Customer( $user->ID );
207
+		if ($user instanceof WP_User) {
208
+			$stripe_user = new WC_Stripe_Customer($user->ID);
209 209
 
210 210
 			$data_to_export[] = array(
211 211
 				'group_id'    => 'woocommerce_customer',
212
-				'group_label' => __( 'Customer Data', 'woocommerce-gateway-stripe' ),
212
+				'group_label' => __('Customer Data', 'woocommerce-gateway-stripe'),
213 213
 				'item_id'     => 'user',
214 214
 				'data'        => array(
215 215
 					array(
216
-						'name'  => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ),
217
-						'value' => get_user_meta( $user->ID, '_stripe_source_id', true ),
216
+						'name'  => __('Stripe payment id', 'woocommerce-gateway-stripe'),
217
+						'value' => get_user_meta($user->ID, '_stripe_source_id', true),
218 218
 					),
219 219
 					array(
220
-						'name'  => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ),
220
+						'name'  => __('Stripe customer id', 'woocommerce-gateway-stripe'),
221 221
 						'value' => $stripe_user->get_id(),
222 222
 					),
223 223
 				),
@@ -237,25 +237,25 @@  discard block
 block discarded – undo
237 237
 	 * @param int    $page  Page.
238 238
 	 * @return array An array of personal data in name value pairs
239 239
 	 */
240
-	public function customer_data_eraser( $email_address, $page ) {
240
+	public function customer_data_eraser($email_address, $page) {
241 241
 		$page               = (int) $page;
242
-		$user               = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
242
+		$user               = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data.
243 243
 		$stripe_customer_id = '';
244 244
 		$stripe_source_id   = '';
245 245
 
246
-		if ( $user instanceof WP_User ) {
247
-			$stripe_customer_id = get_user_meta( $user->ID, '_stripe_customer_id', true );
248
-			$stripe_source_id   = get_user_meta( $user->ID, '_stripe_source_id', true );
246
+		if ($user instanceof WP_User) {
247
+			$stripe_customer_id = get_user_meta($user->ID, '_stripe_customer_id', true);
248
+			$stripe_source_id   = get_user_meta($user->ID, '_stripe_source_id', true);
249 249
 		}
250 250
 
251 251
 		$items_removed = false;
252 252
 		$messages      = array();
253 253
 
254
-		if ( ! empty( $stripe_customer_id ) || ! empty( $stripe_source_id ) ) {
254
+		if ( ! empty($stripe_customer_id) || ! empty($stripe_source_id)) {
255 255
 			$items_removed = true;
256
-			delete_user_meta( $user->ID, '_stripe_customer_id' );
257
-			delete_user_meta( $user->ID, '_stripe_source_id' );
258
-			$messages[] = __( 'Stripe User Data Erased.', 'woocommerce-gateway-stripe' );
256
+			delete_user_meta($user->ID, '_stripe_customer_id');
257
+			delete_user_meta($user->ID, '_stripe_source_id');
258
+			$messages[] = __('Stripe User Data Erased.', 'woocommerce-gateway-stripe');
259 259
 		}
260 260
 
261 261
 		return array(
@@ -273,29 +273,29 @@  discard block
 block discarded – undo
273 273
 	 * @param int    $page  Page.
274 274
 	 * @return array An array of personal data in name value pairs
275 275
 	 */
276
-	public function order_data_eraser( $email_address, $page ) {
277
-		$orders = $this->get_stripe_orders( $email_address, (int) $page );
276
+	public function order_data_eraser($email_address, $page) {
277
+		$orders = $this->get_stripe_orders($email_address, (int) $page);
278 278
 
279 279
 		$items_removed  = false;
280 280
 		$items_retained = false;
281 281
 		$messages       = array();
282 282
 
283
-		foreach ( (array) $orders as $order ) {
284
-			$order = wc_get_order( $order->get_id() );
283
+		foreach ((array) $orders as $order) {
284
+			$order = wc_get_order($order->get_id());
285 285
 
286
-			list( $removed, $retained, $msgs ) = $this->maybe_handle_order( $order );
286
+			list($removed, $retained, $msgs) = $this->maybe_handle_order($order);
287 287
 			$items_removed                    |= $removed;
288 288
 			$items_retained                   |= $retained;
289
-			$messages                          = array_merge( $messages, $msgs );
289
+			$messages                          = array_merge($messages, $msgs);
290 290
 
291
-			list( $removed, $retained, $msgs ) = $this->maybe_handle_subscription( $order );
291
+			list($removed, $retained, $msgs) = $this->maybe_handle_subscription($order);
292 292
 			$items_removed                    |= $removed;
293 293
 			$items_retained                   |= $retained;
294
-			$messages                          = array_merge( $messages, $msgs );
294
+			$messages                          = array_merge($messages, $msgs);
295 295
 		}
296 296
 
297 297
 		// Tell core if we have more orders to work on still
298
-		$done = count( $orders ) < 10;
298
+		$done = count($orders) < 10;
299 299
 
300 300
 		return array(
301 301
 			'items_removed'  => $items_removed,
@@ -311,47 +311,47 @@  discard block
 block discarded – undo
311 311
 	 * @param WC_Order $order
312 312
 	 * @return array
313 313
 	 */
314
-	protected function maybe_handle_subscription( $order ) {
315
-		if ( ! class_exists( 'WC_Subscriptions' ) ) {
316
-			return array( false, false, array() );
314
+	protected function maybe_handle_subscription($order) {
315
+		if ( ! class_exists('WC_Subscriptions')) {
316
+			return array(false, false, array());
317 317
 		}
318 318
 
319
-		if ( ! wcs_order_contains_subscription( $order ) ) {
320
-			return array( false, false, array() );
319
+		if ( ! wcs_order_contains_subscription($order)) {
320
+			return array(false, false, array());
321 321
 		}
322 322
 
323
-		$subscription    = current( wcs_get_subscriptions_for_order( $order->get_id() ) );
323
+		$subscription    = current(wcs_get_subscriptions_for_order($order->get_id()));
324 324
 		$subscription_id = $subscription->get_id();
325 325
 
326
-		$stripe_source_id = get_post_meta( $subscription_id, '_stripe_source_id', true );
326
+		$stripe_source_id = get_post_meta($subscription_id, '_stripe_source_id', true);
327 327
 
328
-		if ( empty( $stripe_source_id ) ) {
329
-			return array( false, false, array() );
328
+		if (empty($stripe_source_id)) {
329
+			return array(false, false, array());
330 330
 		}
331 331
 
332
-		if ( ! $this->is_retention_expired( $order->get_date_created()->getTimestamp() ) ) {
332
+		if ( ! $this->is_retention_expired($order->get_date_created()->getTimestamp())) {
333 333
 			/* translators: %d Order ID */
334
-			return array( false, true, array( sprintf( __( 'Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) );
334
+			return array(false, true, array(sprintf(__('Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id())));
335 335
 		}
336 336
 
337
-		if ( $subscription->has_status( apply_filters( 'wc_stripe_privacy_eraser_subs_statuses', array( 'on-hold', 'active' ) ) ) ) {
337
+		if ($subscription->has_status(apply_filters('wc_stripe_privacy_eraser_subs_statuses', array('on-hold', 'active')))) {
338 338
 			/* translators: %d Order ID */
339
-			return array( false, true, array( sprintf( __( 'Order ID %d contains an active Subscription. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) );
339
+			return array(false, true, array(sprintf(__('Order ID %d contains an active Subscription. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id())));
340 340
 		}
341 341
 
342
-		$renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders( $order->get_id() );
342
+		$renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders($order->get_id());
343 343
 
344
-		foreach ( $renewal_orders as $renewal_order_id ) {
345
-			delete_post_meta( $renewal_order_id, '_stripe_source_id' );
346
-			delete_post_meta( $renewal_order_id, '_stripe_refund_id' );
347
-			delete_post_meta( $renewal_order_id, '_stripe_customer_id' );
344
+		foreach ($renewal_orders as $renewal_order_id) {
345
+			delete_post_meta($renewal_order_id, '_stripe_source_id');
346
+			delete_post_meta($renewal_order_id, '_stripe_refund_id');
347
+			delete_post_meta($renewal_order_id, '_stripe_customer_id');
348 348
 		}
349 349
 
350
-		delete_post_meta( $subscription_id, '_stripe_source_id' );
351
-		delete_post_meta( $subscription_id, '_stripe_refund_id' );
352
-		delete_post_meta( $subscription_id, '_stripe_customer_id' );
350
+		delete_post_meta($subscription_id, '_stripe_source_id');
351
+		delete_post_meta($subscription_id, '_stripe_refund_id');
352
+		delete_post_meta($subscription_id, '_stripe_customer_id');
353 353
 
354
-		return array( true, false, array( __( 'Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe' ) ) );
354
+		return array(true, false, array(__('Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe')));
355 355
 	}
356 356
 
357 357
 	/**
@@ -360,61 +360,61 @@  discard block
 block discarded – undo
360 360
 	 * @param WC_Order $order
361 361
 	 * @return array
362 362
 	 */
363
-	protected function maybe_handle_order( $order ) {
363
+	protected function maybe_handle_order($order) {
364 364
 		$order_id           = $order->get_id();
365
-		$stripe_source_id   = get_post_meta( $order_id, '_stripe_source_id', true );
366
-		$stripe_refund_id   = get_post_meta( $order_id, '_stripe_refund_id', true );
367
-		$stripe_customer_id = get_post_meta( $order_id, '_stripe_customer_id', true );
365
+		$stripe_source_id   = get_post_meta($order_id, '_stripe_source_id', true);
366
+		$stripe_refund_id   = get_post_meta($order_id, '_stripe_refund_id', true);
367
+		$stripe_customer_id = get_post_meta($order_id, '_stripe_customer_id', true);
368 368
 
369
-		if ( ! $this->is_retention_expired( $order->get_date_created()->getTimestamp() ) ) {
369
+		if ( ! $this->is_retention_expired($order->get_date_created()->getTimestamp())) {
370 370
 			/* translators: %d Order ID */
371
-			return array( false, true, array( sprintf( __( 'Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) );
371
+			return array(false, true, array(sprintf(__('Order ID %d is less than set retention days. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id())));
372 372
 		}
373 373
 
374
-		if ( empty( $stripe_source_id ) && empty( $stripe_refund_id ) && empty( $stripe_customer_id ) ) {
375
-			return array( false, false, array() );
374
+		if (empty($stripe_source_id) && empty($stripe_refund_id) && empty($stripe_customer_id)) {
375
+			return array(false, false, array());
376 376
 		}
377 377
 
378
-		delete_post_meta( $order_id, '_stripe_source_id' );
379
-		delete_post_meta( $order_id, '_stripe_refund_id' );
380
-		delete_post_meta( $order_id, '_stripe_customer_id' );
378
+		delete_post_meta($order_id, '_stripe_source_id');
379
+		delete_post_meta($order_id, '_stripe_refund_id');
380
+		delete_post_meta($order_id, '_stripe_customer_id');
381 381
 
382
-		return array( true, false, array( __( 'Stripe personal data erased.', 'woocommerce-gateway-stripe' ) ) );
382
+		return array(true, false, array(__('Stripe personal data erased.', 'woocommerce-gateway-stripe')));
383 383
 	}
384 384
 
385 385
 	/**
386 386
 	 * Checks if create date is passed retention duration.
387 387
 	 *
388 388
 	 */
389
-	public function is_retention_expired( $created_date ) {
390
-		$retention  = wc_parse_relative_date_option( get_option( 'woocommerce_gateway_stripe_retention' ) );
389
+	public function is_retention_expired($created_date) {
390
+		$retention  = wc_parse_relative_date_option(get_option('woocommerce_gateway_stripe_retention'));
391 391
 		$is_expired = false;
392
-		$time_span  = time() - strtotime( $created_date );
393
-		if ( empty( $retention ) || empty( $created_date ) ) {
392
+		$time_span  = time() - strtotime($created_date);
393
+		if (empty($retention) || empty($created_date)) {
394 394
 			return false;
395 395
 		}
396
-		switch ( $retention['unit'] ) {
396
+		switch ($retention['unit']) {
397 397
 			case 'days':
398 398
 				$retention = $retention['number'] * DAY_IN_SECONDS;
399
-				if ( $time_span > $retention ) {
399
+				if ($time_span > $retention) {
400 400
 					$is_expired = true;
401 401
 				}
402 402
 				break;
403 403
 			case 'weeks':
404 404
 				$retention = $retention['number'] * WEEK_IN_SECONDS;
405
-				if ( $time_span > $retention ) {
405
+				if ($time_span > $retention) {
406 406
 					$is_expired = true;
407 407
 				}
408 408
 				break;
409 409
 			case 'months':
410 410
 				$retention = $retention['number'] * MONTH_IN_SECONDS;
411
-				if ( $time_span > $retention ) {
411
+				if ($time_span > $retention) {
412 412
 					$is_expired = true;
413 413
 				}
414 414
 				break;
415 415
 			case 'years':
416 416
 				$retention = $retention['number'] * YEAR_IN_SECONDS;
417
-				if ( $time_span > $retention ) {
417
+				if ($time_span > $retention) {
418 418
 					$is_expired = true;
419 419
 				}
420 420
 				break;
Please login to merge, or discard this patch.
includes/admin/stripe-alipay-settings.php 1 patch
Spacing   +13 added lines, -13 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,40 +7,40 @@  discard block
 block discarded – undo
7 7
 	'wc_stripe_alipay_settings',
8 8
 	array(
9 9
 		'geo_target'  => array(
10
-			'description' => __( 'Relevant Payer Geography: China', 'woocommerce-gateway-stripe' ),
10
+			'description' => __('Relevant Payer Geography: China', 'woocommerce-gateway-stripe'),
11 11
 			'type'        => 'title',
12 12
 		),
13 13
 		'guide'       => array(
14
-			'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#alipay" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ),
14
+			'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#alipay" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe'),
15 15
 			'type'        => 'title',
16 16
 		),
17 17
 		'activation'  => array(
18
-			'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' ),
18
+			'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'),
19 19
 			'type'        => 'title',
20 20
 		),
21 21
 		'enabled'     => array(
22
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
23
-			'label'       => __( 'Enable Stripe Alipay', 'woocommerce-gateway-stripe' ),
22
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
23
+			'label'       => __('Enable Stripe Alipay', 'woocommerce-gateway-stripe'),
24 24
 			'type'        => 'checkbox',
25 25
 			'description' => '',
26 26
 			'default'     => 'no',
27 27
 		),
28 28
 		'title'       => array(
29
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
29
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
30 30
 			'type'        => 'text',
31
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
32
-			'default'     => __( 'Alipay', 'woocommerce-gateway-stripe' ),
31
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
32
+			'default'     => __('Alipay', 'woocommerce-gateway-stripe'),
33 33
 			'desc_tip'    => true,
34 34
 		),
35 35
 		'description' => array(
36
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
36
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
37 37
 			'type'        => 'text',
38
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
39
-			'default'     => __( 'You will be redirected to Alipay.', 'woocommerce-gateway-stripe' ),
38
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
39
+			'default'     => __('You will be redirected to Alipay.', 'woocommerce-gateway-stripe'),
40 40
 			'desc_tip'    => true,
41 41
 		),
42 42
 		'webhook'     => array(
43
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
43
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
44 44
 			'type'        => 'title',
45 45
 			/* translators: webhook URL */
46 46
 			'description' => $this->display_admin_settings_webhook_description(),
Please login to merge, or discard this patch.
includes/class-wc-stripe-apple-pay-registration.php 1 patch
Spacing   +45 added lines, -45 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,21 +60,21 @@  discard block
 block discarded – undo
60 60
 	public $apple_pay_verify_notice;
61 61
 
62 62
 	public function __construct() {
63
-		$this->stripe_settings         = get_option( 'woocommerce_stripe_settings', array() );
64
-		$this->stripe_enabled          = $this->get_option( 'enabled' );
65
-		$this->payment_request         = 'yes' === $this->get_option( 'payment_request', 'yes' );
66
-		$this->apple_pay_domain_set    = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' );
63
+		$this->stripe_settings         = get_option('woocommerce_stripe_settings', array());
64
+		$this->stripe_enabled          = $this->get_option('enabled');
65
+		$this->payment_request         = 'yes' === $this->get_option('payment_request', 'yes');
66
+		$this->apple_pay_domain_set    = 'yes' === $this->get_option('apple_pay_domain_set', 'no');
67 67
 		$this->apple_pay_verify_notice = '';
68
-		$this->testmode                = 'yes' === $this->get_option( 'testmode', 'no' );
69
-		$this->secret_key              = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
68
+		$this->testmode                = 'yes' === $this->get_option('testmode', 'no');
69
+		$this->secret_key              = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
70 70
 
71
-		if ( empty( $this->stripe_settings ) ) {
71
+		if (empty($this->stripe_settings)) {
72 72
 			return;
73 73
 		}
74 74
 
75 75
 		$this->init_apple_pay();
76 76
 
77
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
77
+		add_action('admin_notices', array($this, 'admin_notices'));
78 78
 	}
79 79
 
80 80
 	/**
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 	 * @param string default
86 86
 	 * @return string $setting_value
87 87
 	 */
88
-	public function get_option( $setting = '', $default = '' ) {
89
-		if ( empty( $this->stripe_settings ) ) {
88
+	public function get_option($setting = '', $default = '') {
89
+		if (empty($this->stripe_settings)) {
90 90
 			return $default;
91 91
 		}
92 92
 
93
-		if ( ! empty( $this->stripe_settings[ $setting ] ) ) {
94
-			return $this->stripe_settings[ $setting ];
93
+		if ( ! empty($this->stripe_settings[$setting])) {
94
+			return $this->stripe_settings[$setting];
95 95
 		}
96 96
 
97 97
 		return $default;
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 	public function init_apple_pay() {
107 107
 		if (
108 108
 			is_admin() &&
109
-			isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] &&
110
-			isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'] &&
111
-			isset( $_GET['section'] ) && 'stripe' === $_GET['section'] &&
109
+			isset($_GET['page']) && 'wc-settings' === $_GET['page'] &&
110
+			isset($_GET['tab']) && 'checkout' === $_GET['tab'] &&
111
+			isset($_GET['section']) && 'stripe' === $_GET['section'] &&
112 112
 			$this->payment_request
113 113
 		) {
114 114
 			$this->process_apple_pay_verification();
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 	 * @version 3.1.0
123 123
 	 * @param string $secret_key
124 124
 	 */
125
-	private function register_apple_pay_domain( $secret_key = '' ) {
126
-		if ( empty( $secret_key ) ) {
127
-			throw new Exception( __( 'Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe' ) );
125
+	private function register_apple_pay_domain($secret_key = '') {
126
+		if (empty($secret_key)) {
127
+			throw new Exception(__('Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe'));
128 128
 		}
129 129
 
130 130
 		$endpoint = 'https://api.stripe.com/v1/apple_pay/domains';
@@ -142,22 +142,22 @@  discard block
 block discarded – undo
142 142
 			$endpoint,
143 143
 			array(
144 144
 				'headers' => $headers,
145
-				'body'    => http_build_query( $data ),
145
+				'body'    => http_build_query($data),
146 146
 			)
147 147
 		);
148 148
 
149
-		if ( is_wp_error( $response ) ) {
149
+		if (is_wp_error($response)) {
150 150
 			/* translators: error message */
151
-			throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) );
151
+			throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $response->get_error_message()));
152 152
 		}
153 153
 
154
-		if ( 200 !== $response['response']['code'] ) {
155
-			$parsed_response = json_decode( $response['body'] );
154
+		if (200 !== $response['response']['code']) {
155
+			$parsed_response = json_decode($response['body']);
156 156
 
157 157
 			$this->apple_pay_verify_notice = $parsed_response->error->message;
158 158
 
159 159
 			/* translators: error message */
160
-			throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $parsed_response->error->message ) );
160
+			throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $parsed_response->error->message));
161 161
 		}
162 162
 	}
163 163
 
@@ -169,45 +169,45 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	public function process_apple_pay_verification() {
171 171
 		try {
172
-			$path     = untrailingslashit( $_SERVER['DOCUMENT_ROOT'] );
172
+			$path     = untrailingslashit($_SERVER['DOCUMENT_ROOT']);
173 173
 			$dir      = '.well-known';
174 174
 			$file     = 'apple-developer-merchantid-domain-association';
175 175
 			$fullpath = $path . '/' . $dir . '/' . $file;
176 176
 
177
-			if ( $this->apple_pay_domain_set && file_exists( $fullpath ) ) {
177
+			if ($this->apple_pay_domain_set && file_exists($fullpath)) {
178 178
 				return;
179 179
 			}
180 180
 
181
-			if ( ! file_exists( $path . '/' . $dir ) ) {
182
-				if ( ! @mkdir( $path . '/' . $dir, 0755 ) ) { // @codingStandardsIgnoreLine
183
-					throw new Exception( __( 'Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe' ) );
181
+			if ( ! file_exists($path . '/' . $dir)) {
182
+				if ( ! @mkdir($path . '/' . $dir, 0755)) { // @codingStandardsIgnoreLine
183
+					throw new Exception(__('Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe'));
184 184
 				}
185 185
 			}
186 186
 
187
-			if ( ! file_exists( $fullpath ) ) {
188
-				if ( ! @copy( WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath ) ) { // @codingStandardsIgnoreLine
189
-					throw new Exception( __( 'Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe' ) );
187
+			if ( ! file_exists($fullpath)) {
188
+				if ( ! @copy(WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath)) { // @codingStandardsIgnoreLine
189
+					throw new Exception(__('Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe'));
190 190
 				}
191 191
 			}
192 192
 
193 193
 			// At this point then the domain association folder and file should be available.
194 194
 			// Proceed to verify/and or verify again.
195
-			$this->register_apple_pay_domain( $this->secret_key );
195
+			$this->register_apple_pay_domain($this->secret_key);
196 196
 
197 197
 			// No errors to this point, verification success!
198 198
 			$this->stripe_settings['apple_pay_domain_set'] = 'yes';
199 199
 			$this->apple_pay_domain_set                    = true;
200 200
 
201
-			update_option( 'woocommerce_stripe_settings', $this->stripe_settings );
201
+			update_option('woocommerce_stripe_settings', $this->stripe_settings);
202 202
 
203
-			WC_Stripe_Logger::log( 'Your domain has been verified with Apple Pay!' );
203
+			WC_Stripe_Logger::log('Your domain has been verified with Apple Pay!');
204 204
 
205
-		} catch ( Exception $e ) {
205
+		} catch (Exception $e) {
206 206
 			$this->stripe_settings['apple_pay_domain_set'] = 'no';
207 207
 
208
-			update_option( 'woocommerce_stripe_settings', $this->stripe_settings );
208
+			update_option('woocommerce_stripe_settings', $this->stripe_settings);
209 209
 
210
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
210
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
211 211
 		}
212 212
 	}
213 213
 
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 	 * @since 4.0.6
218 218
 	 */
219 219
 	public function admin_notices() {
220
-		if ( ! $this->stripe_enabled ) {
220
+		if ( ! $this->stripe_enabled) {
221 221
 			return;
222 222
 		}
223 223
 
224
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
224
+		if ( ! current_user_can('manage_woocommerce')) {
225 225
 			return;
226 226
 		}
227 227
 
228
-		if ( $this->payment_request && ! empty( $this->apple_pay_verify_notice ) ) {
228
+		if ($this->payment_request && ! empty($this->apple_pay_verify_notice)) {
229 229
 			$allowed_html = array(
230 230
 				'a' => array(
231 231
 					'href'  => array(),
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 				),
234 234
 			);
235 235
 
236
-			echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses( make_clickable( $this->apple_pay_verify_notice ), $allowed_html ) . '</p></div>';
236
+			echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses(make_clickable($this->apple_pay_verify_notice), $allowed_html) . '</p></div>';
237 237
 		}
238 238
 
239 239
 		/**
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
 		 * when setting screen is displayed. So if domain verification is not set,
242 242
 		 * something went wrong so lets notify user.
243 243
 		 */
244
-		if ( ! empty( $this->secret_key ) && $this->payment_request && ! $this->apple_pay_domain_set ) {
244
+		if ( ! empty($this->secret_key) && $this->payment_request && ! $this->apple_pay_domain_set) {
245 245
 			/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
246
-			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>';
246
+			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>';
247 247
 		}
248 248
 	}
249 249
 }
Please login to merge, or discard this patch.
includes/class-wc-stripe-customer.php 1 patch
Spacing   +82 added lines, -82 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
 
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 	 * Constructor
33 33
 	 * @param int $user_id The WP user ID
34 34
 	 */
35
-	public function __construct( $user_id = 0 ) {
36
-		if ( $user_id ) {
37
-			$this->set_user_id( $user_id );
38
-			$this->set_id( get_user_meta( $user_id, '_stripe_customer_id', true ) );
35
+	public function __construct($user_id = 0) {
36
+		if ($user_id) {
37
+			$this->set_user_id($user_id);
38
+			$this->set_id(get_user_meta($user_id, '_stripe_customer_id', true));
39 39
 		}
40 40
 	}
41 41
 
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
 	 * Set Stripe customer ID.
52 52
 	 * @param [type] $id [description]
53 53
 	 */
54
-	public function set_id( $id ) {
54
+	public function set_id($id) {
55 55
 		// Backwards compat for customer ID stored in array format. (Pre 3.0)
56
-		if ( is_array( $id ) && isset( $id['customer_id'] ) ) {
56
+		if (is_array($id) && isset($id['customer_id'])) {
57 57
 			$id = $id['customer_id'];
58 58
 
59
-			update_user_meta( $this->get_user_id(), '_stripe_customer_id', $id );
59
+			update_user_meta($this->get_user_id(), '_stripe_customer_id', $id);
60 60
 		}
61 61
 
62
-		$this->id = wc_clean( $id );
62
+		$this->id = wc_clean($id);
63 63
 	}
64 64
 
65 65
 	/**
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
 	 * @return int
68 68
 	 */
69 69
 	public function get_user_id() {
70
-		return absint( $this->user_id );
70
+		return absint($this->user_id);
71 71
 	}
72 72
 
73 73
 	/**
74 74
 	 * Set User ID used by WordPress.
75 75
 	 * @param int $user_id
76 76
 	 */
77
-	public function set_user_id( $user_id ) {
78
-		$this->user_id = absint( $user_id );
77
+	public function set_user_id($user_id) {
78
+		$this->user_id = absint($user_id);
79 79
 	}
80 80
 
81 81
 	/**
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
 	 * @return WP_User
84 84
 	 */
85 85
 	protected function get_user() {
86
-		return $this->get_user_id() ? get_user_by( 'id', $this->get_user_id() ) : false;
86
+		return $this->get_user_id() ? get_user_by('id', $this->get_user_id()) : false;
87 87
 	}
88 88
 
89 89
 	/**
90 90
 	 * Store data from the Stripe API about this customer
91 91
 	 */
92
-	public function set_customer_data( $data ) {
92
+	public function set_customer_data($data) {
93 93
 		$this->customer_data = $data;
94 94
 	}
95 95
 
@@ -98,25 +98,25 @@  discard block
 block discarded – undo
98 98
 	 * @param array $args
99 99
 	 * @return WP_Error|int
100 100
 	 */
101
-	public function create_customer( $args = array() ) {
102
-		$billing_email = isset( $_POST['billing_email'] ) ? filter_var( $_POST['billing_email'], FILTER_SANITIZE_EMAIL ) : '';
101
+	public function create_customer($args = array()) {
102
+		$billing_email = isset($_POST['billing_email']) ? filter_var($_POST['billing_email'], FILTER_SANITIZE_EMAIL) : '';
103 103
 		$user          = $this->get_user();
104 104
 
105
-		if ( $user ) {
106
-			$billing_first_name = get_user_meta( $user->ID, 'billing_first_name', true );
107
-			$billing_last_name  = get_user_meta( $user->ID, 'billing_last_name', true );
105
+		if ($user) {
106
+			$billing_first_name = get_user_meta($user->ID, 'billing_first_name', true);
107
+			$billing_last_name  = get_user_meta($user->ID, 'billing_last_name', true);
108 108
 
109 109
 			// If billing first name does not exists try the user first name.
110
-			if ( empty( $billing_first_name ) ) {
111
-				$billing_first_name = get_user_meta( $user->ID, 'first_name', true );
110
+			if (empty($billing_first_name)) {
111
+				$billing_first_name = get_user_meta($user->ID, 'first_name', true);
112 112
 			}
113 113
 
114 114
 			// If billing last name does not exists try the user last name.
115
-			if ( empty( $billing_last_name ) ) {
116
-				$billing_last_name = get_user_meta( $user->ID, 'last_name', true );
115
+			if (empty($billing_last_name)) {
116
+				$billing_last_name = get_user_meta($user->ID, 'last_name', true);
117 117
 			}
118 118
 
119
-			$description = __( 'Name', 'woocommerce-gateway-stripe' ) . ': ' . $billing_first_name . ' ' . $billing_last_name . ' ' . __( 'Username', 'woocommerce-gateway-stripe' ) . ': ' . $user->user_login;
119
+			$description = __('Name', 'woocommerce-gateway-stripe') . ': ' . $billing_first_name . ' ' . $billing_last_name . ' ' . __('Username', 'woocommerce-gateway-stripe') . ': ' . $user->user_login;
120 120
 
121 121
 			$defaults = array(
122 122
 				'email'       => $user->user_email,
@@ -131,24 +131,24 @@  discard block
 block discarded – undo
131 131
 
132 132
 		$metadata = array();
133 133
 
134
-		$defaults['metadata'] = apply_filters( 'wc_stripe_customer_metadata', $metadata, $user );
134
+		$defaults['metadata'] = apply_filters('wc_stripe_customer_metadata', $metadata, $user);
135 135
 
136
-		$args     = wp_parse_args( $args, $defaults );
137
-		$response = WC_Stripe_API::request( apply_filters( 'wc_stripe_create_customer_args', $args ), 'customers' );
136
+		$args     = wp_parse_args($args, $defaults);
137
+		$response = WC_Stripe_API::request(apply_filters('wc_stripe_create_customer_args', $args), 'customers');
138 138
 
139
-		if ( ! empty( $response->error ) ) {
140
-			throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
139
+		if ( ! empty($response->error)) {
140
+			throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
141 141
 		}
142 142
 
143
-		$this->set_id( $response->id );
143
+		$this->set_id($response->id);
144 144
 		$this->clear_cache();
145
-		$this->set_customer_data( $response );
145
+		$this->set_customer_data($response);
146 146
 
147
-		if ( $this->get_user_id() ) {
148
-			update_user_meta( $this->get_user_id(), '_stripe_customer_id', $response->id );
147
+		if ($this->get_user_id()) {
148
+			update_user_meta($this->get_user_id(), '_stripe_customer_id', $response->id);
149 149
 		}
150 150
 
151
-		do_action( 'woocommerce_stripe_add_customer', $args, $response );
151
+		do_action('woocommerce_stripe_add_customer', $args, $response);
152 152
 
153 153
 		return $response->id;
154 154
 	}
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	 * @since 4.1.2
161 161
 	 * @param array $error
162 162
 	 */
163
-	public function is_no_such_customer_error( $error ) {
163
+	public function is_no_such_customer_error($error) {
164 164
 		return (
165 165
 			$error &&
166 166
 			'invalid_request_error' === $error->type &&
167
-			preg_match( '/No such customer/i', $error->message )
167
+			preg_match('/No such customer/i', $error->message)
168 168
 		);
169 169
 	}
170 170
 
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 	 * @param bool $retry
175 175
 	 * @return WP_Error|int
176 176
 	 */
177
-	public function add_source( $source_id, $retry = true ) {
178
-		if ( ! $this->get_id() ) {
179
-			$this->set_id( $this->create_customer() );
177
+	public function add_source($source_id, $retry = true) {
178
+		if ( ! $this->get_id()) {
179
+			$this->set_id($this->create_customer());
180 180
 		}
181 181
 
182 182
 		$response = WC_Stripe_API::request(
@@ -188,63 +188,63 @@  discard block
 block discarded – undo
188 188
 
189 189
 		$wc_token = false;
190 190
 
191
-		if ( ! empty( $response->error ) ) {
191
+		if ( ! empty($response->error)) {
192 192
 			// It is possible the WC user once was linked to a customer on Stripe
193 193
 			// but no longer exists. Instead of failing, lets try to create a
194 194
 			// new customer.
195
-			if ( $this->is_no_such_customer_error( $response->error ) ) {
196
-				delete_user_meta( $this->get_user_id(), '_stripe_customer_id' );
195
+			if ($this->is_no_such_customer_error($response->error)) {
196
+				delete_user_meta($this->get_user_id(), '_stripe_customer_id');
197 197
 				$this->create_customer();
198
-				return $this->add_source( $source_id, false );
198
+				return $this->add_source($source_id, false);
199 199
 			} else {
200 200
 				return $response;
201 201
 			}
202
-		} elseif ( empty( $response->id ) ) {
203
-			return new WP_Error( 'error', __( 'Unable to add payment source.', 'woocommerce-gateway-stripe' ) );
202
+		} elseif (empty($response->id)) {
203
+			return new WP_Error('error', __('Unable to add payment source.', 'woocommerce-gateway-stripe'));
204 204
 		}
205 205
 
206 206
 		// Add token to WooCommerce.
207
-		if ( $this->get_user_id() && class_exists( 'WC_Payment_Token_CC' ) ) {
208
-			if ( ! empty( $response->type ) ) {
209
-				switch ( $response->type ) {
207
+		if ($this->get_user_id() && class_exists('WC_Payment_Token_CC')) {
208
+			if ( ! empty($response->type)) {
209
+				switch ($response->type) {
210 210
 					case 'alipay':
211 211
 						break;
212 212
 					case 'sepa_debit':
213 213
 						$wc_token = new WC_Payment_Token_SEPA();
214
-						$wc_token->set_token( $response->id );
215
-						$wc_token->set_gateway_id( 'stripe_sepa' );
216
-						$wc_token->set_last4( $response->sepa_debit->last4 );
214
+						$wc_token->set_token($response->id);
215
+						$wc_token->set_gateway_id('stripe_sepa');
216
+						$wc_token->set_last4($response->sepa_debit->last4);
217 217
 						break;
218 218
 					default:
219
-						if ( 'source' === $response->object && 'card' === $response->type ) {
219
+						if ('source' === $response->object && 'card' === $response->type) {
220 220
 							$wc_token = new WC_Payment_Token_CC();
221
-							$wc_token->set_token( $response->id );
222
-							$wc_token->set_gateway_id( 'stripe' );
223
-							$wc_token->set_card_type( strtolower( $response->card->brand ) );
224
-							$wc_token->set_last4( $response->card->last4 );
225
-							$wc_token->set_expiry_month( $response->card->exp_month );
226
-							$wc_token->set_expiry_year( $response->card->exp_year );
221
+							$wc_token->set_token($response->id);
222
+							$wc_token->set_gateway_id('stripe');
223
+							$wc_token->set_card_type(strtolower($response->card->brand));
224
+							$wc_token->set_last4($response->card->last4);
225
+							$wc_token->set_expiry_month($response->card->exp_month);
226
+							$wc_token->set_expiry_year($response->card->exp_year);
227 227
 						}
228 228
 						break;
229 229
 				}
230 230
 			} else {
231 231
 				// Legacy.
232 232
 				$wc_token = new WC_Payment_Token_CC();
233
-				$wc_token->set_token( $response->id );
234
-				$wc_token->set_gateway_id( 'stripe' );
235
-				$wc_token->set_card_type( strtolower( $response->brand ) );
236
-				$wc_token->set_last4( $response->last4 );
237
-				$wc_token->set_expiry_month( $response->exp_month );
238
-				$wc_token->set_expiry_year( $response->exp_year );
233
+				$wc_token->set_token($response->id);
234
+				$wc_token->set_gateway_id('stripe');
235
+				$wc_token->set_card_type(strtolower($response->brand));
236
+				$wc_token->set_last4($response->last4);
237
+				$wc_token->set_expiry_month($response->exp_month);
238
+				$wc_token->set_expiry_year($response->exp_year);
239 239
 			}
240 240
 
241
-			$wc_token->set_user_id( $this->get_user_id() );
241
+			$wc_token->set_user_id($this->get_user_id());
242 242
 			$wc_token->save();
243 243
 		}
244 244
 
245 245
 		$this->clear_cache();
246 246
 
247
-		do_action( 'woocommerce_stripe_add_source', $this->get_id(), $wc_token, $response, $source_id );
247
+		do_action('woocommerce_stripe_add_source', $this->get_id(), $wc_token, $response, $source_id);
248 248
 
249 249
 		return $response->id;
250 250
 	}
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
 	 * @return array
257 257
 	 */
258 258
 	public function get_sources() {
259
-		if ( ! $this->get_id() ) {
259
+		if ( ! $this->get_id()) {
260 260
 			return array();
261 261
 		}
262 262
 
263
-		$sources = get_transient( 'stripe_sources_' . $this->get_id() );
263
+		$sources = get_transient('stripe_sources_' . $this->get_id());
264 264
 
265 265
 		$response = WC_Stripe_API::request(
266 266
 			array(
@@ -270,32 +270,32 @@  discard block
 block discarded – undo
270 270
 			'GET'
271 271
 		);
272 272
 
273
-		if ( ! empty( $response->error ) ) {
273
+		if ( ! empty($response->error)) {
274 274
 			return array();
275 275
 		}
276 276
 
277
-		if ( is_array( $response->data ) ) {
277
+		if (is_array($response->data)) {
278 278
 			$sources = $response->data;
279 279
 		}
280 280
 
281
-		return empty( $sources ) ? array() : $sources;
281
+		return empty($sources) ? array() : $sources;
282 282
 	}
283 283
 
284 284
 	/**
285 285
 	 * Delete a source from stripe.
286 286
 	 * @param string $source_id
287 287
 	 */
288
-	public function delete_source( $source_id ) {
289
-		if ( ! $this->get_id() ) {
288
+	public function delete_source($source_id) {
289
+		if ( ! $this->get_id()) {
290 290
 			return false;
291 291
 		}
292 292
 
293
-		$response = WC_Stripe_API::request( array(), 'customers/' . $this->get_id() . '/sources/' . sanitize_text_field( $source_id ), 'DELETE' );
293
+		$response = WC_Stripe_API::request(array(), 'customers/' . $this->get_id() . '/sources/' . sanitize_text_field($source_id), 'DELETE');
294 294
 
295 295
 		$this->clear_cache();
296 296
 
297
-		if ( empty( $response->error ) ) {
298
-			do_action( 'wc_stripe_delete_source', $this->get_id(), $response );
297
+		if (empty($response->error)) {
298
+			do_action('wc_stripe_delete_source', $this->get_id(), $response);
299 299
 
300 300
 			return true;
301 301
 		}
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	 * Set default source in Stripe
308 308
 	 * @param string $source_id
309 309
 	 */
310
-	public function set_default_source( $source_id ) {
310
+	public function set_default_source($source_id) {
311 311
 		$response = WC_Stripe_API::request(
312 312
 			array(
313
-				'default_source' => sanitize_text_field( $source_id ),
313
+				'default_source' => sanitize_text_field($source_id),
314 314
 			),
315 315
 			'customers/' . $this->get_id(),
316 316
 			'POST'
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 
319 319
 		$this->clear_cache();
320 320
 
321
-		if ( empty( $response->error ) ) {
322
-			do_action( 'wc_stripe_set_default_source', $this->get_id(), $response );
321
+		if (empty($response->error)) {
322
+			do_action('wc_stripe_set_default_source', $this->get_id(), $response);
323 323
 
324 324
 			return true;
325 325
 		}
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 	 * Deletes caches for this users cards.
332 332
 	 */
333 333
 	public function clear_cache() {
334
-		delete_transient( 'stripe_sources_' . $this->get_id() );
335
-		delete_transient( 'stripe_customer_' . $this->get_id() );
334
+		delete_transient('stripe_sources_' . $this->get_id());
335
+		delete_transient('stripe_customer_' . $this->get_id());
336 336
 		$this->customer_data = array();
337 337
 	}
338 338
 }
Please login to merge, or discard this patch.
includes/class-wc-stripe-helper.php 1 patch
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 	 * @param object $order
23 23
 	 * @return string $currency
24 24
 	 */
25
-	public static function get_stripe_currency( $order = null ) {
26
-		if ( is_null( $order ) ) {
25
+	public static function get_stripe_currency($order = null) {
26
+		if (is_null($order)) {
27 27
 			return false;
28 28
 		}
29 29
 
30
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
30
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
31 31
 
32
-		return WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::META_NAME_STRIPE_CURRENCY, true ) : $order->get_meta( self::META_NAME_STRIPE_CURRENCY, true );
32
+		return WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::META_NAME_STRIPE_CURRENCY, true) : $order->get_meta(self::META_NAME_STRIPE_CURRENCY, true);
33 33
 	}
34 34
 
35 35
 	/**
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 	 * @param object $order
40 40
 	 * @param string $currency
41 41
 	 */
42
-	public static function update_stripe_currency( $order = null, $currency ) {
43
-		if ( is_null( $order ) ) {
42
+	public static function update_stripe_currency($order = null, $currency) {
43
+		if (is_null($order)) {
44 44
 			return false;
45 45
 		}
46 46
 
47
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
47
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
48 48
 
49
-		WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, self::META_NAME_STRIPE_CURRENCY, $currency ) : $order->update_meta_data( self::META_NAME_STRIPE_CURRENCY, $currency );
49
+		WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, self::META_NAME_STRIPE_CURRENCY, $currency) : $order->update_meta_data(self::META_NAME_STRIPE_CURRENCY, $currency);
50 50
 	}
51 51
 
52 52
 	/**
@@ -56,22 +56,22 @@  discard block
 block discarded – undo
56 56
 	 * @param object $order
57 57
 	 * @return string $amount
58 58
 	 */
59
-	public static function get_stripe_fee( $order = null ) {
60
-		if ( is_null( $order ) ) {
59
+	public static function get_stripe_fee($order = null) {
60
+		if (is_null($order)) {
61 61
 			return false;
62 62
 		}
63 63
 
64
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
64
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
65 65
 
66
-		$amount = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::META_NAME_FEE, true ) : $order->get_meta( self::META_NAME_FEE, true );
66
+		$amount = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::META_NAME_FEE, true) : $order->get_meta(self::META_NAME_FEE, true);
67 67
 
68 68
 		// If not found let's check for legacy name.
69
-		if ( empty( $amount ) ) {
70
-			$amount = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::LEGACY_META_NAME_FEE, true ) : $order->get_meta( self::LEGACY_META_NAME_FEE, true );
69
+		if (empty($amount)) {
70
+			$amount = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::LEGACY_META_NAME_FEE, true) : $order->get_meta(self::LEGACY_META_NAME_FEE, true);
71 71
 
72 72
 			// If found update to new name.
73
-			if ( $amount ) {
74
-				self::update_stripe_fee( $order, $amount );
73
+			if ($amount) {
74
+				self::update_stripe_fee($order, $amount);
75 75
 			}
76 76
 		}
77 77
 
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 	 * @param object $order
86 86
 	 * @param float $amount
87 87
 	 */
88
-	public static function update_stripe_fee( $order = null, $amount = 0.0 ) {
89
-		if ( is_null( $order ) ) {
88
+	public static function update_stripe_fee($order = null, $amount = 0.0) {
89
+		if (is_null($order)) {
90 90
 			return false;
91 91
 		}
92 92
 
93
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
93
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
94 94
 
95
-		WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, self::META_NAME_FEE, $amount ) : $order->update_meta_data( self::META_NAME_FEE, $amount );
95
+		WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, self::META_NAME_FEE, $amount) : $order->update_meta_data(self::META_NAME_FEE, $amount);
96 96
 	}
97 97
 
98 98
 	/**
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 	 * @since 4.1.0
102 102
 	 * @param object $order
103 103
 	 */
104
-	public static function delete_stripe_fee( $order = null ) {
105
-		if ( is_null( $order ) ) {
104
+	public static function delete_stripe_fee($order = null) {
105
+		if (is_null($order)) {
106 106
 			return false;
107 107
 		}
108 108
 
109
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
109
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
110 110
 
111
-		delete_post_meta( $order_id, self::META_NAME_FEE );
112
-		delete_post_meta( $order_id, self::LEGACY_META_NAME_FEE );
111
+		delete_post_meta($order_id, self::META_NAME_FEE);
112
+		delete_post_meta($order_id, self::LEGACY_META_NAME_FEE);
113 113
 	}
114 114
 
115 115
 	/**
@@ -119,22 +119,22 @@  discard block
 block discarded – undo
119 119
 	 * @param object $order
120 120
 	 * @return string $amount
121 121
 	 */
122
-	public static function get_stripe_net( $order = null ) {
123
-		if ( is_null( $order ) ) {
122
+	public static function get_stripe_net($order = null) {
123
+		if (is_null($order)) {
124 124
 			return false;
125 125
 		}
126 126
 
127
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
127
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
128 128
 
129
-		$amount = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::META_NAME_NET, true ) : $order->get_meta( self::META_NAME_NET, true );
129
+		$amount = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::META_NAME_NET, true) : $order->get_meta(self::META_NAME_NET, true);
130 130
 
131 131
 		// If not found let's check for legacy name.
132
-		if ( empty( $amount ) ) {
133
-			$amount = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::LEGACY_META_NAME_NET, true ) : $order->get_meta( self::LEGACY_META_NAME_NET, true );
132
+		if (empty($amount)) {
133
+			$amount = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::LEGACY_META_NAME_NET, true) : $order->get_meta(self::LEGACY_META_NAME_NET, true);
134 134
 
135 135
 			// If found update to new name.
136
-			if ( $amount ) {
137
-				self::update_stripe_net( $order, $amount );
136
+			if ($amount) {
137
+				self::update_stripe_net($order, $amount);
138 138
 			}
139 139
 		}
140 140
 
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 	 * @param object $order
149 149
 	 * @param float $amount
150 150
 	 */
151
-	public static function update_stripe_net( $order = null, $amount = 0.0 ) {
152
-		if ( is_null( $order ) ) {
151
+	public static function update_stripe_net($order = null, $amount = 0.0) {
152
+		if (is_null($order)) {
153 153
 			return false;
154 154
 		}
155 155
 
156
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
156
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
157 157
 
158
-		WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, self::META_NAME_NET, $amount ) : $order->update_meta_data( self::META_NAME_NET, $amount );
158
+		WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, self::META_NAME_NET, $amount) : $order->update_meta_data(self::META_NAME_NET, $amount);
159 159
 	}
160 160
 
161 161
 	/**
@@ -164,15 +164,15 @@  discard block
 block discarded – undo
164 164
 	 * @since 4.1.0
165 165
 	 * @param object $order
166 166
 	 */
167
-	public static function delete_stripe_net( $order = null ) {
168
-		if ( is_null( $order ) ) {
167
+	public static function delete_stripe_net($order = null) {
168
+		if (is_null($order)) {
169 169
 			return false;
170 170
 		}
171 171
 
172
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
172
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
173 173
 
174
-		delete_post_meta( $order_id, self::META_NAME_NET );
175
-		delete_post_meta( $order_id, self::LEGACY_META_NAME_NET );
174
+		delete_post_meta($order_id, self::META_NAME_NET);
175
+		delete_post_meta($order_id, self::LEGACY_META_NAME_NET);
176 176
 	}
177 177
 
178 178
 	/**
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @return float|int
185 185
 	 */
186
-	public static function get_stripe_amount( $total, $currency = '' ) {
187
-		if ( ! $currency ) {
186
+	public static function get_stripe_amount($total, $currency = '') {
187
+		if ( ! $currency) {
188 188
 			$currency = get_woocommerce_currency();
189 189
 		}
190 190
 
191
-		if ( in_array( strtolower( $currency ), self::no_decimal_currencies() ) ) {
192
-			return absint( $total );
191
+		if (in_array(strtolower($currency), self::no_decimal_currencies())) {
192
+			return absint($total);
193 193
 		} else {
194
-			return absint( wc_format_decimal( ( (float) $total * 100 ), wc_get_price_decimals() ) ); // In cents.
194
+			return absint(wc_format_decimal(((float) $total * 100), wc_get_price_decimals())); // In cents.
195 195
 		}
196 196
 	}
197 197
 
@@ -206,23 +206,23 @@  discard block
 block discarded – undo
206 206
 		return apply_filters(
207 207
 			'wc_stripe_localized_messages',
208 208
 			array(
209
-				'invalid_number'           => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ),
210
-				'invalid_expiry_month'     => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ),
211
-				'invalid_expiry_year'      => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ),
212
-				'invalid_cvc'              => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ),
213
-				'incorrect_number'         => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ),
214
-				'incomplete_number'        => __( 'The card number is incomplete.', 'woocommerce-gateway-stripe' ),
215
-				'incomplete_cvc'           => __( 'The card\'s security code is incomplete.', 'woocommerce-gateway-stripe' ),
216
-				'incomplete_expiry'        => __( 'The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe' ),
217
-				'expired_card'             => __( 'The card has expired.', 'woocommerce-gateway-stripe' ),
218
-				'incorrect_cvc'            => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ),
219
-				'incorrect_zip'            => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ),
220
-				'invalid_expiry_year_past' => __( 'The card\'s expiration year is in the past', 'woocommerce-gateway-stripe' ),
221
-				'card_declined'            => __( 'The card was declined.', 'woocommerce-gateway-stripe' ),
222
-				'missing'                  => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ),
223
-				'processing_error'         => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ),
224
-				'invalid_request_error'    => __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ),
225
-				'invalid_sofort_country'   => __( 'The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe' ),
209
+				'invalid_number'           => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'),
210
+				'invalid_expiry_month'     => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'),
211
+				'invalid_expiry_year'      => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'),
212
+				'invalid_cvc'              => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'),
213
+				'incorrect_number'         => __('The card number is incorrect.', 'woocommerce-gateway-stripe'),
214
+				'incomplete_number'        => __('The card number is incomplete.', 'woocommerce-gateway-stripe'),
215
+				'incomplete_cvc'           => __('The card\'s security code is incomplete.', 'woocommerce-gateway-stripe'),
216
+				'incomplete_expiry'        => __('The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe'),
217
+				'expired_card'             => __('The card has expired.', 'woocommerce-gateway-stripe'),
218
+				'incorrect_cvc'            => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'),
219
+				'incorrect_zip'            => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'),
220
+				'invalid_expiry_year_past' => __('The card\'s expiration year is in the past', 'woocommerce-gateway-stripe'),
221
+				'card_declined'            => __('The card was declined.', 'woocommerce-gateway-stripe'),
222
+				'missing'                  => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'),
223
+				'processing_error'         => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'),
224
+				'invalid_request_error'    => __('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe'),
225
+				'invalid_sofort_country'   => __('The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe'),
226 226
 			)
227 227
 		);
228 228
 	}
@@ -261,24 +261,24 @@  discard block
 block discarded – undo
261 261
 	 * @param string $type Type of number to format
262 262
 	 * @return string
263 263
 	 */
264
-	public static function format_balance_fee( $balance_transaction, $type = 'fee' ) {
265
-		if ( ! is_object( $balance_transaction ) ) {
264
+	public static function format_balance_fee($balance_transaction, $type = 'fee') {
265
+		if ( ! is_object($balance_transaction)) {
266 266
 			return;
267 267
 		}
268 268
 
269
-		if ( in_array( strtolower( $balance_transaction->currency ), self::no_decimal_currencies() ) ) {
270
-			if ( 'fee' === $type ) {
269
+		if (in_array(strtolower($balance_transaction->currency), self::no_decimal_currencies())) {
270
+			if ('fee' === $type) {
271 271
 				return $balance_transaction->fee;
272 272
 			}
273 273
 
274 274
 			return $balance_transaction->net;
275 275
 		}
276 276
 
277
-		if ( 'fee' === $type ) {
278
-			return number_format( $balance_transaction->fee / 100, 2, '.', '' );
277
+		if ('fee' === $type) {
278
+			return number_format($balance_transaction->fee / 100, 2, '.', '');
279 279
 		}
280 280
 
281
-		return number_format( $balance_transaction->net / 100, 2, '.', '' );
281
+		return number_format($balance_transaction->net / 100, 2, '.', '');
282 282
 	}
283 283
 
284 284
 	/**
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	public static function get_minimum_amount() {
288 288
 		// Check order amount
289
-		switch ( get_woocommerce_currency() ) {
289
+		switch (get_woocommerce_currency()) {
290 290
 			case 'USD':
291 291
 			case 'CAD':
292 292
 			case 'EUR':
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
 	 * @param string $method The payment method to get the settings from.
332 332
 	 * @param string $setting The name of the setting to get.
333 333
 	 */
334
-	public static function get_settings( $method = null, $setting = null ) {
335
-		$all_settings = null === $method ? get_option( 'woocommerce_stripe_settings', array() ) : get_option( 'woocommerce_stripe_' . $method . '_settings', array() );
334
+	public static function get_settings($method = null, $setting = null) {
335
+		$all_settings = null === $method ? get_option('woocommerce_stripe_settings', array()) : get_option('woocommerce_stripe_' . $method . '_settings', array());
336 336
 
337
-		if ( null === $setting ) {
337
+		if (null === $setting) {
338 338
 			return $all_settings;
339 339
 		}
340 340
 
341
-		return isset( $all_settings[ $setting ] ) ? $all_settings[ $setting ] : '';
341
+		return isset($all_settings[$setting]) ? $all_settings[$setting] : '';
342 342
 	}
343 343
 
344 344
 	/**
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	 * @return bool
349 349
 	 */
350 350
 	public static function is_pre_orders_exists() {
351
-		return class_exists( 'WC_Pre_Orders_Order' );
351
+		return class_exists('WC_Pre_Orders_Order');
352 352
 	}
353 353
 
354 354
 	/**
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 	 * @return bool
361 361
 	 */
362 362
 	public static function is_pre_30() {
363
-		error_log( 'is_pre_30() function has been deprecated since 4.1.11. Please use is_wc_lt( $version ) instead.' );
363
+		error_log('is_pre_30() function has been deprecated since 4.1.11. Please use is_wc_lt( $version ) instead.');
364 364
 
365
-		return self::is_wc_lt( '3.0' );
365
+		return self::is_wc_lt('3.0');
366 366
 	}
367 367
 
368 368
 	/**
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
 	 * @param string $version Version to check against.
373 373
 	 * @return bool
374 374
 	 */
375
-	public static function is_wc_lt( $version ) {
376
-		return version_compare( WC_VERSION, $version, '<' );
375
+	public static function is_wc_lt($version) {
376
+		return version_compare(WC_VERSION, $version, '<');
377 377
 	}
378 378
 
379 379
 	/**
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 	 * @return string
387 387
 	 */
388 388
 	public static function get_webhook_url() {
389
-		return add_query_arg( 'wc-api', 'wc_stripe', trailingslashit( get_home_url() ) );
389
+		return add_query_arg('wc-api', 'wc_stripe', trailingslashit(get_home_url()));
390 390
 	}
391 391
 
392 392
 	/**
@@ -396,13 +396,13 @@  discard block
 block discarded – undo
396 396
 	 * @version 4.0.0
397 397
 	 * @param string $source_id
398 398
 	 */
399
-	public static function get_order_by_source_id( $source_id ) {
399
+	public static function get_order_by_source_id($source_id) {
400 400
 		global $wpdb;
401 401
 
402
-		$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $source_id, '_stripe_source_id' ) );
402
+		$order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $source_id, '_stripe_source_id'));
403 403
 
404
-		if ( ! empty( $order_id ) ) {
405
-			return wc_get_order( $order_id );
404
+		if ( ! empty($order_id)) {
405
+			return wc_get_order($order_id);
406 406
 		}
407 407
 
408 408
 		return false;
@@ -415,13 +415,13 @@  discard block
 block discarded – undo
415 415
 	 * @version 4.0.0
416 416
 	 * @param string $charge_id
417 417
 	 */
418
-	public static function get_order_by_charge_id( $charge_id ) {
418
+	public static function get_order_by_charge_id($charge_id) {
419 419
 		global $wpdb;
420 420
 
421
-		$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $charge_id, '_transaction_id' ) );
421
+		$order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $charge_id, '_transaction_id'));
422 422
 
423
-		if ( ! empty( $order_id ) ) {
424
-			return wc_get_order( $order_id );
423
+		if ( ! empty($order_id)) {
424
+			return wc_get_order($order_id);
425 425
 		}
426 426
 
427 427
 		return false;
@@ -437,13 +437,13 @@  discard block
 block discarded – undo
437 437
 	 * @param string $statement_descriptor
438 438
 	 * @return string $statement_descriptor Sanitized statement descriptor
439 439
 	 */
440
-	public static function clean_statement_descriptor( $statement_descriptor = '' ) {
441
-		$disallowed_characters = array( '<', '>', '"', "'" );
440
+	public static function clean_statement_descriptor($statement_descriptor = '') {
441
+		$disallowed_characters = array('<', '>', '"', "'");
442 442
 
443 443
 		// Remove special characters.
444
-		$statement_descriptor = str_replace( $disallowed_characters, '', $statement_descriptor );
444
+		$statement_descriptor = str_replace($disallowed_characters, '', $statement_descriptor);
445 445
 
446
-		$statement_descriptor = substr( trim( $statement_descriptor ), 0, 22 );
446
+		$statement_descriptor = substr(trim($statement_descriptor), 0, 22);
447 447
 
448 448
 		return $statement_descriptor;
449 449
 	}
Please login to merge, or discard this patch.
includes/class-wc-stripe-exception.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @since 4.0.2
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 	 * @param string $error_message Full response
24 24
 	 * @param string $localized_message user-friendly translated error message
25 25
 	 */
26
-	public function __construct( $error_message = '', $localized_message = '' ) {
26
+	public function __construct($error_message = '', $localized_message = '') {
27 27
 		$this->localized_message = $localized_message;
28
-		parent::__construct( $error_message );
28
+		parent::__construct($error_message);
29 29
 	}
30 30
 
31 31
 	/**
Please login to merge, or discard this patch.
includes/class-wc-stripe-logger.php 1 patch
Spacing   +16 added lines, -16 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
 
@@ -20,32 +20,32 @@  discard block
 block discarded – undo
20 20
 	 * @since 4.0.0
21 21
 	 * @version 4.0.0
22 22
 	 */
23
-	public static function log( $message, $start_time = null, $end_time = null ) {
24
-		if ( ! class_exists( 'WC_Logger' ) ) {
23
+	public static function log($message, $start_time = null, $end_time = null) {
24
+		if ( ! class_exists('WC_Logger')) {
25 25
 			return;
26 26
 		}
27 27
 
28
-		if ( apply_filters( 'wc_stripe_logging', true, $message ) ) {
29
-			if ( empty( self::$logger ) ) {
30
-				if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
28
+		if (apply_filters('wc_stripe_logging', true, $message)) {
29
+			if (empty(self::$logger)) {
30
+				if (WC_Stripe_Helper::is_wc_lt('3.0')) {
31 31
 					self::$logger = new WC_Logger();
32 32
 				} else {
33 33
 					self::$logger = wc_get_logger();
34 34
 				}
35 35
 			}
36 36
 
37
-			$settings = get_option( 'woocommerce_stripe_settings' );
37
+			$settings = get_option('woocommerce_stripe_settings');
38 38
 
39
-			if ( empty( $settings ) || isset( $settings['logging'] ) && 'yes' !== $settings['logging'] ) {
39
+			if (empty($settings) || isset($settings['logging']) && 'yes' !== $settings['logging']) {
40 40
 				return;
41 41
 			}
42 42
 
43
-			if ( ! is_null( $start_time ) ) {
43
+			if ( ! is_null($start_time)) {
44 44
 
45
-				$formatted_start_time = date_i18n( get_option( 'date_format' ) . ' g:ia', $start_time );
46
-				$end_time             = is_null( $end_time ) ? current_time( 'timestamp' ) : $end_time;
47
-				$formatted_end_time   = date_i18n( get_option( 'date_format' ) . ' g:ia', $end_time );
48
-				$elapsed_time         = round( abs( $end_time - $start_time ) / 60, 2 );
45
+				$formatted_start_time = date_i18n(get_option('date_format') . ' g:ia', $start_time);
46
+				$end_time             = is_null($end_time) ? current_time('timestamp') : $end_time;
47
+				$formatted_end_time   = date_i18n(get_option('date_format') . ' g:ia', $end_time);
48
+				$elapsed_time         = round(abs($end_time - $start_time) / 60, 2);
49 49
 
50 50
 				$log_entry  = "\n" . '====Stripe Version: ' . WC_STRIPE_VERSION . '====' . "\n";
51 51
 				$log_entry .= '====Start Log ' . $formatted_start_time . '====' . "\n" . $message . "\n";
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 
58 58
 			}
59 59
 
60
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
61
-				self::$logger->add( self::WC_LOG_FILENAME, $log_entry );
60
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
61
+				self::$logger->add(self::WC_LOG_FILENAME, $log_entry);
62 62
 			} else {
63
-				self::$logger->debug( $log_entry, array( 'source' => self::WC_LOG_FILENAME ) );
63
+				self::$logger->debug($log_entry, array('source' => self::WC_LOG_FILENAME));
64 64
 			}
65 65
 		}
66 66
 	}
Please login to merge, or discard this patch.