Completed
Push — master ( a1581a...b80e00 )
by Roy
26s
created
includes/compat/class-wc-stripe-sepa-subs-compat.php 1 patch
Spacing   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -15,21 +15,21 @@  discard block
 block discarded – undo
15 15
 	public function __construct() {
16 16
 		parent::__construct();
17 17
 
18
-		if ( class_exists( 'WC_Subscriptions_Order' ) ) {
19
-			add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 );
20
-			add_action( 'wcs_resubscribe_order_created', array( $this, 'delete_resubscribe_meta' ), 10 );
21
-			add_action( 'wcs_renewal_order_created', array( $this, 'delete_renewal_meta' ), 10 );
22
-			add_action( 'woocommerce_subscription_failing_payment_method_updated_stripe', array( $this, 'update_failing_payment_method' ), 10, 2 );
23
-			add_action( 'wc_stripe_sepa_payment_fields', array( $this, 'display_update_subs_payment_checkout' ) );
24
-			add_action( 'wc_stripe_add_payment_method_' . $this->id . '_success', array( $this, 'handle_add_payment_method_success' ), 10, 2 );
18
+		if (class_exists('WC_Subscriptions_Order')) {
19
+			add_action('woocommerce_scheduled_subscription_payment_' . $this->id, array($this, 'scheduled_subscription_payment'), 10, 2);
20
+			add_action('wcs_resubscribe_order_created', array($this, 'delete_resubscribe_meta'), 10);
21
+			add_action('wcs_renewal_order_created', array($this, 'delete_renewal_meta'), 10);
22
+			add_action('woocommerce_subscription_failing_payment_method_updated_stripe', array($this, 'update_failing_payment_method'), 10, 2);
23
+			add_action('wc_stripe_sepa_payment_fields', array($this, 'display_update_subs_payment_checkout'));
24
+			add_action('wc_stripe_add_payment_method_' . $this->id . '_success', array($this, 'handle_add_payment_method_success'), 10, 2);
25 25
 
26 26
 			// Display the credit card used for a subscription in the "My Subscriptions" table.
27
-			add_filter( 'woocommerce_my_subscriptions_payment_method', array( $this, 'maybe_render_subscription_payment_method' ), 10, 2 );
27
+			add_filter('woocommerce_my_subscriptions_payment_method', array($this, 'maybe_render_subscription_payment_method'), 10, 2);
28 28
 
29 29
 			// Allow store managers to manually set Stripe as the payment method on a subscription.
30
-			add_filter( 'woocommerce_subscription_payment_meta', array( $this, 'add_subscription_payment_meta' ), 10, 2 );
31
-			add_filter( 'woocommerce_subscription_validate_payment_meta', array( $this, 'validate_subscription_payment_meta' ), 10, 2 );
32
-			add_filter( 'wc_stripe_display_save_payment_method_checkbox', array( $this, 'maybe_hide_save_checkbox' ) );
30
+			add_filter('woocommerce_subscription_payment_meta', array($this, 'add_subscription_payment_meta'), 10, 2);
31
+			add_filter('woocommerce_subscription_validate_payment_meta', array($this, 'validate_subscription_payment_meta'), 10, 2);
32
+			add_filter('wc_stripe_display_save_payment_method_checkbox', array($this, 'maybe_hide_save_checkbox'));
33 33
 		}
34 34
 	}
35 35
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	 * @since 4.0.0
50 50
 	 * @version 4.0.0
51 51
 	 */
52
-	public function maybe_hide_save_checkbox( $display_tokenization ) {
53
-		if ( WC_Subscriptions_Cart::cart_contains_subscription() ) {
52
+	public function maybe_hide_save_checkbox($display_tokenization) {
53
+		if (WC_Subscriptions_Cart::cart_contains_subscription()) {
54 54
 			return false;
55 55
 		}
56 56
 
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 * @param  int  $order_id
63 63
 	 * @return boolean
64 64
 	 */
65
-	public function has_subscription( $order_id ) {
66
-		return ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_is_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ) );
65
+	public function has_subscription($order_id) {
66
+		return (function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order_id) || wcs_is_subscription($order_id) || wcs_order_contains_renewal($order_id)));
67 67
 	}
68 68
 
69 69
 	/**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @return bool
74 74
 	 */
75 75
 	public function is_subs_change_payment() {
76
-		return ( isset( $_GET['pay_for_order'] ) && isset( $_GET['change_payment_method'] ) );
76
+		return (isset($_GET['pay_for_order']) && isset($_GET['change_payment_method']));
77 77
 	}
78 78
 
79 79
 	/**
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function display_update_subs_payment_checkout() {
86 86
 		if (
87
-			apply_filters( 'wc_stripe_display_update_subs_payment_method_card_checkbox', true ) &&
88
-			wcs_user_has_subscription( get_current_user_id(), '', 'active' ) &&
87
+			apply_filters('wc_stripe_display_update_subs_payment_method_card_checkbox', true) &&
88
+			wcs_user_has_subscription(get_current_user_id(), '', 'active') &&
89 89
 			is_add_payment_method_page()
90 90
 		) {
91 91
 			printf(
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 					<input id="wc-%1$s-update-subs-payment-method-card" name="wc-%1$s-update-subs-payment-method-card" type="checkbox" value="true" style="width:auto;" />
94 94
 					<label for="wc-%1$s-update-subs-payment-method-card" style="display:inline;">%2$s</label>
95 95
 				</p>',
96
-				esc_attr( $this->id ),
97
-				esc_html( apply_filters( 'wc_stripe_save_to_subs_text', __( 'Update the Payment Method used for all of my active subscriptions (optional).', 'woocommerce-gateway-stripe' ) ) )
96
+				esc_attr($this->id),
97
+				esc_html(apply_filters('wc_stripe_save_to_subs_text', __('Update the Payment Method used for all of my active subscriptions (optional).', 'woocommerce-gateway-stripe')))
98 98
 			);
99 99
 		}
100 100
 	}
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
 	 * @param string $source_id
107 107
 	 * @param object $source_object
108 108
 	 */
