Completed
Pull Request — master (#1192)
by Dwain
01:49
created
includes/payment-methods/class-wc-gateway-stripe-multibanco.php 1 patch
Spacing   +94 added lines, -94 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
 
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function __construct() {
59 59
 		$this->id           = 'stripe_multibanco';
60
-		$this->method_title = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' );
60
+		$this->method_title = __('Stripe Multibanco', 'woocommerce-gateway-stripe');
61 61
 		/* translators: link */
62
-		$this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
62
+		$this->method_description = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe'));
63 63
 		$this->supports           = array(
64 64
 			'products',
65 65
 			'refunds',
@@ -71,27 +71,27 @@  discard block
 block discarded – undo
71 71
 		// Load the settings.
72 72
 		$this->init_settings();
73 73
 
74
-		$main_settings              = get_option( 'woocommerce_stripe_settings' );
75
-		$this->title                = $this->get_option( 'title' );
76
-		$this->description          = $this->get_option( 'description' );
77
-		$this->enabled              = $this->get_option( 'enabled' );
78
-		$this->testmode             = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false;
79
-		$this->saved_cards          = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false;
80
-		$this->publishable_key      = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : '';
81
-		$this->secret_key           = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : '';
82
-		$this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : '';
83
-
84
-		if ( $this->testmode ) {
85
-			$this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : '';
86
-			$this->secret_key      = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : '';
74
+		$main_settings              = get_option('woocommerce_stripe_settings');
75
+		$this->title                = $this->get_option('title');
76
+		$this->description          = $this->get_option('description');
77
+		$this->enabled              = $this->get_option('enabled');
78
+		$this->testmode             = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false;
79
+		$this->saved_cards          = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false;
80
+		$this->publishable_key      = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : '';
81
+		$this->secret_key           = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : '';
82
+		$this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : '';
83
+
84
+		if ($this->testmode) {
85
+			$this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : '';
86
+			$this->secret_key      = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : '';
87 87
 		}
88 88
 
89
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
90
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
91
-		add_action( 'woocommerce_thankyou_stripe_multibanco', array( $this, 'thankyou_page' ) );
89
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
90
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
91
+		add_action('woocommerce_thankyou_stripe_multibanco', array($this, 'thankyou_page'));
92 92
 
93 93
 		// Customer Emails
94
-		add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 );
94
+		add_action('woocommerce_email_before_order_table', array($this, 'email_instructions'), 10, 3);
95 95
 	}
96 96
 
97 97
 	/**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * @return bool
119 119
 	 */
120 120
 	public function is_available() {
121
-		if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
121
+		if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
122 122
 			return false;
123 123
 		}
124 124
 
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 
138 138
 		$icons_str = '';
139 139
 
140
-		$icons_str .= isset( $icons['multibanco'] ) ? $icons['multibanco'] : '';
140
+		$icons_str .= isset($icons['multibanco']) ? $icons['multibanco'] : '';
141 141
 
142
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
142
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
143 143
 	}
144 144
 
145 145
 	/**
@@ -150,19 +150,19 @@  discard block
 block discarded – undo
150 150
 	 * @access public
151 151
 	 */
152 152
 	public function payment_scripts() {
153
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) {
153
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) {
154 154
 			return;
155 155
 		}
156 156
 
157
-		wp_enqueue_style( 'stripe_styles' );
158
-		wp_enqueue_script( 'woocommerce_stripe' );
157
+		wp_enqueue_style('stripe_styles');
158
+		wp_enqueue_script('woocommerce_stripe');
159 159
 	}
160 160
 
161 161
 	/**
162 162
 	 * Initialize Gateway Settings Form Fields.
163 163
 	 */
164 164
 	public function init_form_fields() {
165
-		$this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-multibanco-settings.php' );
165
+		$this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-multibanco-settings.php');
166 166
 	}
167 167
 
168 168
 	/**
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
 		$description = $this->get_description();
176 176
 
177 177
 		// If paying from order, we need to get total from order not cart.
178
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
179
-			$order = wc_get_order( wc_clean( $wp->query_vars['order-pay'] ) );
178
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
179
+			$order = wc_get_order(wc_clean($wp->query_vars['order-pay']));
180 180
 			$total = $order->get_total();
181 181
 		}
182 182
 
183
-		if ( is_add_payment_method_page() ) {
184
-			$pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' );
183
+		if (is_add_payment_method_page()) {
184
+			$pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe');
185 185
 			$total           = '';
186 186
 		} else {
187 187
 			$pay_button_text = '';
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
 
190 190
 		echo '<div
191 191
 			id="stripe-multibanco-payment-data"
192
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
193
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">';
192
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
193
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">';
194 194
 
195
-		if ( $description ) {
196
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id );
195
+		if ($description) {
196
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id);
197 197
 		}
198 198
 
199 199
 		echo '</div>';
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @param int $order_id
206 206
 	 */
