@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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,14 +31,14 @@ discard block |
||
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 | ), |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | |
47 | 47 | $index = null; |
48 | 48 | |
49 | - foreach ( $settings as $key => $value) { |
|
50 | - if ( 'sectionend' === $value[ 'type' ] && 'personal_data_retention' === $value[ 'id' ] ) { |
|
49 | + foreach ($settings as $key => $value) { |
|
50 | + if ('sectionend' === $value['type'] && 'personal_data_retention' === $value['id']) { |
|
51 | 51 | $index = $key; |
52 | 52 | break; |
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - if ( ! is_null( $index ) ) { |
|
57 | - array_splice( $settings, $index, 0, $insert_setting ); |
|
56 | + if ( ! is_null($index)) { |
|
57 | + array_splice($settings, $index, 0, $insert_setting); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return $settings; |
@@ -68,22 +68,22 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return array WP_Post |
70 | 70 | */ |
71 | - protected function get_stripe_orders( $email_address, $page ) { |
|
72 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
71 | + protected function get_stripe_orders($email_address, $page) { |
|
72 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
73 | 73 | |
74 | 74 | $order_query = array( |
75 | - 'payment_method' => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ), |
|
75 | + 'payment_method' => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'), |
|
76 | 76 | 'limit' => 10, |
77 | 77 | 'page' => $page, |
78 | 78 | ); |
79 | 79 | |
80 | - if ( $user instanceof WP_User ) { |
|
80 | + if ($user instanceof WP_User) { |
|
81 | 81 | $order_query['customer_id'] = (int) $user->ID; |
82 | 82 | } else { |
83 | 83 | $order_query['billing_email'] = $email_address; |
84 | 84 | } |
85 | 85 | |
86 | - return wc_get_orders( $order_query ); |
|
86 | + return wc_get_orders($order_query); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function get_privacy_message() { |
94 | 94 | /* translators: %s URL to docs */ |
95 | - 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' ) ); |
|
95 | + 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')); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -103,34 +103,34 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return array |
105 | 105 | */ |
106 | - public function order_data_exporter( $email_address, $page = 1 ) { |
|
106 | + public function order_data_exporter($email_address, $page = 1) { |
|
107 | 107 | $done = false; |
108 | 108 | $data_to_export = array(); |
109 | 109 | |
110 | - $orders = $this->get_stripe_orders( $email_address, (int) $page ); |
|
110 | + $orders = $this->get_stripe_orders($email_address, (int) $page); |
|
111 | 111 | |
112 | 112 | $done = true; |
113 | 113 | |
114 | - if ( 0 < count( $orders ) ) { |
|
115 | - foreach ( $orders as $order ) { |
|
114 | + if (0 < count($orders)) { |
|
115 | + foreach ($orders as $order) { |
|
116 | 116 | $data_to_export[] = array( |
117 | 117 | 'group_id' => 'woocommerce_orders', |
118 | - 'group_label' => __( 'Orders', 'woocommerce-gateway-stripe' ), |
|
118 | + 'group_label' => __('Orders', 'woocommerce-gateway-stripe'), |
|
119 | 119 | 'item_id' => 'order-' . $order->get_id(), |
120 | 120 | 'data' => array( |
121 | 121 | array( |
122 | - 'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ), |
|
123 | - 'value' => get_post_meta( $order->get_id(), '_stripe_source_id', true ), |
|
122 | + 'name' => __('Stripe payment id', 'woocommerce-gateway-stripe'), |
|
123 | + 'value' => get_post_meta($order->get_id(), '_stripe_source_id', true), |
|
124 | 124 | ), |
125 | 125 | array( |
126 | - 'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ), |
|
127 | - 'value' => get_post_meta( $order->get_id(), '_stripe_customer_id', true ), |
|
126 | + 'name' => __('Stripe customer id', 'woocommerce-gateway-stripe'), |
|
127 | + 'value' => get_post_meta($order->get_id(), '_stripe_customer_id', true), |
|
128 | 128 | ), |
129 | 129 | ), |
130 | 130 | ); |
131 | 131 | } |
132 | 132 | |
133 | - $done = 10 > count( $orders ); |
|
133 | + $done = 10 > count($orders); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | return array( |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return array |
149 | 149 | */ |
150 | - public function subscriptions_data_exporter( $email_address, $page = 1 ) { |
|
150 | + public function subscriptions_data_exporter($email_address, $page = 1) { |
|
151 | 151 | $done = false; |
152 | 152 | $page = (int) $page; |
153 | 153 | $data_to_export = array(); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'relation' => 'AND', |
157 | 157 | array( |
158 | 158 | 'key' => '_payment_method', |
159 | - 'value' => array( 'stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort' ), |
|
159 | + 'value' => array('stripe', 'stripe_alipay', 'stripe_bancontact', 'stripe_eps', 'stripe_giropay', 'stripe_ideal', 'stripe_multibanco', 'stripe_p24', 'stripe_sepa', 'stripe_sofort'), |
|
160 | 160 | 'compare' => 'IN', |
161 | 161 | ), |
162 | 162 | array( |
@@ -172,30 +172,30 @@ discard block |
||
172 | 172 | 'meta_query' => $meta_query, |
173 | 173 | ); |
174 | 174 | |
175 | - $subscriptions = wcs_get_subscriptions( $subscription_query ); |
|
175 | + $subscriptions = wcs_get_subscriptions($subscription_query); |
|
176 | 176 | |
177 | 177 | $done = true; |
178 | 178 | |
179 | - if ( 0 < count( $subscriptions ) ) { |
|
180 | - foreach ( $subscriptions as $subscription ) { |
|
179 | + if (0 < count($subscriptions)) { |
|
180 | + foreach ($subscriptions as $subscription) { |
|
181 | 181 | $data_to_export[] = array( |
182 | 182 | 'group_id' => 'woocommerce_subscriptions', |
183 | - 'group_label' => __( 'Subscriptions', 'woocommerce-gateway-stripe' ), |
|
183 | + 'group_label' => __('Subscriptions', 'woocommerce-gateway-stripe'), |
|
184 | 184 | 'item_id' => 'subscription-' . $subscription->get_id(), |
185 | 185 | 'data' => array( |
186 | 186 | array( |
187 | - 'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ), |
|
188 | - 'value' => get_post_meta( $subscription->get_id(), '_stripe_source_id', true ), |
|
187 | + 'name' => __('Stripe payment id', 'woocommerce-gateway-stripe'), |
|
188 | + 'value' => get_post_meta($subscription->get_id(), '_stripe_source_id', true), |
|
189 | 189 | ), |
190 | 190 | array( |
191 | - 'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ), |
|
192 | - 'value' => get_post_meta( $subscription->get_id(), '_stripe_customer_id', true ), |
|
191 | + 'name' => __('Stripe customer id', 'woocommerce-gateway-stripe'), |
|
192 | + 'value' => get_post_meta($subscription->get_id(), '_stripe_customer_id', true), |
|
193 | 193 | ), |
194 | 194 | ), |
195 | 195 | ); |
196 | 196 | } |
197 | 197 | |
198 | - $done = 10 > count( $subscriptions ); |
|
198 | + $done = 10 > count($subscriptions); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | return array( |
@@ -211,24 +211,24 @@ discard block |
||
211 | 211 | * @param int $page Page. |
212 | 212 | * @return array An array of personal data in name value pairs |
213 | 213 | */ |
214 | - public function customer_data_exporter( $email_address, $page ) { |
|
215 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
214 | + public function customer_data_exporter($email_address, $page) { |
|
215 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
216 | 216 | $data_to_export = array(); |
217 | 217 | |
218 | - if ( $user instanceof WP_User ) { |
|
219 | - $stripe_user = new WC_Stripe_Customer( $user->ID ); |
|
218 | + if ($user instanceof WP_User) { |
|
219 | + $stripe_user = new WC_Stripe_Customer($user->ID); |
|
220 | 220 | |
221 | 221 | $data_to_export[] = array( |
222 | 222 | 'group_id' => 'woocommerce_customer', |
223 | - 'group_label' => __( 'Customer Data', 'woocommerce-gateway-stripe' ), |
|
223 | + 'group_label' => __('Customer Data', 'woocommerce-gateway-stripe'), |
|
224 | 224 | 'item_id' => 'user', |
225 | 225 | 'data' => array( |
226 | 226 | array( |
227 | - 'name' => __( 'Stripe payment id', 'woocommerce-gateway-stripe' ), |
|
228 | - 'value' => get_user_meta( $user->ID, '_stripe_source_id', true ), |
|
227 | + 'name' => __('Stripe payment id', 'woocommerce-gateway-stripe'), |
|
228 | + 'value' => get_user_meta($user->ID, '_stripe_source_id', true), |
|
229 | 229 | ), |
230 | 230 | array( |
231 | - 'name' => __( 'Stripe customer id', 'woocommerce-gateway-stripe' ), |
|
231 | + 'name' => __('Stripe customer id', 'woocommerce-gateway-stripe'), |
|
232 | 232 | 'value' => $stripe_user->get_id(), |
233 | 233 | ), |
234 | 234 | ), |
@@ -248,25 +248,25 @@ discard block |
||
248 | 248 | * @param int $page Page. |
249 | 249 | * @return array An array of personal data in name value pairs |
250 | 250 | */ |
251 | - public function customer_data_eraser( $email_address, $page ) { |
|
251 | + public function customer_data_eraser($email_address, $page) { |
|
252 | 252 | $page = (int) $page; |
253 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
253 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
254 | 254 | $stripe_customer_id = ''; |
255 | 255 | $stripe_source_id = ''; |
256 | 256 | |
257 | - if ( $user instanceof WP_User ) { |
|
258 | - $stripe_customer_id = get_user_meta( $user->ID, '_stripe_customer_id', true ); |
|
259 | - $stripe_source_id = get_user_meta( $user->ID, '_stripe_source_id', true ); |
|
257 | + if ($user instanceof WP_User) { |
|
258 | + $stripe_customer_id = get_user_meta($user->ID, '_stripe_customer_id', true); |
|
259 | + $stripe_source_id = get_user_meta($user->ID, '_stripe_source_id', true); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | $items_removed = false; |
263 | 263 | $messages = array(); |
264 | 264 | |
265 | - if ( ! empty( $stripe_customer_id ) || ! empty( $stripe_source_id ) ) { |
|
265 | + if ( ! empty($stripe_customer_id) || ! empty($stripe_source_id)) { |
|
266 | 266 | $items_removed = true; |
267 | - delete_user_meta( $user->ID, '_stripe_customer_id' ); |
|
268 | - delete_user_meta( $user->ID, '_stripe_source_id' ); |
|
269 | - $messages[] = __( 'Stripe User Data Erased.', 'woocommerce-gateway-stripe' ); |
|
267 | + delete_user_meta($user->ID, '_stripe_customer_id'); |
|
268 | + delete_user_meta($user->ID, '_stripe_source_id'); |
|
269 | + $messages[] = __('Stripe User Data Erased.', 'woocommerce-gateway-stripe'); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | return array( |
@@ -284,29 +284,29 @@ discard block |
||
284 | 284 | * @param int $page Page. |
285 | 285 | * @return array An array of personal data in name value pairs |
286 | 286 | */ |
287 | - public function order_data_eraser( $email_address, $page ) { |
|
288 | - $orders = $this->get_stripe_orders( $email_address, (int) $page ); |
|
287 | + public function order_data_eraser($email_address, $page) { |
|
288 | + $orders = $this->get_stripe_orders($email_address, (int) $page); |
|
289 | 289 | |
290 | 290 | $items_removed = false; |
291 | 291 | $items_retained = false; |
292 | 292 | $messages = array(); |
293 | 293 | |
294 | - foreach ( (array) $orders as $order ) { |
|
295 | - $order = wc_get_order( $order->get_id() ); |
|
294 | + foreach ((array) $orders as $order) { |
|
295 | + $order = wc_get_order($order->get_id()); |
|
296 | 296 | |
297 | - list( $removed, $retained, $msgs ) = $this->maybe_handle_order( $order ); |
|
297 | + list($removed, $retained, $msgs) = $this->maybe_handle_order($order); |
|
298 | 298 | $items_removed |= $removed; |
299 | 299 | $items_retained |= $retained; |
300 | - $messages = array_merge( $messages, $msgs ); |
|
300 | + $messages = array_merge($messages, $msgs); |
|
301 | 301 | |
302 | - list( $removed, $retained, $msgs ) = $this->maybe_handle_subscription( $order ); |
|
302 | + list($removed, $retained, $msgs) = $this->maybe_handle_subscription($order); |
|
303 | 303 | $items_removed |= $removed; |
304 | 304 | $items_retained |= $retained; |
305 | - $messages = array_merge( $messages, $msgs ); |
|
305 | + $messages = array_merge($messages, $msgs); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | // Tell core if we have more orders to work on still |
309 | - $done = count( $orders ) < 10; |
|
309 | + $done = count($orders) < 10; |
|
310 | 310 | |
311 | 311 | return array( |
312 | 312 | 'items_removed' => $items_removed, |
@@ -322,47 +322,47 @@ discard block |
||
322 | 322 | * @param WC_Order $order |
323 | 323 | * @return array |
324 | 324 | */ |
325 | - protected function maybe_handle_subscription( $order ) { |
|
326 | - if ( ! class_exists( 'WC_Subscriptions' ) ) { |
|
327 | - return array( false, false, array() ); |
|
325 | + protected function maybe_handle_subscription($order) { |
|
326 | + if ( ! class_exists('WC_Subscriptions')) { |
|
327 | + return array(false, false, array()); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( ! wcs_order_contains_subscription( $order ) ) { |
|
331 | - return array( false, false, array() ); |
|
330 | + if ( ! wcs_order_contains_subscription($order)) { |
|
331 | + return array(false, false, array()); |
|
332 | 332 | } |
333 | 333 | |
334 | - $subscription = current( wcs_get_subscriptions_for_order( $order->get_id() ) ); |
|
334 | + $subscription = current(wcs_get_subscriptions_for_order($order->get_id())); |
|
335 | 335 | $subscription_id = $subscription->get_id(); |
336 | 336 | |
337 | - $stripe_source_id = get_post_meta( $subscription_id, '_stripe_source_id', true ); |
|
337 | + $stripe_source_id = get_post_meta($subscription_id, '_stripe_source_id', true); |
|
338 | 338 | |
339 | - if ( empty( $stripe_source_id ) ) { |
|
340 | - return array( false, false, array() ); |
|
339 | + if (empty($stripe_source_id)) { |
|
340 | + return array(false, false, array()); |
|
341 | 341 | } |
342 | 342 | |
343 | - if ( ! $this->is_retention_expired( $order->get_date_created()->getTimestamp() ) ) { |
|
343 | + if ( ! $this->is_retention_expired($order->get_date_created()->getTimestamp())) { |
|
344 | 344 | /* translators: %d Order ID */ |
345 | - 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() ) ) ); |
|
345 | + 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()))); |
|
346 | 346 | } |
347 | 347 | |
348 | - if ( $subscription->has_status( apply_filters( 'wc_stripe_privacy_eraser_subs_statuses', array( 'on-hold', 'active' ) ) ) ) { |
|
348 | + if ($subscription->has_status(apply_filters('wc_stripe_privacy_eraser_subs_statuses', array('on-hold', 'active')))) { |
|
349 | 349 | /* translators: %d Order ID */ |
350 | - return array( false, true, array( sprintf( __( 'Order ID %d contains an active Subscription. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe' ), $order->get_id() ) ) ); |
|
350 | + return array(false, true, array(sprintf(__('Order ID %d contains an active Subscription. Personal data retained. (Stripe)', 'woocommerce-gateway-stripe'), $order->get_id()))); |
|
351 | 351 | } |
352 | 352 | |
353 | - $renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders( $order->get_id() ); |
|
353 | + $renewal_orders = WC_Subscriptions_Renewal_Order::get_renewal_orders($order->get_id()); |
|
354 | 354 | |
355 | - foreach ( $renewal_orders as $renewal_order_id ) { |
|
356 | - delete_post_meta( $renewal_order_id, '_stripe_source_id' ); |
|
357 | - delete_post_meta( $renewal_order_id, '_stripe_refund_id' ); |
|
358 | - delete_post_meta( $renewal_order_id, '_stripe_customer_id' ); |
|
355 | + foreach ($renewal_orders as $renewal_order_id) { |
|
356 | + delete_post_meta($renewal_order_id, '_stripe_source_id'); |
|
357 | + delete_post_meta($renewal_order_id, '_stripe_refund_id'); |
|
358 | + delete_post_meta($renewal_order_id, '_stripe_customer_id'); |
|
359 | 359 | } |
360 | 360 | |
361 | - delete_post_meta( $subscription_id, '_stripe_source_id' ); |
|
362 | - delete_post_meta( $subscription_id, '_stripe_refund_id' ); |
|
363 | - delete_post_meta( $subscription_id, '_stripe_customer_id' ); |
|
361 | + delete_post_meta($subscription_id, '_stripe_source_id'); |
|
362 | + delete_post_meta($subscription_id, '_stripe_refund_id'); |
|
363 | + delete_post_meta($subscription_id, '_stripe_customer_id'); |
|
364 | 364 | |
365 | - return array( true, false, array( __( 'Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe' ) ) ); |
|
365 | + return array(true, false, array(__('Stripe Subscription Data Erased.', 'woocommerce-gateway-stripe'))); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -371,61 +371,61 @@ discard block |
||
371 | 371 | * @param WC_Order $order |
372 | 372 | * @return array |
373 | 373 | */ |
374 | - protected function maybe_handle_order( $order ) { |
|
374 | + protected function maybe_handle_order($order) { |
|
375 | 375 | $order_id = $order->get_id(); |
376 | - $stripe_source_id = get_post_meta( $order_id, '_stripe_source_id', true ); |
|
377 | - $stripe_refund_id = get_post_meta( $order_id, '_stripe_refund_id', true ); |
|
378 | - $stripe_customer_id = get_post_meta( $order_id, '_stripe_customer_id', true ); |
|
376 | + $stripe_source_id = get_post_meta($order_id, '_stripe_source_id', true); |
|
377 | + $stripe_refund_id = get_post_meta($order_id, '_stripe_refund_id', true); |
|
378 | + $stripe_customer_id = get_post_meta($order_id, '_stripe_customer_id', true); |
|
379 | 379 | |
380 | - if ( ! $this->is_retention_expired( $order->get_date_created()->getTimestamp() ) ) { |
|
380 | + if ( ! $this->is_retention_expired($order->get_date_created()->getTimestamp())) { |
|
381 | 381 | /* translators: %d Order ID */ |
382 | - 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() ) ) ); |
|
382 | + 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()))); |
|
383 | 383 | } |
384 | 384 | |
385 | - if ( empty( $stripe_source_id ) && empty( $stripe_refund_id ) && empty( $stripe_customer_id ) ) { |
|
386 | - return array( false, false, array() ); |
|
385 | + if (empty($stripe_source_id) && empty($stripe_refund_id) && empty($stripe_customer_id)) { |
|
386 | + return array(false, false, array()); |
|
387 | 387 | } |
388 | 388 | |
389 | - delete_post_meta( $order_id, '_stripe_source_id' ); |
|
390 | - delete_post_meta( $order_id, '_stripe_refund_id' ); |
|
391 | - delete_post_meta( $order_id, '_stripe_customer_id' ); |
|
389 | + delete_post_meta($order_id, '_stripe_source_id'); |
|
390 | + delete_post_meta($order_id, '_stripe_refund_id'); |
|
391 | + delete_post_meta($order_id, '_stripe_customer_id'); |
|
392 | 392 | |
393 | - return array( true, false, array( __( 'Stripe personal data erased.', 'woocommerce-gateway-stripe' ) ) ); |
|
393 | + return array(true, false, array(__('Stripe personal data erased.', 'woocommerce-gateway-stripe'))); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Checks if create date is passed retention duration. |
398 | 398 | * |
399 | 399 | */ |
400 | - public function is_retention_expired( $created_date ) { |
|
401 | - $retention = wc_parse_relative_date_option( get_option( 'woocommerce_gateway_stripe_retention' ) ); |
|
400 | + public function is_retention_expired($created_date) { |
|
401 | + $retention = wc_parse_relative_date_option(get_option('woocommerce_gateway_stripe_retention')); |
|
402 | 402 | $is_expired = false; |
403 | - $time_span = time() - strtotime( $created_date ); |
|
404 | - if ( empty( $retention ) || empty( $created_date ) ) { |
|
403 | + $time_span = time() - strtotime($created_date); |
|
404 | + if (empty($retention) || empty($created_date)) { |
|
405 | 405 | return false; |
406 | 406 | } |
407 | - switch ( $retention['unit'] ) { |
|
407 | + switch ($retention['unit']) { |
|
408 | 408 | case 'days': |
409 | 409 | $retention = $retention['number'] * DAY_IN_SECONDS; |
410 | - if ( $time_span > $retention ) { |
|
410 | + if ($time_span > $retention) { |
|
411 | 411 | $is_expired = true; |
412 | 412 | } |
413 | 413 | break; |
414 | 414 | case 'weeks': |
415 | 415 | $retention = $retention['number'] * WEEK_IN_SECONDS; |
416 | - if ( $time_span > $retention ) { |
|
416 | + if ($time_span > $retention) { |
|
417 | 417 | $is_expired = true; |
418 | 418 | } |
419 | 419 | break; |
420 | 420 | case 'months': |
421 | 421 | $retention = $retention['number'] * MONTH_IN_SECONDS; |
422 | - if ( $time_span > $retention ) { |
|
422 | + if ($time_span > $retention) { |
|
423 | 423 | $is_expired = true; |
424 | 424 | } |
425 | 425 | break; |
426 | 426 | case 'years': |
427 | 427 | $retention = $retention['number'] * YEAR_IN_SECONDS; |
428 | - if ( $time_span > $retention ) { |
|
428 | + if ($time_span > $retention) { |
|
429 | 429 | $is_expired = true; |
430 | 430 | } |
431 | 431 | break; |