109
-	public function handle_add_payment_method_success( $source_id, $source_object ) {
110
-		if ( isset( $_POST[ 'wc-' . $this->id . '-update-subs-payment-method-card' ] ) ) {
109
+	public function handle_add_payment_method_success($source_id, $source_object) {
110
+		if (isset($_POST['wc-' . $this->id . '-update-subs-payment-method-card'])) {
111 111
 			$all_subs = wcs_get_users_subscriptions();
112 112
 
113
-			if ( ! empty( $all_subs ) ) {
114
-				foreach ( $all_subs as $sub ) {
115
-					if ( 'active' === $sub->get_status() ) {
116
-						update_post_meta( $sub->get_id(), '_stripe_source_id', $source_id );
117
-						update_post_meta( $sub->get_id(), '_payment_method', $this->id );
118
-						update_post_meta( $sub->get_id(), '_payment_method_title', $this->method_title );
113
+			if ( ! empty($all_subs)) {
114
+				foreach ($all_subs as $sub) {
115
+					if ('active' === $sub->get_status()) {
116
+						update_post_meta($sub->get_id(), '_stripe_source_id', $source_id);
117
+						update_post_meta($sub->get_id(), '_payment_method', $this->id);
118
+						update_post_meta($sub->get_id(), '_payment_method_title', $this->method_title);
119 119
 					}
120 120
 				}
121 121
 			}
@@ -128,24 +128,24 @@  discard block
 block discarded – undo
128 128
 	 * @since 3.1.0
129 129
 	 * @version 4.0.0
130 130
 	 */
131
-	public function save_source_to_order( $order, $source ) {
132
-		parent::save_source_to_order( $order, $source );
131
+	public function save_source_to_order($order, $source) {
132
+		parent::save_source_to_order($order, $source);
133 133
 
134
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
134
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
135 135
 
136 136
 		// Also store it on the subscriptions being purchased or paid for in the order.
137
-		if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) {
138
-			$subscriptions = wcs_get_subscriptions_for_order( $order_id );
139
-		} elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) {
140
-			$subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id );
137
+		if (function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($order_id)) {
138
+			$subscriptions = wcs_get_subscriptions_for_order($order_id);
139
+		} elseif (function_exists('wcs_order_contains_renewal') && wcs_order_contains_renewal($order_id)) {
140
+			$subscriptions = wcs_get_subscriptions_for_renewal_order($order_id);
141 141
 		} else {
142 142
 			$subscriptions = array();
143 143
 		}
144 144
 
145
-		foreach ( $subscriptions as $subscription ) {
146
-			$subscription_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id();
147
-			update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer );
148
-			update_post_meta( $subscription_id, '_stripe_source_id', $source->source );
145
+		foreach ($subscriptions as $subscription) {
146
+			$subscription_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->id : $subscription->get_id();
147
+			update_post_meta($subscription_id, '_stripe_customer_id', $source->customer);
148
+			update_post_meta($subscription_id, '_stripe_source_id', $source->source);
149 149
 		}
150 150
 	}
151 151
 
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
 	 * @param  int $order_id
155 155
 	 * @return array
156 156
 	 */
157
-	public function process_payment( $order_id, $retry = true, $force_save_source = false, $previous_error = false ) {
158
-		if ( $this->has_subscription( $order_id ) ) {
159
-			if ( $this->is_subs_change_payment() ) {
160
-				return $this->change_subs_payment_method( $order_id );
157
+	public function process_payment($order_id, $retry = true, $force_save_source = false, $previous_error = false) {
158
+		if ($this->has_subscription($order_id)) {
159
+			if ($this->is_subs_change_payment()) {
160
+				return $this->change_subs_payment_method($order_id);
161 161
 			}
162 162
 
163 163
 			// Regular payment with force customer enabled
164
-			return parent::process_payment( $order_id, $retry, true, $previous_error );
164
+			return parent::process_payment($order_id, $retry, true, $previous_error);
165 165
 		} else {
166
-			return parent::process_payment( $order_id, $retry, $force_save_source, $previous_error );
166
+			return parent::process_payment($order_id, $retry, $force_save_source, $previous_error);
167 167
 		}
168 168
 	}
169 169
 
@@ -173,27 +173,27 @@  discard block
 block discarded – undo
173 173
 	 * @since 4.0.4
174 174
 	 * @param int $order_id
175 175
 	 */
176
-	public function change_subs_payment_method( $order_id ) {
176
+	public function change_subs_payment_method($order_id) {
177 177
 		try {
178
-			$subscription    = wc_get_order( $order_id );
179
-			$prepared_source = $this->prepare_source( get_current_user_id(), true );
178
+			$subscription    = wc_get_order($order_id);
179
+			$prepared_source = $this->prepare_source(get_current_user_id(), true);
180 180
 
181
-			if ( empty( $prepared_source->source ) ) {
182
-				$localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
183
-				throw new WC_Stripe_Exception( print_r( $prepared_source, true ), $localized_message );
181
+			if (empty($prepared_source->source)) {
182
+				$localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
183
+				throw new WC_Stripe_Exception(print_r($prepared_source, true), $localized_message);
184 184
 			}
185 185
 
186
-			$this->save_source_to_order( $subscription, $prepared_source );
186
+			$this->save_source_to_order($subscription, $prepared_source);
187 187
 
188
-			do_action( 'wc_stripe_change_subs_payment_method_success', $prepared_source->source, $prepared_source );
188
+			do_action('wc_stripe_change_subs_payment_method_success', $prepared_source->source, $prepared_source);
189 189
 
190 190
 			return array(
191 191
 				'result'   => 'success',
192
-				'redirect' => $this->get_return_url( $subscription ),
192
+				'redirect' => $this->get_return_url($subscription),
193 193
 			);
194
-		} catch ( WC_Stripe_Exception $e ) {
195
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
196
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
194
+		} catch (WC_Stripe_Exception $e) {
195
+			wc_add_notice($e->getLocalizedMessage(), 'error');
196
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
197 197
 		}
198 198
 	}
199 199
 
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 	 * @param $amount_to_charge float The amount to charge.
204 204
 	 * @param $renewal_order WC_Order A WC_Order object created to record the renewal payment.
205 205
 	 */
206
-	public function scheduled_subscription_payment( $amount_to_charge, $renewal_order ) {
207
-		$this->process_subscription_payment( $amount_to_charge, $renewal_order, true, false );
206
+	public function scheduled_subscription_payment($amount_to_charge, $renewal_order) {
207
+		$this->process_subscription_payment($amount_to_charge, $renewal_order, true, false);
208 208
 	}
209 209
 
210 210
 	/**
@@ -218,86 +218,86 @@  discard block
 block discarded – undo
218 218
 	 * @param bool $retry Should we retry the process?
219 219
 	 * @param object $previous_error
220 220
 	 */
221
-	public function process_subscription_payment( $amount = 0.0, $renewal_order, $retry = true, $previous_error ) {
221
+	public function process_subscription_payment($amount = 0.0, $renewal_order, $retry = true, $previous_error) {
222 222
 		try {
223
-			if ( $amount * 100 < WC_Stripe_Helper::get_minimum_amount() ) {
223
+			if ($amount * 100 < WC_Stripe_Helper::get_minimum_amount()) {
224 224
 				/* translators: minimum amount */
225
-				return new WP_Error( 'stripe_error', sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe_Helper::get_minimum_amount() / 100 ) ) );
225
+				return new WP_Error('stripe_error', sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe_Helper::get_minimum_amount() / 100)));
226 226
 			}
227 227
 
228
-			$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $renewal_order->id : $renewal_order->get_id();
228
+			$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $renewal_order->id : $renewal_order->get_id();
229 229
 
230 230
 			// Get source from order
231
-			$prepared_source = $this->prepare_order_source( $renewal_order );
231
+			$prepared_source = $this->prepare_order_source($renewal_order);
232 232
 			$source_object   = $prepared_source->source_object;
233 233
 
234
-			if ( ! $prepared_source->customer ) {
235
-				return new WP_Error( 'stripe_error', __( 'Customer not found', 'woocommerce-gateway-stripe' ) );
234
+			if ( ! $prepared_source->customer) {
235
+				return new WP_Error('stripe_error', __('Customer not found', 'woocommerce-gateway-stripe'));
236 236
 			}
237 237
 
238
-			WC_Stripe_Logger::log( "Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}" );
238
+			WC_Stripe_Logger::log("Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}");
239 239
 
240 240
 			/* If we're doing a retry and source is chargeable, we need to pass
241 241
 			 * a different idempotency key and retry for success.
242 242
 			 */
243
-			if ( is_object( $source_object ) && empty( $source_object->error ) && $this->need_update_idempotency_key( $source_object, $previous_error ) ) {
244
-				add_filter( 'wc_stripe_idempotency_key', array( $this, 'change_idempotency_key' ), 10, 2 );
243
+			if (is_object($source_object) && empty($source_object->error) && $this->need_update_idempotency_key($source_object, $previous_error)) {
244
+				add_filter('wc_stripe_idempotency_key', array($this, 'change_idempotency_key'), 10, 2);
245 245
 			}
246 246
 
247
-			if ( ( $this->is_no_such_source_error( $previous_error ) || $this->is_no_linked_source_error( $previous_error ) ) && apply_filters( 'wc_stripe_use_default_customer_source', true ) ) {
247
+			if (($this->is_no_such_source_error($previous_error) || $this->is_no_linked_source_error($previous_error)) && apply_filters('wc_stripe_use_default_customer_source', true)) {
248 248
 				// Passing empty source will charge customer default.
249 249
 				$prepared_source->source = '';
250 250
 			}
251 251
 
252
-			$request            = $this->generate_payment_request( $renewal_order, $prepared_source );
252
+			$request            = $this->generate_payment_request($renewal_order, $prepared_source);
253 253
 			$request['capture'] = 'true';
254
-			$request['amount']  = WC_Stripe_Helper::get_stripe_amount( $amount, $request['currency'] );
255
-			$response           = WC_Stripe_API::request( $request );
254
+			$request['amount']  = WC_Stripe_Helper::get_stripe_amount($amount, $request['currency']);
255
+			$response           = WC_Stripe_API::request($request);
256 256
 
257
-			if ( ! empty( $response->error ) ) {
257
+			if ( ! empty($response->error)) {
258 258
 				// We want to retry.
259
-				if ( $this->is_retryable_error( $response->error ) ) {
260
-					if ( $retry ) {
259
+				if ($this->is_retryable_error($response->error)) {
260
+					if ($retry) {
261 261
 						// Don't do anymore retries after this.
262
-						if ( 5 <= $this->retry_interval ) {
263
-							return $this->process_subscription_payment( $amount, $renewal_order, false, $response->error );
262
+						if (5 <= $this->retry_interval) {
263
+							return $this->process_subscription_payment($amount, $renewal_order, false, $response->error);
264 264
 						}
265 265
 
266
-						sleep( $this->retry_interval );
266
+						sleep($this->retry_interval);
267 267
 
268 268
 						$this->retry_interval++;
269 269
 
270
-						return $this->process_subscription_payment( $amount, $renewal_order, true, $response->error );
270
+						return $this->process_subscription_payment($amount, $renewal_order, true, $response->error);
271 271
 					} else {
272
-						$localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' );
273
-						$renewal_order->add_order_note( $localized_message );
274
-						throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
272
+						$localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe');
273
+						$renewal_order->add_order_note($localized_message);
274
+						throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
275 275
 					}
276 276
 				}
277 277
 
278 278
 				$localized_messages = WC_Stripe_Helper::get_localized_messages();
279 279
 
280
-				if ( 'card_error' === $response->error->type ) {
281
-					$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
280
+				if ('card_error' === $response->error->type) {
281
+					$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
282 282
 				} else {
283
-					$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
283
+					$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
284 284
 				}
285 285
 
286
-				$renewal_order->add_order_note( $localized_message );
286
+				$renewal_order->add_order_note($localized_message);
287 287
 
288
-				throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
288
+				throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
289 289
 			}
290 290
 
291
-			do_action( 'wc_gateway_stripe_process_payment', $response, $renewal_order );
291
+			do_action('wc_gateway_stripe_process_payment', $response, $renewal_order);
292 292
 
293
-			$this->process_response( $response, $renewal_order );
294
-		} catch ( WC_Stripe_Exception $e ) {
295
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
293
+			$this->process_response($response, $renewal_order);
294
+		} catch (WC_Stripe_Exception $e) {
295
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
296 296
 
297
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $renewal_order );
297
+			do_action('wc_gateway_stripe_process_payment_error', $e, $renewal_order);
298 298
 
299 299
 			/* translators: error message */
300
-			$renewal_order->update_status( 'failed' );
300
+			$renewal_order->update_status('failed');
301 301
 		}
302 302
 	}
303 303
 
@@ -305,21 +305,21 @@  discard block
 block discarded – undo
305 305
 	 * Don't transfer Stripe customer/token meta to resubscribe orders.
306 306
 	 * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
307 307
 	 */
308
-	public function delete_resubscribe_meta( $resubscribe_order ) {
309
-		delete_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_customer_id' );
310
-		delete_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_source_id' );
308
+	public function delete_resubscribe_meta($resubscribe_order) {
309
+		delete_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_customer_id');
310
+		delete_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_source_id');
311 311
 		// For BW compat will remove in future
312
-		delete_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_card_id' );
313
-		$this->delete_renewal_meta( $resubscribe_order );
312
+		delete_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_card_id');
313
+		$this->delete_renewal_meta($resubscribe_order);
314 314
 	}
315 315
 
316 316
 	/**
317 317
 	 * Don't transfer Stripe fee/ID meta to renewal orders.
318 318
 	 * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
319 319
 	 */
320
-	public function delete_renewal_meta( $renewal_order ) {
321
-		WC_Stripe_Helper::delete_stripe_fee( $renewal_order );
322
-		WC_Stripe_Helper::delete_stripe_net( $renewal_order );
320
+	public function delete_renewal_meta($renewal_order) {
321
+		WC_Stripe_Helper::delete_stripe_fee($renewal_order);
322
+		WC_Stripe_Helper::delete_stripe_net($renewal_order);
323 323
 
324 324
 		return $renewal_order;
325 325
 	}
@@ -333,14 +333,14 @@  discard block
 block discarded – undo
333 333
 	 * @param WC_Order $renewal_order The order which recorded the successful payment (to make up for the failed automatic payment).
334 334
 	 * @return void
335 335
 	 */
336
-	public function update_failing_payment_method( $subscription, $renewal_order ) {
337
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
338
-			update_post_meta( $subscription->id, '_stripe_customer_id', $renewal_order->stripe_customer_id );
339
-			update_post_meta( $subscription->id, '_stripe_source_id', $renewal_order->stripe_source_id );
336
+	public function update_failing_payment_method($subscription, $renewal_order) {
337
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
338
+			update_post_meta($subscription->id, '_stripe_customer_id', $renewal_order->stripe_customer_id);
339
+			update_post_meta($subscription->id, '_stripe_source_id', $renewal_order->stripe_source_id);
340 340
 
341 341
 		} else {
342
-			update_post_meta( $subscription->get_id(), '_stripe_customer_id', $renewal_order->get_meta( '_stripe_customer_id', true ) );
343
-			update_post_meta( $subscription->get_id(), '_stripe_source_id', $renewal_order->get_meta( '_stripe_source_id', true ) );
342
+			update_post_meta($subscription->get_id(), '_stripe_customer_id', $renewal_order->get_meta('_stripe_customer_id', true));
343
+			update_post_meta($subscription->get_id(), '_stripe_source_id', $renewal_order->get_meta('_stripe_source_id', true));
344 344
 		}
345 345
 	}
346 346
 
@@ -353,21 +353,21 @@  discard block
 block discarded – undo
353 353
 	 * @param WC_Subscription $subscription An instance of a subscription object
354 354
 	 * @return array
355 355
 	 */
356
-	public function add_subscription_payment_meta( $payment_meta, $subscription ) {
357
-		$source_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id() ), '_stripe_source_id', true );
356
+	public function add_subscription_payment_meta($payment_meta, $subscription) {
357
+		$source_id = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->id : $subscription->get_id()), '_stripe_source_id', true);
358 358
 
359 359
 		// For BW compat will remove in future.
360
-		if ( empty( $source_id ) ) {
361
-			$source_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true );
360
+		if (empty($source_id)) {
361
+			$source_id = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->id : $subscription->get_id()), '_stripe_card_id', true);
362 362
 
363 363
 			// Take this opportunity to update the key name.
364
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $subscription->id, '_stripe_source_id', $source_id ) : update_post_meta( $subscription->get_id(), '_stripe_source_id', $source_id );
364
+			WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($subscription->id, '_stripe_source_id', $source_id) : update_post_meta($subscription->get_id(), '_stripe_source_id', $source_id);
365 365
 		}
366 366
 
367
-		$payment_meta[ $this->id ] = array(
367
+		$payment_meta[$this->id] = array(
368 368
 			'post_meta' => array(
369 369
 				'_stripe_customer_id' => array(
370
-					'value' => get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true ),
370
+					'value' => get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->id : $subscription->get_id()), '_stripe_customer_id', true),
371 371
 					'label' => 'Stripe Customer ID',
372 372
 				),
373 373
 				'_stripe_source_id'   => array(
@@ -388,22 +388,22 @@  discard block
 block discarded – undo
388 388
 	 * @param array $payment_meta associative array of meta data required for automatic payments
389 389
 	 * @return array
390 390
 	 */
391
-	public function validate_subscription_payment_meta( $payment_method_id, $payment_meta ) {
392
-		if ( $this->id === $payment_method_id ) {
391
+	public function validate_subscription_payment_meta($payment_method_id, $payment_meta) {
392
+		if ($this->id === $payment_method_id) {
393 393
 
394
-			if ( ! isset( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) || empty( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) ) {
395
-				throw new Exception( __( 'A "Stripe Customer ID" value is required.', 'woocommerce-gateway-stripe' ) );
396
-			} elseif ( 0 !== strpos( $payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_' ) ) {
397
-				throw new Exception( __( 'Invalid customer ID. A valid "Stripe Customer ID" must begin with "cus_".', 'woocommerce-gateway-stripe' ) );
394
+			if ( ! isset($payment_meta['post_meta']['_stripe_customer_id']['value']) || empty($payment_meta['post_meta']['_stripe_customer_id']['value'])) {
395
+				throw new Exception(__('A "Stripe Customer ID" value is required.', 'woocommerce-gateway-stripe'));
396
+			} elseif (0 !== strpos($payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_')) {
397
+				throw new Exception(__('Invalid customer ID. A valid "Stripe Customer ID" must begin with "cus_".', 'woocommerce-gateway-stripe'));
398 398
 			}
399 399
 
400 400
 			if (
401
-				( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] )
402
-				&& 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'card_' ) )
403
-				&& ( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] )
404
-				&& 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'src_' ) ) ) {
401
+				( ! empty($payment_meta['post_meta']['_stripe_source_id']['value'])
402
+				&& 0 !== strpos($payment_meta['post_meta']['_stripe_source_id']['value'], 'card_'))
403
+				&& ( ! empty($payment_meta['post_meta']['_stripe_source_id']['value'])
404
+				&& 0 !== strpos($payment_meta['post_meta']['_stripe_source_id']['value'], 'src_')) ) {
405 405
 
406
-				throw new Exception( __( 'Invalid source ID. A valid source "Stripe Source ID" must begin with "src_" or "card_".', 'woocommerce-gateway-stripe' ) );
406
+				throw new Exception(__('Invalid source ID. A valid source "Stripe Source ID" must begin with "src_" or "card_".', 'woocommerce-gateway-stripe'));
407 407
 			}
408 408
 		}
409 409
 	}
@@ -416,67 +416,67 @@  discard block
 block discarded – undo
416 416
 	 * @param WC_Subscription $subscription the subscription details
417 417
 	 * @return string the subscription payment method
418 418
 	 */
419
-	public function maybe_render_subscription_payment_method( $payment_method_to_display, $subscription ) {
420
-		$customer_user = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->customer_user : $subscription->get_customer_id();
419
+	public function maybe_render_subscription_payment_method($payment_method_to_display, $subscription) {
420
+		$customer_user = WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->customer_user : $subscription->get_customer_id();
421 421
 
422 422
 		// bail for other payment methods
423
-		if ( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->payment_method : $subscription->get_payment_method() ) !== $this->id || ! $customer_user ) {
423
+		if ((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->payment_method : $subscription->get_payment_method()) !== $this->id || ! $customer_user) {
424 424
 			return $payment_method_to_display;
425 425
 		}
426 426
 
427
-		$stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id() ), '_stripe_source_id', true );
427
+		$stripe_source_id = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->id : $subscription->get_id()), '_stripe_source_id', true);
428 428
 
429 429
 		// For BW compat will remove in future.
430
-		if ( empty( $stripe_source_id ) ) {
431
-			$stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true );
430
+		if (empty($stripe_source_id)) {
431
+			$stripe_source_id = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->id : $subscription->get_id()), '_stripe_card_id', true);
432 432
 
433 433
 			// Take this opportunity to update the key name.
434
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $subscription->id, '_stripe_source_id', $stripe_source_id ) : update_post_meta( $subscription->get_id(), '_stripe_source_id', $stripe_source_id );
434
+			WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($subscription->id, '_stripe_source_id', $stripe_source_id) : update_post_meta($subscription->get_id(), '_stripe_source_id', $stripe_source_id);
435 435
 		}
436 436
 
437 437
 		$stripe_customer    = new WC_Stripe_Customer();
438
-		$stripe_customer_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true );
438
+		$stripe_customer_id = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->id : $subscription->get_id()), '_stripe_customer_id', true);
439 439
 
440 440
 		// If we couldn't find a Stripe customer linked to the subscription, fallback to the user meta data.
441
-		if ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) {
441
+		if ( ! $stripe_customer_id || ! is_string($stripe_customer_id)) {
442 442
 			$user_id            = $customer_user;
443
-			$stripe_customer_id = get_user_meta( $user_id, '_stripe_customer_id', true );
444
-			$stripe_source_id   = get_user_meta( $user_id, '_stripe_source_id', true );
443
+			$stripe_customer_id = get_user_meta($user_id, '_stripe_customer_id', true);
444
+			$stripe_source_id   = get_user_meta($user_id, '_stripe_source_id', true);
445 445
 
446 446
 			// For BW compat will remove in future.
447
-			if ( empty( $stripe_source_id ) ) {
448
-				$stripe_source_id = get_user_meta( $user_id, '_stripe_card_id', true );
447
+			if (empty($stripe_source_id)) {
448
+				$stripe_source_id = get_user_meta($user_id, '_stripe_card_id', true);
449 449
 
450 450
 				// Take this opportunity to update the key name.
451
-				update_user_meta( $user_id, '_stripe_source_id', $stripe_source_id );
451
+				update_user_meta($user_id, '_stripe_source_id', $stripe_source_id);
452 452
 			}
453 453
 		}
454 454
 
455 455
 		// If we couldn't find a Stripe customer linked to the account, fallback to the order meta data.
456
-		if ( ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) && false !== $subscription->order ) {
457
-			$stripe_customer_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_customer_id', true );
458
-			$stripe_source_id   = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_source_id', true );
456
+		if (( ! $stripe_customer_id || ! is_string($stripe_customer_id)) && false !== $subscription->order) {
457
+			$stripe_customer_id = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_customer_id', true);
458
+			$stripe_source_id   = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_source_id', true);
459 459
 
460 460
 			// For BW compat will remove in future.
461
-			if ( empty( $stripe_source_id ) ) {
462
-				$stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_card_id', true );
461
+			if (empty($stripe_source_id)) {
462
+				$stripe_source_id = get_post_meta((WC_Stripe_Helper::is_wc_lt('3.0') ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_card_id', true);
463 463
 
464 464
 				// Take this opportunity to update the key name.
465
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $subscription->order->id, '_stripe_source_id', $stripe_source_id ) : update_post_meta( $subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id );
465
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($subscription->order->id, '_stripe_source_id', $stripe_source_id) : update_post_meta($subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id);
466 466
 			}
467 467
 		}
468 468
 
469
-		$stripe_customer->set_id( $stripe_customer_id );
469
+		$stripe_customer->set_id($stripe_customer_id);
470 470
 
471 471
 		$sources                   = $stripe_customer->get_sources();
472
-		$payment_method_to_display = __( 'N/A', 'woocommerce-gateway-stripe' );
472
+		$payment_method_to_display = __('N/A', 'woocommerce-gateway-stripe');
473 473
 
474
-		if ( $sources ) {
475
-			foreach ( $sources as $source ) {
476
-				if ( $source->id === $stripe_source_id ) {
477
-					if ( $source->sepa_debit ) {
474
+		if ($sources) {
475
+			foreach ($sources as $source) {
476
+				if ($source->id === $stripe_source_id) {
477
+					if ($source->sepa_debit) {
478 478
 						/* translators: 1) last 4 digits of SEPA Direct Debit */
479
-						$payment_method_to_display = sprintf( __( 'Via SEPA Direct Debit ending in %1$s', 'woocommerce-gateway-stripe' ), $source->sepa_debit->last4 );
479
+						$payment_method_to_display = sprintf(__('Via SEPA Direct Debit ending in %1$s', 'woocommerce-gateway-stripe'), $source->sepa_debit->last4);
480 480
 					}
481 481
 
482 482
 					break;
Please login to merge, or discard this patch.
includes/class-wc-stripe-webhook-handler.php 1 patch
Spacing   +189 added lines, -189 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,9 +32,9 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public function __construct() {
34 34
 		$this->retry_interval = 2;
35
-		$stripe_settings      = get_option( 'woocommerce_stripe_settings', array() );
36
-		$this->testmode       = ( ! empty( $stripe_settings['testmode'] ) && 'yes' === $stripe_settings['testmode'] ) ? true : false;
37
-		add_action( 'woocommerce_api_wc_stripe', array( $this, 'check_for_webhook' ) );
35
+		$stripe_settings      = get_option('woocommerce_stripe_settings', array());
36
+		$this->testmode       = ( ! empty($stripe_settings['testmode']) && 'yes' === $stripe_settings['testmode']) ? true : false;
37
+		add_action('woocommerce_api_wc_stripe', array($this, 'check_for_webhook'));
38 38
 	}
39 39
 
40 40
 	/**
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
 	 * @version 4.0.0
45 45
 	 */
46 46
 	public function check_for_webhook() {
47
-		if ( ( 'POST' !== $_SERVER['REQUEST_METHOD'] )
48
-			|| ! isset( $_GET['wc-api'] )
49
-			|| ( 'wc_stripe' !== $_GET['wc-api'] )
47
+		if (('POST' !== $_SERVER['REQUEST_METHOD'])
48
+			|| ! isset($_GET['wc-api'])
49
+			|| ('wc_stripe' !== $_GET['wc-api'])
50 50
 		) {
51 51
 			return;
52 52
 		}
53 53
 
54
-		$request_body    = file_get_contents( 'php://input' );
55
-		$request_headers = array_change_key_case( $this->get_request_headers(), CASE_UPPER );
54
+		$request_body    = file_get_contents('php://input');
55
+		$request_headers = array_change_key_case($this->get_request_headers(), CASE_UPPER);
56 56
 
57 57
 		// Validate it to make sure it is legit.
58
-		if ( $this->is_valid_request( $request_headers, $request_body ) ) {
59
-			$this->process_webhook( $request_body );
60
-			status_header( 200 );
58
+		if ($this->is_valid_request($request_headers, $request_body)) {
59
+			$this->process_webhook($request_body);
60
+			status_header(200);
61 61
 			exit;
62 62
 		} else {
63
-			WC_Stripe_Logger::log( 'Incoming webhook failed validation: ' . print_r( $request_body, true ) );
64
-			status_header( 400 );
63
+			WC_Stripe_Logger::log('Incoming webhook failed validation: ' . print_r($request_body, true));
64
+			status_header(400);
65 65
 			exit;
66 66
 		}
67 67
 	}
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 	 * @param string $request_body The request body from Stripe.
77 77
 	 * @return bool
78 78
 	 */
79
-	public function is_valid_request( $request_headers = null, $request_body = null ) {
80
-		if ( null === $request_headers || null === $request_body ) {
79
+	public function is_valid_request($request_headers = null, $request_body = null) {
80
+		if (null === $request_headers || null === $request_body) {
81 81
 			return false;
82 82
 		}
83 83
 
84
-		if ( ! empty( $request_headers['USER-AGENT'] ) && ! preg_match( '/Stripe/', $request_headers['USER-AGENT'] ) ) {
84
+		if ( ! empty($request_headers['USER-AGENT']) && ! preg_match('/Stripe/', $request_headers['USER-AGENT'])) {
85 85
 			return false;
86 86
 		}
87 87
 
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 	 * @version 4.0.0
98 98
 	 */
99 99
 	public function get_request_headers() {
100
-		if ( ! function_exists( 'getallheaders' ) ) {
100
+		if ( ! function_exists('getallheaders')) {
101 101
 			$headers = array();
102 102
 
103
-			foreach ( $_SERVER as $name => $value ) {
104
-				if ( 'HTTP_' === substr( $name, 0, 5 ) ) {
105
-					$headers[ str_replace( ' ', '-', ucwords( strtolower( str_replace( '_', ' ', substr( $name, 5 ) ) ) ) ) ] = $value;
103
+			foreach ($_SERVER as $name => $value) {
104
+				if ('HTTP_' === substr($name, 0, 5)) {
105
+					$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
106 106
 				}
107 107
 			}
108 108
 
@@ -121,30 +121,30 @@  discard block
 block discarded – undo
121 121
 	 * @param object $notification
122 122
 	 * @param bool $retry
123 123
 	 */
124
-	public function process_webhook_payment( $notification, $retry = true ) {
124
+	public function process_webhook_payment($notification, $retry = true) {
125 125
 		// The following 3 payment methods are synchronous so does not need to be handle via webhook.
126
-		if ( 'card' === $notification->data->object->type || 'sepa_debit' === $notification->data->object->type || 'three_d_secure' === $notification->data->object->type ) {
126
+		if ('card' === $notification->data->object->type || 'sepa_debit' === $notification->data->object->type || 'three_d_secure' === $notification->data->object->type) {
127 127
 			return;
128 128
 		}
129 129
 
130
-		$order = WC_Stripe_Helper::get_order_by_source_id( $notification->data->object->id );
130
+		$order = WC_Stripe_Helper::get_order_by_source_id($notification->data->object->id);
131 131
 
132
-		if ( ! $order ) {
133
-			WC_Stripe_Logger::log( 'Could not find order via source ID: ' . $notification->data->object->id );
132
+		if ( ! $order) {
133
+			WC_Stripe_Logger::log('Could not find order via source ID: ' . $notification->data->object->id);
134 134
 			return;
135 135
 		}
136 136
 
137
-		$order_id  = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
137
+		$order_id  = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
138 138
 		$source_id = $notification->data->object->id;
139 139
 
140
-		$is_pending_receiver = ( 'receiver' === $notification->data->object->flow );
140
+		$is_pending_receiver = ('receiver' === $notification->data->object->flow);
141 141
 
142 142
 		try {
143
-			if ( 'processing' === $order->get_status() || 'completed' === $order->get_status() ) {
143
+			if ('processing' === $order->get_status() || 'completed' === $order->get_status()) {
144 144
 				return;
145 145
 			}
146 146
 
147
-			if ( 'on-hold' === $order->get_status() && ! $is_pending_receiver ) {
147
+			if ('on-hold' === $order->get_status() && ! $is_pending_receiver) {
148 148
 				return;
149 149
 			}
150 150
 
@@ -152,94 +152,94 @@  discard block
 block discarded – undo
152 152
 			$response = null;
153 153
 
154 154
 			// This will throw exception if not valid.
155
-			$this->validate_minimum_order_amount( $order );
155
+			$this->validate_minimum_order_amount($order);
156 156
 
157
-			WC_Stripe_Logger::log( "Info: (Webhook) Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
157
+			WC_Stripe_Logger::log("Info: (Webhook) Begin processing payment for order $order_id for the amount of {$order->get_total()}");
158 158
 
159 159
 			// Prep source object.
160 160
 			$source_object           = new stdClass();
161 161
 			$source_object->token_id = '';
162
-			$source_object->customer = $this->get_stripe_customer_id( $order );
162
+			$source_object->customer = $this->get_stripe_customer_id($order);
163 163
 			$source_object->source   = $source_id;
164 164
 
165 165
 			// Make the request.
166
-			$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source_object ), 'charges', 'POST', true );
166
+			$response = WC_Stripe_API::request($this->generate_payment_request($order, $source_object), 'charges', 'POST', true);
167 167
 			$headers  = $response['headers'];
168 168
 			$response = $response['body'];
169 169
 
170
-			if ( ! empty( $response->error ) ) {
170
+			if ( ! empty($response->error)) {
171 171
 				// Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without.
172
-				if ( $this->is_no_such_customer_error( $response->error ) ) {
173
-					if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
174
-						delete_user_meta( $order->customer_user, '_stripe_customer_id' );
175
-						delete_post_meta( $order_id, '_stripe_customer_id' );
172
+				if ($this->is_no_such_customer_error($response->error)) {
173
+					if (WC_Stripe_Helper::is_wc_lt('3.0')) {
174
+						delete_user_meta($order->customer_user, '_stripe_customer_id');
175
+						delete_post_meta($order_id, '_stripe_customer_id');
176 176
 					} else {
177
-						delete_user_meta( $order->get_customer_id(), '_stripe_customer_id' );
178
-						$order->delete_meta_data( '_stripe_customer_id' );
177
+						delete_user_meta($order->get_customer_id(), '_stripe_customer_id');
178
+						$order->delete_meta_data('_stripe_customer_id');
179 179
 						$order->save();
180 180
 					}
181 181
 				}
182 182
 
183
-				if ( $this->is_no_such_token_error( $response->error ) && $prepared_source->token_id ) {
183
+				if ($this->is_no_such_token_error($response->error) && $prepared_source->token_id) {
184 184
 					// Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message.
185
-					$wc_token = WC_Payment_Tokens::get( $prepared_source->token_id );
185
+					$wc_token = WC_Payment_Tokens::get($prepared_source->token_id);
186 186
 					$wc_token->delete();
187
-					$localized_message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' );
188
-					$order->add_order_note( $localized_message );
189
-					throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
187
+					$localized_message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe');
188
+					$order->add_order_note($localized_message);
189
+					throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
190 190
 				}
191 191
 
192 192
 				// We want to retry.
193
-				if ( $this->is_retryable_error( $response->error ) ) {
194
-					if ( $retry ) {
193
+				if ($this->is_retryable_error($response->error)) {
194
+					if ($retry) {
195 195
 						// Don't do anymore retries after this.
196
-						if ( 5 <= $this->retry_interval ) {
196
+						if (5 <= $this->retry_interval) {
197 197
 
198
-							return $this->process_webhook_payment( $notification, false );
198
+							return $this->process_webhook_payment($notification, false);
199 199
 						}
200 200
 
201
-						sleep( $this->retry_interval );
201
+						sleep($this->retry_interval);
202 202
 
203 203
 						$this->retry_interval++;
204
-						return $this->process_webhook_payment( $notification, true );
204
+						return $this->process_webhook_payment($notification, true);
205 205
 					} else {
206
-						$localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' );
207
-						$order->add_order_note( $localized_message );
208
-						throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
206
+						$localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe');
207
+						$order->add_order_note($localized_message);
208
+						throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
209 209
 					}
210 210
 				}
211 211
 
212 212
 				$localized_messages = WC_Stripe_Helper::get_localized_messages();
213 213
 
214
-				if ( 'card_error' === $response->error->type ) {
215
-					$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
214
+				if ('card_error' === $response->error->type) {
215
+					$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
216 216
 				} else {
217
-					$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
217
+					$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
218 218
 				}
219 219
 
220
-				$order->add_order_note( $localized_message );
220
+				$order->add_order_note($localized_message);
221 221
 
222
-				throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
222
+				throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
223 223
 			}
224 224
 
225 225
 			// To prevent double processing the order on WC side.
226
-			if ( ! $this->is_original_request( $headers ) ) {
226
+			if ( ! $this->is_original_request($headers)) {
227 227
 				return;
228 228
 			}
229 229
 
230
-			do_action( 'wc_gateway_stripe_process_webhook_payment', $response, $order );
230
+			do_action('wc_gateway_stripe_process_webhook_payment', $response, $order);
231 231
 
232
-			$this->process_response( $response, $order );
232
+			$this->process_response($response, $order);
233 233
 
234
-		} catch ( WC_Stripe_Exception $e ) {
235
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
234
+		} catch (WC_Stripe_Exception $e) {
235
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
236 236
 
237
-			do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification, $e );
237
+			do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification, $e);
238 238
 
239
-			$statuses = array( 'pending', 'failed' );
239
+			$statuses = array('pending', 'failed');
240 240
 
241
-			if ( $order->has_status( $statuses ) ) {
242
-				$this->send_failed_order_email( $order_id );
241
+			if ($order->has_status($statuses)) {
242
+				$this->send_failed_order_email($order_id);
243 243
 			}
244 244
 		}
245 245
 	}
@@ -252,21 +252,21 @@  discard block
 block discarded – undo
252 252
 	 * @since 4.0.0
253 253
 	 * @param object $notification
254 254
 	 */
255
-	public function process_webhook_dispute( $notification ) {
256
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge );
255
+	public function process_webhook_dispute($notification) {
256
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->charge);
257 257
 
258
-		if ( ! $order ) {
259
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->charge );
258
+		if ( ! $order) {
259
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->charge);
260 260
 			return;
261 261
 		}
262 262
 
263 263
 		/* translators: 1) The URL to the order. */
264
-		$order->update_status( 'on-hold', sprintf( __( 'A dispute was created for this order. Response is needed. Please go to your <a href="%s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review this dispute.', 'woocommerce-gateway-stripe' ), $this->get_transaction_url( $order ) ) );
264
+		$order->update_status('on-hold', sprintf(__('A dispute was created for this order. Response is needed. Please go to your <a href="%s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review this dispute.', 'woocommerce-gateway-stripe'), $this->get_transaction_url($order)));
265 265
 
266
-		do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification );
266
+		do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification);
267 267
 
268
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
269
-		$this->send_failed_order_email( $order_id );
268
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
269
+		$this->send_failed_order_email($order_id);
270 270
 	}
271 271
 
272 272
 	/**
@@ -277,44 +277,44 @@  discard block
 block discarded – undo
277 277
 	 * @version 4.0.0
278 278
 	 * @param object $notification
279 279
 	 */
280
-	public function process_webhook_capture( $notification ) {
281
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id );
280
+	public function process_webhook_capture($notification) {
281
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id);
282 282
 
283
-		if ( ! $order ) {
284
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id );
283
+		if ( ! $order) {
284
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->id);
285 285
 			return;
286 286
 		}
287 287
 
288
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
288
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
289 289
 
290
-		if ( 'stripe' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method() ) ) {
291
-			$charge   = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_transaction_id', true ) : $order->get_transaction_id();
292
-			$captured = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_stripe_charge_captured', true ) : $order->get_meta( '_stripe_charge_captured', true );
290
+		if ('stripe' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method())) {
291
+			$charge   = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_transaction_id', true) : $order->get_transaction_id();
292
+			$captured = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_stripe_charge_captured', true) : $order->get_meta('_stripe_charge_captured', true);
293 293
 
294
-			if ( $charge && 'no' === $captured ) {
295
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_stripe_charge_captured', 'yes' ) : $order->update_meta_data( '_stripe_charge_captured', 'yes' );
294
+			if ($charge && 'no' === $captured) {
295
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_stripe_charge_captured', 'yes') : $order->update_meta_data('_stripe_charge_captured', 'yes');
296 296
 
297 297
 				// Store other data such as fees
298
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_transaction_id', $notification->data->object->id ) : $order->set_transaction_id( $notification->data->object->id );
298
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_transaction_id', $notification->data->object->id) : $order->set_transaction_id($notification->data->object->id);
299 299
 
300
-				if ( isset( $notification->data->object->balance_transaction ) ) {
301
-					$this->update_fees( $order, $notification->data->object->balance_transaction );
300
+				if (isset($notification->data->object->balance_transaction)) {
301
+					$this->update_fees($order, $notification->data->object->balance_transaction);
302 302
 				}
303 303
 
304 304
 				// Check and see if capture is partial.
305
-				if ( $this->is_partial_capture( $notification ) ) {
306
-					$partial_amount = $this->get_partial_amount_to_charge( $notification );
307
-					$order->set_total( $partial_amount );
305
+				if ($this->is_partial_capture($notification)) {
306
+					$partial_amount = $this->get_partial_amount_to_charge($notification);
307
+					$order->set_total($partial_amount);
308 308
 					/* translators: partial captured amount */
309
-					$order->add_order_note( sprintf( __( 'This charge was partially captured via Stripe Dashboard in the amount of: %s', 'woocommerce-gateway-stripe' ), $partial_amount ) );
309
+					$order->add_order_note(sprintf(__('This charge was partially captured via Stripe Dashboard in the amount of: %s', 'woocommerce-gateway-stripe'), $partial_amount));
310 310
 				} else {
311
-					$order->payment_complete( $notification->data->object->id );
311
+					$order->payment_complete($notification->data->object->id);
312 312
 
313 313
 					/* translators: transaction id */
314
-					$order->add_order_note( sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $notification->data->object->id ) );
314
+					$order->add_order_note(sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $notification->data->object->id));
315 315
 				}
316 316
 
317
-				if ( is_callable( array( $order, 'save' ) ) ) {
317
+				if (is_callable(array($order, 'save'))) {
318 318
 					$order->save();
319 319
 				}
320 320
 			}
@@ -329,38 +329,38 @@  discard block
 block discarded – undo
329 329
 	 * @version 4.0.0
330 330
 	 * @param object $notification
331 331
 	 */
332
-	public function process_webhook_charge_succeeded( $notification ) {
332
+	public function process_webhook_charge_succeeded($notification) {
333 333
 		// The following payment methods are synchronous so does not need to be handle via webhook.
334
-		if ( ( isset( $notification->data->object->source->type ) && 'card' === $notification->data->object->source->type ) || ( isset( $notification->data->object->source->type ) && 'three_d_secure' === $notification->data->object->source->type ) ) {
334
+		if ((isset($notification->data->object->source->type) && 'card' === $notification->data->object->source->type) || (isset($notification->data->object->source->type) && 'three_d_secure' === $notification->data->object->source->type)) {
335 335
 			return;
336 336
 		}
337 337
 
338
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id );
338
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id);
339 339
 
340
-		if ( ! $order ) {
341
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id );
340
+		if ( ! $order) {
341
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->id);
342 342
 			return;
343 343
 		}
344 344
 
345
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
345
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
346 346
 
347
-		if ( 'on-hold' !== $order->get_status() ) {
347
+		if ('on-hold' !== $order->get_status()) {
348 348
 			return;
349 349
 		}
350 350
 
351 351
 		// Store other data such as fees
352
-		WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_transaction_id', $notification->data->object->id ) : $order->set_transaction_id( $notification->data->object->id );
352
+		WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_transaction_id', $notification->data->object->id) : $order->set_transaction_id($notification->data->object->id);
353 353
 
354
-		if ( isset( $notification->data->object->balance_transaction ) ) {
355
-			$this->update_fees( $order, $notification->data->object->balance_transaction );
354
+		if (isset($notification->data->object->balance_transaction)) {
355
+			$this->update_fees($order, $notification->data->object->balance_transaction);
356 356
 		}
357 357
 
358
-		$order->payment_complete( $notification->data->object->id );
358
+		$order->payment_complete($notification->data->object->id);
359 359
 
360 360
 		/* translators: transaction id */
361
-		$order->add_order_note( sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $notification->data->object->id ) );
361
+		$order->add_order_note(sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $notification->data->object->id));
362 362
 
363
-		if ( is_callable( array( $order, 'save' ) ) ) {
363
+		if (is_callable(array($order, 'save'))) {
364 364
 			$order->save();
365 365
 		}
366 366
 	}
@@ -372,24 +372,24 @@  discard block
 block discarded – undo
372 372
 	 * @since 4.1.5 Can handle any fail payments from any methods.
373 373
 	 * @param object $notification
374 374
 	 */
375
-	public function process_webhook_charge_failed( $notification ) {
376
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id );
375
+	public function process_webhook_charge_failed($notification) {
376
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id);
377 377
 
378
-		if ( ! $order ) {
379
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id );
378
+		if ( ! $order) {
379
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->id);
380 380
 			return;
381 381
 		}
382 382
 
383
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
383
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
384 384
 
385 385
 		// If order status is already in failed status don't continue.
386
-		if ( 'failed' === $order->get_status() ) {
386
+		if ('failed' === $order->get_status()) {
387 387
 			return;
388 388
 		}
389 389
 
390
-		$order->update_status( 'failed', __( 'This payment failed to clear.', 'woocommerce-gateway-stripe' ) );
390
+		$order->update_status('failed', __('This payment failed to clear.', 'woocommerce-gateway-stripe'));
391 391
 
392
-		do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification );
392
+		do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification);
393 393
 	}
394 394
 
395 395
 	/**
@@ -400,24 +400,24 @@  discard block
 block discarded – undo
400 400
 	 * @version 4.0.0
401 401
 	 * @param object $notification
402 402
 	 */
403
-	public function process_webhook_source_canceled( $notification ) {
404
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id );
403
+	public function process_webhook_source_canceled($notification) {
404
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id);
405 405
 
406 406
 		// If can't find order by charge ID, try source ID.
407
-		if ( ! $order ) {
408
-			$order = WC_Stripe_Helper::get_order_by_source_id( $notification->data->object->id );
407
+		if ( ! $order) {
408
+			$order = WC_Stripe_Helper::get_order_by_source_id($notification->data->object->id);
409 409
 
410
-			if ( ! $order ) {
411
-				WC_Stripe_Logger::log( 'Could not find order via charge/source ID: ' . $notification->data->object->id );
410
+			if ( ! $order) {
411
+				WC_Stripe_Logger::log('Could not find order via charge/source ID: ' . $notification->data->object->id);
412 412
 				return;
413 413
 			}
414 414
 		}
415 415
 
416
-		if ( 'cancelled' !== $order->get_status() ) {
417
-			$order->update_status( 'cancelled', __( 'This payment has cancelled.', 'woocommerce-gateway-stripe' ) );
416
+		if ('cancelled' !== $order->get_status()) {
417
+			$order->update_status('cancelled', __('This payment has cancelled.', 'woocommerce-gateway-stripe'));
418 418
 		}
419 419
 
420
-		do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification );
420
+		do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification);
421 421
 	}
422 422
 
423 423
 	/**
@@ -427,59 +427,59 @@  discard block
 block discarded – undo
427 427
 	 * @version 4.0.0
428 428
 	 * @param object $notification
429 429
 	 */
430
-	public function process_webhook_refund( $notification ) {
431
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id );
430
+	public function process_webhook_refund($notification) {
431
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id);
432 432
 
433
-		if ( ! $order ) {
434
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id );
433
+		if ( ! $order) {
434
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->id);
435 435
 			return;
436 436
 		}
437 437
 
438
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
438
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
439 439
 
440
-		if ( 'stripe' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method() ) ) {
441
-			$charge    = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_transaction_id', true ) : $order->get_transaction_id();
442
-			$captured  = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_stripe_charge_captured', true ) : $order->get_meta( '_stripe_charge_captured', true );
443
-			$refund_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_stripe_refund_id', true ) : $order->get_meta( '_stripe_refund_id', true );
440
+		if ('stripe' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method())) {
441
+			$charge    = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_transaction_id', true) : $order->get_transaction_id();
442
+			$captured  = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_stripe_charge_captured', true) : $order->get_meta('_stripe_charge_captured', true);
443
+			$refund_id = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_stripe_refund_id', true) : $order->get_meta('_stripe_refund_id', true);
444 444
 
445 445
 			// If the refund ID matches, don't continue to prevent double refunding.
446
-			if ( $notification->data->object->refunds->data[0]->id === $refund_id ) {
446
+			if ($notification->data->object->refunds->data[0]->id === $refund_id) {
447 447
 				return;
448 448
 			}
449 449
 
450 450
 			// Only refund captured charge.
451
-			if ( $charge ) {
452
-				$reason = ( isset( $captured ) && 'yes' === $captured ) ? __( 'Refunded via Stripe Dashboard', 'woocommerce-gateway-stripe' ) : __( 'Pre-Authorization Released via Stripe Dashboard', 'woocommerce-gateway-stripe' );
451
+			if ($charge) {
452
+				$reason = (isset($captured) && 'yes' === $captured) ? __('Refunded via Stripe Dashboard', 'woocommerce-gateway-stripe') : __('Pre-Authorization Released via Stripe Dashboard', 'woocommerce-gateway-stripe');
453 453
 
454 454
 				// Create the refund.
455 455
 				$refund = wc_create_refund(
456 456
 					array(
457 457
 						'order_id' => $order_id,
458
-						'amount'   => $this->get_refund_amount( $notification ),
458
+						'amount'   => $this->get_refund_amount($notification),
459 459
 						'reason'   => $reason,
460 460
 					)
461 461
 				);
462 462
 
463
-				if ( is_wp_error( $refund ) ) {
464
-					WC_Stripe_Logger::log( $refund->get_error_message() );
463
+				if (is_wp_error($refund)) {
464
+					WC_Stripe_Logger::log($refund->get_error_message());
465 465
 				}
466 466
 
467
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_stripe_refund_id', $notification->data->object->refunds->data[0]->id ) : $order->update_meta_data( '_stripe_refund_id', $notification->data->object->refunds->data[0]->id );
467
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_stripe_refund_id', $notification->data->object->refunds->data[0]->id) : $order->update_meta_data('_stripe_refund_id', $notification->data->object->refunds->data[0]->id);
468 468
 
469
-				$amount = wc_price( $notification->data->object->refunds->data[0]->amount / 100 );
469
+				$amount = wc_price($notification->data->object->refunds->data[0]->amount / 100);
470 470
 
471
-				if ( in_array( strtolower( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency() ), WC_Stripe_Helper::no_decimal_currencies() ) ) {
472
-					$amount = wc_price( $notification->data->object->refunds->data[0]->amount );
471
+				if (in_array(strtolower(WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency()), WC_Stripe_Helper::no_decimal_currencies())) {
472
+					$amount = wc_price($notification->data->object->refunds->data[0]->amount);
473 473
 				}
474 474
 
475
-				if ( isset( $notification->data->object->refunds->data[0]->balance_transaction ) ) {
476
-					$this->update_fees( $order, $notification->data->object->refunds->data[0]->balance_transaction );
475
+				if (isset($notification->data->object->refunds->data[0]->balance_transaction)) {
476
+					$this->update_fees($order, $notification->data->object->refunds->data[0]->balance_transaction);
477 477
 				}
478 478
 
479 479
 				/* translators: 1) dollar amount 2) transaction id 3) refund message */
480
-				$refund_message = ( isset( $captured ) && 'yes' === $captured ) ? sprintf( __( 'Refunded %1$s - Refund ID: %2$s - %3$s', 'woocommerce-gateway-stripe' ), $amount, $notification->data->object->refunds->data[0]->id, $reason ) : __( 'Pre-Authorization Released via Stripe Dashboard', 'woocommerce-gateway-stripe' );
480
+				$refund_message = (isset($captured) && 'yes' === $captured) ? sprintf(__('Refunded %1$s - Refund ID: %2$s - %3$s', 'woocommerce-gateway-stripe'), $amount, $notification->data->object->refunds->data[0]->id, $reason) : __('Pre-Authorization Released via Stripe Dashboard', 'woocommerce-gateway-stripe');
481 481
 
482
-				$order->add_order_note( $refund_message );
482
+				$order->add_order_note($refund_message);
483 483
 			}
484 484
 		}
485 485
 	}
@@ -490,21 +490,21 @@  discard block
 block discarded – undo
490 490
 	 * @since 4.0.6
491 491
 	 * @param object $notification
492 492
 	 */
493
-	public function process_review_opened( $notification ) {
494
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge );
493
+	public function process_review_opened($notification) {
494
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->charge);
495 495
 
496
-		if ( ! $order ) {
497
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->charge );
496
+		if ( ! $order) {
497
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->charge);
498 498
 			return;
499 499
 		}
500 500
 
501 501
 		/* translators: 1) The URL to the order. 2) The reason type. */
502
-		$message = sprintf( __( 'A review has been opened for this order. Action is needed. Please go to your <a href="%1$s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review the issue. Reason: (%2$s)', 'woocommerce-gateway-stripe' ), $this->get_transaction_url( $order ), $notification->data->object->reason );
502
+		$message = sprintf(__('A review has been opened for this order. Action is needed. Please go to your <a href="%1$s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review the issue. Reason: (%2$s)', 'woocommerce-gateway-stripe'), $this->get_transaction_url($order), $notification->data->object->reason);
503 503
 
504
-		if ( apply_filters( 'wc_stripe_webhook_review_change_order_status', true, $order, $notification ) ) {
505
-			$order->update_status( 'on-hold', $message );
504
+		if (apply_filters('wc_stripe_webhook_review_change_order_status', true, $order, $notification)) {
505
+			$order->update_status('on-hold', $message);
506 506
 		} else {
507
-			$order->add_order_note( $message );
507
+			$order->add_order_note($message);
508 508
 		}
509 509
 	}
510 510
 
@@ -514,25 +514,25 @@  discard block
 block discarded – undo
514 514
 	 * @since 4.0.6
515 515
 	 * @param object $notification
516 516
 	 */
517
-	public function process_review_closed( $notification ) {
518
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge );
517
+	public function process_review_closed($notification) {
518
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->charge);
519 519
 
520
-		if ( ! $order ) {
521
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->charge );
520
+		if ( ! $order) {
521
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->charge);
522 522
 			return;
523 523
 		}
524 524
 
525 525
 		/* translators: 1) The reason type. */
526
-		$message = sprintf( __( 'The opened review for this order is now closed. Reason: (%s)', 'woocommerce-gateway-stripe' ), $notification->data->object->reason );
526
+		$message = sprintf(__('The opened review for this order is now closed. Reason: (%s)', 'woocommerce-gateway-stripe'), $notification->data->object->reason);
527 527
 
528
-		if ( 'on-hold' === $order->get_status() ) {
529
-			if ( apply_filters( 'wc_stripe_webhook_review_change_order_status', true, $order, $notification ) ) {
530
-				$order->update_status( 'processing', $message );
528
+		if ('on-hold' === $order->get_status()) {
529
+			if (apply_filters('wc_stripe_webhook_review_change_order_status', true, $order, $notification)) {
530
+				$order->update_status('processing', $message);
531 531
 			} else {
532
-				$order->add_order_note( $message );
532
+				$order->add_order_note($message);
533 533
 			}
534 534
 		} else {
535
-			$order->add_order_note( $message );
535
+			$order->add_order_note($message);
536 536
 		}
537 537
 	}
538 538
 
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 	 * @version 4.0.0
544 544
 	 * @param object $notification
545 545
 	 */
546
-	public function is_partial_capture( $notification ) {
546
+	public function is_partial_capture($notification) {
547 547
 		return 0 < $notification->data->object->amount_refunded;
548 548
 	}
549 549
 
@@ -554,11 +554,11 @@  discard block
 block discarded – undo
554 554
 	 * @version 4.0.0
555 555
 	 * @param object $notification
556 556
 	 */
557
-	public function get_refund_amount( $notification ) {
558
-		if ( $this->is_partial_capture( $notification ) ) {
557
+	public function get_refund_amount($notification) {
558
+		if ($this->is_partial_capture($notification)) {
559 559
 			$amount = $notification->data->object->refunds->data[0]->amount / 100;
560 560
 
561
-			if ( in_array( strtolower( $notification->data->object->currency ), WC_Stripe_Helper::no_decimal_currencies() ) ) {
561
+			if (in_array(strtolower($notification->data->object->currency), WC_Stripe_Helper::no_decimal_currencies())) {
562 562
 				$amount = $notification->data->object->refunds->data[0]->amount;
563 563
 			}
564 564
 
@@ -575,12 +575,12 @@  discard block
 block discarded – undo
575 575
 	 * @version 4.0.0
576 576
 	 * @param object $notification
577 577
 	 */
578
-	public function get_partial_amount_to_charge( $notification ) {
579
-		if ( $this->is_partial_capture( $notification ) ) {
580
-			$amount = ( $notification->data->object->amount - $notification->data->object->amount_refunded ) / 100;
578
+	public function get_partial_amount_to_charge($notification) {
579
+		if ($this->is_partial_capture($notification)) {
580
+			$amount = ($notification->data->object->amount - $notification->data->object->amount_refunded) / 100;
581 581
 
582
-			if ( in_array( strtolower( $notification->data->object->currency ), WC_Stripe_Helper::no_decimal_currencies() ) ) {
583
-				$amount = ( $notification->data->object->amount - $notification->data->object->amount_refunded );
582
+			if (in_array(strtolower($notification->data->object->currency), WC_Stripe_Helper::no_decimal_currencies())) {
583
+				$amount = ($notification->data->object->amount - $notification->data->object->amount_refunded);
584 584
 			}
585 585
 
586 586
 			return $amount;
@@ -596,44 +596,44 @@  discard block
 block discarded – undo
596 596
 	 * @version 4.0.0
597 597
 	 * @param string $request_body
598 598
 	 */
599
-	public function process_webhook( $request_body ) {
600
-		$notification = json_decode( $request_body );
599
+	public function process_webhook($request_body) {
600
+		$notification = json_decode($request_body);
601 601
 
602
-		switch ( $notification->type ) {
602
+		switch ($notification->type) {
603 603
 			case 'source.chargeable':
604
-				$this->process_webhook_payment( $notification );
604
+				$this->process_webhook_payment($notification);
605 605
 				break;
606 606
 
607 607
 			case 'source.canceled':
608
-				$this->process_webhook_source_canceled( $notification );
608
+				$this->process_webhook_source_canceled($notification);
609 609
 				break;
610 610
 
611 611
 			case 'charge.succeeded':
612
-				$this->process_webhook_charge_succeeded( $notification );
612
+				$this->process_webhook_charge_succeeded($notification);
613 613
 				break;
614 614
 
615 615
 			case 'charge.failed':
616
-				$this->process_webhook_charge_failed( $notification );
616
+				$this->process_webhook_charge_failed($notification);
617 617
 				break;
618 618
 
619 619
 			case 'charge.captured':
620
-				$this->process_webhook_capture( $notification );
620
+				$this->process_webhook_capture($notification);
621 621
 				break;
622 622
 
623 623
 			case 'charge.dispute.created':
624
-				$this->process_webhook_dispute( $notification );
624
+				$this->process_webhook_dispute($notification);
625 625
 				break;
626 626
 
627 627
 			case 'charge.refunded':
628
-				$this->process_webhook_refund( $notification );
628
+				$this->process_webhook_refund($notification);
629 629
 				break;
630 630
 
631 631
 			case 'review.opened':
632
-				$this->process_review_opened( $notification );
632
+				$this->process_review_opened($notification);
633 633
 				break;
634 634
 
635 635
 			case 'review.closed':
636
-				$this->process_review_closed( $notification );
636
+				$this->process_review_closed($notification);
637 637
 				break;
638 638
 
639 639
 		}
Please login to merge, or discard this patch.
includes/abstracts/abstract-wc-stripe-payment-gateway.php 1 patch
Spacing   +269 added lines, -270 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function display_admin_settings_webhook_description() {
23 23
 		/* translators: 1) webhook url */
24
-		return sprintf( __( 'You must add the following webhook endpoint <strong style="background-color:#ddd;">&nbsp;%s&nbsp;</strong> to your <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Stripe account settings</a>. This will enable you to receive notifications on the charge statuses.', 'woocommerce-gateway-stripe' ), WC_Stripe_Helper::get_webhook_url() );
24
+		return sprintf(__('You must add the following webhook endpoint <strong style="background-color:#ddd;">&nbsp;%s&nbsp;</strong> to your <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Stripe account settings</a>. This will enable you to receive notifications on the charge statuses.', 'woocommerce-gateway-stripe'), WC_Stripe_Helper::get_webhook_url());
25 25
 	}
26 26
 
27 27
 	/**
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 				<input id="wc-%1$s-new-payment-method" name="wc-%1$s-new-payment-method" type="checkbox" value="true" style="width:auto;" />
36 36
 				<label for="wc-%1$s-new-payment-method" style="display:inline;">%2$s</label>
37 37
 			</p>',
38
-			esc_attr( $this->id ),
39
-			esc_html( apply_filters( 'wc_stripe_save_to_account_text', __( 'Save payment information to my account for future purchases.', 'woocommerce-gateway-stripe' ) ) )
38
+			esc_attr($this->id),
39
+			esc_html(apply_filters('wc_stripe_save_to_account_text', __('Save payment information to my account for future purchases.', 'woocommerce-gateway-stripe')))
40 40
 		);
41 41
 	}
42 42
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @since 4.0.5
48 48
 	 * @param array $error
49 49
 	 */
50
-	public function is_retryable_error( $error ) {
50
+	public function is_retryable_error($error) {
51 51
 		return (
52 52
 			'invalid_request_error' === $error->type ||
53 53
 			'idempotency_error' === $error->type ||
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 	 * @since 4.1.0
65 65
 	 * @param array $error
66 66
 	 */
67
-	public function is_same_idempotency_error( $error ) {
67
+	public function is_same_idempotency_error($error) {
68 68
 		return (
69 69
 			$error &&
70 70
 			'idempotency_error' === $error->type &&
71
-			preg_match( '/Keys for idempotent requests can only be used with the same parameters they were first used with./i', $error->message )
71
+			preg_match('/Keys for idempotent requests can only be used with the same parameters they were first used with./i', $error->message)
72 72
 		);
73 73
 	}
74 74
 
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
 	 * @since 4.1.0
80 80
 	 * @param array $error
81 81
 	 */
82
-	public function is_source_already_consumed_error( $error ) {
82
+	public function is_source_already_consumed_error($error) {
83 83
 		return (
84 84
 			$error &&
85 85
 			'invalid_request_error' === $error->type &&
86
-			preg_match( '/The reusable source you provided is consumed because it was previously charged without being attached to a customer or was detached from a customer. To charge a reusable source multiple time you must attach it to a customer first./i', $error->message )
86
+			preg_match('/The reusable source you provided is consumed because it was previously charged without being attached to a customer or was detached from a customer. To charge a reusable source multiple time you must attach it to a customer first./i', $error->message)
87 87
 		);
88 88
 	}
89 89
 
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 	 * @since 4.1.0
95 95
 	 * @param array $error
96 96
 	 */
97
-	public function is_no_such_customer_error( $error ) {
97
+	public function is_no_such_customer_error($error) {
98 98
 		return (
99 99
 			$error &&
100 100
 			'invalid_request_error' === $error->type &&
101
-			preg_match( '/No such customer/i', $error->message )
101
+			preg_match('/No such customer/i', $error->message)
102 102
 		);
103 103
 	}
104 104
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 	 * @since 4.1.0
110 110
 	 * @param array $error
111 111
 	 */
112
-	public function is_no_such_token_error( $error ) {
112
+	public function is_no_such_token_error($error) {
113 113
 		return (
114 114
 			$error &&
115 115
 			'invalid_request_error' === $error->type &&
116
-			preg_match( '/No such token/i', $error->message )
116
+			preg_match('/No such token/i', $error->message)
117 117
 		);
118 118
 	}
119 119
 
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 	 * @since 4.1.0
125 125
 	 * @param array $error
126 126
 	 */
127
-	public function is_no_such_source_error( $error ) {
127
+	public function is_no_such_source_error($error) {
128 128
 		return (
129 129
 			$error &&
130 130
 			'invalid_request_error' === $error->type &&
131
-			preg_match( '/No such source/i', $error->message )
131
+			preg_match('/No such source/i', $error->message)
132 132
 		);
133 133
 	}
134 134
 
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 	 * @since 4.1.0
140 140
 	 * @param array $error
141 141
 	 */
142
-	public function is_no_linked_source_error( $error ) {
142
+	public function is_no_linked_source_error($error) {
143 143
 		return (
144 144
 			$error &&
145 145
 			'invalid_request_error' === $error->type &&
146
-			preg_match( '/does not have a linked source with ID/i', $error->message )
146
+			preg_match('/does not have a linked source with ID/i', $error->message)
147 147
 		);
148 148
 	}
149 149
 
@@ -156,13 +156,13 @@  discard block
 block discarded – undo
156 156
 	 * @param object $error
157 157
 	 * @return bool
158 158
 	 */
159
-	public function need_update_idempotency_key( $source_object, $error ) {
159
+	public function need_update_idempotency_key($source_object, $error) {
160 160
 		return (
161 161
 			$error &&
162 162
 			1 < $this->retry_interval &&
163
-			! empty( $source_object ) &&
163
+			! empty($source_object) &&
164 164
 			'chargeable' === $source_object->status &&
165
-			self::is_same_idempotency_error( $error )
165
+			self::is_same_idempotency_error($error)
166 166
 		);
167 167
 	}
168 168
 
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	 * @since 4.1.3
173 173
 	 */
174 174
 	public function is_available() {
175
-		if ( 'yes' === $this->enabled ) {
176
-			if ( ! $this->secret_key || ! $this->publishable_key ) {
175
+		if ('yes' === $this->enabled) {
176
+			if ( ! $this->secret_key || ! $this->publishable_key) {
177 177
 				return false;
178 178
 			}
179 179
 			return true;
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 	 * @param int $order_id
191 191
 	 * @return bool
192 192
 	 */
193
-	public function maybe_process_pre_orders( $order_id ) {
193
+	public function maybe_process_pre_orders($order_id) {
194 194
 		return (
195 195
 			WC_Stripe_Helper::is_pre_orders_exists() &&
196
-			$this->pre_orders->is_pre_order( $order_id ) &&
197
-			WC_Pre_Orders_Order::order_requires_payment_tokenization( $order_id ) &&
198
-			! is_wc_endpoint_url( 'order-pay' )
196
+			$this->pre_orders->is_pre_order($order_id) &&
197
+			WC_Pre_Orders_Order::order_requires_payment_tokenization($order_id) &&
198
+			! is_wc_endpoint_url('order-pay')
199 199
 		);
200 200
 	}
201 201
 
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 	 * @since 1.0.0
206 206
 	 * @version 4.0.0
207 207
 	 */
208
-	public function add_admin_notice( $slug, $class, $message, $dismissible = false ) {
209
-		$this->notices[ $slug ] = array(
208
+	public function add_admin_notice($slug, $class, $message, $dismissible = false) {
209
+		$this->notices[$slug] = array(
210 210
 			'class'       => $class,
211 211
 			'message'     => $message,
212 212
 			'dismissible' => $dismissible,
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 	 * @version 4.0.0
254 254
 	 * @param object $order
255 255
 	 */
256
-	public function validate_minimum_order_amount( $order ) {
257
-		if ( $order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount() ) {
256
+	public function validate_minimum_order_amount($order) {
257
+		if ($order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount()) {
258 258
 			/* translators: 1) dollar amount */
259
-			throw new WC_Stripe_Exception( 'Did not meet minimum amount', sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe_Helper::get_minimum_amount() / 100 ) ) );
259
+			throw new WC_Stripe_Exception('Did not meet minimum amount', sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe_Helper::get_minimum_amount() / 100)));
260 260
 		}
261 261
 	}
262 262
 
@@ -266,14 +266,14 @@  discard block
 block discarded – undo
266 266
 	 * @since 4.0.0
267 267
 	 * @version 4.0.0
268 268
 	 */
269
-	public function get_transaction_url( $order ) {
270
-		if ( $this->testmode ) {
269
+	public function get_transaction_url($order) {
270
+		if ($this->testmode) {
271 271
 			$this->view_transaction_url = 'https://dashboard.stripe.com/test/payments/%s';
272 272
 		} else {
273 273
 			$this->view_transaction_url = 'https://dashboard.stripe.com/payments/%s';
274 274
 		}
275 275
 
276
-		return parent::get_transaction_url( $order );
276
+		return parent::get_transaction_url($order);
277 277
 	}
278 278
 
279 279
 	/**
@@ -282,15 +282,15 @@  discard block
 block discarded – undo
282 282
 	 * @since 4.0.0
283 283
 	 * @version 4.0.0
284 284
 	 */
285
-	public function get_stripe_customer_id( $order ) {
286
-		$customer = get_user_meta( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id(), '_stripe_customer_id', true );
285
+	public function get_stripe_customer_id($order) {
286
+		$customer = get_user_meta(WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id(), '_stripe_customer_id', true);
287 287
 
288
-		if ( empty( $customer ) ) {
288
+		if (empty($customer)) {
289 289
 			// Try to get it via the order.
290
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
291
-				return get_post_meta( $order->id, '_stripe_customer_id', true );
290
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
291
+				return get_post_meta($order->id, '_stripe_customer_id', true);
292 292
 			} else {
293
-				return $order->get_meta( '_stripe_customer_id', true );
293
+				return $order->get_meta('_stripe_customer_id', true);
294 294
 			}
295 295
 		} else {
296 296
 			return $customer;
@@ -307,23 +307,23 @@  discard block
 block discarded – undo
307 307
 	 * @param object $order
308 308
 	 * @param int $id Stripe session id.
309 309
 	 */
310
-	public function get_stripe_return_url( $order = null, $id = null ) {
311
-		if ( is_object( $order ) ) {
312
-			if ( empty( $id ) ) {
310
+	public function get_stripe_return_url($order = null, $id = null) {
311
+		if (is_object($order)) {
312
+			if (empty($id)) {
313 313
 				$id = uniqid();
314 314
 			}
315 315
 
316
-			$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
316
+			$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
317 317
 
318 318
 			$args = array(
319 319
 				'utm_nooverride' => '1',
320 320
 				'order_id'       => $order_id,
321 321
 			);
322 322
 
323
-			return esc_url_raw( add_query_arg( $args, $this->get_return_url( $order ) ) );
323
+			return esc_url_raw(add_query_arg($args, $this->get_return_url($order)));
324 324
 		}
325 325
 
326
-		return esc_url_raw( add_query_arg( array( 'utm_nooverride' => '1' ), $this->get_return_url() ) );
326
+		return esc_url_raw(add_query_arg(array('utm_nooverride' => '1'), $this->get_return_url()));
327 327
 	}
328 328
 
329 329
 	/**
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 	 * @param  int  $order_id
332 332
 	 * @return boolean
333 333
 	 */
334
-	public function has_subscription( $order_id ) {
335
-		return ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_is_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ) );
334
+	public function has_subscription($order_id) {
335
+		return (function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order_id) || wcs_is_subscription($order_id) || wcs_order_contains_renewal($order_id)));
336 336
 	}
337 337
 
338 338
 	/**
@@ -344,34 +344,33 @@  discard block
 block discarded – undo
344 344
 	 * @param  object $prepared_source
345 345
 	 * @return array()
346 346
 	 */
347
-	public function generate_payment_request( $order, $prepared_source ) {
348
-		$settings              = get_option( 'woocommerce_stripe_settings', array() );
349
-		$statement_descriptor  = ! empty( $settings['statement_descriptor'] ) ? str_replace( "'", '', $settings['statement_descriptor'] ) : '';
350
-		$capture               = ! empty( $settings['capture'] ) && 'yes' === $settings['capture'] ? true : false;
347
+	public function generate_payment_request($order, $prepared_source) {
348
+		$settings              = get_option('woocommerce_stripe_settings', array());
349
+		$statement_descriptor  = ! empty($settings['statement_descriptor']) ? str_replace("'", '', $settings['statement_descriptor']) : '';
350
+		$capture               = ! empty($settings['capture']) && 'yes' === $settings['capture'] ? true : false;
351 351
 		$post_data             = array();
352
-		$post_data['currency'] = strtolower( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency() );
353
-		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $post_data['currency'] );
352
+		$post_data['currency'] = strtolower(WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency());
353
+		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $post_data['currency']);
354 354
 		/* translators: 1) blog name 2) order number */
355
-		$post_data['description'] = sprintf( __( '%1$s - Order %2$s', 'woocommerce-gateway-stripe' ), wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $order->get_order_number() );
356
-		$billing_email            = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_email : $order->get_billing_email();
357
-		$billing_first_name       = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_first_name : $order->get_billing_first_name();
358
-		$billing_last_name        = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_last_name : $order->get_billing_last_name();
355
+		$post_data['description'] = sprintf(__('%1$s - Order %2$s', 'woocommerce-gateway-stripe'), wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES), $order->get_order_number());
356
+		$billing_email            = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_email : $order->get_billing_email();
357
+		$billing_first_name       = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_first_name : $order->get_billing_first_name();
358
+		$billing_last_name        = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_last_name : $order->get_billing_last_name();
359 359
 
360
-		if ( ! empty( $billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) {
360
+		if ( ! empty($billing_email) && apply_filters('wc_stripe_send_stripe_receipt', false)) {
361 361
 			$post_data['receipt_email'] = $billing_email;
362 362
 		}
363 363
 
364
-		switch ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method() ) {
365
-			case 'stripe':
366
-				if ( ! empty( $statement_descriptor ) ) {
367
-					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor );
364
+		switch (WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method()) {
365
+			case 'stripe' : if ( ! empty($statement_descriptor)) {
366
+					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor);
368 367
 				}
369 368
 
370 369
 				$post_data['capture'] = $capture ? 'true' : 'false';
371 370
 				break;
372 371
 			case 'stripe_sepa':
373
-				if ( ! empty( $statement_descriptor ) ) {
374
-					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor );
372
+				if ( ! empty($statement_descriptor)) {
373
+					$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor);
375 374
 				}
376 375
 				break;
377 376
 		}
@@ -379,25 +378,25 @@  discard block
 block discarded – undo
379 378
 		$post_data['expand[]'] = 'balance_transaction';
380 379
 
381 380
 		$metadata = array(
382
-			__( 'customer_name', 'woocommerce-gateway-stripe' ) => sanitize_text_field( $billing_first_name ) . ' ' . sanitize_text_field( $billing_last_name ),
383
-			__( 'customer_email', 'woocommerce-gateway-stripe' ) => sanitize_email( $billing_email ),
381
+			__('customer_name', 'woocommerce-gateway-stripe') => sanitize_text_field($billing_first_name) . ' ' . sanitize_text_field($billing_last_name),
382
+			__('customer_email', 'woocommerce-gateway-stripe') => sanitize_email($billing_email),
384 383
 			'order_id' => $order->get_order_number(),
385 384
 		);
386 385
 
387
-		if ( $this->has_subscription( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id() ) ) {
386
+		if ($this->has_subscription(WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id())) {
388 387
 			$metadata += array(
389 388
 				'payment_type' => 'recurring',
390
-				'site_url'     => esc_url( get_site_url() ),
389
+				'site_url'     => esc_url(get_site_url()),
391 390
 			);
392 391
 		}
393 392
 
394
-		$post_data['metadata'] = apply_filters( 'wc_stripe_payment_metadata', $metadata, $order, $prepared_source );
393
+		$post_data['metadata'] = apply_filters('wc_stripe_payment_metadata', $metadata, $order, $prepared_source);
395 394
 
396
-		if ( $prepared_source->customer ) {
395
+		if ($prepared_source->customer) {
397 396
 			$post_data['customer'] = $prepared_source->customer;
398 397
 		}
399 398
 
400
-		if ( $prepared_source->source ) {
399
+		if ($prepared_source->source) {
401 400
 			$post_data['source'] = $prepared_source->source;
402 401
 		}
403 402
 
@@ -409,83 +408,83 @@  discard block
 block discarded – undo
409 408
 		 * @param WC_Order $order
410 409
 		 * @param object $source
411 410
 		 */
412
-		return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order, $prepared_source );
411
+		return apply_filters('wc_stripe_generate_payment_request', $post_data, $order, $prepared_source);
413 412
 	}
414 413
 
415 414
 	/**
416 415
 	 * Store extra meta data for an order from a Stripe Response.
417 416
 	 */
418
-	public function process_response( $response, $order ) {
419
-		WC_Stripe_Logger::log( 'Processing response: ' . print_r( $response, true ) );
417
+	public function process_response($response, $order) {
418
+		WC_Stripe_Logger::log('Processing response: ' . print_r($response, true));
420 419
 
421
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
420
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
422 421
 
423
-		$captured = ( isset( $response->captured ) && $response->captured ) ? 'yes' : 'no';
422
+		$captured = (isset($response->captured) && $response->captured) ? 'yes' : 'no';
424 423
 
425 424
 		// Store charge data.
426
-		WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_stripe_charge_captured', $captured ) : $order->update_meta_data( '_stripe_charge_captured', $captured );
425
+		WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_stripe_charge_captured', $captured) : $order->update_meta_data('_stripe_charge_captured', $captured);
427 426
 
428 427
 		// Store other data such as fees.
429
-		if ( isset( $response->balance_transaction ) && isset( $response->balance_transaction->fee ) ) {
428
+		if (isset($response->balance_transaction) && isset($response->balance_transaction->fee)) {
430 429
 			// Fees and Net needs to both come from Stripe to be accurate as the returned
431 430
 			// values are in the local currency of the Stripe account, not from WC.
432
-			$fee = ! empty( $response->balance_transaction->fee ) ? WC_Stripe_Helper::format_balance_fee( $response->balance_transaction, 'fee' ) : 0;
433
-			$net = ! empty( $response->balance_transaction->net ) ? WC_Stripe_Helper::format_balance_fee( $response->balance_transaction, 'net' ) : 0;
434
-			WC_Stripe_Helper::update_stripe_fee( $order, $fee );
435
-			WC_Stripe_Helper::update_stripe_net( $order, $net );
431
+			$fee = ! empty($response->balance_transaction->fee) ? WC_Stripe_Helper::format_balance_fee($response->balance_transaction, 'fee') : 0;
432
+			$net = ! empty($response->balance_transaction->net) ? WC_Stripe_Helper::format_balance_fee($response->balance_transaction, 'net') : 0;
433
+			WC_Stripe_Helper::update_stripe_fee($order, $fee);
434
+			WC_Stripe_Helper::update_stripe_net($order, $net);
436 435
 
437 436
 			// Store currency stripe.
438
-			$currency = ! empty( $response->balance_transaction->currency ) ? strtoupper( $response->balance_transaction->currency ) : null;
439
-			WC_Stripe_Helper::update_stripe_currency( $order, $currency );
437
+			$currency = ! empty($response->balance_transaction->currency) ? strtoupper($response->balance_transaction->currency) : null;
438
+			WC_Stripe_Helper::update_stripe_currency($order, $currency);
440 439
 		}
441 440
 
442
-		if ( 'yes' === $captured ) {
441
+		if ('yes' === $captured) {
443 442
 			/**
444 443
 			 * Charge can be captured but in a pending state. Payment methods
445 444
 			 * that are asynchronous may take couple days to clear. Webhook will
446 445
 			 * take care of the status changes.
447 446
 			 */
448
-			if ( 'pending' === $response->status ) {
449
-				$order_stock_reduced = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_order_stock_reduced', true ) : $order->get_meta( '_order_stock_reduced', true );
447
+			if ('pending' === $response->status) {
448
+				$order_stock_reduced = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_order_stock_reduced', true) : $order->get_meta('_order_stock_reduced', true);
450 449
 
451
-				if ( ! $order_stock_reduced ) {
452
-					WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->reduce_order_stock() : wc_reduce_stock_levels( $order_id );
450
+				if ( ! $order_stock_reduced) {
451
+					WC_Stripe_Helper::is_wc_lt('3.0') ? $order->reduce_order_stock() : wc_reduce_stock_levels($order_id);
453 452
 				}
454 453
 
455
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_transaction_id', $response->id ) : $order->set_transaction_id( $response->id );
454
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_transaction_id', $response->id) : $order->set_transaction_id($response->id);
456 455
 				/* translators: transaction id */
457
-				$order->update_status( 'on-hold', sprintf( __( 'Stripe charge awaiting payment: %s.', 'woocommerce-gateway-stripe' ), $response->id ) );
456
+				$order->update_status('on-hold', sprintf(__('Stripe charge awaiting payment: %s.', 'woocommerce-gateway-stripe'), $response->id));
458 457
 			}
459 458
 
460
-			if ( 'succeeded' === $response->status ) {
461
-				$order->payment_complete( $response->id );
459
+			if ('succeeded' === $response->status) {
460
+				$order->payment_complete($response->id);
462 461
 
463 462
 				/* translators: transaction id */
464
-				$message = sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $response->id );
465
-				$order->add_order_note( $message );
463
+				$message = sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $response->id);
464
+				$order->add_order_note($message);
466 465
 			}
467 466
 
468
-			if ( 'failed' === $response->status ) {
469
-				$localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
470
-				$order->add_order_note( $localized_message );
471
-				throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
467
+			if ('failed' === $response->status) {
468
+				$localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
469
+				$order->add_order_note($localized_message);
470
+				throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
472 471
 			}
473 472
 		} else {
474
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_transaction_id', $response->id ) : $order->set_transaction_id( $response->id );
473
+			WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_transaction_id', $response->id) : $order->set_transaction_id($response->id);
475 474
 
476
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
477
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->reduce_order_stock() : wc_reduce_stock_levels( $order_id );
475
+			if ($order->has_status(array('pending', 'failed'))) {
476
+				WC_Stripe_Helper::is_wc_lt('3.0') ? $order->reduce_order_stock() : wc_reduce_stock_levels($order_id);
478 477
 			}
479 478
 
480 479
 			/* translators: transaction id */
481
-			$order->update_status( 'on-hold', sprintf( __( 'Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe' ), $response->id ) );
480
+			$order->update_status('on-hold', sprintf(__('Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe'), $response->id));
482 481
 		}
483 482
 
484
-		if ( is_callable( array( $order, 'save' ) ) ) {
483
+		if (is_callable(array($order, 'save'))) {
485 484
 			$order->save();
486 485
 		}
487 486
 
488
-		do_action( 'wc_gateway_stripe_process_response', $response, $order );
487
+		do_action('wc_gateway_stripe_process_response', $response, $order);
489 488
 
490 489
 		return $response;
491 490
 	}
@@ -498,10 +497,10 @@  discard block
 block discarded – undo
498 497
 	 * @param int $order_id
499 498
 	 * @return null
500 499
 	 */
501
-	public function send_failed_order_email( $order_id ) {
500
+	public function send_failed_order_email($order_id) {
502 501
 		$emails = WC()->mailer()->get_emails();
503
-		if ( ! empty( $emails ) && ! empty( $order_id ) ) {
504
-			$emails['WC_Email_Failed_Order']->trigger( $order_id );
502
+		if ( ! empty($emails) && ! empty($order_id)) {
503
+			$emails['WC_Email_Failed_Order']->trigger($order_id);
505 504
 		}
506 505
 	}
507 506
 
@@ -513,36 +512,36 @@  discard block
 block discarded – undo
513 512
 	 * @param object $order
514 513
 	 * @return object $details
515 514
 	 */
516
-	public function get_owner_details( $order ) {
517
-		$billing_first_name = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_first_name : $order->get_billing_first_name();
518
-		$billing_last_name  = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_last_name : $order->get_billing_last_name();
515
+	public function get_owner_details($order) {
516
+		$billing_first_name = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_first_name : $order->get_billing_first_name();
517
+		$billing_last_name  = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_last_name : $order->get_billing_last_name();
519 518
 
520 519
 		$details = array();
521 520
 
522 521
 		$name  = $billing_first_name . ' ' . $billing_last_name;
523
-		$email = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_email : $order->get_billing_email();
524
-		$phone = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_phone : $order->get_billing_phone();
522
+		$email = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_email : $order->get_billing_email();
523
+		$phone = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_phone : $order->get_billing_phone();
525 524
 
526
-		if ( ! empty( $phone ) ) {
525
+		if ( ! empty($phone)) {
527 526
 			$details['phone'] = $phone;
528 527
 		}
529 528
 
530
-		if ( ! empty( $name ) ) {
529
+		if ( ! empty($name)) {
531 530
 			$details['name'] = $name;
532 531
 		}
533 532
 
534
-		if ( ! empty( $email ) ) {
533
+		if ( ! empty($email)) {
535 534
 			$details['email'] = $email;
536 535
 		}
537 536
 
538
-		$details['address']['line1']       = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_address_1 : $order->get_billing_address_1();
539
-		$details['address']['line2']       = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_address_2 : $order->get_billing_address_2();
540
-		$details['address']['state']       = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_state : $order->get_billing_state();
541
-		$details['address']['city']        = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_city : $order->get_billing_city();
542
-		$details['address']['postal_code'] = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_postcode : $order->get_billing_postcode();
543
-		$details['address']['country']     = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->billing_country : $order->get_billing_country();
537
+		$details['address']['line1']       = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_address_1 : $order->get_billing_address_1();
538
+		$details['address']['line2']       = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_address_2 : $order->get_billing_address_2();
539
+		$details['address']['state']       = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_state : $order->get_billing_state();
540
+		$details['address']['city']        = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_city : $order->get_billing_city();
541
+		$details['address']['postal_code'] = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_postcode : $order->get_billing_postcode();
542
+		$details['address']['country']     = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->billing_country : $order->get_billing_country();
544 543
 
545
-		return (object) apply_filters( 'wc_stripe_owner_details', $details, $order );
544
+		return (object) apply_filters('wc_stripe_owner_details', $details, $order);
546 545
 	}
547 546
 
548 547
 	/**
@@ -551,15 +550,15 @@  discard block
 block discarded – undo
551 550
 	 * @since 4.0.3
552 551
 	 * @param string $source_id The source ID to get source object for.
553 552
 	 */
554
-	public function get_source_object( $source_id = '' ) {
555
-		if ( empty( $source_id ) ) {
553
+	public function get_source_object($source_id = '') {
554
+		if (empty($source_id)) {
556 555
 			return '';
557 556
 		}
558 557
 
559
-		$source_object = WC_Stripe_API::retrieve( 'sources/' . $source_id );
558
+		$source_object = WC_Stripe_API::retrieve('sources/' . $source_id);
560 559
 
561
-		if ( ! empty( $source_object->error ) ) {
562
-			throw new WC_Stripe_Exception( print_r( $source_object, true ), $source_object->error->message );
560
+		if ( ! empty($source_object->error)) {
561
+			throw new WC_Stripe_Exception(print_r($source_object, true), $source_object->error->message);
563 562
 		}
564 563
 
565 564
 		return $source_object;
@@ -573,13 +572,13 @@  discard block
 block discarded – undo
573 572
 	 * @param object $source_object
574 573
 	 * @return bool
575 574
 	 */
576
-	public function is_3ds_required( $source_object ) {
575
+	public function is_3ds_required($source_object) {
577 576
 		return apply_filters(
578 577
 			'wc_stripe_require_3ds',
579 578
 			(
580
-			$source_object && ! empty( $source_object->card ) ) &&
581
-			( 'card' === $source_object->type && 'required' === $source_object->card->three_d_secure ||
582
-			( $this->three_d_secure && 'recommended' === $source_object->card->three_d_secure )
579
+			$source_object && ! empty($source_object->card) ) &&
580
+			('card' === $source_object->type && 'required' === $source_object->card->three_d_secure ||
581
+			($this->three_d_secure && 'recommended' === $source_object->card->three_d_secure)
583 582
 			),
584 583
 			$source_object,
585 584
 			$this->three_d_secure
@@ -593,8 +592,8 @@  discard block
 block discarded – undo
593 592
 	 * @param object $source_object
594 593
 	 * @return bool
595 594
 	 */
596
-	public function is_3ds_card( $source_object ) {
597
-		return ( $source_object && 'three_d_secure' === $source_object->type );
595
+	public function is_3ds_card($source_object) {
596
+		return ($source_object && 'three_d_secure' === $source_object->type);
598 597
 	}
599 598
 
600 599
 	/**
@@ -604,8 +603,8 @@  discard block
 block discarded – undo
604 603
 	 * @param object $source_object
605 604
 	 * @return bool
606 605
 	 */
607
-	public function is_prepaid_card( $source_object ) {
608
-		return ( $source_object && 'token' === $source_object->object && 'prepaid' === $source_object->card->funding );
606
+	public function is_prepaid_card($source_object) {
607
+		return ($source_object && 'token' === $source_object->object && 'prepaid' === $source_object->card->funding);
609 608
 	}
610 609
 
611 610
 	/**
@@ -615,8 +614,8 @@  discard block
 block discarded – undo
615 614
 	 * @param string $source_id
616 615
 	 * @return bool
617 616
 	 */
618
-	public function is_type_legacy_card( $source_id ) {
619
-		return ( preg_match( '/^card_/', $source_id ) );
617
+	public function is_type_legacy_card($source_id) {
618
+		return (preg_match('/^card_/', $source_id));
620 619
 	}
621 620
 
622 621
 	/**
@@ -626,9 +625,9 @@  discard block
 block discarded – undo
626 625
 	 * @return bool
627 626
 	 */
628 627
 	public function is_using_saved_payment_method() {
629
-		$payment_method = isset( $_POST['payment_method'] ) ? wc_clean( $_POST['payment_method'] ) : 'stripe';
628
+		$payment_method = isset($_POST['payment_method']) ? wc_clean($_POST['payment_method']) : 'stripe';
630 629
 
631
-		return ( isset( $_POST[ 'wc-' . $payment_method . '-payment-token' ] ) && 'new' !== $_POST[ 'wc-' . $payment_method . '-payment-token' ] );
630
+		return (isset($_POST['wc-' . $payment_method . '-payment-token']) && 'new' !== $_POST['wc-' . $payment_method . '-payment-token']);
632 631
 	}
633 632
 
634 633
 	/**
@@ -641,22 +640,22 @@  discard block
 block discarded – undo
641 640
 	 * @param string $return_url
642 641
 	 * @return mixed
643 642
 	 */
644
-	public function create_3ds_source( $order, $source_object, $return_url = '' ) {
645
-		$currency   = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency();
646
-		$order_id   = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
647
-		$return_url = empty( $return_url ) ? $this->get_stripe_return_url( $order ) : $return_url;
643
+	public function create_3ds_source($order, $source_object, $return_url = '') {
644
+		$currency   = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency();
645
+		$order_id   = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
646
+		$return_url = empty($return_url) ? $this->get_stripe_return_url($order) : $return_url;
648 647
 
649 648
 		$post_data                   = array();
650
-		$post_data['amount']         = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency );
651
-		$post_data['currency']       = strtolower( $currency );
649
+		$post_data['amount']         = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency);
650
+		$post_data['currency']       = strtolower($currency);
652 651
 		$post_data['type']           = 'three_d_secure';
653
-		$post_data['owner']          = $this->get_owner_details( $order );
654
-		$post_data['three_d_secure'] = array( 'card' => $source_object->id );
655
-		$post_data['redirect']       = array( 'return_url' => $return_url );
652
+		$post_data['owner']          = $this->get_owner_details($order);
653
+		$post_data['three_d_secure'] = array('card' => $source_object->id);
654
+		$post_data['redirect']       = array('return_url' => $return_url);
656 655
 
657
-		WC_Stripe_Logger::log( 'Info: Begin creating 3DS source...' );
656
+		WC_Stripe_Logger::log('Info: Begin creating 3DS source...');
658 657
 
659
-		return WC_Stripe_API::request( apply_filters( 'wc_stripe_3ds_source', $post_data, $order ), 'sources' );
658
+		return WC_Stripe_API::request(apply_filters('wc_stripe_3ds_source', $post_data, $order), 'sources');
660 659
 	}
661 660
 
662 661
 	/**
@@ -672,61 +671,61 @@  discard block
 block discarded – undo
672 671
 	 * @throws Exception When card was not added or for and invalid card.
673 672
 	 * @return object
674 673
 	 */
675
-	public function prepare_source( $user_id, $force_save_source = false ) {
676
-		$customer          = new WC_Stripe_Customer( $user_id );
674
+	public function prepare_source($user_id, $force_save_source = false) {
675
+		$customer          = new WC_Stripe_Customer($user_id);
677 676
 		$set_customer      = true;
678
-		$force_save_source = apply_filters( 'wc_stripe_force_save_source', $force_save_source, $customer );
677
+		$force_save_source = apply_filters('wc_stripe_force_save_source', $force_save_source, $customer);
679 678
 		$source_object     = '';
680 679
 		$source_id         = '';
681 680
 		$wc_token_id       = false;
682
-		$payment_method    = isset( $_POST['payment_method'] ) ? wc_clean( $_POST['payment_method'] ) : 'stripe';
681
+		$payment_method    = isset($_POST['payment_method']) ? wc_clean($_POST['payment_method']) : 'stripe';
683 682
 		$is_token          = false;
684 683
 
685 684
 		// New CC info was entered and we have a new source to process.
686
-		if ( ! empty( $_POST['stripe_source'] ) ) {
687
-			$source_object = self::get_source_object( wc_clean( $_POST['stripe_source'] ) );
685
+		if ( ! empty($_POST['stripe_source'])) {
686
+			$source_object = self::get_source_object(wc_clean($_POST['stripe_source']));
688 687
 			$source_id     = $source_object->id;
689 688
 
690 689
 			// This checks to see if customer opted to save the payment method to file.
691
-			$maybe_saved_card = isset( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] ) && ! empty( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] );
690
+			$maybe_saved_card = isset($_POST['wc-' . $payment_method . '-new-payment-method']) && ! empty($_POST['wc-' . $payment_method . '-new-payment-method']);
692 691
 
693 692
 			/**
694 693
 			 * This is true if the user wants to store the card to their account.
695 694
 			 * Criteria to save to file is they are logged in, they opted to save or product requirements and the source is
696 695
 			 * actually reusable. Either that or force_save_source is true.
697 696
 			 */
698
-			if ( ( $user_id && $this->saved_cards && $maybe_saved_card && 'reusable' === $source_object->usage ) || $force_save_source ) {
699
-				$response = $customer->add_source( $source_object->id );
697
+			if (($user_id && $this->saved_cards && $maybe_saved_card && 'reusable' === $source_object->usage) || $force_save_source) {
698
+				$response = $customer->add_source($source_object->id);
700 699
 
701
-				if ( ! empty( $response->error ) ) {
702
-					throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
700
+				if ( ! empty($response->error)) {
701
+					throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
703 702
 				}
704 703
 			}
705
-		} elseif ( $this->is_using_saved_payment_method() ) {
704
+		} elseif ($this->is_using_saved_payment_method()) {
706 705
 			// Use an existing token, and then process the payment.
707
-			$wc_token_id = wc_clean( $_POST[ 'wc-' . $payment_method . '-payment-token' ] );
708
-			$wc_token    = WC_Payment_Tokens::get( $wc_token_id );
706
+			$wc_token_id = wc_clean($_POST['wc-' . $payment_method . '-payment-token']);
707
+			$wc_token    = WC_Payment_Tokens::get($wc_token_id);
709 708
 
710
-			if ( ! $wc_token || $wc_token->get_user_id() !== get_current_user_id() ) {
711
-				WC()->session->set( 'refresh_totals', true );
712
-				throw new WC_Stripe_Exception( 'Invalid payment method', __( 'Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe' ) );
709
+			if ( ! $wc_token || $wc_token->get_user_id() !== get_current_user_id()) {
710
+				WC()->session->set('refresh_totals', true);
711
+				throw new WC_Stripe_Exception('Invalid payment method', __('Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe'));
713 712
 			}
714 713
 
715 714
 			$source_id = $wc_token->get_token();
716 715
 
717
-			if ( $this->is_type_legacy_card( $source_id ) ) {
716
+			if ($this->is_type_legacy_card($source_id)) {
718 717
 				$is_token = true;
719 718
 			}
720
-		} elseif ( isset( $_POST['stripe_token'] ) && 'new' !== $_POST['stripe_token'] ) {
721
-			$stripe_token     = wc_clean( $_POST['stripe_token'] );
722
-			$maybe_saved_card = isset( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] ) && ! empty( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] );
719
+		} elseif (isset($_POST['stripe_token']) && 'new' !== $_POST['stripe_token']) {
720
+			$stripe_token     = wc_clean($_POST['stripe_token']);
721
+			$maybe_saved_card = isset($_POST['wc-' . $payment_method . '-new-payment-method']) && ! empty($_POST['wc-' . $payment_method . '-new-payment-method']);
723 722
 
724 723
 			// This is true if the user wants to store the card to their account.
725
-			if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_save_source ) {
726
-				$response = $customer->add_source( $stripe_token );
724
+			if (($user_id && $this->saved_cards && $maybe_saved_card) || $force_save_source) {
725
+				$response = $customer->add_source($stripe_token);
727 726
 
728
-				if ( ! empty( $response->error ) ) {
729
-					throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
727
+				if ( ! empty($response->error)) {
728
+					throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
730 729
 				}
731 730
 			} else {
732 731
 				$set_customer = false;
@@ -735,14 +734,14 @@  discard block
 block discarded – undo
735 734
 			}
736 735
 		}
737 736
 
738
-		if ( ! $set_customer ) {
737
+		if ( ! $set_customer) {
739 738
 			$customer_id = false;
740 739
 		} else {
741 740
 			$customer_id = $customer->get_id() ? $customer->get_id() : false;
742 741
 		}
743 742
 
744
-		if ( empty( $source_object ) && ! $is_token ) {
745
-			$source_object = self::get_source_object( $source_id );
743
+		if (empty($source_object) && ! $is_token) {
744
+			$source_object = self::get_source_object($source_id);
746 745
 		}
747 746
 
748 747
 		return (object) array(
@@ -766,39 +765,39 @@  discard block
 block discarded – undo
766 765
 	 * @param object $order
767 766
 	 * @return object
768 767
 	 */
769
-	public function prepare_order_source( $order = null ) {
768
+	public function prepare_order_source($order = null) {
770 769
 		$stripe_customer = new WC_Stripe_Customer();
771 770
 		$stripe_source   = false;
772 771
 		$token_id        = false;
773 772
 		$source_object   = false;
774 773
 
775
-		if ( $order ) {
776
-			$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
774
+		if ($order) {
775
+			$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
777 776
 
778
-			$stripe_customer_id = get_post_meta( $order_id, '_stripe_customer_id', true );
777
+			$stripe_customer_id = get_post_meta($order_id, '_stripe_customer_id', true);
779 778
 
780
-			if ( $stripe_customer_id ) {
781
-				$stripe_customer->set_id( $stripe_customer_id );
779
+			if ($stripe_customer_id) {
780
+				$stripe_customer->set_id($stripe_customer_id);
782 781
 			}
783 782
 
784
-			$source_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_stripe_source_id', true ) : $order->get_meta( '_stripe_source_id', true );
783
+			$source_id = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_stripe_source_id', true) : $order->get_meta('_stripe_source_id', true);
785 784
 
786 785
 			// Since 4.0.0, we changed card to source so we need to account for that.
787
-			if ( empty( $source_id ) ) {
788
-				$source_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_stripe_card_id', true ) : $order->get_meta( '_stripe_card_id', true );
786
+			if (empty($source_id)) {
787
+				$source_id = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_stripe_card_id', true) : $order->get_meta('_stripe_card_id', true);
789 788
 
790 789
 				// Take this opportunity to update the key name.
791
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_stripe_source_id', $source_id ) : $order->update_meta_data( '_stripe_source_id', $source_id );
790
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_stripe_source_id', $source_id) : $order->update_meta_data('_stripe_source_id', $source_id);
792 791
 
793
-				if ( is_callable( array( $order, 'save' ) ) ) {
792
+				if (is_callable(array($order, 'save'))) {
794 793
 					$order->save();
795 794
 				}
796 795
 			}
797 796
 
798
-			if ( $source_id ) {
797
+			if ($source_id) {
799 798
 				$stripe_source = $source_id;
800
-				$source_object = WC_Stripe_API::retrieve( 'sources/' . $source_id );
801
-			} elseif ( apply_filters( 'wc_stripe_use_default_customer_source', true ) ) {
799
+				$source_object = WC_Stripe_API::retrieve('sources/' . $source_id);
800
+			} elseif (apply_filters('wc_stripe_use_default_customer_source', true)) {
802 801
 				/*
803 802
 				 * We can attempt to charge the customer's default source
804 803
 				 * by sending empty source id.
@@ -823,27 +822,27 @@  discard block
 block discarded – undo
823 822
 	 * @param WC_Order $order For to which the source applies.
824 823
 	 * @param stdClass $source Source information.
825 824
 	 */
826
-	public function save_source_to_order( $order, $source ) {
827
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
825
+	public function save_source_to_order($order, $source) {
826
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
828 827
 
829 828
 		// Store source in the order.
830
-		if ( $source->customer ) {
831
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
832
-				update_post_meta( $order_id, '_stripe_customer_id', $source->customer );
829
+		if ($source->customer) {
830
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
831
+				update_post_meta($order_id, '_stripe_customer_id', $source->customer);
833 832
 			} else {
834
-				$order->update_meta_data( '_stripe_customer_id', $source->customer );
833
+				$order->update_meta_data('_stripe_customer_id', $source->customer);
835 834
 			}
836 835
 		}
837 836
 
838
-		if ( $source->source ) {
839
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
840
-				update_post_meta( $order_id, '_stripe_source_id', $source->source );
837
+		if ($source->source) {
838
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
839
+				update_post_meta($order_id, '_stripe_source_id', $source->source);
841 840
 			} else {
842
-				$order->update_meta_data( '_stripe_source_id', $source->source );
841
+				$order->update_meta_data('_stripe_source_id', $source->source);
843 842
 			}
844 843
 		}
845 844
 
846
-		if ( is_callable( array( $order, 'save' ) ) ) {
845
+		if (is_callable(array($order, 'save'))) {
847 846
 			$order->save();
848 847
 		}
849 848
 	}
@@ -857,38 +856,38 @@  discard block
 block discarded – undo
857 856
 	 * @param object $order The order object
858 857
 	 * @param int $balance_transaction_id
859 858
 	 */
860
-	public function update_fees( $order, $balance_transaction_id ) {
861
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
859
+	public function update_fees($order, $balance_transaction_id) {
860
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
862 861
 
863
-		$balance_transaction = WC_Stripe_API::retrieve( 'balance/history/' . $balance_transaction_id );
862
+		$balance_transaction = WC_Stripe_API::retrieve('balance/history/' . $balance_transaction_id);
864 863
 
865
-		if ( empty( $balance_transaction->error ) ) {
866
-			if ( isset( $balance_transaction ) && isset( $balance_transaction->fee ) ) {
864
+		if (empty($balance_transaction->error)) {
865
+			if (isset($balance_transaction) && isset($balance_transaction->fee)) {
867 866
 				// Fees and Net needs to both come from Stripe to be accurate as the returned
868 867
 				// values are in the local currency of the Stripe account, not from WC.
869
-				$fee_refund = ! empty( $balance_transaction->fee ) ? WC_Stripe_Helper::format_balance_fee( $balance_transaction, 'fee' ) : 0;
870
-				$net_refund = ! empty( $balance_transaction->net ) ? WC_Stripe_Helper::format_balance_fee( $balance_transaction, 'net' ) : 0;
868
+				$fee_refund = ! empty($balance_transaction->fee) ? WC_Stripe_Helper::format_balance_fee($balance_transaction, 'fee') : 0;
869
+				$net_refund = ! empty($balance_transaction->net) ? WC_Stripe_Helper::format_balance_fee($balance_transaction, 'net') : 0;
871 870
 
872 871
 				// Current data fee & net.
873
-				$fee_current = WC_Stripe_Helper::get_stripe_fee( $order );
874
-				$net_current = WC_Stripe_Helper::get_stripe_net( $order );
872
+				$fee_current = WC_Stripe_Helper::get_stripe_fee($order);
873
+				$net_current = WC_Stripe_Helper::get_stripe_net($order);
875 874
 
876 875
 				// Calculation.
877 876
 				$fee = (float) $fee_current + (float) $fee_refund;
878 877
 				$net = (float) $net_current + (float) $net_refund;
879 878
 
880
-				WC_Stripe_Helper::update_stripe_fee( $order, $fee );
881
-				WC_Stripe_Helper::update_stripe_net( $order, $net );
879
+				WC_Stripe_Helper::update_stripe_fee($order, $fee);
880
+				WC_Stripe_Helper::update_stripe_net($order, $net);
882 881
 
883
-				$currency = ! empty( $balance_transaction->currency ) ? strtoupper( $balance_transaction->currency ) : null;
884
-				WC_Stripe_Helper::update_stripe_currency( $order, $currency );
882
+				$currency = ! empty($balance_transaction->currency) ? strtoupper($balance_transaction->currency) : null;
883
+				WC_Stripe_Helper::update_stripe_currency($order, $currency);
885 884
 
886
-				if ( is_callable( array( $order, 'save' ) ) ) {
885
+				if (is_callable(array($order, 'save'))) {
887 886
 					$order->save();
888 887
 				}
889 888
 			}
890 889
 		} else {
891
-			WC_Stripe_Logger::log( "Unable to update fees/net meta for order: {$order_id}" );
890
+			WC_Stripe_Logger::log("Unable to update fees/net meta for order: {$order_id}");
892 891
 		}
893 892
 	}
894 893
 
@@ -901,33 +900,33 @@  discard block
 block discarded – undo
901 900
 	 * @param  float $amount
902 901
 	 * @return bool
903 902
 	 */
904
-	public function process_refund( $order_id, $amount = null, $reason = '' ) {
905
-		$order = wc_get_order( $order_id );
903
+	public function process_refund($order_id, $amount = null, $reason = '') {
904
+		$order = wc_get_order($order_id);
906 905
 
907
-		if ( ! $order || ! $order->get_transaction_id() ) {
906
+		if ( ! $order || ! $order->get_transaction_id()) {
908 907
 			return false;
909 908
 		}
910 909
 
911 910
 		$request = array();
912 911
 
913
-		if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
914
-			$order_currency = get_post_meta( $order_id, '_order_currency', true );
915
-			$captured       = get_post_meta( $order_id, '_stripe_charge_captured', true );
912
+		if (WC_Stripe_Helper::is_wc_lt('3.0')) {
913
+			$order_currency = get_post_meta($order_id, '_order_currency', true);
914
+			$captured       = get_post_meta($order_id, '_stripe_charge_captured', true);
916 915
 		} else {
917 916
 			$order_currency = $order->get_currency();
918
-			$captured       = $order->get_meta( '_stripe_charge_captured', true );
917
+			$captured       = $order->get_meta('_stripe_charge_captured', true);
919 918
 		}
920 919
 
921
-		if ( ! is_null( $amount ) ) {
922
-			$request['amount'] = WC_Stripe_Helper::get_stripe_amount( $amount, $order_currency );
920
+		if ( ! is_null($amount)) {
921
+			$request['amount'] = WC_Stripe_Helper::get_stripe_amount($amount, $order_currency);
923 922
 		}
924 923
 
925 924
 		// If order is only authorized, don't pass amount.
926
-		if ( 'yes' !== $captured ) {
927
-			unset( $request['amount'] );
925
+		if ('yes' !== $captured) {
926
+			unset($request['amount']);
928 927
 		}
929 928
 
930
-		if ( $reason ) {
929
+		if ($reason) {
931 930
 			$request['metadata'] = array(
932 931
 				'reason' => $reason,
933 932
 			);
@@ -935,35 +934,35 @@  discard block
 block discarded – undo
935 934
 
936 935
 		$request['charge'] = $order->get_transaction_id();
937 936
 
938
-		WC_Stripe_Logger::log( "Info: Beginning refund for order {$order->get_transaction_id()} for the amount of {$amount}" );
937
+		WC_Stripe_Logger::log("Info: Beginning refund for order {$order->get_transaction_id()} for the amount of {$amount}");
939 938
 
940
-		$request = apply_filters( 'wc_stripe_refund_request', $request, $order );
939
+		$request = apply_filters('wc_stripe_refund_request', $request, $order);
941 940
 
942
-		$response = WC_Stripe_API::request( $request, 'refunds' );
941
+		$response = WC_Stripe_API::request($request, 'refunds');
943 942
 
944
-		if ( ! empty( $response->error ) ) {
945
-			WC_Stripe_Logger::log( 'Error: ' . $response->error->message );
943
+		if ( ! empty($response->error)) {
944
+			WC_Stripe_Logger::log('Error: ' . $response->error->message);
946 945
 
947 946
 			return $response;
948 947
 
949
-		} elseif ( ! empty( $response->id ) ) {
950
-			WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_stripe_refund_id', $response->id ) : $order->update_meta_data( '_stripe_refund_id', $response->id );
948
+		} elseif ( ! empty($response->id)) {
949
+			WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_stripe_refund_id', $response->id) : $order->update_meta_data('_stripe_refund_id', $response->id);
951 950
 
952
-			$amount = wc_price( $response->amount / 100 );
951
+			$amount = wc_price($response->amount / 100);
953 952
 
954
-			if ( in_array( strtolower( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency() ), WC_Stripe_Helper::no_decimal_currencies() ) ) {
955
-				$amount = wc_price( $response->amount );
953
+			if (in_array(strtolower(WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency()), WC_Stripe_Helper::no_decimal_currencies())) {
954
+				$amount = wc_price($response->amount);
956 955
 			}
957 956
 
958
-			if ( isset( $response->balance_transaction ) ) {
959
-				$this->update_fees( $order, $response->balance_transaction );
957
+			if (isset($response->balance_transaction)) {
958
+				$this->update_fees($order, $response->balance_transaction);
960 959
 			}
961 960
 
962 961
 			/* translators: 1) dollar amount 2) transaction id 3) refund message */
963
-			$refund_message = ( isset( $captured ) && 'yes' === $captured ) ? sprintf( __( 'Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe' ), $amount, $response->id, $reason ) : __( 'Pre-Authorization Released', 'woocommerce-gateway-stripe' );
962
+			$refund_message = (isset($captured) && 'yes' === $captured) ? sprintf(__('Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe'), $amount, $response->id, $reason) : __('Pre-Authorization Released', 'woocommerce-gateway-stripe');
964 963
 
965
-			$order->add_order_note( $refund_message );
966
-			WC_Stripe_Logger::log( 'Success: ' . html_entity_decode( wp_strip_all_tags( $refund_message ) ) );
964
+			$order->add_order_note($refund_message);
965
+			WC_Stripe_Logger::log('Success: ' . html_entity_decode(wp_strip_all_tags($refund_message)));
967 966
 
968 967
 			return true;
969 968
 		}
@@ -978,46 +977,46 @@  discard block
 block discarded – undo
978 977
 	 */
979 978
 	public function add_payment_method() {
980 979
 		$error     = false;
981
-		$error_msg = __( 'There was a problem adding the payment method.', 'woocommerce-gateway-stripe' );
980
+		$error_msg = __('There was a problem adding the payment method.', 'woocommerce-gateway-stripe');
982 981
 		$source_id = '';
983 982
 
984
-		if ( empty( $_POST['stripe_source'] ) && empty( $_POST['stripe_token'] ) || ! is_user_logged_in() ) {
983
+		if (empty($_POST['stripe_source']) && empty($_POST['stripe_token']) || ! is_user_logged_in()) {
985 984
 			$error = true;
986 985
 		}
987 986
 
988
-		$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
987
+		$stripe_customer = new WC_Stripe_Customer(get_current_user_id());
989 988
 
990
-		$source = ! empty( $_POST['stripe_source'] ) ? wc_clean( $_POST['stripe_source'] ) : '';
989
+		$source = ! empty($_POST['stripe_source']) ? wc_clean($_POST['stripe_source']) : '';
991 990
 
992
-		$source_object = WC_Stripe_API::retrieve( 'sources/' . $source );
991
+		$source_object = WC_Stripe_API::retrieve('sources/' . $source);
993 992
 
994
-		if ( isset( $source_object ) ) {
995
-			if ( ! empty( $source_object->error ) ) {
993
+		if (isset($source_object)) {
994
+			if ( ! empty($source_object->error)) {
996 995
 				$error = true;
997 996
 			}
998 997
 
999 998
 			$source_id = $source_object->id;
1000
-		} elseif ( isset( $_POST['stripe_token'] ) ) {
1001
-			$source_id = wc_clean( $_POST['stripe_token'] );
999
+		} elseif (isset($_POST['stripe_token'])) {
1000
+			$source_id = wc_clean($_POST['stripe_token']);
1002 1001
 		}
1003 1002
 
1004
-		$response = $stripe_customer->add_source( $source_id );
1003
+		$response = $stripe_customer->add_source($source_id);
1005 1004
 
1006
-		if ( ! $response || is_wp_error( $response ) || ! empty( $response->error ) ) {
1005
+		if ( ! $response || is_wp_error($response) || ! empty($response->error)) {
1007 1006
 			$error = true;
1008 1007
 		}
1009 1008
 
1010
-		if ( $error ) {
1011
-			wc_add_notice( $error_msg, 'error' );
1012
-			WC_Stripe_Logger::log( 'Add payment method Error: ' . $error_msg );
1009
+		if ($error) {
1010
+			wc_add_notice($error_msg, 'error');
1011
+			WC_Stripe_Logger::log('Add payment method Error: ' . $error_msg);
1013 1012
 			return;
1014 1013
 		}
1015 1014
 
1016
-		do_action( 'wc_stripe_add_payment_method_' . $_POST['payment_method'] . '_success', $source_id, $source_object );
1015
+		do_action('wc_stripe_add_payment_method_' . $_POST['payment_method'] . '_success', $source_id, $source_object);
1017 1016
 
1018 1017
 		return array(
1019 1018
 			'result'   => 'success',
1020
-			'redirect' => wc_get_endpoint_url( 'payment-methods' ),
1019
+			'redirect' => wc_get_endpoint_url('payment-methods'),
1021 1020
 		);
1022 1021
 	}
1023 1022
 
@@ -1034,10 +1033,10 @@  discard block
 block discarded – undo
1034 1033
 		 * Stripe expects Norwegian to only be passed NO.
1035 1034
 		 * But WP has different dialects.
1036 1035
 		 */
1037
-		if ( 'NO' === substr( $locale, 3, 2 ) ) {
1036
+		if ('NO' === substr($locale, 3, 2)) {
1038 1037
 			$locale = 'no';
1039 1038
 		} else {
1040
-			$locale = substr( get_locale(), 0, 2 );
1039
+			$locale = substr(get_locale(), 0, 2);
1041 1040
 		}
1042 1041
 
1043 1042
 		return $locale;
@@ -1051,9 +1050,9 @@  discard block
 block discarded – undo
1051 1050
 	 * @param string $idempotency_key
1052 1051
 	 * @param array $request
1053 1052
 	 */
1054
-	public function change_idempotency_key( $idempotency_key, $request ) {
1055
-		$customer = ! empty( $request['customer'] ) ? $request['customer'] : '';
1056
-		$source   = ! empty( $request['source'] ) ? $request['source'] : $customer;
1053
+	public function change_idempotency_key($idempotency_key, $request) {
1054
+		$customer = ! empty($request['customer']) ? $request['customer'] : '';
1055
+		$source   = ! empty($request['source']) ? $request['source'] : $customer;
1057 1056
 		$count    = $this->retry_interval;
1058 1057
 
1059 1058
 		return $request['metadata']['order_id'] . '-' . $count . '-' . $source;
@@ -1067,8 +1066,8 @@  discard block
 block discarded – undo
1067 1066
 	 * @since 4.0.6
1068 1067
 	 * @param array $headers
1069 1068
 	 */
1070
-	public function is_original_request( $headers ) {
1071
-		if ( $headers['original-request'] === $headers['request-id'] ) {
1069
+	public function is_original_request($headers) {
1070
+		if ($headers['original-request'] === $headers['request-id']) {
1072 1071
 			return true;
1073 1072
 		}
1074 1073
 
Please login to merge, or discard this patch.
includes/admin/stripe-giropay-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_giropay_settings',
8 8
 	array(
9 9
 		'geo_target'  => array(
10
-			'description' => __( 'Relevant Payer Geography: Germany', 'woocommerce-gateway-stripe' ),
10
+			'description' => __('Relevant Payer Geography: Germany', 'woocommerce-gateway-stripe'),
11 11
 			'type'        => 'title',
12 12
 		),
13 13
 		'guide'       => array(
14
-			'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#giropay" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ),
14
+			'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#giropay" 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 Giropay', 'woocommerce-gateway-stripe' ),
22
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
23
+			'label'       => __('Enable Stripe Giropay', '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'     => __( 'Giropay', 'woocommerce-gateway-stripe' ),
31
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
32
+			'default'     => __('Giropay', '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 Giropay.', '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 Giropay.', '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/admin/stripe-bancontact-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_bancontact_settings',
8 8
 	array(
9 9
 		'geo_target'  => array(
10
-			'description' => __( 'Relevant Payer Geography: Belgium', 'woocommerce-gateway-stripe' ),
10
+			'description' => __('Relevant Payer Geography: Belgium', 'woocommerce-gateway-stripe'),
11 11
 			'type'        => 'title',
12 12
 		),
13 13
 		'guide'       => array(
14
-			'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#bancontact" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ),
14
+			'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#bancontact" 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 Bancontact', 'woocommerce-gateway-stripe' ),
22
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
23
+			'label'       => __('Enable Stripe Bancontact', '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'     => __( 'Bancontact', 'woocommerce-gateway-stripe' ),
31
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
32
+			'default'     => __('Bancontact', '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 Bancontact.', '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 Bancontact.', '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/admin/stripe-multibanco-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_multibanco_settings',
8 8
 	array(
9 9
 		'geo_target'  => array(
10
-			'description' => __( 'Relevant Payer Geography: Portugal', 'woocommerce-gateway-stripe' ),
10
+			'description' => __('Relevant Payer Geography: Portugal', '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 Multibanco', 'woocommerce-gateway-stripe' ),
18
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
19
+			'label'       => __('Enable Stripe Multibanco', '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'     => __( 'Multibanco', 'woocommerce-gateway-stripe' ),
27
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
28
+			'default'     => __('Multibanco', '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 Multibanco.', '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 Multibanco.', '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-ideal-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_ideal_settings',
8 8
 	array(
9 9
 		'geo_target'  => array(
10
-			'description' => __( 'Relevant Payer Geography: The Netherlands', 'woocommerce-gateway-stripe' ),
10
+			'description' => __('Relevant Payer Geography: The Netherlands', 'woocommerce-gateway-stripe'),
11 11
 			'type'        => 'title',
12 12
 		),
13 13
 		'guide'       => array(
14
-			'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#ideal" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ),
14
+			'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#ideal" 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 iDeal', 'woocommerce-gateway-stripe' ),
22
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
23
+			'label'       => __('Enable Stripe iDeal', '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'     => __( 'iDeal', 'woocommerce-gateway-stripe' ),
31
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
32
+			'default'     => __('iDeal', '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 iDeal.', '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 iDeal.', '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/admin/stripe-settings.php 1 patch
Spacing   +62 added lines, -62 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,176 +7,176 @@  discard block
 block discarded – undo
7 7
 	'wc_stripe_settings',
8 8
 	array(
9 9
 		'enabled'                       => array(
10
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
11
-			'label'       => __( 'Enable Stripe', 'woocommerce-gateway-stripe' ),
10
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
11
+			'label'       => __('Enable Stripe', 'woocommerce-gateway-stripe'),
12 12
 			'type'        => 'checkbox',
13 13
 			'description' => '',
14 14
 			'default'     => 'no',
15 15
 		),
16 16
 		'title'                         => array(
17
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
17
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
18 18
 			'type'        => 'text',
19
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
20
-			'default'     => __( 'Credit Card (Stripe)', 'woocommerce-gateway-stripe' ),
19
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
20
+			'default'     => __('Credit Card (Stripe)', 'woocommerce-gateway-stripe'),
21 21
 			'desc_tip'    => true,
22 22
 		),
23 23
 		'description'                   => array(
24
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
24
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
25 25
 			'type'        => 'text',
26
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
27
-			'default'     => __( 'Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe' ),
26
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
27
+			'default'     => __('Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe'),
28 28
 			'desc_tip'    => true,
29 29
 		),
30 30
 		'webhook'                       => array(
31
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
31
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
32 32
 			'type'        => 'title',
33 33
 			/* translators: webhook URL */
34 34
 			'description' => $this->display_admin_settings_webhook_description(),
35 35
 		),
36 36
 		'testmode'                      => array(
37
-			'title'       => __( 'Test mode', 'woocommerce-gateway-stripe' ),
38
-			'label'       => __( 'Enable Test Mode', 'woocommerce-gateway-stripe' ),
37
+			'title'       => __('Test mode', 'woocommerce-gateway-stripe'),
38
+			'label'       => __('Enable Test Mode', 'woocommerce-gateway-stripe'),
39 39
 			'type'        => 'checkbox',
40
-			'description' => __( 'Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe' ),
40
+			'description' => __('Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe'),
41 41
 			'default'     => 'yes',
42 42
 			'desc_tip'    => true,
43 43
 		),
44 44
 		'test_publishable_key'          => array(
45
-			'title'       => __( 'Test Publishable Key', 'woocommerce-gateway-stripe' ),
45
+			'title'       => __('Test Publishable Key', 'woocommerce-gateway-stripe'),
46 46
 			'type'        => 'password',
47
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
47
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
48 48
 			'default'     => '',
49 49
 			'desc_tip'    => true,
50 50
 		),
51 51
 		'test_secret_key'               => array(
52
-			'title'       => __( 'Test Secret Key', 'woocommerce-gateway-stripe' ),
52
+			'title'       => __('Test Secret Key', 'woocommerce-gateway-stripe'),
53 53
 			'type'        => 'password',
54
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
54
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
55 55
 			'default'     => '',
56 56
 			'desc_tip'    => true,
57 57
 		),
58 58
 		'publishable_key'               => array(
59
-			'title'       => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ),
59
+			'title'       => __('Live Publishable Key', 'woocommerce-gateway-stripe'),
60 60
 			'type'        => 'password',
61
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
61
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
62 62
 			'default'     => '',
63 63
 			'desc_tip'    => true,
64 64
 		),
65 65
 		'secret_key'                    => array(
66
-			'title'       => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ),
66
+			'title'       => __('Live Secret Key', 'woocommerce-gateway-stripe'),
67 67
 			'type'        => 'password',
68
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
68
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
69 69
 			'default'     => '',
70 70
 			'desc_tip'    => true,
71 71
 		),
72 72
 		'inline_cc_form'                => array(
73
-			'title'       => __( 'Inline Credit Card Form', 'woocommerce-gateway-stripe' ),
73
+			'title'       => __('Inline Credit Card Form', 'woocommerce-gateway-stripe'),
74 74
 			'type'        => 'checkbox',
75
-			'description' => __( 'Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe' ),
75
+			'description' => __('Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe'),
76 76
 			'default'     => 'no',
77 77
 			'desc_tip'    => true,
78 78
 		),
79 79
 		'statement_descriptor'          => array(
80
-			'title'       => __( 'Statement Descriptor', 'woocommerce-gateway-stripe' ),
80
+			'title'       => __('Statement Descriptor', 'woocommerce-gateway-stripe'),
81 81
 			'type'        => 'text',
82
-			'description' => __( 'This may be up to 22 characters. The statement description must contain at least one letter, may not include ><"\' characters, and will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe' ),
82
+			'description' => __('This may be up to 22 characters. The statement description must contain at least one letter, may not include ><"\' characters, and will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe'),
83 83
 			'default'     => '',
84 84
 			'desc_tip'    => true,
85 85
 		),
86 86
 		'capture'                       => array(
87
-			'title'       => __( 'Capture', 'woocommerce-gateway-stripe' ),
88
-			'label'       => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ),
87
+			'title'       => __('Capture', 'woocommerce-gateway-stripe'),
88
+			'label'       => __('Capture charge immediately', 'woocommerce-gateway-stripe'),
89 89
 			'type'        => 'checkbox',
90
-			'description' => __( 'Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe' ),
90
+			'description' => __('Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe'),
91 91
 			'default'     => 'yes',
92 92
 			'desc_tip'    => true,
93 93
 		),
94 94
 		'three_d_secure'                => array(
95
-			'title'       => __( '3D Secure', 'woocommerce-gateway-stripe' ),
96
-			'label'       => __( 'Require 3D Secure when applicable', 'woocommerce-gateway-stripe' ),
95
+			'title'       => __('3D Secure', 'woocommerce-gateway-stripe'),
96
+			'label'       => __('Require 3D Secure when applicable', 'woocommerce-gateway-stripe'),
97 97
 			'type'        => 'checkbox',
98
-			'description' => __( 'Some payment methods have 3D Secure feature. This is an extra security layer for your store. Choose how to handle payments when 3D Secure is recommended. Enabling would require customers to use 3D Secure when recommended.', 'woocommerce-gateway-stripe' ),
98
+			'description' => __('Some payment methods have 3D Secure feature. This is an extra security layer for your store. Choose how to handle payments when 3D Secure is recommended. Enabling would require customers to use 3D Secure when recommended.', 'woocommerce-gateway-stripe'),
99 99
 			'default'     => 'yes',
100 100
 			'desc_tip'    => true,
101 101
 		),
102 102
 		'stripe_checkout'               => array(
103
-			'title'       => __( 'Stripe Modal Checkout', 'woocommerce-gateway-stripe' ),
104
-			'label'       => __( 'Enable Stripe Checkout', 'woocommerce-gateway-stripe' ),
103
+			'title'       => __('Stripe Modal Checkout', 'woocommerce-gateway-stripe'),
104
+			'label'       => __('Enable Stripe Checkout', 'woocommerce-gateway-stripe'),
105 105
 			'type'        => 'checkbox',
106
-			'description' => __( 'If enabled, this option shows a "pay" button and modal credit card form on the checkout, instead of credit card fields directly on the page. We recommend you leave this disabled and use the embedded form as that is the preferred method.', 'woocommerce-gateway-stripe' ),
106
+			'description' => __('If enabled, this option shows a "pay" button and modal credit card form on the checkout, instead of credit card fields directly on the page. We recommend you leave this disabled and use the embedded form as that is the preferred method.', 'woocommerce-gateway-stripe'),
107 107
 			'default'     => 'no',
108 108
 			'desc_tip'    => true,
109 109
 		),
110 110
 		'stripe_checkout_image'         => array(
111
-			'title'       => __( 'Stripe Checkout Image', 'woocommerce-gateway-stripe' ),
112
-			'description' => __( 'Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe' ),
111
+			'title'       => __('Stripe Checkout Image', 'woocommerce-gateway-stripe'),
112
+			'description' => __('Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe'),
113 113
 			'type'        => 'text',
114 114
 			'default'     => '',
115 115
 			'desc_tip'    => true,
116 116
 		),
117 117
 		'stripe_checkout_description'   => array(
118
-			'title'       => __( 'Stripe Checkout Description', 'woocommerce-gateway-stripe' ),
118
+			'title'       => __('Stripe Checkout Description', 'woocommerce-gateway-stripe'),
119 119
 			'type'        => 'text',
120
-			'description' => __( 'Shows a description of your store on Stripe Modal Checkout.', 'woocommerce-gateway-stripe' ),
120
+			'description' => __('Shows a description of your store on Stripe Modal Checkout.', 'woocommerce-gateway-stripe'),
121 121
 			'default'     => '',
122 122
 			'desc_tip'    => true,
123 123
 		),
124 124
 		'payment_request'               => array(
125
-			'title'       => __( 'Payment Request Buttons', 'woocommerce-gateway-stripe' ),
125
+			'title'       => __('Payment Request Buttons', 'woocommerce-gateway-stripe'),
126 126
 			/* translators: 1) br tag 2) opening anchor tag 3) closing anchor tag */
127
-			'label'       => sprintf( __( 'Enable Payment Request Buttons. (Apple Pay/Chrome Payment Request API) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe' ), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>' ),
127
+			'label'       => sprintf(__('Enable Payment Request Buttons. (Apple Pay/Chrome Payment Request API) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe'), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>'),
128 128
 			'type'        => 'checkbox',
129
-			'description' => __( 'If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe' ),
129
+			'description' => __('If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe'),
130 130
 			'default'     => 'yes',
131 131
 			'desc_tip'    => true,
132 132
 		),
133 133
 		'payment_request_button_type'   => array(
134
-			'title'       => __( 'Payment Request Button Type', 'woocommerce-gateway-stripe' ),
135
-			'label'       => __( 'Button Type', 'woocommerce-gateway-stripe' ),
134
+			'title'       => __('Payment Request Button Type', 'woocommerce-gateway-stripe'),
135
+			'label'       => __('Button Type', 'woocommerce-gateway-stripe'),
136 136
 			'type'        => 'select',
137
-			'description' => __( 'Select the button type you would like to show.', 'woocommerce-gateway-stripe' ),
137
+			'description' => __('Select the button type you would like to show.', 'woocommerce-gateway-stripe'),
138 138
 			'default'     => 'buy',
139 139
 			'desc_tip'    => true,
140 140
 			'options'     => array(
141
-				'default' => __( 'Default', 'woocommerce-gateway-stripe' ),
142
-				'buy'     => __( 'Buy', 'woocommerce-gateway-stripe' ),
143
-				'donate'  => __( 'Donate', 'woocommerce-gateway-stripe' ),
141
+				'default' => __('Default', 'woocommerce-gateway-stripe'),
142
+				'buy'     => __('Buy', 'woocommerce-gateway-stripe'),
143
+				'donate'  => __('Donate', 'woocommerce-gateway-stripe'),
144 144
 			),
145 145
 		),
146 146
 		'payment_request_button_theme'  => array(
147
-			'title'       => __( 'Payment Request Button Theme', 'woocommerce-gateway-stripe' ),
148
-			'label'       => __( 'Button Theme', 'woocommerce-gateway-stripe' ),
147
+			'title'       => __('Payment Request Button Theme', 'woocommerce-gateway-stripe'),
148
+			'label'       => __('Button Theme', 'woocommerce-gateway-stripe'),
149 149
 			'type'        => 'select',
150
-			'description' => __( 'Select the button theme you would like to show.', 'woocommerce-gateway-stripe' ),
150
+			'description' => __('Select the button theme you would like to show.', 'woocommerce-gateway-stripe'),
151 151
 			'default'     => 'dark',
152 152
 			'desc_tip'    => true,
153 153
 			'options'     => array(
154
-				'dark'          => __( 'Dark', 'woocommerce-gateway-stripe' ),
155
-				'light'         => __( 'Light', 'woocommerce-gateway-stripe' ),
156
-				'light-outline' => __( 'Light-Outline', 'woocommerce-gateway-stripe' ),
154
+				'dark'          => __('Dark', 'woocommerce-gateway-stripe'),
155
+				'light'         => __('Light', 'woocommerce-gateway-stripe'),
156
+				'light-outline' => __('Light-Outline', 'woocommerce-gateway-stripe'),
157 157
 			),
158 158
 		),
159 159
 		'payment_request_button_height' => array(
160
-			'title'       => __( 'Payment Request Button Height', 'woocommerce-gateway-stripe' ),
161
-			'label'       => __( 'Button Height', 'woocommerce-gateway-stripe' ),
160
+			'title'       => __('Payment Request Button Height', 'woocommerce-gateway-stripe'),
161
+			'label'       => __('Button Height', 'woocommerce-gateway-stripe'),
162 162
 			'type'        => 'text',
163
-			'description' => __( 'Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe' ),
163
+			'description' => __('Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe'),
164 164
 			'default'     => '44',
165 165
 			'desc_tip'    => true,
166 166
 		),
167 167
 		'saved_cards'                   => array(
168
-			'title'       => __( 'Saved Cards', 'woocommerce-gateway-stripe' ),
169
-			'label'       => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ),
168
+			'title'       => __('Saved Cards', 'woocommerce-gateway-stripe'),
169
+			'label'       => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'),
170 170
 			'type'        => 'checkbox',
171
-			'description' => __( 'If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe' ),
171
+			'description' => __('If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe'),
172 172
 			'default'     => 'no',
173 173
 			'desc_tip'    => true,
174 174
 		),
175 175
 		'logging'                       => array(
176
-			'title'       => __( 'Logging', 'woocommerce-gateway-stripe' ),
177
-			'label'       => __( 'Log debug messages', 'woocommerce-gateway-stripe' ),
176
+			'title'       => __('Logging', 'woocommerce-gateway-stripe'),
177
+			'label'       => __('Log debug messages', 'woocommerce-gateway-stripe'),
178 178
 			'type'        => 'checkbox',
179
-			'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ),
179
+			'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'),
180 180
 			'default'     => 'no',
181 181
 			'desc_tip'    => true,
182 182
 		),
Please login to merge, or discard this patch.
includes/admin/stripe-sepa-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_sepa_settings',
8 8
 	array(
9 9
 		'geo_target'  => array(
10
-			'description' => __( 'Relevant Payer Geography: France, Germany, Spain, Belgium, Netherlands, Luxembourg, Italy, Portugal, Austria, Ireland', 'woocommerce-gateway-stripe' ),
10
+			'description' => __('Relevant Payer Geography: France, Germany, Spain, Belgium, Netherlands, Luxembourg, Italy, Portugal, Austria, Ireland', 'woocommerce-gateway-stripe'),
11 11
 			'type'        => 'title',
12 12
 		),
13 13
 		'guide'       => array(
14
-			'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#sepa-direct-debit" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ),
14
+			'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#sepa-direct-debit" 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 SEPA Direct Debit', 'woocommerce-gateway-stripe' ),
22
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
23
+			'label'       => __('Enable Stripe SEPA Direct Debit', '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'     => __( 'SEPA Direct Debit', 'woocommerce-gateway-stripe' ),
31
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
32
+			'default'     => __('SEPA Direct Debit', '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'     => __( 'Mandate Information.', 'woocommerce-gateway-stripe' ),
38
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
39
+			'default'     => __('Mandate Information.', '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.