207
-	public function thankyou_page( $order_id ) {
208
-		$this->get_instructions( $order_id );
207
+	public function thankyou_page($order_id) {
208
+		$this->get_instructions($order_id);
209 209
 	}
210 210
 
211 211
 	/**
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 	 * @param bool $sent_to_admin
218 218
 	 * @param bool $plain_text
219 219
 	 */
220
-	public function email_instructions( $order, $sent_to_admin, $plain_text = false ) {
221
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
220
+	public function email_instructions($order, $sent_to_admin, $plain_text = false) {
221
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
222 222
 
223
-		$payment_method = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method();
223
+		$payment_method = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method();
224 224
 
225
-		if ( ! $sent_to_admin && 'stripe_multibanco' === $payment_method && $order->has_status( 'on-hold' ) ) {
226
-			WC_Stripe_Logger::log( 'Sending multibanco email for order #' . $order_id );
225
+		if ( ! $sent_to_admin && 'stripe_multibanco' === $payment_method && $order->has_status('on-hold')) {
226
+			WC_Stripe_Logger::log('Sending multibanco email for order #' . $order_id);
227 227
 
228
-			$this->get_instructions( $order_id, $plain_text );
228
+			$this->get_instructions($order_id, $plain_text);
229 229
 		}
230 230
 	}
231 231
 
@@ -236,34 +236,34 @@  discard block
 block discarded – undo
236 236
 	 * @version 4.1.0
237 237
 	 * @param int $order_id
238 238
 	 */
239
-	public function get_instructions( $order_id, $plain_text = false ) {
240
-		$data = get_post_meta( $order_id, '_stripe_multibanco', true );
239
+	public function get_instructions($order_id, $plain_text = false) {
240
+		$data = get_post_meta($order_id, '_stripe_multibanco', true);
241 241
 
242
-		if ( $plain_text ) {
243
-			esc_html_e( 'MULTIBANCO INFORMAÇÕES DE ENCOMENDA:', 'woocommerce-gateway-stripe' ) . "\n\n";
242
+		if ($plain_text) {
243
+			esc_html_e('MULTIBANCO INFORMAÇÕES DE ENCOMENDA:', 'woocommerce-gateway-stripe') . "\n\n";
244 244
 			echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
245
-			esc_html_e( 'Montante:', 'woocommerce-gateway-stripe' ) . "\n\n";
245
+			esc_html_e('Montante:', 'woocommerce-gateway-stripe') . "\n\n";
246 246
 			echo $data['amount'] . "\n\n";
247 247
 			echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
248
-			esc_html_e( 'Entidade:', 'woocommerce-gateway-stripe' ) . "\n\n";
248
+			esc_html_e('Entidade:', 'woocommerce-gateway-stripe') . "\n\n";
249 249
 			echo $data['entity'] . "\n\n";
250 250
 			echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
251
-			esc_html_e( 'Referencia:', 'woocommerce-gateway-stripe' ) . "\n\n";
251
+			esc_html_e('Referencia:', 'woocommerce-gateway-stripe') . "\n\n";
252 252
 			echo $data['reference'] . "\n\n";
253 253
 		} else {
254 254
 			?>
255
-			<h3><?php esc_html_e( 'MULTIBANCO INFORMAÇÕES DE ENCOMENDA:', 'woocommerce-gateway-stripe' ); ?></h3>
255
+			<h3><?php esc_html_e('MULTIBANCO INFORMAÇÕES DE ENCOMENDA:', 'woocommerce-gateway-stripe'); ?></h3>
256 256
 			<ul class="woocommerce-order-overview woocommerce-thankyou-order-details order_details">
257 257
 			<li class="woocommerce-order-overview__order order">
258
-				<?php esc_html_e( 'Montante:', 'woocommerce-gateway-stripe' ); ?>
258
+				<?php esc_html_e('Montante:', 'woocommerce-gateway-stripe'); ?>
259 259
 				<strong><?php echo $data['amount']; ?></strong>
260 260
 			</li>
261 261
 			<li class="woocommerce-order-overview__order order">
262
-				<?php esc_html_e( 'Entidade:', 'woocommerce-gateway-stripe' ); ?>
262
+				<?php esc_html_e('Entidade:', 'woocommerce-gateway-stripe'); ?>
263 263
 				<strong><?php echo $data['entity']; ?></strong>
264 264
 			</li>
265 265
 			<li class="woocommerce-order-overview__order order">
266
-				<?php esc_html_e( 'Referencia:', 'woocommerce-gateway-stripe' ); ?>
266
+				<?php esc_html_e('Referencia:', 'woocommerce-gateway-stripe'); ?>
267 267
 				<strong><?php echo $data['reference']; ?></strong>
268 268
 			</li>
269 269
 			</ul>
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
 	 * @param object $order
280 280
 	 * @param object $source_object
281 281
 	 */
282
-	public function save_instructions( $order, $source_object ) {
282
+	public function save_instructions($order, $source_object) {
283 283
 		$data = array(
284 284
 			'amount'    => $order->get_formatted_order_total(),
285 285
 			'entity'    => $source_object->multibanco->entity,
286 286
 			'reference' => $source_object->multibanco->reference,
287 287
 		);
288 288
 
289
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
289
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
290 290
 
291
-		update_post_meta( $order_id, '_stripe_multibanco', $data );
291
+		update_post_meta($order_id, '_stripe_multibanco', $data);
292 292
 	}
293 293
 
294 294
 	/**
@@ -299,24 +299,24 @@  discard block
 block discarded – undo
299 299
 	 * @param object $order
300 300
 	 * @return mixed
301 301
 	 */
302
-	public function create_source( $order ) {
303
-		$currency              = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency();
304
-		$order_id              = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
305
-		$return_url            = $this->get_stripe_return_url( $order );
302
+	public function create_source($order) {
303
+		$currency              = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency();
304
+		$order_id              = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
305
+		$return_url            = $this->get_stripe_return_url($order);
306 306
 		$post_data             = array();
307
-		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency );
308
-		$post_data['currency'] = strtolower( $currency );
307
+		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency);
308
+		$post_data['currency'] = strtolower($currency);
309 309
 		$post_data['type']     = 'multibanco';
310
-		$post_data['owner']    = $this->get_owner_details( $order );
311
-		$post_data['redirect'] = array( 'return_url' => $return_url );
310
+		$post_data['owner']    = $this->get_owner_details($order);
311
+		$post_data['redirect'] = array('return_url' => $return_url);
312 312
 
313
-		if ( ! empty( $this->statement_descriptor ) ) {
314
-			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor );
313
+		if ( ! empty($this->statement_descriptor)) {
314
+			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor);
315 315
 		}
316 316
 
317
-		WC_Stripe_Logger::log( 'Info: Begin creating Multibanco source' );
317
+		WC_Stripe_Logger::log('Info: Begin creating Multibanco source');
318 318
 
319
-		return WC_Stripe_API::request( $post_data, 'sources' );
319
+		return WC_Stripe_API::request($post_data, 'sources');
320 320
 	}
321 321
 
322 322
 	/**
@@ -330,62 +330,62 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @return array|void
332 332
 	 */
333
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
333
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
334 334
 		try {
335
-			$order = wc_get_order( $order_id );
335
+			$order = wc_get_order($order_id);
336 336
 
337 337
 			// This will throw exception if not valid.
338
-			$this->validate_minimum_order_amount( $order );
338
+			$this->validate_minimum_order_amount($order);
339 339
 
340 340
 			// This comes from the create account checkbox in the checkout page.
341
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
341
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
342 342
 
343
-			if ( $create_account ) {
344
-				$new_customer_id     = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id();
345
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
343
+			if ($create_account) {
344
+				$new_customer_id     = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id();
345
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
346 346
 				$new_stripe_customer->create_customer();
347 347
 			}
348 348
 
349
-			$response = $this->create_source( $order );
349
+			$response = $this->create_source($order);
350 350
 
351
-			if ( ! empty( $response->error ) ) {
352
-				$order->add_order_note( $response->error->message );
351
+			if ( ! empty($response->error)) {
352
+				$order->add_order_note($response->error->message);
353 353
 
354
-				throw new Exception( $response->error->message );
354
+				throw new Exception($response->error->message);
355 355
 			}
356 356
 
357
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
358
-				update_post_meta( $order_id, '_stripe_source_id', $response->id );
357
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
358
+				update_post_meta($order_id, '_stripe_source_id', $response->id);
359 359
 			} else {
360
-				$order->update_meta_data( '_stripe_source_id', $response->id );
360
+				$order->update_meta_data('_stripe_source_id', $response->id);
361 361
 				$order->save();
362 362
 			}
363 363
 
364
-			$this->save_instructions( $order, $response );
364
+			$this->save_instructions($order, $response);
365 365
 
366 366
 			// Mark as on-hold (we're awaiting the payment)
367
-			$order->update_status( 'on-hold', __( 'Awaiting Multibanco payment', 'woocommerce-gateway-stripe' ) );
367
+			$order->update_status('on-hold', __('Awaiting Multibanco payment', 'woocommerce-gateway-stripe'));
368 368
 
369 369
 			// Reduce stock levels
370
-			wc_reduce_stock_levels( $order_id );
370
+			wc_reduce_stock_levels($order_id);
371 371
 
372 372
 			// Remove cart
373 373
 			WC()->cart->empty_cart();
374 374
 
375
-			WC_Stripe_Logger::log( 'Info: Redirecting to Multibanco...' );
375
+			WC_Stripe_Logger::log('Info: Redirecting to Multibanco...');
376 376
 
377 377
 			return array(
378 378
 				'result'   => 'success',
379
-				'redirect' => esc_url_raw( $response->redirect->url ),
379
+				'redirect' => esc_url_raw($response->redirect->url),
380 380
 			);
381
-		} catch ( Exception $e ) {
382
-			wc_add_notice( $e->getMessage(), 'error' );
383
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
381
+		} catch (Exception $e) {
382
+			wc_add_notice($e->getMessage(), 'error');
383
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
384 384
 
385
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
385
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
386 386
 
387
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
388
-				$this->send_failed_order_email( $order_id );
387
+			if ($order->has_status(array('pending', 'failed'))) {
388
+				$this->send_failed_order_email($order_id);
389 389
 			}
390 390
 
391 391
 			return array(
Please login to merge, or discard this patch.
includes/payment-methods/class-wc-gateway-stripe-ideal.php 1 patch
Spacing   +67 added lines, -67 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
 
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function __construct() {
59 59
 		$this->id           = 'stripe_ideal';
60
-		$this->method_title = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' );
60
+		$this->method_title = __('Stripe iDeal', 'woocommerce-gateway-stripe');
61 61
 		/* translators: link */
62
-		$this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
62
+		$this->method_description = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe'));
63 63
 		$this->supports           = array(
64 64
 			'products',
65 65
 			'refunds',
@@ -71,23 +71,23 @@  discard block
 block discarded – undo
71 71
 		// Load the settings.
72 72
 		$this->init_settings();
73 73
 
74
-		$main_settings              = get_option( 'woocommerce_stripe_settings' );
75
-		$this->title                = $this->get_option( 'title' );
76
-		$this->description          = $this->get_option( 'description' );
77
-		$this->enabled              = $this->get_option( 'enabled' );
78
-		$this->testmode             = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false;
79
-		$this->saved_cards          = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false;
80
-		$this->publishable_key      = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : '';
81
-		$this->secret_key           = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : '';
82
-		$this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : '';
83
-
84
-		if ( $this->testmode ) {
85
-			$this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : '';
86
-			$this->secret_key      = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : '';
74
+		$main_settings              = get_option('woocommerce_stripe_settings');
75
+		$this->title                = $this->get_option('title');
76
+		$this->description          = $this->get_option('description');
77
+		$this->enabled              = $this->get_option('enabled');
78
+		$this->testmode             = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false;
79
+		$this->saved_cards          = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false;
80
+		$this->publishable_key      = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : '';
81
+		$this->secret_key           = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : '';
82
+		$this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : '';
83
+
84
+		if ($this->testmode) {
85
+			$this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : '';
86
+			$this->secret_key      = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : '';
87 87
 		}
88 88
 
89
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
90
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
89
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
90
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
91 91
 	}
92 92
 
93 93
 	/**
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @return bool
115 115
 	 */
116 116
 	public function is_available() {
117
-		if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
117
+		if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
118 118
 			return false;
119 119
 		}
120 120
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 
134 134
 		$icons_str = '';
135 135
 
136
-		$icons_str .= isset( $icons['ideal'] ) ? $icons['ideal'] : '';
136
+		$icons_str .= isset($icons['ideal']) ? $icons['ideal'] : '';
137 137
 
138
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
138
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
139 139
 	}
140 140
 
141 141
 	/**
@@ -146,19 +146,19 @@  discard block
 block discarded – undo
146 146
 	 * @access public
147 147
 	 */
148 148
 	public function payment_scripts() {
149
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) {
149
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) {
150 150
 			return;
151 151
 		}
152 152
 
153
-		wp_enqueue_style( 'stripe_styles' );
154
-		wp_enqueue_script( 'woocommerce_stripe' );
153
+		wp_enqueue_style('stripe_styles');
154
+		wp_enqueue_script('woocommerce_stripe');
155 155
 	}
156 156
 
157 157
 	/**
158 158
 	 * Initialize Gateway Settings Form Fields.
159 159
 	 */
160 160
 	public function init_form_fields() {
161
-		$this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-ideal-settings.php' );
161
+		$this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-ideal-settings.php');
162 162
 	}
163 163
 
164 164
 	/**
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 		$description = $this->get_description();
172 172
 
173 173
 		// If paying from order, we need to get total from order not cart.
174
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
175
-			$order = wc_get_order( wc_clean( $wp->query_vars['order-pay'] ) );
174
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
175
+			$order = wc_get_order(wc_clean($wp->query_vars['order-pay']));
176 176
 			$total = $order->get_total();
177 177
 		}
178 178
 
179
-		if ( is_add_payment_method_page() ) {
180
-			$pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' );
179
+		if (is_add_payment_method_page()) {
180
+			$pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe');
181 181
 			$total           = '';
182 182
 		} else {
183 183
 			$pay_button_text = '';
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 
186 186
 		echo '<div
187 187
 			id="stripe-ideal-payment-data"
188
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
189
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">';
188
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
189
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">';
190 190
 
191
-		if ( $description ) {
192
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id );
191
+		if ($description) {
192
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id);
193 193
 		}
194 194
 
195 195
 		echo '</div>';
@@ -203,24 +203,24 @@  discard block
 block discarded – undo
203 203
 	 * @param object $order
204 204
 	 * @return mixed
205 205
 	 */
206
-	public function create_source( $order ) {
207
-		$currency              = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency();
208
-		$order_id              = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
209
-		$return_url            = $this->get_stripe_return_url( $order );
206
+	public function create_source($order) {
207
+		$currency              = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency();
208
+		$order_id              = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
209
+		$return_url            = $this->get_stripe_return_url($order);
210 210
 		$post_data             = array();
211
-		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency );
212
-		$post_data['currency'] = strtolower( $currency );
211
+		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency);
212
+		$post_data['currency'] = strtolower($currency);
213 213
 		$post_data['type']     = 'ideal';
214
-		$post_data['owner']    = $this->get_owner_details( $order );
215
-		$post_data['redirect'] = array( 'return_url' => $return_url );
214
+		$post_data['owner']    = $this->get_owner_details($order);
215
+		$post_data['redirect'] = array('return_url' => $return_url);
216 216
 
217
-		if ( ! empty( $this->statement_descriptor ) ) {
218
-			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor );
217
+		if ( ! empty($this->statement_descriptor)) {
218
+			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor);
219 219
 		}
220 220
 
221
-		WC_Stripe_Logger::log( 'Info: Begin creating iDeal source' );
221
+		WC_Stripe_Logger::log('Info: Begin creating iDeal source');
222 222
 
223
-		return WC_Stripe_API::request( apply_filters( 'wc_stripe_ideal_source', $post_data, $order ), 'sources' );
223
+		return WC_Stripe_API::request(apply_filters('wc_stripe_ideal_source', $post_data, $order), 'sources');
224 224
 	}
225 225
 
226 226
 	/**
@@ -234,51 +234,51 @@  discard block
 block discarded – undo
234 234
 	 *
235 235
 	 * @return array|void
236 236
 	 */
237
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
237
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
238 238
 		try {
239
-			$order = wc_get_order( $order_id );
239
+			$order = wc_get_order($order_id);
240 240
 
241 241
 			// This will throw exception if not valid.
242
-			$this->validate_minimum_order_amount( $order );
242
+			$this->validate_minimum_order_amount($order);
243 243
 
244 244
 			// This comes from the create account checkbox in the checkout page.
245
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
245
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
246 246
 
247
-			if ( $create_account ) {
248
-				$new_customer_id     = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id();
249
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
247
+			if ($create_account) {
248
+				$new_customer_id     = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id();
249
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
250 250
 				$new_stripe_customer->create_customer();
251 251
 			}
252 252
 
253
-			$response = $this->create_source( $order );
253
+			$response = $this->create_source($order);
254 254
 
255
-			if ( ! empty( $response->error ) ) {
256
-				$order->add_order_note( $response->error->message );
255
+			if ( ! empty($response->error)) {
256
+				$order->add_order_note($response->error->message);
257 257
 
258
-				throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
258
+				throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
259 259
 			}
260 260
 
261
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
262
-				update_post_meta( $order_id, '_stripe_source_id', $response->id );
261
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
262
+				update_post_meta($order_id, '_stripe_source_id', $response->id);
263 263
 			} else {
264
-				$order->update_meta_data( '_stripe_source_id', $response->id );
264
+				$order->update_meta_data('_stripe_source_id', $response->id);
265 265
 				$order->save();
266 266
 			}
267 267
 
268
-			WC_Stripe_Logger::log( 'Info: Redirecting to iDeal...' );
268
+			WC_Stripe_Logger::log('Info: Redirecting to iDeal...');
269 269
 
270 270
 			return array(
271 271
 				'result'   => 'success',
272
-				'redirect' => esc_url_raw( $response->redirect->url ),
272
+				'redirect' => esc_url_raw($response->redirect->url),
273 273
 			);
274
-		} catch ( WC_Stripe_Exception $e ) {
275
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
276
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
274
+		} catch (WC_Stripe_Exception $e) {
275
+			wc_add_notice($e->getLocalizedMessage(), 'error');
276
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
277 277
 
278
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
278
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
279 279
 
280
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
281
-				$this->send_failed_order_email( $order_id );
280
+			if ($order->has_status(array('pending', 'failed'))) {
281
+				$this->send_failed_order_email($order_id);
282 282
 			}
283 283
 
284 284
 			return array(
Please login to merge, or discard this patch.
includes/payment-methods/class-wc-gateway-stripe-bancontact.php 1 patch
Spacing   +68 added lines, -68 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
 
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function __construct() {
59 59
 		$this->id           = 'stripe_bancontact';
60
-		$this->method_title = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' );
60
+		$this->method_title = __('Stripe Bancontact', 'woocommerce-gateway-stripe');
61 61
 		/* translators: link */
62
-		$this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
62
+		$this->method_description = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe'));
63 63
 		$this->supports           = array(
64 64
 			'products',
65 65
 			'refunds',
@@ -71,23 +71,23 @@  discard block
 block discarded – undo
71 71
 		// Load the settings.
72 72
 		$this->init_settings();
73 73
 
74
-		$main_settings              = get_option( 'woocommerce_stripe_settings' );
75
-		$this->title                = $this->get_option( 'title' );
76
-		$this->description          = $this->get_option( 'description' );
77
-		$this->enabled              = $this->get_option( 'enabled' );
78
-		$this->testmode             = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false;
79
-		$this->saved_cards          = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false;
80
-		$this->publishable_key      = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : '';
81
-		$this->secret_key           = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : '';
82
-		$this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : '';
83
-
84
-		if ( $this->testmode ) {
85
-			$this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : '';
86
-			$this->secret_key      = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : '';
74
+		$main_settings              = get_option('woocommerce_stripe_settings');
75
+		$this->title                = $this->get_option('title');
76
+		$this->description          = $this->get_option('description');
77
+		$this->enabled              = $this->get_option('enabled');
78
+		$this->testmode             = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false;
79
+		$this->saved_cards          = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false;
80
+		$this->publishable_key      = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : '';
81
+		$this->secret_key           = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : '';
82
+		$this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : '';
83
+
84
+		if ($this->testmode) {
85
+			$this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : '';
86
+			$this->secret_key      = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : '';
87 87
 		}
88 88
 
89
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
90
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
89
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
90
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
91 91
 	}
92 92
 
93 93
 	/**
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @return bool
115 115
 	 */
116 116
 	public function is_available() {
117
-		if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
117
+		if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
118 118
 			return false;
119 119
 		}
120 120
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 
134 134
 		$icons_str = '';
135 135
 
136
-		$icons_str .= isset( $icons['bancontact'] ) ? $icons['bancontact'] : '';
136
+		$icons_str .= isset($icons['bancontact']) ? $icons['bancontact'] : '';
137 137
 
138
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
138
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
139 139
 	}
140 140
 
141 141
 	/**
@@ -146,19 +146,19 @@  discard block
 block discarded – undo
146 146
 	 * @access public
147 147
 	 */
148 148
 	public function payment_scripts() {
149
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) {
149
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) {
150 150
 			return;
151 151
 		}
152 152
 
153
-		wp_enqueue_style( 'stripe_styles' );
154
-		wp_enqueue_script( 'woocommerce_stripe' );
153
+		wp_enqueue_style('stripe_styles');
154
+		wp_enqueue_script('woocommerce_stripe');
155 155
 	}
156 156
 
157 157
 	/**
158 158
 	 * Initialize Gateway Settings Form Fields.
159 159
 	 */
160 160
 	public function init_form_fields() {
161
-		$this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-bancontact-settings.php' );
161
+		$this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-bancontact-settings.php');
162 162
 	}
163 163
 
164 164
 	/**
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 		$description = $this->get_description();
172 172
 
173 173
 		// If paying from order, we need to get total from order not cart.
174
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
175
-			$order = wc_get_order( wc_clean( $wp->query_vars['order-pay'] ) );
174
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
175
+			$order = wc_get_order(wc_clean($wp->query_vars['order-pay']));
176 176
 			$total = $order->get_total();
177 177
 		}
178 178
 
179
-		if ( is_add_payment_method_page() ) {
180
-			$pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' );
179
+		if (is_add_payment_method_page()) {
180
+			$pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe');
181 181
 			$total           = '';
182 182
 		} else {
183 183
 			$pay_button_text = '';
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 
186 186
 		echo '<div
187 187
 			id="stripe-bancontact-payment-data"
188
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
189
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">';
188
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
189
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">';
190 190
 
191
-		if ( $description ) {
192
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id );
191
+		if ($description) {
192
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id);
193 193
 		}
194 194
 
195 195
 		echo '</div>';
@@ -203,25 +203,25 @@  discard block
 block discarded – undo
203 203
 	 * @param object $order
204 204
 	 * @return mixed
205 205
 	 */
206
-	public function create_source( $order ) {
207
-		$currency                = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency();
208
-		$order_id                = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
209
-		$return_url              = $this->get_stripe_return_url( $order );
206
+	public function create_source($order) {
207
+		$currency                = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency();
208
+		$order_id                = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
209
+		$return_url              = $this->get_stripe_return_url($order);
210 210
 		$post_data               = array();
211
-		$post_data['amount']     = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency );
212
-		$post_data['currency']   = strtolower( $currency );
211
+		$post_data['amount']     = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency);
212
+		$post_data['currency']   = strtolower($currency);
213 213
 		$post_data['type']       = 'bancontact';
214
-		$post_data['owner']      = $this->get_owner_details( $order );
215
-		$post_data['redirect']   = array( 'return_url' => $return_url );
216
-		$post_data['bancontact'] = array( 'preferred_language' => $this->get_locale() );
214
+		$post_data['owner']      = $this->get_owner_details($order);
215
+		$post_data['redirect']   = array('return_url' => $return_url);
216
+		$post_data['bancontact'] = array('preferred_language' => $this->get_locale());
217 217
 
218
-		if ( ! empty( $this->statement_descriptor ) ) {
219
-			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor );
218
+		if ( ! empty($this->statement_descriptor)) {
219
+			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor);
220 220
 		}
221 221
 
222
-		WC_Stripe_Logger::log( 'Info: Begin creating Bancontact source' );
222
+		WC_Stripe_Logger::log('Info: Begin creating Bancontact source');
223 223
 
224
-		return WC_Stripe_API::request( apply_filters( 'wc_stripe_bancontact_source', $post_data, $order ), 'sources' );
224
+		return WC_Stripe_API::request(apply_filters('wc_stripe_bancontact_source', $post_data, $order), 'sources');
225 225
 	}
226 226
 
227 227
 	/**
@@ -235,51 +235,51 @@  discard block
 block discarded – undo
235 235
 	 *
236 236
 	 * @return array|void
237 237
 	 */
238
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
238
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
239 239
 		try {
240
-			$order = wc_get_order( $order_id );
240
+			$order = wc_get_order($order_id);
241 241
 
242 242
 			// This will throw exception if not valid.
243
-			$this->validate_minimum_order_amount( $order );
243
+			$this->validate_minimum_order_amount($order);
244 244
 
245 245
 			// This comes from the create account checkbox in the checkout page.
246
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
246
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
247 247
 
248
-			if ( $create_account ) {
249
-				$new_customer_id     = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->customer_user : $order->get_customer_id();
250
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
248
+			if ($create_account) {
249
+				$new_customer_id     = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->customer_user : $order->get_customer_id();
250
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
251 251
 				$new_stripe_customer->create_customer();
252 252
 			}
253 253
 
254
-			$response = $this->create_source( $order );
254
+			$response = $this->create_source($order);
255 255
 
256
-			if ( ! empty( $response->error ) ) {
257
-				$order->add_order_note( $response->error->message );
256
+			if ( ! empty($response->error)) {
257
+				$order->add_order_note($response->error->message);
258 258
 
259
-				throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
259
+				throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
260 260
 			}
261 261
 
262
-			if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
263
-				update_post_meta( $order_id, '_stripe_source_id', $response->id );
262
+			if (WC_Stripe_Helper::is_wc_lt('3.0')) {
263
+				update_post_meta($order_id, '_stripe_source_id', $response->id);
264 264
 			} else {
265
-				$order->update_meta_data( '_stripe_source_id', $response->id );
265
+				$order->update_meta_data('_stripe_source_id', $response->id);
266 266
 				$order->save();
267 267
 			}
268 268
 
269
-			WC_Stripe_Logger::log( 'Info: Redirecting to Bancontact...' );
269
+			WC_Stripe_Logger::log('Info: Redirecting to Bancontact...');
270 270
 
271 271
 			return array(
272 272
 				'result'   => 'success',
273
-				'redirect' => esc_url_raw( $response->redirect->url ),
273
+				'redirect' => esc_url_raw($response->redirect->url),
274 274
 			);
275
-		} catch ( WC_Stripe_Exception $e ) {
276
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
277
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
275
+		} catch (WC_Stripe_Exception $e) {
276
+			wc_add_notice($e->getLocalizedMessage(), 'error');
277
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
278 278
 
279
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
279
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
280 280
 
281
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
282
-				$this->send_failed_order_email( $order_id );
281
+			if ($order->has_status(array('pending', 'failed'))) {
282
+				$this->send_failed_order_email($order_id);
283 283
 			}
284 284
 
285 285
 			return array(
Please login to merge, or discard this patch.
tests/phpunit/test-wc-stripe-payment-gateway.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * Helper function to update test order meta data
27 27
 	 */
28
-	private function updateOrderMeta( $order, $key, $value ) {
29
-		WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order->id, $key, $value ) : $order->update_meta_data( $key, $value );
28
+	private function updateOrderMeta($order, $key, $value) {
29
+		WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order->id, $key, $value) : $order->update_meta_data($key, $value);
30 30
 	}
31 31
 
32 32
 	/**
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	public function test_default_get_payment_intent_from_order() {
36 36
 		$order = WC_Helper_Order::create_order();
37
-		$intent = $this->gateway->get_intent_from_order( $order );
38
-		$this->assertFalse( $intent );
37
+		$intent = $this->gateway->get_intent_from_order($order);
38
+		$this->assertFalse($intent);
39 39
 	}
40 40
 
41 41
 	/**
@@ -43,30 +43,30 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function test_success_get_payment_intent_from_order() {
45 45
 		$order = WC_Helper_Order::create_order();
46
-		$this->updateOrderMeta( $order, '_stripe_intent_id', 'pi_123' );
47
-		$expected_intent = ( object ) [ 'id' => 'pi_123' ];
48
-		$callback = function( $preempt, $request_args, $url ) use ( $expected_intent ) {
46
+		$this->updateOrderMeta($order, '_stripe_intent_id', 'pi_123');
47
+		$expected_intent = (object) ['id' => 'pi_123'];
48
+		$callback = function($preempt, $request_args, $url) use ($expected_intent) {
49 49
 			$response = [
50 50
 				'headers' 	=> [],
51
-				'body'		=> json_encode( $expected_intent ),
51
+				'body'		=> json_encode($expected_intent),
52 52
 				'response'	=> [
53 53
 					'code' 		=> 200,
54 54
 					'message' 	=> 'OK',
55 55
 				],
56 56
 			];
57 57
 
58
-			$this->assertEquals( 'GET', $request_args['method'] );
59
-			$this->assertStringEndsWith( 'payment_intents/pi_123', $url );
58
+			$this->assertEquals('GET', $request_args['method']);
59
+			$this->assertStringEndsWith('payment_intents/pi_123', $url);
60 60
 
61 61
 			return $response;
62 62
 		};
63 63
 
64
-		add_filter( 'pre_http_request', $callback, 10, 3);
64
+		add_filter('pre_http_request', $callback, 10, 3);
65 65
 
66
-		$intent = $this->gateway->get_intent_from_order( $order );
67
-		$this->assertEquals( $expected_intent, $intent );
66
+		$intent = $this->gateway->get_intent_from_order($order);
67
+		$this->assertEquals($expected_intent, $intent);
68 68
 
69
-		remove_filter( 'pre_http_request', $callback );
69
+		remove_filter('pre_http_request', $callback);
70 70
 	}
71 71
 
72 72
 	/**
@@ -74,34 +74,34 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function test_error_get_payment_intent_from_order() {
76 76
 		$order = WC_Helper_Order::create_order();
77
-		$this->updateOrderMeta( $order, '_stripe_intent_id', 'pi_123' );
78
-		$response_error = ( object ) [
77
+		$this->updateOrderMeta($order, '_stripe_intent_id', 'pi_123');
78
+		$response_error = (object) [
79 79
 			'error' => [
80 80
 				'code' 		=> 'resource_missing',
81 81
 				'message' 	=> 'error_message'
82 82
 			]
83 83
 		];
84
-		$callback = function( $preempt, $request_args, $url ) use ( $response_error ) {
84
+		$callback = function($preempt, $request_args, $url) use ($response_error) {
85 85
 			$response = [
86 86
 				'headers' 	=> [],
87
-				'body'		=> json_encode( $response_error ),
87
+				'body'		=> json_encode($response_error),
88 88
 				'response'	=> [
89 89
 					'code' 		=> 404,
90 90
 					'message' 	=> 'ERR',
91 91
 				],
92 92
 			];
93 93
 
94
-			$this->assertEquals( 'GET', $request_args['method'] );
95
-			$this->assertStringEndsWith( 'payment_intents/pi_123', $url );
94
+			$this->assertEquals('GET', $request_args['method']);
95
+			$this->assertStringEndsWith('payment_intents/pi_123', $url);
96 96
 
97 97
 			return $response;
98 98
 		};
99 99
 
100
-		add_filter( 'pre_http_request', $callback, 10, 3);
100
+		add_filter('pre_http_request', $callback, 10, 3);
101 101
 
102
-		$intent = $this->gateway->get_intent_from_order( $order );
103
-		$this->assertFalse( $intent );
102
+		$intent = $this->gateway->get_intent_from_order($order);
103
+		$this->assertFalse($intent);
104 104
 
105
-		remove_filter( 'pre_http_request', $callback );
105
+		remove_filter('pre_http_request', $callback);
106 106
 	}
107 107
 }
Please login to merge, or discard this patch.
woocommerce-gateway-stripe.php 1 patch
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  *
16 16
  */
17 17
 
18
-if ( ! defined( 'ABSPATH' ) ) {
18
+if ( ! defined('ABSPATH')) {
19 19
 	exit;
20 20
 }
21 21
 
@@ -29,30 +29,30 @@  discard block
 block discarded – undo
29 29
  */
30 30
 function woocommerce_stripe_missing_wc_notice() {
31 31
 	/* translators: 1. URL link. */
32
-	echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'Stripe requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-gateway-stripe' ), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>' ) . '</strong></p></div>';
32
+	echo '<div class="error"><p><strong>' . sprintf(esc_html__('Stripe requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-gateway-stripe'), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>') . '</strong></p></div>';
33 33
 }
34 34
 
35
-add_action( 'plugins_loaded', 'woocommerce_gateway_stripe_init' );
35
+add_action('plugins_loaded', 'woocommerce_gateway_stripe_init');
36 36
 
37 37
 function woocommerce_gateway_stripe_init() {
38
-	load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
38
+	load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages');
39 39
 
40
-	if ( ! class_exists( 'WooCommerce' ) ) {
41
-		add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' );
40
+	if ( ! class_exists('WooCommerce')) {
41
+		add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice');
42 42
 		return;
43 43
 	}
44 44
 
45
-	if ( ! class_exists( 'WC_Stripe' ) ) :
45
+	if ( ! class_exists('WC_Stripe')) :
46 46
 		/**
47 47
 		 * Required minimums and constants
48 48
 		 */
49
-		define( 'WC_STRIPE_VERSION', '4.3.3' );
50
-		define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
51
-		define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' );
52
-		define( 'WC_STRIPE_FUTURE_MIN_WC_VER', '3.0' );
53
-		define( 'WC_STRIPE_MAIN_FILE', __FILE__ );
54
-		define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
55
-		define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
49
+		define('WC_STRIPE_VERSION', '4.3.3');
50
+		define('WC_STRIPE_MIN_PHP_VER', '5.6.0');
51
+		define('WC_STRIPE_MIN_WC_VER', '2.6.0');
52
+		define('WC_STRIPE_FUTURE_MIN_WC_VER', '3.0');
53
+		define('WC_STRIPE_MAIN_FILE', __FILE__);
54
+		define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__))));
55
+		define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__)));
56 56
 
57 57
 		class WC_Stripe {
58 58
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			 * @return Singleton The *Singleton* instance.
68 68
 			 */
69 69
 			public static function get_instance() {
70
-				if ( null === self::$instance ) {
70
+				if (null === self::$instance) {
71 71
 					self::$instance = new self();
72 72
 				}
73 73
 				return self::$instance;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 			 * *Singleton* via the `new` operator from outside of this class.
95 95
 			 */
96 96
 			private function __construct() {
97
-				add_action( 'admin_init', array( $this, 'install' ) );
97
+				add_action('admin_init', array($this, 'install'));
98 98
 				$this->init();
99 99
 			}
100 100
 
@@ -105,52 +105,52 @@  discard block
 block discarded – undo
105 105
 			 * @version 4.0.0
106 106
 			 */
107 107
 			public function init() {
108
-				if ( is_admin() ) {
109
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php';
108
+				if (is_admin()) {
109
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php';
110 110
 				}
111 111
 
112
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php';
113
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php';
114
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php';
115
-				include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php';
116
-				require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
117
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php';
118
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php';
119
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php';
120
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
121
-				require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php';
122
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
123
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
124
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
125
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
126
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
127
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
128
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
129
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
130
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
131
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
132
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php';
133
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
134
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php';
135
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php';
136
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php';
137
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-intent-controller.php';
138
-
139
-				if ( is_admin() ) {
140
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php';
112
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-exception.php';
113
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-logger.php';
114
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-helper.php';
115
+				include_once dirname(__FILE__) . '/includes/class-wc-stripe-api.php';
116
+				require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
117
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php';
118
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php';
119
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php';
120
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
121
+				require_once dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php';
122
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
123
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
124
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
125
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
126
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
127
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
128
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
129
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
130
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
131
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
132
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php';
133
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
134
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php';
135
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php';
136
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-customer.php';
137
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-intent-controller.php';
138
+
139
+				if (is_admin()) {
140
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php';
141 141
 				}
142 142
 
143 143
 				// REMOVE IN THE FUTURE.
144
-				require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
144
+				require_once dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
145 145
 
146
-				add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) );
147
-				add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
146
+				add_filter('woocommerce_payment_gateways', array($this, 'add_gateways'));
147
+				add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
148 148
 
149 149
 				// Modify emails emails.
150
-				add_filter( 'woocommerce_email_classes', array( $this, 'add_emails' ), 20 );
150
+				add_filter('woocommerce_email_classes', array($this, 'add_emails'), 20);
151 151
 
152
-				if ( version_compare( WC_VERSION, '3.4', '<' ) ) {
153
-					add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) );
152
+				if (version_compare(WC_VERSION, '3.4', '<')) {
153
+					add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin'));
154 154
 				}
155 155
 			}
156 156
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 			 * @version 4.0.0
162 162
 			 */
163 163
 			public function update_plugin_version() {
164
-				delete_option( 'wc_stripe_version' );
165
-				update_option( 'wc_stripe_version', WC_STRIPE_VERSION );
164
+				delete_option('wc_stripe_version');
165
+				update_option('wc_stripe_version', WC_STRIPE_VERSION);
166 166
 			}
167 167
 
168 168
 			/**
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
 			 * @version 3.1.0
173 173
 			 */
174 174
 			public function install() {
175
-				if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) {
175
+				if ( ! is_plugin_active(plugin_basename(__FILE__))) {
176 176
 					return;
177 177
 				}
178 178
 
179
-				if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) {
180
-					do_action( 'woocommerce_stripe_updated' );
179
+				if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) {
180
+					do_action('woocommerce_stripe_updated');
181 181
 
182
-					if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) {
183
-						define( 'WC_STRIPE_INSTALLING', true );
182
+					if ( ! defined('WC_STRIPE_INSTALLING')) {
183
+						define('WC_STRIPE_INSTALLING', true);
184 184
 					}
185 185
 
186 186
 					$this->update_plugin_version();
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 			 * @since 1.0.0
194 194
 			 * @version 4.0.0
195 195
 			 */
196
-			public function plugin_action_links( $links ) {
196
+			public function plugin_action_links($links) {
197 197
 				$plugin_links = array(
198
-					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
199
-					'<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>',
200
-					'<a href="https://woocommerce.com/my-account/create-a-ticket?broken=primary&select=18627">' . esc_html__( 'Support', 'woocommerce-gateway-stripe' ) . '</a>',
198
+					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>',
199
+					'<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__('Docs', 'woocommerce-gateway-stripe') . '</a>',
200
+					'<a href="https://woocommerce.com/my-account/create-a-ticket?broken=primary&select=18627">' . esc_html__('Support', 'woocommerce-gateway-stripe') . '</a>',
201 201
 				);
202
-				return array_merge( $plugin_links, $links );
202
+				return array_merge($plugin_links, $links);
203 203
 			}
204 204
 
205 205
 			/**
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 			 * @since 1.0.0
209 209
 			 * @version 4.0.0
210 210
 			 */
211
-			public function add_gateways( $methods ) {
212
-				if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) {
211
+			public function add_gateways($methods) {
212
+				if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) {
213 213
 					$methods[] = 'WC_Stripe_Subs_Compat';
214 214
 					$methods[] = 'WC_Stripe_Sepa_Subs_Compat';
215 215
 				} else {
@@ -235,28 +235,28 @@  discard block
 block discarded – undo
235 235
 			 * @since 4.0.0
236 236
 			 * @version 4.0.0
237 237
 			 */
238
-			public function filter_gateway_order_admin( $sections ) {
239
-				unset( $sections['stripe'] );
240
-				unset( $sections['stripe_bancontact'] );
241
-				unset( $sections['stripe_sofort'] );
242
-				unset( $sections['stripe_giropay'] );
243
-				unset( $sections['stripe_eps'] );
244
-				unset( $sections['stripe_ideal'] );
245
-				unset( $sections['stripe_p24'] );
246
-				unset( $sections['stripe_alipay'] );
247
-				unset( $sections['stripe_sepa'] );
248
-				unset( $sections['stripe_multibanco'] );
238
+			public function filter_gateway_order_admin($sections) {
239
+				unset($sections['stripe']);
240
+				unset($sections['stripe_bancontact']);
241
+				unset($sections['stripe_sofort']);
242
+				unset($sections['stripe_giropay']);
243
+				unset($sections['stripe_eps']);
244
+				unset($sections['stripe_ideal']);
245
+				unset($sections['stripe_p24']);
246
+				unset($sections['stripe_alipay']);
247
+				unset($sections['stripe_sepa']);
248
+				unset($sections['stripe_multibanco']);
249 249
 
250 250
 				$sections['stripe']            = 'Stripe';
251
-				$sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' );
252
-				$sections['stripe_sofort']     = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' );
253
-				$sections['stripe_giropay']    = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' );
254
-				$sections['stripe_eps']        = __( 'Stripe EPS', 'woocommerce-gateway-stripe' );
255
-				$sections['stripe_ideal']      = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' );
256
-				$sections['stripe_p24']        = __( 'Stripe P24', 'woocommerce-gateway-stripe' );
257
-				$sections['stripe_alipay']     = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' );
258
-				$sections['stripe_sepa']       = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' );
259
-				$sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' );
251
+				$sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe');
252
+				$sections['stripe_sofort']     = __('Stripe SOFORT', 'woocommerce-gateway-stripe');
253
+				$sections['stripe_giropay']    = __('Stripe Giropay', 'woocommerce-gateway-stripe');
254
+				$sections['stripe_eps']        = __('Stripe EPS', 'woocommerce-gateway-stripe');
255
+				$sections['stripe_ideal']      = __('Stripe iDeal', 'woocommerce-gateway-stripe');
256
+				$sections['stripe_p24']        = __('Stripe P24', 'woocommerce-gateway-stripe');
257
+				$sections['stripe_alipay']     = __('Stripe Alipay', 'woocommerce-gateway-stripe');
258
+				$sections['stripe_sepa']       = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe');
259
+				$sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe');
260 260
 
261 261
 				return $sections;
262 262
 			}
@@ -267,16 +267,16 @@  discard block
 block discarded – undo
267 267
 			 * @param WC_Email[] $email_classes All existing emails.
268 268
 			 * @return WC_Email[]
269 269
 			 */
270
-			public function add_emails( $email_classes ) {
270
+			public function add_emails($email_classes) {
271 271
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication.php';
272 272
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-renewal-authentication.php';
273 273
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-preorder-authentication.php';
274 274
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication-retry.php';
275 275
 
276 276
 				// Add all emails, generated by the gateway.
277
-				$email_classes['WC_Stripe_Email_Failed_Renewal_Authentication']  = new WC_Stripe_Email_Failed_Renewal_Authentication( $email_classes );
278
-				$email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication( $email_classes );
279
-				$email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry( $email_classes );
277
+				$email_classes['WC_Stripe_Email_Failed_Renewal_Authentication']  = new WC_Stripe_Email_Failed_Renewal_Authentication($email_classes);
278
+				$email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication($email_classes);
279
+				$email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry($email_classes);
280 280
 
281 281
 				return $email_classes;
282 282
 			}
Please login to merge, or discard this patch.
includes/admin/class-wc-stripe-admin-notices.php 1 patch
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 * @since 4.1.0
22 22
 	 */
23 23
 	public function __construct() {
24
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
25
-		add_action( 'wp_loaded', array( $this, 'hide_notices' ) );
26
-		add_action( 'woocommerce_stripe_updated', array( $this, 'stripe_updated' ) );
24
+		add_action('admin_notices', array($this, 'admin_notices'));
25
+		add_action('wp_loaded', array($this, 'hide_notices'));
26
+		add_action('woocommerce_stripe_updated', array($this, 'stripe_updated'));
27 27
 	}
28 28
 
29 29
 	/**
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 * @since 1.0.0
33 33
 	 * @version 4.0.0
34 34
 	 */
35
-	public function add_admin_notice( $slug, $class, $message, $dismissible = false ) {
36
-		$this->notices[ $slug ] = array(
35
+	public function add_admin_notice($slug, $class, $message, $dismissible = false) {
36
+		$this->notices[$slug] = array(
37 37
 			'class'       => $class,
38 38
 			'message'     => $message,
39 39
 			'dismissible' => $dismissible,
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @version 4.0.0
48 48
 	 */
49 49
 	public function admin_notices() {
50
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
50
+		if ( ! current_user_can('manage_woocommerce')) {
51 51
 			return;
52 52
 		}
53 53
 
@@ -57,17 +57,17 @@  discard block
 block discarded – undo
57 57
 		// All other payment methods.
58 58
 		$this->payment_methods_check_environment();
59 59
 
60
-		foreach ( (array) $this->notices as $notice_key => $notice ) {
61
-			echo '<div class="' . esc_attr( $notice['class'] ) . '" style="position:relative;">';
60
+		foreach ((array) $this->notices as $notice_key => $notice) {
61
+			echo '<div class="' . esc_attr($notice['class']) . '" style="position:relative;">';
62 62
 
63
-			if ( $notice['dismissible'] ) {
63
+			if ($notice['dismissible']) {
64 64
 				?>
65
-				<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-stripe-hide-notice', $notice_key ), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce' ) ); ?>" class="woocommerce-message-close notice-dismiss" style="position:relative;float:right;padding:9px 0px 9px 9px 9px;text-decoration:none;"></a>
65
+				<a href="<?php echo esc_url(wp_nonce_url(add_query_arg('wc-stripe-hide-notice', $notice_key), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce')); ?>" class="woocommerce-message-close notice-dismiss" style="position:relative;float:right;padding:9px 0px 9px 9px 9px;text-decoration:none;"></a>
66 66
 				<?php
67 67
 			}
68 68
 
69 69
 			echo '<p>';
70
-			echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array(), 'target' => array() ) ) );
70
+			echo wp_kses($notice['message'], array('a' => array('href' => array(), 'target' => array())));
71 71
 			echo '</p></div>';
72 72
 		}
73 73
 	}
@@ -100,118 +100,118 @@  discard block
 block discarded – undo
100 100
 	 * @version 4.0.0
101 101
 	 */
102 102
 	public function stripe_check_environment() {
103
-		$show_style_notice   = get_option( 'wc_stripe_show_style_notice' );
104
-		$show_ssl_notice     = get_option( 'wc_stripe_show_ssl_notice' );
105
-		$show_keys_notice    = get_option( 'wc_stripe_show_keys_notice' );
106
-		$show_3ds_notice     = get_option( 'wc_stripe_show_3ds_notice' );
107
-		$show_phpver_notice  = get_option( 'wc_stripe_show_phpver_notice' );
108
-		$show_wcver_notice   = get_option( 'wc_stripe_show_wcver_notice' );
109
-		$show_curl_notice    = get_option( 'wc_stripe_show_curl_notice' );
110
-		$show_sca_notice     = get_option( 'wc_stripe_show_sca_notice' );
111
-		$changed_keys_notice = get_option( 'wc_stripe_show_changed_keys_notice' );
112
-		$options             = get_option( 'woocommerce_stripe_settings' );
113
-		$testmode            = ( isset( $options['testmode'] ) && 'yes' === $options['testmode'] ) ? true : false;
114
-		$test_pub_key        = isset( $options['test_publishable_key'] ) ? $options['test_publishable_key'] : '';
115
-		$test_secret_key     = isset( $options['test_secret_key'] ) ? $options['test_secret_key'] : '';
116
-		$live_pub_key        = isset( $options['publishable_key'] ) ? $options['publishable_key'] : '';
117
-		$live_secret_key     = isset( $options['secret_key'] ) ? $options['secret_key'] : '';
118
-		$three_d_secure      = isset( $options['three_d_secure'] ) && 'yes' === $options['three_d_secure'];
119
-
120
-		if ( isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) {
121
-			if ( empty( $show_3ds_notice ) && $three_d_secure ) {
103
+		$show_style_notice   = get_option('wc_stripe_show_style_notice');
104
+		$show_ssl_notice     = get_option('wc_stripe_show_ssl_notice');
105
+		$show_keys_notice    = get_option('wc_stripe_show_keys_notice');
106
+		$show_3ds_notice     = get_option('wc_stripe_show_3ds_notice');
107
+		$show_phpver_notice  = get_option('wc_stripe_show_phpver_notice');
108
+		$show_wcver_notice   = get_option('wc_stripe_show_wcver_notice');
109
+		$show_curl_notice    = get_option('wc_stripe_show_curl_notice');
110
+		$show_sca_notice     = get_option('wc_stripe_show_sca_notice');
111
+		$changed_keys_notice = get_option('wc_stripe_show_changed_keys_notice');
112
+		$options             = get_option('woocommerce_stripe_settings');
113
+		$testmode            = (isset($options['testmode']) && 'yes' === $options['testmode']) ? true : false;
114
+		$test_pub_key        = isset($options['test_publishable_key']) ? $options['test_publishable_key'] : '';
115
+		$test_secret_key     = isset($options['test_secret_key']) ? $options['test_secret_key'] : '';
116
+		$live_pub_key        = isset($options['publishable_key']) ? $options['publishable_key'] : '';
117
+		$live_secret_key     = isset($options['secret_key']) ? $options['secret_key'] : '';
118
+		$three_d_secure      = isset($options['three_d_secure']) && 'yes' === $options['three_d_secure'];
119
+
120
+		if (isset($options['enabled']) && 'yes' === $options['enabled']) {
121
+			if (empty($show_3ds_notice) && $three_d_secure) {
122 122
 				$url = 'https://stripe.com/docs/payments/3d-secure#three-ds-radar';
123 123
 
124 124
 				/* translators: 1) A URL that explains Stripe Radar. */
125
-				$message = __( 'WooCommerce Stripe - We see that you had the "Require 3D secure when applicable" setting turned on. This setting is not available here anymore, because it is now replaced by Stripe Radar. You can learn more about it <a href="%s" target="_blank">here</a>.', 'woocommerce-gateway-stripe' );
125
+				$message = __('WooCommerce Stripe - We see that you had the "Require 3D secure when applicable" setting turned on. This setting is not available here anymore, because it is now replaced by Stripe Radar. You can learn more about it <a href="%s" target="_blank">here</a>.', 'woocommerce-gateway-stripe');
126 126
 
127
-				$this->add_admin_notice( '3ds', 'notice notice-warning', sprintf( $message, $url ), true );
127
+				$this->add_admin_notice('3ds', 'notice notice-warning', sprintf($message, $url), true);
128 128
 			}
129 129
 
130
-			if ( empty( $show_style_notice ) ) {
130
+			if (empty($show_style_notice)) {
131 131
 				/* translators: 1) int version 2) int version */
132
-				$message = __( 'WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://docs.woocommerce.com/document/stripe/#styling" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe' );
132
+				$message = __('WooCommerce Stripe - We recently made changes to Stripe that may impact the appearance of your checkout. If your checkout has changed unexpectedly, please follow these <a href="https://docs.woocommerce.com/document/stripe/#styling" target="_blank">instructions</a> to fix.', 'woocommerce-gateway-stripe');
133 133
 
134
-				$this->add_admin_notice( 'style', 'notice notice-warning', $message, true );
134
+				$this->add_admin_notice('style', 'notice notice-warning', $message, true);
135 135
 
136 136
 				return;
137 137
 			}
138 138
 
139
-			if ( empty( $show_phpver_notice ) ) {
140
-				if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) {
139
+			if (empty($show_phpver_notice)) {
140
+				if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) {
141 141
 					/* translators: 1) int version 2) int version */
142
-					$message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' );
142
+					$message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe');
143 143
 
144
-					$this->add_admin_notice( 'phpver', 'error', sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() ), true );
144
+					$this->add_admin_notice('phpver', 'error', sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion()), true);
145 145
 
146 146
 					return;
147 147
 				}
148 148
 			}
149 149
 
150
-			if ( empty( $show_wcver_notice ) ) {
151
-				if ( WC_Stripe_Helper::is_wc_lt( WC_STRIPE_MIN_WC_VER ) ) {
150
+			if (empty($show_wcver_notice)) {
151
+				if (WC_Stripe_Helper::is_wc_lt(WC_STRIPE_MIN_WC_VER)) {
152 152
 					/* translators: 1) int version 2) int version */
153
-					$message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' );
153
+					$message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe');
154 154
 
155
-					$this->add_admin_notice( 'wcver', 'notice notice-warning', sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION ), true );
155
+					$this->add_admin_notice('wcver', 'notice notice-warning', sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION), true);
156 156
 
157 157
 					return;
158
-				} elseif ( WC_Stripe_Helper::is_wc_lt( WC_STRIPE_FUTURE_MIN_WC_VER ) ) {
158
+				} elseif (WC_Stripe_Helper::is_wc_lt(WC_STRIPE_FUTURE_MIN_WC_VER)) {
159 159
 					/* translators: 1) int version 2) int version */
160
-					$message = __( 'WooCommerce Stripe - This is the last version of the plugin compatible with WooCommerce %1$s. All furture versions of the plugin will require WooCommerce %2$s or greater.', 'woocommerce-gateway-stripe' );
161
-					$this->add_admin_notice( 'wcver', 'notice notice-warning', sprintf( $message, WC_VERSION, WC_STRIPE_FUTURE_MIN_WC_VER ), true );
160
+					$message = __('WooCommerce Stripe - This is the last version of the plugin compatible with WooCommerce %1$s. All furture versions of the plugin will require WooCommerce %2$s or greater.', 'woocommerce-gateway-stripe');
161
+					$this->add_admin_notice('wcver', 'notice notice-warning', sprintf($message, WC_VERSION, WC_STRIPE_FUTURE_MIN_WC_VER), true);
162 162
 				}
163 163
 			}
164 164
 
165
-			if ( empty( $show_curl_notice ) ) {
166
-				if ( ! function_exists( 'curl_init' ) ) {
167
-					$this->add_admin_notice( 'curl', 'notice notice-warning', __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' ), true );
165
+			if (empty($show_curl_notice)) {
166
+				if ( ! function_exists('curl_init')) {
167
+					$this->add_admin_notice('curl', 'notice notice-warning', __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe'), true);
168 168
 				}
169 169
 			}
170 170
 
171
-			if ( empty( $show_keys_notice ) ) {
171
+			if (empty($show_keys_notice)) {
172 172
 				$secret = WC_Stripe_API::get_secret_key();
173 173
 
174
-				if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) {
174
+				if (empty($secret) && ! (isset($_GET['page'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'])) {
175 175
 					$setting_link = $this->get_setting_link();
176 176
 					/* translators: 1) link */
177
-					$this->add_admin_notice( 'keys', 'notice notice-warning', sprintf( __( 'Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
177
+					$this->add_admin_notice('keys', 'notice notice-warning', sprintf(__('Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
178 178
 				}
179 179
 
180 180
 				// Check if keys are entered properly per live/test mode.
181
-				if ( $testmode ) {
181
+				if ($testmode) {
182 182
 					if (
183
-						! empty( $test_pub_key ) && ! preg_match( '/^pk_test_/', $test_pub_key )
184
-						|| ! empty( $test_secret_key ) && ! preg_match( '/^[rs]k_test_/', $test_secret_key ) ) {
183
+						! empty($test_pub_key) && ! preg_match('/^pk_test_/', $test_pub_key)
184
+						|| ! empty($test_secret_key) && ! preg_match('/^[rs]k_test_/', $test_secret_key) ) {
185 185
 						$setting_link = $this->get_setting_link();
186 186
 						/* translators: 1) link */
187
-						$this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
187
+						$this->add_admin_notice('keys', 'notice notice-error', sprintf(__('Stripe is in test mode however your test keys may not be valid. Test keys start with pk_test and sk_test or rk_test. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
188 188
 					}
189 189
 				} else {
190 190
 					if (
191
-						! empty( $live_pub_key ) && ! preg_match( '/^pk_live_/', $live_pub_key )
192
-						|| ! empty( $live_secret_key ) && ! preg_match( '/^[rs]k_live_/', $live_secret_key ) ) {
191
+						! empty($live_pub_key) && ! preg_match('/^pk_live_/', $live_pub_key)
192
+						|| ! empty($live_secret_key) && ! preg_match('/^[rs]k_live_/', $live_secret_key) ) {
193 193
 						$setting_link = $this->get_setting_link();
194 194
 						/* translators: 1) link */
195
-						$this->add_admin_notice( 'keys', 'notice notice-error', sprintf( __( 'Stripe is in live mode however your live keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true );
195
+						$this->add_admin_notice('keys', 'notice notice-error', sprintf(__('Stripe is in live mode however your live keys may not be valid. Live keys start with pk_live and sk_live or rk_live. Please go to your settings and, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true);
196 196
 					}
197 197
 				}
198 198
 			}
199 199
 
200
-			if ( empty( $show_ssl_notice ) ) {
200
+			if (empty($show_ssl_notice)) {
201 201
 				// Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected.
202
-				if ( ! wc_checkout_is_https() ) {
202
+				if ( ! wc_checkout_is_https()) {
203 203
 					/* translators: 1) link */
204
-					$this->add_admin_notice( 'ssl', 'notice notice-warning', sprintf( __( 'Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe' ), 'https://en.wikipedia.org/wiki/Transport_Layer_Security' ), true );
204
+					$this->add_admin_notice('ssl', 'notice notice-warning', sprintf(__('Stripe is enabled, but a SSL certificate is not detected. Your checkout may not be secure! Please ensure your server has a valid <a href="%1$s" target="_blank">SSL certificate</a>', 'woocommerce-gateway-stripe'), 'https://en.wikipedia.org/wiki/Transport_Layer_Security'), true);
205 205
 				}
206 206
 			}
207 207
 
208
-			if ( empty( $show_sca_notice ) ) {
209
-				$this->add_admin_notice( 'sca', 'notice notice-success', sprintf( __( 'Stripe is now ready for Strong Customer Authentication (SCA) and 3D Secure 2! <a href="%1$s" target="_blank">Read about SCA</a>', 'woocommerce-gateway-stripe' ), 'https://woocommerce.com/posts/introducing-strong-customer-authentication-sca/' ), true );
208
+			if (empty($show_sca_notice)) {
209
+				$this->add_admin_notice('sca', 'notice notice-success', sprintf(__('Stripe is now ready for Strong Customer Authentication (SCA) and 3D Secure 2! <a href="%1$s" target="_blank">Read about SCA</a>', 'woocommerce-gateway-stripe'), 'https://woocommerce.com/posts/introducing-strong-customer-authentication-sca/'), true);
210 210
 			}
211 211
 
212
-			if ( 'yes' === $changed_keys_notice ) {
212
+			if ('yes' === $changed_keys_notice) {
213 213
 				// translators: %s is a the URL for the link.
214
-				$this->add_admin_notice( 'changed_keys', 'notice notice-warning', sprintf( __( 'The public and/or secret keys for the Stripe gateway have been changed. This might cause errors for existing customers and saved payment methods. <a href="%s" target="_blank">Click here to learn more</a>.', 'woocommerce-gateway-stripe' ), 'https://docs.woocommerce.com/document/stripe-fixing-customer-errors/' ), true );
214
+				$this->add_admin_notice('changed_keys', 'notice notice-warning', sprintf(__('The public and/or secret keys for the Stripe gateway have been changed. This might cause errors for existing customers and saved payment methods. <a href="%s" target="_blank">Click here to learn more</a>.', 'woocommerce-gateway-stripe'), 'https://docs.woocommerce.com/document/stripe-fixing-customer-errors/'), true);
215 215
 			}
216 216
 		}
217 217
 	}
@@ -224,17 +224,17 @@  discard block
 block discarded – undo
224 224
 	public function payment_methods_check_environment() {
225 225
 		$payment_methods = $this->get_payment_methods();
226 226
 
227
-		foreach ( $payment_methods as $method => $class ) {
228
-			$show_notice = get_option( 'wc_stripe_show_' . strtolower( $method ) . '_notice' );
227
+		foreach ($payment_methods as $method => $class) {
228
+			$show_notice = get_option('wc_stripe_show_' . strtolower($method) . '_notice');
229 229
 			$gateway     = new $class();
230 230
 
231
-			if ( 'yes' !== $gateway->enabled || 'no' === $show_notice ) {
231
+			if ('yes' !== $gateway->enabled || 'no' === $show_notice) {
232 232
 				continue;
233 233
 			}
234 234
 
235
-			if ( ! in_array( get_woocommerce_currency(), $gateway->get_supported_currency() ) ) {
235
+			if ( ! in_array(get_woocommerce_currency(), $gateway->get_supported_currency())) {
236 236
 				/* translators: %1$s Payment method, %2$s List of supported currencies */
237
-				$this->add_admin_notice( $method, 'notice notice-error', sprintf( __( '%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe' ), $method, implode( ', ', $gateway->get_supported_currency() ) ), true );
237
+				$this->add_admin_notice($method, 'notice notice-error', sprintf(__('%1$s is enabled - it requires store currency to be set to %2$s', 'woocommerce-gateway-stripe'), $method, implode(', ', $gateway->get_supported_currency())), true);
238 238
 			}
239 239
 		}
240 240
 	}
@@ -246,71 +246,71 @@  discard block
 block discarded – undo
246 246
 	 * @version 4.0.0
247 247
 	 */
248 248
 	public function hide_notices() {
249
-		if ( isset( $_GET['wc-stripe-hide-notice'] ) && isset( $_GET['_wc_stripe_notice_nonce'] ) ) {
250
-			if ( ! wp_verify_nonce( $_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce' ) ) {
251
-				wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe' ) );
249
+		if (isset($_GET['wc-stripe-hide-notice']) && isset($_GET['_wc_stripe_notice_nonce'])) {
250
+			if ( ! wp_verify_nonce($_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce')) {
251
+				wp_die(__('Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe'));
252 252
 			}
253 253
 
254
-			if ( ! current_user_can( 'manage_woocommerce' ) ) {
255
-				wp_die( __( 'Cheatin&#8217; huh?', 'woocommerce-gateway-stripe' ) );
254
+			if ( ! current_user_can('manage_woocommerce')) {
255
+				wp_die(__('Cheatin&#8217; huh?', 'woocommerce-gateway-stripe'));
256 256
 			}
257 257
 
258
-			$notice = wc_clean( $_GET['wc-stripe-hide-notice'] );
258
+			$notice = wc_clean($_GET['wc-stripe-hide-notice']);
259 259
 
260
-			switch ( $notice ) {
260
+			switch ($notice) {
261 261
 				case 'style':
262
-					update_option( 'wc_stripe_show_style_notice', 'no' );
262
+					update_option('wc_stripe_show_style_notice', 'no');
263 263
 					break;
264 264
 				case 'phpver':
265
-					update_option( 'wc_stripe_show_phpver_notice', 'no' );
265
+					update_option('wc_stripe_show_phpver_notice', 'no');
266 266
 					break;
267 267
 				case 'wcver':
268
-					update_option( 'wc_stripe_show_wcver_notice', 'no' );
268
+					update_option('wc_stripe_show_wcver_notice', 'no');
269 269
 					break;
270 270
 				case 'curl':
271
-					update_option( 'wc_stripe_show_curl_notice', 'no' );
271
+					update_option('wc_stripe_show_curl_notice', 'no');
272 272
 					break;
273 273
 				case 'ssl':
274
-					update_option( 'wc_stripe_show_ssl_notice', 'no' );
274
+					update_option('wc_stripe_show_ssl_notice', 'no');
275 275
 					break;
276 276
 				case 'keys':
277
-					update_option( 'wc_stripe_show_keys_notice', 'no' );
277
+					update_option('wc_stripe_show_keys_notice', 'no');
278 278
 					break;
279 279
 				case '3ds':
280
-					update_option( 'wc_stripe_show_3ds_notice', 'no' );
280
+					update_option('wc_stripe_show_3ds_notice', 'no');
281 281
 					break;
282 282
 				case 'Alipay':
283
-					update_option( 'wc_stripe_show_alipay_notice', 'no' );
283
+					update_option('wc_stripe_show_alipay_notice', 'no');
284 284
 					break;
285 285
 				case 'Bancontact':
286
-					update_option( 'wc_stripe_show_bancontact_notice', 'no' );
286
+					update_option('wc_stripe_show_bancontact_notice', 'no');
287 287
 					break;
288 288
 				case 'EPS':
289
-					update_option( 'wc_stripe_show_eps_notice', 'no' );
289
+					update_option('wc_stripe_show_eps_notice', 'no');
290 290
 					break;
291 291
 				case 'Giropay':
292
-					update_option( 'wc_stripe_show_giropay_notice', 'no' );
292
+					update_option('wc_stripe_show_giropay_notice', 'no');
293 293
 					break;
294 294
 				case 'iDeal':
295
-					update_option( 'wc_stripe_show_ideal_notice', 'no' );
295
+					update_option('wc_stripe_show_ideal_notice', 'no');
296 296
 					break;
297 297
 				case 'Multibanco':
298
-					update_option( 'wc_stripe_show_multibanco_notice', 'no' );
298
+					update_option('wc_stripe_show_multibanco_notice', 'no');
299 299
 					break;
300 300
 				case 'P24':
301
-					update_option( 'wc_stripe_show_p24_notice', 'no' );
301
+					update_option('wc_stripe_show_p24_notice', 'no');
302 302
 					break;
303 303
 				case 'SEPA':
304
-					update_option( 'wc_stripe_show_sepa_notice', 'no' );
304
+					update_option('wc_stripe_show_sepa_notice', 'no');
305 305
 					break;
306 306
 				case 'SOFORT':
307
-					update_option( 'wc_stripe_show_sofort_notice', 'no' );
307
+					update_option('wc_stripe_show_sofort_notice', 'no');
308 308
 					break;
309 309
 				case 'sca':
310
-					update_option( 'wc_stripe_show_sca_notice', 'no' );
310
+					update_option('wc_stripe_show_sca_notice', 'no');
311 311
 					break;
312 312
 				case 'changed_keys':
313
-					update_option( 'wc_stripe_show_changed_keys_notice', 'no' );
313
+					update_option('wc_stripe_show_changed_keys_notice', 'no');
314 314
 			}
315 315
 		}
316 316
 	}
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
 	 * @return string Setting link
324 324
 	 */
325 325
 	public function get_setting_link() {
326
-		$use_id_as_section = function_exists( 'WC' ) ? version_compare( WC()->version, '2.6', '>=' ) : false;
326
+		$use_id_as_section = function_exists('WC') ? version_compare(WC()->version, '2.6', '>=') : false;
327 327
 
328
-		$section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' );
328
+		$section_slug = $use_id_as_section ? 'stripe' : strtolower('WC_Gateway_Stripe');
329 329
 
330
-		return admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . $section_slug );
330
+		return admin_url('admin.php?page=wc-settings&tab=checkout&section=' . $section_slug);
331 331
 	}
332 332
 
333 333
 	/**
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
 	 * @since 4.3.0
337 337
 	 */
338 338
 	public function stripe_updated() {
339
-		$previous_version = get_option( 'wc_stripe_version' );
339
+		$previous_version = get_option('wc_stripe_version');
340 340
 
341 341
 		// Only show the style notice if the plugin was installed and older than 4.1.4.
342
-		if ( empty( $previous_version ) || version_compare( $previous_version, '4.1.4', 'ge' ) ) {
343
-			update_option( 'wc_stripe_show_style_notice', 'no' );
342
+		if (empty($previous_version) || version_compare($previous_version, '4.1.4', 'ge')) {
343
+			update_option('wc_stripe_show_style_notice', 'no');
344 344
 		}
345 345
 
346 346
 		// Only show the SCA notice on pre-4.3.0 installs.
347
-		if ( empty( $previous_version ) || version_compare( $previous_version, '4.3.0', 'ge' ) ) {
348
-			update_option( 'wc_stripe_show_sca_notice', 'no' );
347
+		if (empty($previous_version) || version_compare($previous_version, '4.3.0', 'ge')) {
348
+			update_option('wc_stripe_show_sca_notice', 'no');
349 349
 		}
350 350
 	}
351 351
 }
Please login to merge, or discard this patch.
includes/admin/stripe-settings.php 1 patch
Spacing   +56 added lines, -56 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,160 +7,160 @@  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'        => 'text',
47
-			'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_test_" will be saved.', 'woocommerce-gateway-stripe' ),
47
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_test_" will be saved.', '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. Invalid values will be rejected. Only values starting with "sk_test_" or "rk_test_" will be saved.', 'woocommerce-gateway-stripe' ),
54
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_test_" or "rk_test_" will be saved.', 'woocommerce-gateway-stripe'),
55 55
 			'default'     => '',
56 56
 			'desc_tip'    => true,
57 57
 		),
58 58
 		'test_webhook_secret'           => array(
59
-			'title'       => __( 'Test Webhook Secret', 'woocommerce-gateway-stripe' ),
59
+			'title'       => __('Test Webhook Secret', 'woocommerce-gateway-stripe'),
60 60
 			'type'        => 'password',
61
-			'description' => __( 'Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe' ),
61
+			'description' => __('Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe'),
62 62
 			'default'     => '',
63 63
 			'desc_tip'    => true,
64 64
 		),
65 65
 		'publishable_key'               => array(
66
-			'title'       => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ),
66
+			'title'       => __('Live Publishable Key', 'woocommerce-gateway-stripe'),
67 67
 			'type'        => 'text',
68
-			'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_live_" will be saved.', 'woocommerce-gateway-stripe' ),
68
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_live_" will be saved.', 'woocommerce-gateway-stripe'),
69 69
 			'default'     => '',
70 70
 			'desc_tip'    => true,
71 71
 		),
72 72
 		'secret_key'                    => array(
73
-			'title'       => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ),
73
+			'title'       => __('Live Secret Key', 'woocommerce-gateway-stripe'),
74 74
 			'type'        => 'password',
75
-			'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_live_" or "rk_live_" will be saved.', 'woocommerce-gateway-stripe' ),
75
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_live_" or "rk_live_" will be saved.', 'woocommerce-gateway-stripe'),
76 76
 			'default'     => '',
77 77
 			'desc_tip'    => true,
78 78
 		),
79 79
 		'webhook_secret'               => array(
80
-			'title'       => __( 'Webhook Secret', 'woocommerce-gateway-stripe' ),
80
+			'title'       => __('Webhook Secret', 'woocommerce-gateway-stripe'),
81 81
 			'type'        => 'password',
82
-			'description' => __( 'Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe' ),
82
+			'description' => __('Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe'),
83 83
 			'default'     => '',
84 84
 			'desc_tip'    => true,
85 85
 		),
86 86
 		'inline_cc_form'                => array(
87
-			'title'       => __( 'Inline Credit Card Form', 'woocommerce-gateway-stripe' ),
87
+			'title'       => __('Inline Credit Card Form', 'woocommerce-gateway-stripe'),
88 88
 			'type'        => 'checkbox',
89
-			'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' ),
89
+			'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'),
90 90
 			'default'     => 'no',
91 91
 			'desc_tip'    => true,
92 92
 		),
93 93
 		'statement_descriptor'          => array(
94
-			'title'       => __( 'Statement Descriptor', 'woocommerce-gateway-stripe' ),
94
+			'title'       => __('Statement Descriptor', 'woocommerce-gateway-stripe'),
95 95
 			'type'        => 'text',
96
-			'description' => __( 'Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe' ),
96
+			'description' => __('Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe'),
97 97
 			'default'     => '',
98 98
 			'desc_tip'    => true,
99 99
 		),
100 100
 		'capture'                       => array(
101
-			'title'       => __( 'Capture', 'woocommerce-gateway-stripe' ),
102
-			'label'       => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ),
101
+			'title'       => __('Capture', 'woocommerce-gateway-stripe'),
102
+			'label'       => __('Capture charge immediately', 'woocommerce-gateway-stripe'),
103 103
 			'type'        => 'checkbox',
104
-			'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' ),
104
+			'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'),
105 105
 			'default'     => 'yes',
106 106
 			'desc_tip'    => true,
107 107
 		),
108 108
 		'payment_request'               => array(
109
-			'title'       => __( 'Payment Request Buttons', 'woocommerce-gateway-stripe' ),
109
+			'title'       => __('Payment Request Buttons', 'woocommerce-gateway-stripe'),
110 110
 			/* translators: 1) br tag 2) opening anchor tag 3) closing anchor tag */
111
-			'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>' ),
111
+			'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>'),
112 112
 			'type'        => 'checkbox',
113
-			'description' => __( 'If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe' ),
113
+			'description' => __('If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe'),
114 114
 			'default'     => 'yes',
115 115
 			'desc_tip'    => true,
116 116
 		),
117 117
 		'payment_request_button_type'   => array(
118
-			'title'       => __( 'Payment Request Button Type', 'woocommerce-gateway-stripe' ),
119
-			'label'       => __( 'Button Type', 'woocommerce-gateway-stripe' ),
118
+			'title'       => __('Payment Request Button Type', 'woocommerce-gateway-stripe'),
119
+			'label'       => __('Button Type', 'woocommerce-gateway-stripe'),
120 120
 			'type'        => 'select',
121
-			'description' => __( 'Select the button type you would like to show.', 'woocommerce-gateway-stripe' ),
121
+			'description' => __('Select the button type you would like to show.', 'woocommerce-gateway-stripe'),
122 122
 			'default'     => 'buy',
123 123
 			'desc_tip'    => true,
124 124
 			'options'     => array(
125
-				'default' => __( 'Default', 'woocommerce-gateway-stripe' ),
126
-				'buy'     => __( 'Buy', 'woocommerce-gateway-stripe' ),
127
-				'donate'  => __( 'Donate', 'woocommerce-gateway-stripe' ),
125
+				'default' => __('Default', 'woocommerce-gateway-stripe'),
126
+				'buy'     => __('Buy', 'woocommerce-gateway-stripe'),
127
+				'donate'  => __('Donate', 'woocommerce-gateway-stripe'),
128 128
 			),
129 129
 		),
130 130
 		'payment_request_button_theme'  => array(
131
-			'title'       => __( 'Payment Request Button Theme', 'woocommerce-gateway-stripe' ),
132
-			'label'       => __( 'Button Theme', 'woocommerce-gateway-stripe' ),
131
+			'title'       => __('Payment Request Button Theme', 'woocommerce-gateway-stripe'),
132
+			'label'       => __('Button Theme', 'woocommerce-gateway-stripe'),
133 133
 			'type'        => 'select',
134
-			'description' => __( 'Select the button theme you would like to show.', 'woocommerce-gateway-stripe' ),
134
+			'description' => __('Select the button theme you would like to show.', 'woocommerce-gateway-stripe'),
135 135
 			'default'     => 'dark',
136 136
 			'desc_tip'    => true,
137 137
 			'options'     => array(
138
-				'dark'          => __( 'Dark', 'woocommerce-gateway-stripe' ),
139
-				'light'         => __( 'Light', 'woocommerce-gateway-stripe' ),
140
-				'light-outline' => __( 'Light-Outline', 'woocommerce-gateway-stripe' ),
138
+				'dark'          => __('Dark', 'woocommerce-gateway-stripe'),
139
+				'light'         => __('Light', 'woocommerce-gateway-stripe'),
140
+				'light-outline' => __('Light-Outline', 'woocommerce-gateway-stripe'),
141 141
 			),
142 142
 		),
143 143
 		'payment_request_button_height' => array(
144
-			'title'       => __( 'Payment Request Button Height', 'woocommerce-gateway-stripe' ),
145
-			'label'       => __( 'Button Height', 'woocommerce-gateway-stripe' ),
144
+			'title'       => __('Payment Request Button Height', 'woocommerce-gateway-stripe'),
145
+			'label'       => __('Button Height', 'woocommerce-gateway-stripe'),
146 146
 			'type'        => 'text',
147
-			'description' => __( 'Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe' ),
147
+			'description' => __('Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe'),
148 148
 			'default'     => '44',
149 149
 			'desc_tip'    => true,
150 150
 		),
151 151
 		'saved_cards'                   => array(
152
-			'title'       => __( 'Saved Cards', 'woocommerce-gateway-stripe' ),
153
-			'label'       => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ),
152
+			'title'       => __('Saved Cards', 'woocommerce-gateway-stripe'),
153
+			'label'       => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'),
154 154
 			'type'        => 'checkbox',
155
-			'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' ),
155
+			'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'),
156 156
 			'default'     => 'yes',
157 157
 			'desc_tip'    => true,
158 158
 		),
159 159
 		'logging'                       => array(
160
-			'title'       => __( 'Logging', 'woocommerce-gateway-stripe' ),
161
-			'label'       => __( 'Log debug messages', 'woocommerce-gateway-stripe' ),
160
+			'title'       => __('Logging', 'woocommerce-gateway-stripe'),
161
+			'label'       => __('Log debug messages', 'woocommerce-gateway-stripe'),
162 162
 			'type'        => 'checkbox',
163
-			'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ),
163
+			'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'),
164 164
 			'default'     => 'no',
165 165
 			'desc_tip'    => true,
166 166
 		),
Please login to merge, or discard this patch.