Completed
Push — master ( bc7ba4...ae6ee3 )
by Roy
02:07
created
includes/class-wc-gateway-stripe.php 1 patch
Spacing   +222 added lines, -222 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
 
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function __construct() {
108 108
 		$this->id                   = 'stripe';
109
-		$this->method_title         = __( 'Stripe', 'woocommerce-gateway-stripe' );
110
-		$this->method_description   = __( 'Stripe works by adding credit card fields on the checkout and then sending the details to Stripe for verification.', 'woocommerce-gateway-stripe' );
109
+		$this->method_title         = __('Stripe', 'woocommerce-gateway-stripe');
110
+		$this->method_description   = __('Stripe works by adding credit card fields on the checkout and then sending the details to Stripe for verification.', 'woocommerce-gateway-stripe');
111 111
 		$this->has_fields           = true;
112 112
 		$this->view_transaction_url = 'https://dashboard.stripe.com/payments/%s';
113 113
 		$this->supports             = array(
@@ -135,38 +135,38 @@  discard block
 block discarded – undo
135 135
 		$this->init_settings();
136 136
 
137 137
 		// Get setting values.
138
-		$this->title                  = $this->get_option( 'title' );
139
-		$this->description            = $this->get_option( 'description' );
140
-		$this->enabled                = $this->get_option( 'enabled' );
141
-		$this->testmode               = 'yes' === $this->get_option( 'testmode' );
142
-		$this->capture                = 'yes' === $this->get_option( 'capture', 'yes' );
143
-		$this->stripe_checkout        = 'yes' === $this->get_option( 'stripe_checkout' );
144
-		$this->stripe_checkout_locale = $this->get_option( 'stripe_checkout_locale' );
145
-		$this->stripe_checkout_image  = $this->get_option( 'stripe_checkout_image', '' );
146
-		$this->saved_cards            = 'yes' === $this->get_option( 'saved_cards' );
147
-		$this->secret_key             = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
148
-		$this->publishable_key        = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' );
149
-		$this->bitcoin                = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' );
150
-		$this->apple_pay              = 'yes' === $this->get_option( 'apple_pay' );
151
-		$this->apple_pay_button       = $this->get_option( 'apple_pay_button', 'black' );
152
-		$this->logging                = 'yes' === $this->get_option( 'logging' );
153
-		$this->allow_remember_me      = 'yes' === $this->get_option( 'allow_remember_me', 'no' );
154
-
155
-		if ( $this->stripe_checkout ) {
156
-			$this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' );
157
-		}
158
-
159
-		if ( $this->testmode ) {
160
-			$this->description .= ' ' . sprintf( __( 'TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the documentation "<a href="%s">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' );
161
-			$this->description  = trim( $this->description );
162
-		}
163
-
164
-		WC_Stripe_API::set_secret_key( $this->secret_key );
138
+		$this->title                  = $this->get_option('title');
139
+		$this->description            = $this->get_option('description');
140
+		$this->enabled                = $this->get_option('enabled');
141
+		$this->testmode               = 'yes' === $this->get_option('testmode');
142
+		$this->capture                = 'yes' === $this->get_option('capture', 'yes');
143
+		$this->stripe_checkout        = 'yes' === $this->get_option('stripe_checkout');
144
+		$this->stripe_checkout_locale = $this->get_option('stripe_checkout_locale');
145
+		$this->stripe_checkout_image  = $this->get_option('stripe_checkout_image', '');
146
+		$this->saved_cards            = 'yes' === $this->get_option('saved_cards');
147
+		$this->secret_key             = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
148
+		$this->publishable_key        = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key');
149
+		$this->bitcoin                = 'USD' === strtoupper(get_woocommerce_currency()) && 'yes' === $this->get_option('stripe_bitcoin');
150
+		$this->apple_pay              = 'yes' === $this->get_option('apple_pay');
151
+		$this->apple_pay_button       = $this->get_option('apple_pay_button', 'black');
152
+		$this->logging                = 'yes' === $this->get_option('logging');
153
+		$this->allow_remember_me      = 'yes' === $this->get_option('allow_remember_me', 'no');
154
+
155
+		if ($this->stripe_checkout) {
156
+			$this->order_button_text = __('Continue to payment', 'woocommerce-gateway-stripe');
157
+		}
158
+
159
+		if ($this->testmode) {
160
+			$this->description .= ' ' . sprintf(__('TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the documentation "<a href="%s">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe'), 'https://stripe.com/docs/testing');
161
+			$this->description  = trim($this->description);
162
+		}
163
+
164
+		WC_Stripe_API::set_secret_key($this->secret_key);
165 165
 
166 166
 		// Hooks.
167
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
168
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
169
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
167
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
168
+		add_action('admin_notices', array($this, 'admin_notices'));
169
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
170 170
 	}
171 171
 
172 172
 	/**
@@ -176,24 +176,24 @@  discard block
 block discarded – undo
176 176
 	 * @return string
177 177
 	 */
178 178
 	public function get_icon() {
179
-		$ext   = version_compare( WC()->version, '2.6', '>=' ) ? '.svg' : '.png';
180
-		$style = version_compare( WC()->version, '2.6', '>=' ) ? 'style="margin-left: 0.3em"' : '';
179
+		$ext   = version_compare(WC()->version, '2.6', '>=') ? '.svg' : '.png';
180
+		$style = version_compare(WC()->version, '2.6', '>=') ? 'style="margin-left: 0.3em"' : '';
181 181
 
182
-		$icon  = '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/visa' . $ext ) . '" alt="Visa" width="32" ' . $style . ' />';
183
-		$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard' . $ext ) . '" alt="Mastercard" width="32" ' . $style . ' />';
184
-		$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/amex' . $ext ) . '" alt="Amex" width="32" ' . $style . ' />';
182
+		$icon  = '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/visa' . $ext) . '" alt="Visa" width="32" ' . $style . ' />';
183
+		$icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard' . $ext) . '" alt="Mastercard" width="32" ' . $style . ' />';
184
+		$icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/amex' . $ext) . '" alt="Amex" width="32" ' . $style . ' />';
185 185
 
186
-		if ( 'USD' === get_woocommerce_currency() ) {
187
-			$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/discover' . $ext ) . '" alt="Discover" width="32" ' . $style . ' />';
188
-			$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb' . $ext ) . '" alt="JCB" width="32" ' . $style . ' />';
189
-			$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/diners' . $ext ) . '" alt="Diners" width="32" ' . $style . ' />';
186
+		if ('USD' === get_woocommerce_currency()) {
187
+			$icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/discover' . $ext) . '" alt="Discover" width="32" ' . $style . ' />';
188
+			$icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb' . $ext) . '" alt="JCB" width="32" ' . $style . ' />';
189
+			$icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/diners' . $ext) . '" alt="Diners" width="32" ' . $style . ' />';
190 190
 		}
191 191
 
192
-		if ( $this->bitcoin && $this->stripe_checkout ) {
193
-			$icon .= '<img src="' . WC_HTTPS::force_https_url( plugins_url( '/assets/images/bitcoin' . $ext, WC_STRIPE_MAIN_FILE ) ) . '" alt="Bitcoin" width="24" ' . $style . ' />';
192
+		if ($this->bitcoin && $this->stripe_checkout) {
193
+			$icon .= '<img src="' . WC_HTTPS::force_https_url(plugins_url('/assets/images/bitcoin' . $ext, WC_STRIPE_MAIN_FILE)) . '" alt="Bitcoin" width="24" ' . $style . ' />';
194 194
 		}
195 195
 
196
-		return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id );
196
+		return apply_filters('woocommerce_gateway_icon', $icon, $this->id);
197 197
 	}
198 198
 
199 199
 	/**
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return float|int
206 206
 	 */
207
-	public function get_stripe_amount( $total, $currency = '' ) {
208
-		if ( ! $currency ) {
207
+	public function get_stripe_amount($total, $currency = '') {
208
+		if ( ! $currency) {
209 209
 			$currency = get_woocommerce_currency();
210 210
 		}
211
-		switch ( strtoupper( $currency ) ) {
211
+		switch (strtoupper($currency)) {
212 212
 			// Zero decimal currencies.
213 213
 			case 'BIF' :
214 214
 			case 'CLP' :
@@ -225,10 +225,10 @@  discard block
 block discarded – undo
225 225
 			case 'XAF' :
226 226
 			case 'XOF' :
227 227
 			case 'XPF' :
228
-				$total = absint( $total );
228
+				$total = absint($total);
229 229
 				break;
230 230
 			default :
231
-				$total = round( $total, 2 ) * 100; // In cents.
231
+				$total = round($total, 2) * 100; // In cents.
232 232
 				break;
233 233
 		}
234 234
 		return $total;
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
 	 * Check if SSL is enabled and notify the user
239 239
 	 */
240 240
 	public function admin_notices() {
241
-		if ( 'no' === $this->enabled ) {
241
+		if ('no' === $this->enabled) {
242 242
 			return;
243 243
 		}
244 244
 
245 245
 		// Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected.
246
-		if ( ( function_exists( 'wc_site_is_https' ) && ! wc_site_is_https() ) && ( 'no' === get_option( 'woocommerce_force_ssl_checkout' ) && ! class_exists( 'WordPressHTTPS' ) ) ) {
247
-			echo '<div class="error stripe-ssl-message"><p>' . sprintf( __( 'Stripe is enabled, but the <a href="%s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate - Stripe will only work in test mode.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout' ) ) . '</p></div>';
246
+		if ((function_exists('wc_site_is_https') && ! wc_site_is_https()) && ('no' === get_option('woocommerce_force_ssl_checkout') && ! class_exists('WordPressHTTPS'))) {
247
+			echo '<div class="error stripe-ssl-message"><p>' . sprintf(__('Stripe is enabled, but the <a href="%s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate - Stripe will only work in test mode.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout')) . '</p></div>';
248 248
 		}
249 249
 	}
250 250
 
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
 	 * Check if this gateway is enabled
253 253
 	 */
254 254
 	public function is_available() {
255
-		if ( 'yes' === $this->enabled ) {
256
-			if ( ! $this->testmode && is_checkout() && ! is_ssl() ) {
255
+		if ('yes' === $this->enabled) {
256
+			if ( ! $this->testmode && is_checkout() && ! is_ssl()) {
257 257
 				return false;
258 258
 			}
259
-			if ( ! $this->secret_key || ! $this->publishable_key ) {
259
+			if ( ! $this->secret_key || ! $this->publishable_key) {
260 260
 				return false;
261 261
 			}
262 262
 			return true;
@@ -268,9 +268,9 @@  discard block
 block discarded – undo
268 268
 	 * Initialise Gateway Settings Form Fields
269 269
 	 */
270 270
 	public function init_form_fields() {
271
-		$this->form_fields = include( 'settings-stripe.php' );
271
+		$this->form_fields = include('settings-stripe.php');
272 272
 
273
-		wc_enqueue_js( "
273
+		wc_enqueue_js("
274 274
 			jQuery( function( $ ) {
275 275
 				$( document.body ).on( 'change', '#woocommerce_stripe_testmode', function() {
276 276
 					var test_secret_key = $( '#woocommerce_stripe_test_secret_key' ).parents( 'tr' ).eq( 0 ),
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 					var value = $( this ).val();
316 316
 
317 317
 					if ( value.indexOf( '_test_' ) >= 0 ) {
318
-						$( this ).css( 'border-color', 'red' ).after( '<span class=\"description stripe-error-description\" style=\"color:red; display:block;\">" . __( 'This is not a valid live key. Live keys start with "sk_live_" and "pk_live_".', 'woocommerce-gateway-stripe' ) . "</span>' );
318
+						$( this ).css( 'border-color', 'red' ).after( '<span class=\"description stripe-error-description\" style=\"color:red; display:block;\">" . __('This is not a valid live key. Live keys start with "sk_live_" and "pk_live_".', 'woocommerce-gateway-stripe') . "</span>' );
319 319
 					} else {
320 320
 						$( this ).css( 'border-color', '' );
321 321
 						$( '.stripe-error-description', $( this ).parent() ).remove();
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 					var value = $( this ).val();
327 327
 
328 328
 					if ( value.indexOf( '_live_' ) >= 0 ) {
329
-						$( this ).css( 'border-color', 'red' ).after( '<span class=\"description stripe-error-description\" style=\"color:red; display:block;\">" . __( 'This is not a valid test key. Test keys start with "sk_test_" and "pk_test_".', 'woocommerce-gateway-stripe' ) . "</span>' );
329
+						$( this ).css( 'border-color', 'red' ).after( '<span class=\"description stripe-error-description\" style=\"color:red; display:block;\">" . __('This is not a valid test key. Test keys start with "sk_test_" and "pk_test_".', 'woocommerce-gateway-stripe') . "</span>' );
330 330
 					} else {
331 331
 						$( this ).css( 'border-color', '' );
332 332
 						$( '.stripe-error-description', $( this ).parent() ).remove();
@@ -341,54 +341,54 @@  discard block
 block discarded – undo
341 341
 	 */
342 342
 	public function payment_fields() {
343 343
 		$user                 = wp_get_current_user();
344
-		$display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards;
344
+		$display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards;
345 345
 		$total                = WC()->cart->total;
346 346
 
347 347
 		// If paying from order, we need to get total from order not cart.
348
-		if ( isset( $_GET['pay_for_order'] ) && isset( $_GET['key'] ) ) {
349
-			$order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) );
348
+		if (isset($_GET['pay_for_order']) && isset($_GET['key'])) {
349
+			$order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key'])));
350 350
 			$total = $order->get_total();
351 351
 		}
352 352
 
353
-		if ( $user->ID ) {
354
-			$user_email = get_user_meta( $user->ID, 'billing_email', true );
353
+		if ($user->ID) {
354
+			$user_email = get_user_meta($user->ID, 'billing_email', true);
355 355
 			$user_email = $user_email ? $user_email : $user->user_email;
356 356
 		} else {
357 357
 			$user_email = '';
358 358
 		}
359 359
 
360
-		if ( is_add_payment_method_page() ) {
361
-			$pay_button_text = __( 'Add Card', 'woocommerce-gateway-stripe' );
360
+		if (is_add_payment_method_page()) {
361
+			$pay_button_text = __('Add Card', 'woocommerce-gateway-stripe');
362 362
 		} else {
363 363
 			$pay_button_text = '';
364 364
 		}
365 365
 
366 366
 		echo '<div
367 367
 			id="stripe-payment-data"
368
-			data-panel-label="' . esc_attr( $pay_button_text ) . '"
368
+			data-panel-label="' . esc_attr($pay_button_text) . '"
369 369
 			data-description=""
370
-			data-email="' . esc_attr( $user_email ) . '"
371
-			data-amount="' . esc_attr( $this->get_stripe_amount( $total ) ) . '"
372
-			data-name="' . esc_attr( get_bloginfo( 'name', 'display' ) ) . '"
373
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '"
374
-			data-image="' . esc_attr( $this->stripe_checkout_image ) . '"
375
-			data-bitcoin="' . esc_attr( $this->bitcoin ? 'true' : 'false' ) . '"
376
-			data-locale="' . esc_attr( $this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en' ) . '"
377
-			data-allow-remember-me="' . esc_attr( $this->allow_remember_me ? 'true' : 'false' ) . '">';
370
+			data-email="' . esc_attr($user_email) . '"
371
+			data-amount="' . esc_attr($this->get_stripe_amount($total)) . '"
372
+			data-name="' . esc_attr(get_bloginfo('name', 'display')) . '"
373
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '"
374
+			data-image="' . esc_attr($this->stripe_checkout_image) . '"
375
+			data-bitcoin="' . esc_attr($this->bitcoin ? 'true' : 'false') . '"
376
+			data-locale="' . esc_attr($this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en') . '"
377
+			data-allow-remember-me="' . esc_attr($this->allow_remember_me ? 'true' : 'false') . '">';
378 378
 
379
-		if ( $this->description ) {
380
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) );
379
+		if ($this->description) {
380
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description)));
381 381
 		}
382 382
 
383
-		if ( $display_tokenization ) {
383
+		if ($display_tokenization) {
384 384
 			$this->tokenization_script();
385 385
 			$this->saved_payment_methods();
386 386
 		}
387 387
 
388
-		if ( ! $this->stripe_checkout ) {
388
+		if ( ! $this->stripe_checkout) {
389 389
 			$this->form();
390 390
 
391
-			if ( $display_tokenization ) {
391
+			if ($display_tokenization) {
392 392
 				$this->save_payment_method_checkbox();
393 393
 			}
394 394
 		}
@@ -404,20 +404,20 @@  discard block
 block discarded – undo
404 404
 	 * @return array
405 405
 	 */
406 406
 	public function get_localized_messages() {
407
-		return apply_filters( 'wc_stripe_localized_messages', array(
408
-			'invalid_number'        => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ),
409
-			'invalid_expiry_month'  => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ),
410
-			'invalid_expiry_year'   => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ),
411
-			'invalid_cvc'           => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ),
412
-			'incorrect_number'      => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ),
413
-			'expired_card'          => __( 'The card has expired.', 'woocommerce-gateway-stripe' ),
414
-			'incorrect_cvc'         => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ),
415
-			'incorrect_zip'         => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ),
416
-			'card_declined'         => __( 'The card was declined.', 'woocommerce-gateway-stripe' ),
417
-			'missing'               => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ),
418
-			'processing_error'      => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ),
419
-			'invalid_request_error' => __( 'Could not find payment information.', 'woocommerce-gateway-stripe' ),
420
-			) );
407
+		return apply_filters('wc_stripe_localized_messages', array(
408
+			'invalid_number'        => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'),
409
+			'invalid_expiry_month'  => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'),
410
+			'invalid_expiry_year'   => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'),
411
+			'invalid_cvc'           => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'),
412
+			'incorrect_number'      => __('The card number is incorrect.', 'woocommerce-gateway-stripe'),
413
+			'expired_card'          => __('The card has expired.', 'woocommerce-gateway-stripe'),
414
+			'incorrect_cvc'         => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'),
415
+			'incorrect_zip'         => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'),
416
+			'card_declined'         => __('The card was declined.', 'woocommerce-gateway-stripe'),
417
+			'missing'               => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'),
418
+			'processing_error'      => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'),
419
+			'invalid_request_error' => __('Could not find payment information.', 'woocommerce-gateway-stripe'),
420
+			));
421 421
 	}
422 422
 
423 423
 	/**
@@ -428,30 +428,30 @@  discard block
 block discarded – undo
428 428
 	 * @access public
429 429
 	 */
430 430
 	public function payment_scripts() {
431
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) ) {
431
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order'])) {
432 432
 			return;
433 433
 		}
434 434
 
435
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
435
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
436 436
 
437
-		if ( $this->stripe_checkout ) {
438
-			wp_enqueue_script( 'stripe_checkout', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true );
439
-			wp_enqueue_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe_checkout' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'stripe' ), WC_STRIPE_VERSION, true );
437
+		if ($this->stripe_checkout) {
438
+			wp_enqueue_script('stripe_checkout', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true);
439
+			wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe_checkout' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('stripe'), WC_STRIPE_VERSION, true);
440 440
 		} else {
441
-			wp_enqueue_script( 'stripe', 'https://js.stripe.com/v2/', '', '1.0', true );
442
-			wp_enqueue_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripe' ), WC_STRIPE_VERSION, true );
441
+			wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', '', '1.0', true);
442
+			wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripe'), WC_STRIPE_VERSION, true);
443 443
 		}
444 444
 
445 445
 		$stripe_params = array(
446 446
 			'key'                  => $this->publishable_key,
447
-			'i18n_terms'           => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ),
448
-			'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ),
447
+			'i18n_terms'           => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'),
448
+			'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'),
449 449
 		);
450 450
 
451 451
 		// If we're on the pay page we need to pass stripe.js the address of the order.
452
-		if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) {
453
-			$order_id = wc_get_order_id_by_order_key( urldecode( $_GET['key'] ) );
454
-			$order    = wc_get_order( $order_id );
452
+		if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) {
453
+			$order_id = wc_get_order_id_by_order_key(urldecode($_GET['key']));
454
+			$order    = wc_get_order($order_id);
455 455
 
456 456
 			$stripe_params['billing_first_name'] = $order->billing_first_name;
457 457
 			$stripe_params['billing_last_name']  = $order->billing_last_name;
@@ -463,14 +463,14 @@  discard block
 block discarded – undo
463 463
 			$stripe_params['billing_country']    = $order->billing_country;
464 464
 		}
465 465
 
466
-		$stripe_params['no_prepaid_card_msg']                     = __( 'Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe' );
467
-		$stripe_params['allow_prepaid_card']                      = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no';
468
-		$stripe_params['stripe_checkout_require_billing_address'] = apply_filters( 'wc_stripe_checkout_require_billing_address', false ) ? 'yes' : 'no';
466
+		$stripe_params['no_prepaid_card_msg']                     = __('Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe');
467
+		$stripe_params['allow_prepaid_card']                      = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no';
468
+		$stripe_params['stripe_checkout_require_billing_address'] = apply_filters('wc_stripe_checkout_require_billing_address', false) ? 'yes' : 'no';
469 469
 
470 470
 		// merge localized messages to be use in JS
471
-		$stripe_params = array_merge( $stripe_params, $this->get_localized_messages() );
471
+		$stripe_params = array_merge($stripe_params, $this->get_localized_messages());
472 472
 
473
-		wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
473
+		wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
474 474
 	}
475 475
 
476 476
 	/**
@@ -479,24 +479,24 @@  discard block
 block discarded – undo
479 479
 	 * @param  object $source
480 480
 	 * @return array()
481 481
 	 */
482
-	protected function generate_payment_request( $order, $source ) {
482
+	protected function generate_payment_request($order, $source) {
483 483
 		$post_data                = array();
484
-		$post_data['currency']    = strtolower( $order->get_order_currency() ? $order->get_order_currency() : get_woocommerce_currency() );
485
-		$post_data['amount']      = $this->get_stripe_amount( $order->get_total(), $post_data['currency'] );
486
-		$post_data['description'] = sprintf( __( '%s - Order %s', 'woocommerce-gateway-stripe' ), wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $order->get_order_number() );
484
+		$post_data['currency']    = strtolower($order->get_order_currency() ? $order->get_order_currency() : get_woocommerce_currency());
485
+		$post_data['amount']      = $this->get_stripe_amount($order->get_total(), $post_data['currency']);
486
+		$post_data['description'] = sprintf(__('%s - Order %s', 'woocommerce-gateway-stripe'), wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES), $order->get_order_number());
487 487
 		$post_data['capture']     = $this->capture ? 'true' : 'false';
488 488
 
489
-		if ( ! empty( $order->billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) {
489
+		if ( ! empty($order->billing_email) && apply_filters('wc_stripe_send_stripe_receipt', false)) {
490 490
 			$post_data['receipt_email'] = $order->billing_email;
491 491
 		}
492 492
 
493
-		$post_data['expand[]']    = 'balance_transaction';
493
+		$post_data['expand[]'] = 'balance_transaction';
494 494
 
495
-		if ( $source->customer ) {
495
+		if ($source->customer) {
496 496
 			$post_data['customer'] = $source->customer;
497 497
 		}
498 498
 
499
-		if ( $source->source ) {
499
+		if ($source->source) {
500 500
 			$post_data['source'] = $source->source;
501 501
 		}
502 502
 		
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 		 * @param WC_Order $order
509 509
 		 * @param object $source
510 510
 		 */
511
-		return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order, $source );
511
+		return apply_filters('wc_stripe_generate_payment_request', $post_data, $order, $source);
512 512
 	}
513 513
 
514 514
 	/**
@@ -520,22 +520,22 @@  discard block
 block discarded – undo
520 520
 	 * @throws Exception When card was not added or for and invalid card.
521 521
 	 * @return object
522 522
 	 */
523
-	protected function get_source( $user_id, $force_customer = false ) {
524
-		$stripe_customer = new WC_Stripe_Customer( $user_id );
523
+	protected function get_source($user_id, $force_customer = false) {
524
+		$stripe_customer = new WC_Stripe_Customer($user_id);
525 525
 		$stripe_source   = false;
526 526
 		$token_id        = false;
527 527
 
528 528
 		// New CC info was entered and we have a new token to process
529
-		if ( isset( $_POST['stripe_token'] ) ) {
530
-			$stripe_token     = wc_clean( $_POST['stripe_token'] );
531
-			$maybe_saved_card = isset( $_POST['wc-stripe-new-payment-method'] ) && ! empty( $_POST['wc-stripe-new-payment-method'] );
529
+		if (isset($_POST['stripe_token'])) {
530
+			$stripe_token     = wc_clean($_POST['stripe_token']);
531
+			$maybe_saved_card = isset($_POST['wc-stripe-new-payment-method']) && ! empty($_POST['wc-stripe-new-payment-method']);
532 532
 
533 533
 			// This is true if the user wants to store the card to their account.
534
-			if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_customer ) {
535
-				$stripe_source = $stripe_customer->add_card( $stripe_token );
534
+			if (($user_id && $this->saved_cards && $maybe_saved_card) || $force_customer) {
535
+				$stripe_source = $stripe_customer->add_card($stripe_token);
536 536
 
537
-				if ( is_wp_error( $stripe_source ) ) {
538
-					throw new Exception( $stripe_source->get_error_message() );
537
+				if (is_wp_error($stripe_source)) {
538
+					throw new Exception($stripe_source->get_error_message());
539 539
 				}
540 540
 
541 541
 			} else {
@@ -546,13 +546,13 @@  discard block
 block discarded – undo
546 546
 		}
547 547
 
548 548
 		// Use an existing token, and then process the payment
549
-		elseif ( isset( $_POST['wc-stripe-payment-token'] ) && 'new' !== $_POST['wc-stripe-payment-token'] ) {
550
-			$token_id = wc_clean( $_POST['wc-stripe-payment-token'] );
551
-			$token    = WC_Payment_Tokens::get( $token_id );
549
+		elseif (isset($_POST['wc-stripe-payment-token']) && 'new' !== $_POST['wc-stripe-payment-token']) {
550
+			$token_id = wc_clean($_POST['wc-stripe-payment-token']);
551
+			$token    = WC_Payment_Tokens::get($token_id);
552 552
 
553
-			if ( ! $token || $token->get_user_id() !== get_current_user_id() ) {
554
-				WC()->session->set( 'refresh_totals', true );
555
-				throw new Exception( __( 'Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe' ) );
553
+			if ( ! $token || $token->get_user_id() !== get_current_user_id()) {
554
+				WC()->session->set('refresh_totals', true);
555
+				throw new Exception(__('Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe'));
556 556
 			}
557 557
 
558 558
 			$stripe_source = $token->get_token();
@@ -576,16 +576,16 @@  discard block
 block discarded – undo
576 576
 	 * @param object $order
577 577
 	 * @return object
578 578
 	 */
579
-	protected function get_order_source( $order = null ) {
579
+	protected function get_order_source($order = null) {
580 580
 		$stripe_customer = new WC_Stripe_Customer();
581 581
 		$stripe_source   = false;
582 582
 		$token_id        = false;
583 583
 
584
-		if ( $order ) {
585
-			if ( $meta_value = get_post_meta( $order->id, '_stripe_customer_id', true ) ) {
586
-				$stripe_customer->set_id( $meta_value );
584
+		if ($order) {
585
+			if ($meta_value = get_post_meta($order->id, '_stripe_customer_id', true)) {
586
+				$stripe_customer->set_id($meta_value);
587 587
 			}
588
-			if ( $meta_value = get_post_meta( $order->id, '_stripe_card_id', true ) ) {
588
+			if ($meta_value = get_post_meta($order->id, '_stripe_card_id', true)) {
589 589
 				$stripe_source = $meta_value;
590 590
 			}
591 591
 		}
@@ -608,50 +608,50 @@  discard block
 block discarded – undo
608 608
 	 *
609 609
 	 * @return array|void
610 610
 	 */
611
-	public function process_payment( $order_id, $retry = true, $force_customer = false ) {
611
+	public function process_payment($order_id, $retry = true, $force_customer = false) {
612 612
 		try {
613
-			$order  = wc_get_order( $order_id );
614
-			$source = $this->get_source( get_current_user_id(), $force_customer );
613
+			$order  = wc_get_order($order_id);
614
+			$source = $this->get_source(get_current_user_id(), $force_customer);
615 615
 
616
-			if ( empty( $source->source ) && empty( $source->customer ) ) {
617
-				$error_msg = __( 'Please enter your card details to make a payment.', 'woocommerce-gateway-stripe' );
618
-				$error_msg .= ' ' . __( 'Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce-gateway-stripe' );
619
-				throw new Exception( $error_msg );
616
+			if (empty($source->source) && empty($source->customer)) {
617
+				$error_msg = __('Please enter your card details to make a payment.', 'woocommerce-gateway-stripe');
618
+				$error_msg .= ' ' . __('Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce-gateway-stripe');
619
+				throw new Exception($error_msg);
620 620
 			}
621 621
 
622 622
 			// Store source to order meta.
623
-			$this->save_source( $order, $source );
623
+			$this->save_source($order, $source);
624 624
 
625 625
 			// Handle payment.
626
-			if ( $order->get_total() > 0 ) {
626
+			if ($order->get_total() > 0) {
627 627
 
628
-				if ( $order->get_total() * 100 < WC_Stripe::get_minimum_amount() ) {
629
-					throw new Exception( sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe::get_minimum_amount() / 100 ) ) );
628
+				if ($order->get_total() * 100 < WC_Stripe::get_minimum_amount()) {
629
+					throw new Exception(sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe::get_minimum_amount() / 100)));
630 630
 				}
631 631
 
632
-				WC_Stripe::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
632
+				WC_Stripe::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}");
633 633
 
634 634
 				// Make the request.
635
-				$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source ) );
635
+				$response = WC_Stripe_API::request($this->generate_payment_request($order, $source));
636 636
 
637
-				if ( is_wp_error( $response ) ) {
637
+				if (is_wp_error($response)) {
638 638
 					// Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without.
639
-					if ( 'customer' === $response->get_error_code() && $retry ) {
640
-						delete_user_meta( get_current_user_id(), '_stripe_customer_id' );
641
-						return $this->process_payment( $order_id, false, $force_customer );
639
+					if ('customer' === $response->get_error_code() && $retry) {
640
+						delete_user_meta(get_current_user_id(), '_stripe_customer_id');
641
+						return $this->process_payment($order_id, false, $force_customer);
642 642
 						// Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message.
643
-					} elseif ( 'source' === $response->get_error_code() && $source->token_id ) {
644
-						$token = WC_Payment_Tokens::get( $source->token_id );
643
+					} elseif ('source' === $response->get_error_code() && $source->token_id) {
644
+						$token = WC_Payment_Tokens::get($source->token_id);
645 645
 						$token->delete();
646
-						throw new Exception( __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' ) );
646
+						throw new Exception(__('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe'));
647 647
 					}
648 648
 					$localized_messages = $this->get_localized_messages();
649 649
 
650
-					throw new Exception( ( isset( $localized_messages[ $response->get_error_code() ] ) ? $localized_messages[ $response->get_error_code() ] : $response->get_error_message() ) );
650
+					throw new Exception((isset($localized_messages[$response->get_error_code()]) ? $localized_messages[$response->get_error_code()] : $response->get_error_message()));
651 651
 				}
652 652
 
653 653
 				// Process valid response.
654
-				$this->process_response( $response, $order );
654
+				$this->process_response($response, $order);
655 655
 			} else {
656 656
 				$order->payment_complete();
657 657
 			}
@@ -659,23 +659,23 @@  discard block
 block discarded – undo
659 659
 			// Remove cart.
660 660
 			WC()->cart->empty_cart();
661 661
 
662
-			do_action( 'wc_gateway_stripe_process_payment', $response, $order );
662
+			do_action('wc_gateway_stripe_process_payment', $response, $order);
663 663
 
664 664
 			// Return thank you page redirect.
665 665
 			return array(
666 666
 				'result'   => 'success',
667
-				'redirect' => $this->get_return_url( $order )
667
+				'redirect' => $this->get_return_url($order)
668 668
 			);
669 669
 
670
-		} catch ( Exception $e ) {
671
-			wc_add_notice( $e->getMessage(), 'error' );
672
-			WC_Stripe::log( sprintf( __( 'Error: %s', 'woocommerce-gateway-stripe' ), $e->getMessage() ) );
670
+		} catch (Exception $e) {
671
+			wc_add_notice($e->getMessage(), 'error');
672
+			WC_Stripe::log(sprintf(__('Error: %s', 'woocommerce-gateway-stripe'), $e->getMessage()));
673 673
 
674
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
675
-				$this->send_failed_order_email( $order_id );
674
+			if ($order->has_status(array('pending', 'failed'))) {
675
+				$this->send_failed_order_email($order_id);
676 676
 			}
677 677
 
678
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
678
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
679 679
 
680 680
 			return array(
681 681
 				'result'   => 'fail',
@@ -690,52 +690,52 @@  discard block
 block discarded – undo
690 690
 	 * @param WC_Order $order For to which the source applies.
691 691
 	 * @param stdClass $source Source information.
692 692
 	 */
693
-	protected function save_source( $order, $source ) {
693
+	protected function save_source($order, $source) {
694 694
 		// Store source in the order.
695
-		if ( $source->customer ) {
696
-			update_post_meta( $order->id, '_stripe_customer_id', $source->customer );
695
+		if ($source->customer) {
696
+			update_post_meta($order->id, '_stripe_customer_id', $source->customer);
697 697
 		}
698
-		if ( $source->source ) {
699
-			update_post_meta( $order->id, '_stripe_card_id', $source->source );
698
+		if ($source->source) {
699
+			update_post_meta($order->id, '_stripe_card_id', $source->source);
700 700
 		}
701 701
 	}
702 702
 
703 703
 	/**
704 704
 	 * Store extra meta data for an order from a Stripe Response.
705 705
 	 */
706
-	public function process_response( $response, $order ) {
707
-		WC_Stripe::log( "Processing response: " . print_r( $response, true ) );
706
+	public function process_response($response, $order) {
707
+		WC_Stripe::log("Processing response: " . print_r($response, true));
708 708
 
709 709
 		// Store charge data
710
-		update_post_meta( $order->id, '_stripe_charge_id', $response->id );
711
-		update_post_meta( $order->id, '_stripe_charge_captured', $response->captured ? 'yes' : 'no' );
710
+		update_post_meta($order->id, '_stripe_charge_id', $response->id);
711
+		update_post_meta($order->id, '_stripe_charge_captured', $response->captured ? 'yes' : 'no');
712 712
 
713 713
 		// Store other data such as fees
714
-		if ( isset( $response->balance_transaction ) && isset( $response->balance_transaction->fee ) ) {
714
+		if (isset($response->balance_transaction) && isset($response->balance_transaction->fee)) {
715 715
 			// Fees and Net needs to both come from Stripe to be accurate as the returned
716 716
 			// values are in the local currency of the Stripe account, not from WC.
717
-			$fee = ! empty( $response->balance_transaction->fee ) ? number_format( $response->balance_transaction->fee / 100, 2, '.', '' ) : 0;
718
-			$net = ! empty( $response->balance_transaction->net ) ? number_format( $response->balance_transaction->net / 100, 2, '.', '' ) : 0;
719
-			update_post_meta( $order->id, 'Stripe Fee', $fee );
720
-			update_post_meta( $order->id, 'Net Revenue From Stripe', $net );
717
+			$fee = ! empty($response->balance_transaction->fee) ? number_format($response->balance_transaction->fee / 100, 2, '.', '') : 0;
718
+			$net = ! empty($response->balance_transaction->net) ? number_format($response->balance_transaction->net / 100, 2, '.', '') : 0;
719
+			update_post_meta($order->id, 'Stripe Fee', $fee);
720
+			update_post_meta($order->id, 'Net Revenue From Stripe', $net);
721 721
 		}
722 722
 
723
-		if ( $response->captured ) {
724
-			$order->payment_complete( $response->id );
723
+		if ($response->captured) {
724
+			$order->payment_complete($response->id);
725 725
 
726
-			$message = sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $response->id );
727
-			$order->add_order_note( $message );
728
-			WC_Stripe::log( 'Success: ' . $message );
726
+			$message = sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $response->id);
727
+			$order->add_order_note($message);
728
+			WC_Stripe::log('Success: ' . $message);
729 729
 
730 730
 		} else {
731
-			add_post_meta( $order->id, '_transaction_id', $response->id, true );
731
+			add_post_meta($order->id, '_transaction_id', $response->id, true);
732 732
 
733
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
733
+			if ($order->has_status(array('pending', 'failed'))) {
734 734
 				$order->reduce_order_stock();
735 735
 			}
736 736
 
737
-			$order->update_status( 'on-hold', sprintf( __( 'Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe' ), $response->id ) );
738
-			WC_Stripe::log( "Successful auth: $response->id" );
737
+			$order->update_status('on-hold', sprintf(__('Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe'), $response->id));
738
+			WC_Stripe::log("Successful auth: $response->id");
739 739
 		}
740 740
 
741 741
 		return $response;
@@ -747,32 +747,32 @@  discard block
 block discarded – undo
747 747
 	 * @since 3.0.0
748 748
 	 */
749 749
 	public function add_payment_method() {
750
-		if ( empty( $_POST['stripe_token'] ) || ! is_user_logged_in() ) {
751
-			wc_add_notice( __( 'There was a problem adding the card.', 'woocommerce-gateway-stripe' ), 'error' );
750
+		if (empty($_POST['stripe_token']) || ! is_user_logged_in()) {
751
+			wc_add_notice(__('There was a problem adding the card.', 'woocommerce-gateway-stripe'), 'error');
752 752
 			return;
753 753
 		}
754 754
 
755
-		$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
756
-		$card            = $stripe_customer->add_card( wc_clean( $_POST['stripe_token'] ) );
755
+		$stripe_customer = new WC_Stripe_Customer(get_current_user_id());
756
+		$card            = $stripe_customer->add_card(wc_clean($_POST['stripe_token']));
757 757
 
758
-		if ( is_wp_error( $card ) ) {
758
+		if (is_wp_error($card)) {
759 759
 			$localized_messages = $this->get_localized_messages();
760
-			$error_msg = __( 'There was a problem adding the card.', 'woocommerce-gateway-stripe' );
760
+			$error_msg = __('There was a problem adding the card.', 'woocommerce-gateway-stripe');
761 761
 
762 762
 			// loop through the errors to find matching localized message
763
-			foreach ( $card->errors as $error => $msg ) {
764
-				if ( isset( $localized_messages[ $error ] ) ) {
765
-					$error_msg = $localized_messages[ $error ];
763
+			foreach ($card->errors as $error => $msg) {
764
+				if (isset($localized_messages[$error])) {
765
+					$error_msg = $localized_messages[$error];
766 766
 				}
767 767
 			}
768 768
 
769
-			wc_add_notice( $error_msg, 'error' );
769
+			wc_add_notice($error_msg, 'error');
770 770
 			return;
771 771
 		}
772 772
 
773 773
 		return array(
774 774
 			'result'   => 'success',
775
-			'redirect' => wc_get_endpoint_url( 'payment-methods' ),
775
+			'redirect' => wc_get_endpoint_url('payment-methods'),
776 776
 		);
777 777
 	}
778 778
 
@@ -782,36 +782,36 @@  discard block
 block discarded – undo
782 782
 	 * @param  float $amount
783 783
 	 * @return bool
784 784
 	 */
785
-	public function process_refund( $order_id, $amount = null, $reason = '' ) {
786
-		$order = wc_get_order( $order_id );
785
+	public function process_refund($order_id, $amount = null, $reason = '') {
786
+		$order = wc_get_order($order_id);
787 787
 
788
-		if ( ! $order || ! $order->get_transaction_id() ) {
788
+		if ( ! $order || ! $order->get_transaction_id()) {
789 789
 			return false;
790 790
 		}
791 791
 
792 792
 		$body = array();
793 793
 
794
-		if ( ! is_null( $amount ) ) {
795
-			$body['amount']	= $this->get_stripe_amount( $amount );
794
+		if ( ! is_null($amount)) {
795
+			$body['amount'] = $this->get_stripe_amount($amount);
796 796
 		}
797 797
 
798
-		if ( $reason ) {
798
+		if ($reason) {
799 799
 			$body['metadata'] = array(
800 800
 				'reason'	=> $reason,
801 801
 			);
802 802
 		}
803 803
 
804
-		WC_Stripe::log( "Info: Beginning refund for order $order_id for the amount of {$amount}" );
804
+		WC_Stripe::log("Info: Beginning refund for order $order_id for the amount of {$amount}");
805 805
 
806
-		$response = WC_Stripe_API::request( $body, 'charges/' . $order->get_transaction_id() . '/refunds' );
806
+		$response = WC_Stripe_API::request($body, 'charges/' . $order->get_transaction_id() . '/refunds');
807 807
 
808
-		if ( is_wp_error( $response ) ) {
809
-			WC_Stripe::log( "Error: " . $response->get_error_message() );
808
+		if (is_wp_error($response)) {
809
+			WC_Stripe::log("Error: " . $response->get_error_message());
810 810
 			return $response;
811
-		} elseif ( ! empty( $response->id ) ) {
812
-			$refund_message = sprintf( __( 'Refunded %s - Refund ID: %s - Reason: %s', 'woocommerce-gateway-stripe' ), wc_price( $response->amount / 100 ), $response->id, $reason );
813
-			$order->add_order_note( $refund_message );
814
-			WC_Stripe::log( "Success: " . html_entity_decode( strip_tags( $refund_message ) ) );
811
+		} elseif ( ! empty($response->id)) {
812
+			$refund_message = sprintf(__('Refunded %s - Refund ID: %s - Reason: %s', 'woocommerce-gateway-stripe'), wc_price($response->amount / 100), $response->id, $reason);
813
+			$order->add_order_note($refund_message);
814
+			WC_Stripe::log("Success: " . html_entity_decode(strip_tags($refund_message)));
815 815
 			return true;
816 816
 		}
817 817
 	}
@@ -824,10 +824,10 @@  discard block
 block discarded – undo
824 824
 	 * @param int $order_id
825 825
 	 * @return null
826 826
 	 */
827
-	public function send_failed_order_email( $order_id ) {
827
+	public function send_failed_order_email($order_id) {
828 828
 		$emails = WC()->mailer()->get_emails();
829
-		if ( ! empty( $emails ) && ! empty( $order_id ) ) {
830
-			$emails['WC_Email_Failed_Order']->trigger( $order_id );
829
+		if ( ! empty($emails) && ! empty($order_id)) {
830
+			$emails['WC_Email_Failed_Order']->trigger($order_id);
831 831
 		}
832 832
 	}
833 833
 }
Please login to merge, or discard this patch.
includes/class-wc-stripe-apple-pay.php 1 patch
Spacing   +125 added lines, -125 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
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	public function __construct() {
41 41
 		self::$_this = $this;
42 42
 
43
-		$this->_gateway_settings = get_option( 'woocommerce_stripe_settings', '' );
43
+		$this->_gateway_settings = get_option('woocommerce_stripe_settings', '');
44 44
 
45 45
 		$this->init();
46 46
 	}
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
 	 * @version 3.1.0
58 58
 	 */
59 59
 	public function init() {
60
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
61
-		add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_apple_pay_button' ), 20 );
62
-		add_action( 'woocommerce_review_order_before_payment', array( $this, 'display_apple_pay_button' ) );
60
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
61
+		add_action('woocommerce_proceed_to_checkout', array($this, 'display_apple_pay_button'), 20);
62
+		add_action('woocommerce_review_order_before_payment', array($this, 'display_apple_pay_button'));
63 63
 		
64
-		if ( is_admin() ) {
65
-			add_action( 'wp_ajax_wc_stripe_apple_pay', array( $this, 'process_apple_pay' ) );
66
-			add_action( 'wp_ajax_nopriv_wc_stripe_apple_pay', array( $this, 'process_apple_pay' ) );
67
-			add_action( 'wp_ajax_wc_stripe_generate_apple_pay_cart', array( $this, 'generate_apple_pay_cart' ) );
68
-			add_action( 'wp_ajax_nopriv_wc_stripe_generate_apple_pay_cart', array( $this, 'generate_apple_pay_cart' ) );
64
+		if (is_admin()) {
65
+			add_action('wp_ajax_wc_stripe_apple_pay', array($this, 'process_apple_pay'));
66
+			add_action('wp_ajax_nopriv_wc_stripe_apple_pay', array($this, 'process_apple_pay'));
67
+			add_action('wp_ajax_wc_stripe_generate_apple_pay_cart', array($this, 'generate_apple_pay_cart'));
68
+			add_action('wp_ajax_nopriv_wc_stripe_generate_apple_pay_cart', array($this, 'generate_apple_pay_cart'));
69 69
 		}
70 70
 	}
71 71
 
@@ -76,38 +76,38 @@  discard block
 block discarded – undo
76 76
 	 * @version 3.1.0
77 77
 	 */
78 78
 	public function payment_scripts() {
79
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) ) {
79
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order'])) {
80 80
 			return;
81 81
 		}
82 82
 
83
-		if ( ! $this->is_supported_product_type() ) {
83
+		if ( ! $this->is_supported_product_type()) {
84 84
 			return;
85 85
 		}
86 86
 		
87
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
87
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
88 88
 		
89
-		wp_enqueue_style( 'stripe_apple_pay', plugins_url( 'assets/css/stripe-apple-pay.css', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION );
89
+		wp_enqueue_style('stripe_apple_pay', plugins_url('assets/css/stripe-apple-pay.css', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION);
90 90
 
91
-		wp_enqueue_script( 'stripe', 'https://js.stripe.com/v2/', '', '1.0', true );
92
-		wp_enqueue_script( 'woocommerce_stripe_apple_pay', plugins_url( 'assets/js/stripe-apple-pay' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'stripe' ), WC_STRIPE_VERSION, true );
91
+		wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', '', '1.0', true);
92
+		wp_enqueue_script('woocommerce_stripe_apple_pay', plugins_url('assets/js/stripe-apple-pay' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('stripe'), WC_STRIPE_VERSION, true);
93 93
 
94 94
 		$publishable_key = 'yes' === $this->_gateway_settings['testmode'] ? $this->_gateway_settings['test_publishable_key'] : $this->_gateway_settings['publishable_key'];
95 95
 
96 96
 		$stripe_params = array(
97 97
 			'key'                         => $publishable_key,
98 98
 			'currency_code'               => get_woocommerce_currency(),
99
-			'country_code'                => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
100
-			'label'                       => get_bloginfo( 'name', 'display' ),
101
-			'ajaxurl'                     => admin_url( 'admin-ajax.php' ),
102
-			'stripe_apple_pay_nonce'      => wp_create_nonce( '_wc_stripe_apple_pay_nonce' ),
103
-			'stripe_apple_pay_cart_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_cart_nonce' ),
99
+			'country_code'                => substr(get_option('woocommerce_default_country'), 0, 2),
100
+			'label'                       => get_bloginfo('name', 'display'),
101
+			'ajaxurl'                     => admin_url('admin-ajax.php'),
102
+			'stripe_apple_pay_nonce'      => wp_create_nonce('_wc_stripe_apple_pay_nonce'),
103
+			'stripe_apple_pay_cart_nonce' => wp_create_nonce('_wc_stripe_apple_pay_cart_nonce'),
104 104
 			'needs_shipping'              => WC()->cart->needs_shipping() ? 'yes' : 'no',
105
-			'needs_shipping_msg'          => __( 'Please first calculate your shipping.', 'woocommerce-gateway-stripe' ),
105
+			'needs_shipping_msg'          => __('Please first calculate your shipping.', 'woocommerce-gateway-stripe'),
106 106
 			'is_cart_page'                => is_cart() ? 'yes' : 'no',
107 107
 			'chosen_shipping'             => wc_get_chosen_shipping_method_ids(),
108 108
 		);
109 109
 
110
-		wp_localize_script( 'woocommerce_stripe_apple_pay', 'wc_stripe_apple_pay_params', apply_filters( 'wc_stripe_apple_pay_params', $stripe_params ) );
110
+		wp_localize_script('woocommerce_stripe_apple_pay', 'wc_stripe_apple_pay_params', apply_filters('wc_stripe_apple_pay_params', $stripe_params));
111 111
 	}
112 112
 		
113 113
 	/**
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 */
117 117
 	public function is_supported_product_type() {
118
-		foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
119
-			if ( 'subscription' === $values['data']->product_type ) {
118
+		foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
119
+			if ('subscription' === $values['data']->product_type) {
120 120
 				return false;
121 121
 			}
122 122
 		}
@@ -139,19 +139,19 @@  discard block
 block discarded – undo
139 139
 		 */
140 140
 		if ( 
141 141
 			'yes' !== $this->_gateway_settings['apple_pay']
142
-			|| ! isset( $gateways['stripe'] ) 
142
+			|| ! isset($gateways['stripe']) 
143 143
 		) {
144 144
 			return;
145 145
 		}
146 146
 
147
-		if ( ! $this->is_supported_product_type() ) {
147
+		if ( ! $this->is_supported_product_type()) {
148 148
 			return;
149 149
 		}
150 150
 
151
-		$apple_pay_button = ! empty( $this->_gateway_settings['apple_pay_button'] ) ? $this->_gateway_settings['apple_pay_button'] : 'black';
152
-		$country = strtolower( substr( get_option( 'woocommerce_default_country' ), 0, 2 ) );
151
+		$apple_pay_button = ! empty($this->_gateway_settings['apple_pay_button']) ? $this->_gateway_settings['apple_pay_button'] : 'black';
152
+		$country = strtolower(substr(get_option('woocommerce_default_country'), 0, 2));
153 153
 		?>
154
-		<button class="apple-pay-button" lang="<?php echo esc_attr( $country ); ?>" style="-webkit-appearance: -apple-pay-button; -apple-pay-button-type: buy; -apple-pay-button-style: <?php echo esc_attr( $apple_pay_button ); ?>;"></button>
154
+		<button class="apple-pay-button" lang="<?php echo esc_attr($country); ?>" style="-webkit-appearance: -apple-pay-button; -apple-pay-button-type: buy; -apple-pay-button-style: <?php echo esc_attr($apple_pay_button); ?>;"></button>
155 155
 		<?php
156 156
 	}
157 157
 
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
 	 * @version 3.1.0
163 163
 	 */
164 164
 	public function generate_apple_pay_cart() {
165
-		if ( ! defined( 'DOING_AJAX' ) ) {
166
-			define( 'DOING_AJAX', true );
165
+		if ( ! defined('DOING_AJAX')) {
166
+			define('DOING_AJAX', true);
167 167
 		}
168 168
 
169
-		if ( ! wp_verify_nonce( $_POST['nonce'], '_wc_stripe_apple_pay_cart_nonce' ) ) {
170
-			wp_die( __( 'Cheatin&#8217; huh?', 'woocommerce-gateway-stripe' ) );
169
+		if ( ! wp_verify_nonce($_POST['nonce'], '_wc_stripe_apple_pay_cart_nonce')) {
170
+			wp_die(__('Cheatin&#8217; huh?', 'woocommerce-gateway-stripe'));
171 171
 		}
172 172
 
173
-		wp_send_json( array( 'line_items' => $this->build_line_items(), 'total' => WC()->cart->total, 'chosen_shipping' => wc_get_chosen_shipping_method_ids() ) );
173
+		wp_send_json(array('line_items' => $this->build_line_items(), 'total' => WC()->cart->total, 'chosen_shipping' => wc_get_chosen_shipping_method_ids()));
174 174
 	}
175 175
 
176 176
 	/**
@@ -181,39 +181,39 @@  discard block
 block discarded – undo
181 181
 	 * @version 3.1.0
182 182
 	 */
183 183
 	public function process_apple_pay() {
184
-		if ( ! defined( 'DOING_AJAX' ) ) {
185
-			define( 'DOING_AJAX', true );
184
+		if ( ! defined('DOING_AJAX')) {
185
+			define('DOING_AJAX', true);
186 186
 		}
187 187
 
188
-		if ( ! wp_verify_nonce( $_POST['nonce'], '_wc_stripe_apple_pay_nonce' ) ) {
189
-			wp_die( __( 'Cheatin&#8217; huh?', 'woocommerce-gateway-stripe' ) );
188
+		if ( ! wp_verify_nonce($_POST['nonce'], '_wc_stripe_apple_pay_nonce')) {
189
+			wp_die(__('Cheatin&#8217; huh?', 'woocommerce-gateway-stripe'));
190 190
 		}
191 191
 
192 192
 		try {
193
-			$result = array_map( 'wc_clean', $_POST['result'] );
193
+			$result = array_map('wc_clean', $_POST['result']);
194 194
 
195
-			$order = $this->create_order( $result );
195
+			$order = $this->create_order($result);
196 196
 
197 197
 			// Handle payment.
198
-			if ( $order->get_total() > 0 ) {
198
+			if ($order->get_total() > 0) {
199 199
 
200
-				if ( $order->get_total() * 100 < WC_Stripe::get_minimum_amount() ) {
201
-					return new WP_Error( 'stripe_error', sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe::get_minimum_amount() / 100 ) ) );
200
+				if ($order->get_total() * 100 < WC_Stripe::get_minimum_amount()) {
201
+					return new WP_Error('stripe_error', sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe::get_minimum_amount() / 100)));
202 202
 				}
203 203
 
204
-				WC_Stripe::log( "Info: Begin processing payment for order $order->id for the amount of {$order->get_total()}" );
204
+				WC_Stripe::log("Info: Begin processing payment for order $order->id for the amount of {$order->get_total()}");
205 205
 
206 206
 				// Make the request.
207
-				$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $result['token']['id'] ) );
207
+				$response = WC_Stripe_API::request($this->generate_payment_request($order, $result['token']['id']));
208 208
 
209
-				if ( is_wp_error( $response ) ) {
209
+				if (is_wp_error($response)) {
210 210
 					$localized_messages = $this->get_localized_messages();
211 211
 
212
-					throw new Exception( ( isset( $localized_messages[ $response->get_error_code() ] ) ? $localized_messages[ $response->get_error_code() ] : $response->get_error_message() ) );
212
+					throw new Exception((isset($localized_messages[$response->get_error_code()]) ? $localized_messages[$response->get_error_code()] : $response->get_error_message()));
213 213
 				}
214 214
 
215 215
 				// Process valid response.
216
-				$this->process_response( $response, $order );
216
+				$this->process_response($response, $order);
217 217
 			} else {
218 218
 				$order->payment_complete();
219 219
 			}
@@ -221,23 +221,23 @@  discard block
 block discarded – undo
221 221
 			// Remove cart.
222 222
 			WC()->cart->empty_cart();
223 223
 
224
-			update_post_meta( $order->id, '_customer_user', get_current_user_id() );
224
+			update_post_meta($order->id, '_customer_user', get_current_user_id());
225 225
 
226 226
 			// Return thank you page redirect.
227
-			wp_send_json( array(
227
+			wp_send_json(array(
228 228
 				'success'  => 'true',
229
-				'redirect' => $this->get_return_url( $order ),
230
-			) );
229
+				'redirect' => $this->get_return_url($order),
230
+			));
231 231
 
232
-		} catch ( Exception $e ) {
233
-			WC()->session->set( 'refresh_totals', true );
234
-			WC_Stripe::log( sprintf( __( 'Error: %s', 'woocommerce-gateway-stripe' ), $e->getMessage() ) );
232
+		} catch (Exception $e) {
233
+			WC()->session->set('refresh_totals', true);
234
+			WC_Stripe::log(sprintf(__('Error: %s', 'woocommerce-gateway-stripe'), $e->getMessage()));
235 235
 
236
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
237
-				$this->send_failed_order_email( $order->id );
236
+			if ($order->has_status(array('pending', 'failed'))) {
237
+				$this->send_failed_order_email($order->id);
238 238
 			}
239 239
 
240
-			wp_send_json( array( 'success' => 'false', 'msg' => $e->getMessage() ) );
240
+			wp_send_json(array('success' => 'false', 'msg' => $e->getMessage()));
241 241
 		}
242 242
 	}
243 243
 
@@ -247,14 +247,14 @@  discard block
 block discarded – undo
247 247
 	 * @param string $source token
248 248
 	 * @return array()
249 249
 	 */
250
-	protected function generate_payment_request( $order, $source ) {
250
+	protected function generate_payment_request($order, $source) {
251 251
 		$post_data                = array();
252
-		$post_data['currency']    = strtolower( $order->get_order_currency() ? $order->get_order_currency() : get_woocommerce_currency() );
253
-		$post_data['amount']      = $this->get_stripe_amount( $order->get_total(), $post_data['currency'] );
254
-		$post_data['description'] = sprintf( __( '%s - Order %s', 'woocommerce-gateway-stripe' ), wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $order->get_order_number() );
252
+		$post_data['currency']    = strtolower($order->get_order_currency() ? $order->get_order_currency() : get_woocommerce_currency());
253
+		$post_data['amount']      = $this->get_stripe_amount($order->get_total(), $post_data['currency']);
254
+		$post_data['description'] = sprintf(__('%s - Order %s', 'woocommerce-gateway-stripe'), wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES), $order->get_order_number());
255 255
 		$post_data['capture']     = 'yes' === $this->_gateway_settings['capture'] ? 'true' : 'false';
256 256
 
257
-		if ( ! empty( $order->billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) {
257
+		if ( ! empty($order->billing_email) && apply_filters('wc_stripe_send_stripe_receipt', false)) {
258 258
 			$post_data['receipt_email'] = $order->billing_email;
259 259
 		}
260 260
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		 * @param WC_Order $order
270 270
 		 * @param object $source
271 271
 		 */
272
-		return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order );
272
+		return apply_filters('wc_stripe_generate_payment_request', $post_data, $order);
273 273
 	}
274 274
 
275 275
 	/**
@@ -279,49 +279,49 @@  discard block
 block discarded – undo
279 279
 	 * @version 3.1.0
280 280
 	 */	
281 281
 	public function build_line_items() {
282
-		$decimals = apply_filters( 'wc_stripe_apple_pay_decimals', 2 );
282
+		$decimals = apply_filters('wc_stripe_apple_pay_decimals', 2);
283 283
 
284 284
 		$items = array();
285 285
 
286
-		foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
287
-			$amount         = wc_format_decimal( $values['line_subtotal'], $decimals );
286
+		foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
287
+			$amount         = wc_format_decimal($values['line_subtotal'], $decimals);
288 288
 			$quantity_label = 1 < $values['quantity'] ? ' (x' . $values['quantity'] . ')' : '';
289 289
 
290 290
 			$item = array(
291 291
 				'type'   => 'final',
292 292
 				'label'  => $values['data']->post->post_title . $quantity_label,
293
-				'amount' => wc_format_decimal( $amount, $decimals ),
293
+				'amount' => wc_format_decimal($amount, $decimals),
294 294
 			);
295 295
 
296 296
 			$items[] = $item;
297 297
 		}
298 298
 
299
-		$discounts   = wc_format_decimal( WC()->cart->get_cart_discount_total(), $decimals );
300
-		$tax         = wc_format_decimal( WC()->cart->tax_total + WC()->cart->shipping_tax_total, $decimals );
301
-		$shipping    = wc_format_decimal( WC()->cart->shipping_total, $decimals );
302
-		$item_total  = wc_format_decimal( WC()->cart->cart_contents_total, $decimals ) + $discounts;
303
-		$order_total = wc_format_decimal( $item_total + $tax + $shipping, $decimals );
299
+		$discounts   = wc_format_decimal(WC()->cart->get_cart_discount_total(), $decimals);
300
+		$tax         = wc_format_decimal(WC()->cart->tax_total + WC()->cart->shipping_tax_total, $decimals);
301
+		$shipping    = wc_format_decimal(WC()->cart->shipping_total, $decimals);
302
+		$item_total  = wc_format_decimal(WC()->cart->cart_contents_total, $decimals) + $discounts;
303
+		$order_total = wc_format_decimal($item_total + $tax + $shipping, $decimals);
304 304
 
305
-		if ( wc_tax_enabled() ) {
305
+		if (wc_tax_enabled()) {
306 306
 			$items[] = array(
307 307
 				'type'   => 'final',
308
-				'label'  => __( 'Tax', 'woocommerce-gateway-stripe' ),
308
+				'label'  => __('Tax', 'woocommerce-gateway-stripe'),
309 309
 				'amount' => $tax,
310 310
 			);
311 311
 		}
312 312
 
313
-		if ( WC()->cart->needs_shipping() ) {
313
+		if (WC()->cart->needs_shipping()) {
314 314
 			$items[] = array(
315 315
 				'type'   => 'final',
316
-				'label'  => __( 'Shipping', 'woocommerce-gateway-stripe' ),
316
+				'label'  => __('Shipping', 'woocommerce-gateway-stripe'),
317 317
 				'amount' => $shipping,
318 318
 			);
319 319
 		}
320 320
 
321
-		if ( WC()->cart->has_discount() ) {
321
+		if (WC()->cart->has_discount()) {
322 322
 			$items[] = array(
323 323
 				'type'   => 'final',
324
-				'label'  => __( 'Discount', 'woocommerce-gateway-stripe' ),
324
+				'label'  => __('Discount', 'woocommerce-gateway-stripe'),
325 325
 				'amount' => $discounts,
326 326
 			);
327 327
 		}
@@ -337,24 +337,24 @@  discard block
 block discarded – undo
337 337
 	 * @param array $data
338 338
 	 * @return object $order
339 339
 	 */
340
-	public function create_order( $data = array() ) {
341
-		if ( empty( $data ) ) {
342
-			throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 520 ) );
340
+	public function create_order($data = array()) {
341
+		if (empty($data)) {
342
+			throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 520));
343 343
 		}
344 344
 
345 345
 		$order = wc_create_order();
346 346
 
347
-		if ( is_wp_error( $order ) ) {
348
-			throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 520 ) );
349
-		} elseif ( false === $order ) {
350
-			throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 521 ) );
347
+		if (is_wp_error($order)) {
348
+			throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 520));
349
+		} elseif (false === $order) {
350
+			throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 521));
351 351
 		} else {
352 352
 			$order_id = $order->id;
353
-			do_action( 'woocommerce_new_order', $order_id );
353
+			do_action('woocommerce_new_order', $order_id);
354 354
 		}
355 355
 
356 356
 		// Store the line items to the new/resumed order
357
-		foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
357
+		foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
358 358
 			$item_id = $order->add_product(
359 359
 				$values['data'],
360 360
 				$values['quantity'],
@@ -370,47 +370,47 @@  discard block
 block discarded – undo
370 370
 				)
371 371
 			);
372 372
 
373
-			if ( ! $item_id ) {
374
-				throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 525 ) );
373
+			if ( ! $item_id) {
374
+				throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 525));
375 375
 			}
376 376
 
377 377
 			// Allow plugins to add order item meta
378
-			do_action( 'woocommerce_add_order_item_meta', $item_id, $values, $cart_item_key );
378
+			do_action('woocommerce_add_order_item_meta', $item_id, $values, $cart_item_key);
379 379
 		}
380 380
 
381 381
 		// Store fees
382
-		foreach ( WC()->cart->get_fees() as $fee_key => $fee ) {
383
-			$item_id = $order->add_fee( $fee );
382
+		foreach (WC()->cart->get_fees() as $fee_key => $fee) {
383
+			$item_id = $order->add_fee($fee);
384 384
 
385
-			if ( ! $item_id ) {
386
-				throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 526 ) );
385
+			if ( ! $item_id) {
386
+				throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 526));
387 387
 			}
388 388
 
389 389
 			// Allow plugins to add order item meta to fees
390
-			do_action( 'woocommerce_add_order_fee_meta', $order_id, $item_id, $fee, $fee_key );
390
+			do_action('woocommerce_add_order_fee_meta', $order_id, $item_id, $fee, $fee_key);
391 391
 		}
392 392
 
393 393
 		// Store tax rows
394
-		foreach ( array_keys( WC()->cart->taxes + WC()->cart->shipping_taxes ) as $tax_rate_id ) {
395
-			if ( $tax_rate_id && ! $order->add_tax( $tax_rate_id, WC()->cart->get_tax_amount( $tax_rate_id ), WC()->cart->get_shipping_tax_amount( $tax_rate_id ) ) && apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) !== $tax_rate_id ) {
396
-				throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 528 ) );
394
+		foreach (array_keys(WC()->cart->taxes + WC()->cart->shipping_taxes) as $tax_rate_id) {
395
+			if ($tax_rate_id && ! $order->add_tax($tax_rate_id, WC()->cart->get_tax_amount($tax_rate_id), WC()->cart->get_shipping_tax_amount($tax_rate_id)) && apply_filters('woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated') !== $tax_rate_id) {
396
+				throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 528));
397 397
 			}
398 398
 		}
399 399
 
400 400
 		// Store coupons
401
-		foreach ( WC()->cart->get_coupons() as $code => $coupon ) {
402
-			if ( ! $order->add_coupon( $code, WC()->cart->get_coupon_discount_amount( $code ), WC()->cart->get_coupon_discount_tax_amount( $code ) ) ) {
403
-				throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 529 ) );
401
+		foreach (WC()->cart->get_coupons() as $code => $coupon) {
402
+			if ( ! $order->add_coupon($code, WC()->cart->get_coupon_discount_amount($code), WC()->cart->get_coupon_discount_tax_amount($code))) {
403
+				throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 529));
404 404
 			}
405 405
 		}
406 406
 
407 407
 		// Billing address
408 408
 		$billing_address = array();
409
-		if ( ! empty( $data['token']['card'] ) ) {
409
+		if ( ! empty($data['token']['card'])) {
410 410
 			// Name from Stripe is a full name string.
411
-			$name                          = explode( ' ', $data['token']['card']['name'] );
412
-			$lastname                      = array_pop( $name );
413
-			$firstname                     = implode( ' ', $name );
411
+			$name                          = explode(' ', $data['token']['card']['name']);
412
+			$lastname                      = array_pop($name);
413
+			$firstname                     = implode(' ', $name);
414 414
 			$billing_address['first_name'] = $firstname;
415 415
 			$billing_address['last_name']  = $lastname;
416 416
 			$billing_address['email']      = $data['shippingContact']['emailAddress'];
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 
426 426
 		// Shipping address.
427 427
 		$shipping_address = array();
428
-		if ( WC()->cart->needs_shipping() && ! empty( $data['shippingContact'] ) ) {
428
+		if (WC()->cart->needs_shipping() && ! empty($data['shippingContact'])) {
429 429
 			$shipping_address['first_name'] = $data['shippingContact']['givenName'];
430 430
 			$shipping_address['last_name']  = $data['shippingContact']['familyName'];
431 431
 			$shipping_address['email']      = $data['shippingContact']['emailAddress'];
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 			$shipping_address['city']       = $data['shippingContact']['locality'];
437 437
 			$shipping_address['state']      = $data['shippingContact']['administrativeArea'];
438 438
 			$shipping_address['postcode']   = $data['shippingContact']['postalCode'];
439
-		} elseif ( ! empty( $data['shippingContact'] ) ) {
439
+		} elseif ( ! empty($data['shippingContact'])) {
440 440
 			$shipping_address['first_name'] = $firstname;
441 441
 			$shipping_address['last_name']  = $lastname;
442 442
 			$shipping_address['email']      = $data['shippingContact']['emailAddress'];
@@ -449,34 +449,34 @@  discard block
 block discarded – undo
449 449
 			$shipping_address['postcode']   = $data['token']['card']['address_zip'];
450 450
 		}
451 451
 
452
-		$order->set_address( $billing_address, 'billing' );
453
-		$order->set_address( $shipping_address, 'shipping' );
452
+		$order->set_address($billing_address, 'billing');
453
+		$order->set_address($shipping_address, 'shipping');
454 454
 
455
-		WC()->shipping->calculate_shipping( WC()->cart->get_shipping_packages() );
455
+		WC()->shipping->calculate_shipping(WC()->cart->get_shipping_packages());
456 456
 		
457 457
 		// Get the rate object selected by user.
458
-		foreach ( WC()->shipping->get_packages() as $package_key => $package ) {
459
-			foreach ( $package['rates'] as $key => $rate ) {
458
+		foreach (WC()->shipping->get_packages() as $package_key => $package) {
459
+			foreach ($package['rates'] as $key => $rate) {
460 460
 				// Loop through user chosen shipping methods.
461
-				foreach( WC()->session->get( 'chosen_shipping_methods' ) as $method ) {
462
-					if ( $method === $key ) {
463
-						$order->add_shipping( $rate );
461
+				foreach (WC()->session->get('chosen_shipping_methods') as $method) {
462
+					if ($method === $key) {
463
+						$order->add_shipping($rate);
464 464
 					}
465 465
 				}
466 466
 			}
467 467
 		}
468 468
 
469 469
 		$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
470
-		$order->set_payment_method( $available_gateways['stripe'] );
471
-		$order->set_total( WC()->cart->shipping_total, 'shipping' );
472
-		$order->set_total( WC()->cart->get_cart_discount_total(), 'cart_discount' );
473
-		$order->set_total( WC()->cart->get_cart_discount_tax_total(), 'cart_discount_tax' );
474
-		$order->set_total( WC()->cart->tax_total, 'tax' );
475
-		$order->set_total( WC()->cart->shipping_tax_total, 'shipping_tax' );
476
-		$order->set_total( WC()->cart->total );
470
+		$order->set_payment_method($available_gateways['stripe']);
471
+		$order->set_total(WC()->cart->shipping_total, 'shipping');
472
+		$order->set_total(WC()->cart->get_cart_discount_total(), 'cart_discount');
473
+		$order->set_total(WC()->cart->get_cart_discount_tax_total(), 'cart_discount_tax');
474
+		$order->set_total(WC()->cart->tax_total, 'tax');
475
+		$order->set_total(WC()->cart->shipping_tax_total, 'shipping_tax');
476
+		$order->set_total(WC()->cart->total);
477 477
 
478 478
 		// If we got here, the order was created without problems!
479
-		wc_transaction_query( 'commit' );
479
+		wc_transaction_query('commit');
480 480
 
481 481
 		return $order;
482 482
 	}
Please login to merge, or discard this patch.
includes/settings-stripe.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,170 +1,170 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6
-return apply_filters( 'wc_stripe_settings',
6
+return apply_filters('wc_stripe_settings',
7 7
 	array(
8 8
 		'enabled' => array(
9
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
10
-			'label'       => __( 'Enable Stripe', 'woocommerce-gateway-stripe' ),
9
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
10
+			'label'       => __('Enable Stripe', 'woocommerce-gateway-stripe'),
11 11
 			'type'        => 'checkbox',
12 12
 			'description' => '',
13 13
 			'default'     => 'no'
14 14
 		),
15 15
 		'title' => array(
16
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
16
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
17 17
 			'type'        => 'text',
18
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
19
-			'default'     => __( 'Credit Card (Stripe)', 'woocommerce-gateway-stripe' ),
18
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
19
+			'default'     => __('Credit Card (Stripe)', 'woocommerce-gateway-stripe'),
20 20
 			'desc_tip'    => true,
21 21
 		),
22 22
 		'description' => array(
23
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
23
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
24 24
 			'type'        => 'text',
25
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
26
-			'default'     => __( 'Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe'),
25
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
26
+			'default'     => __('Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe'),
27 27
 			'desc_tip'    => true,
28 28
 		),
29 29
 		'testmode' => array(
30
-			'title'       => __( 'Test mode', 'woocommerce-gateway-stripe' ),
31
-			'label'       => __( 'Enable Test Mode', 'woocommerce-gateway-stripe' ),
30
+			'title'       => __('Test mode', 'woocommerce-gateway-stripe'),
31
+			'label'       => __('Enable Test Mode', 'woocommerce-gateway-stripe'),
32 32
 			'type'        => 'checkbox',
33
-			'description' => __( 'Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe' ),
33
+			'description' => __('Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe'),
34 34
 			'default'     => 'yes',
35 35
 			'desc_tip'    => true,
36 36
 		),
37 37
 		'test_secret_key' => array(
38
-			'title'       => __( 'Test Secret Key', 'woocommerce-gateway-stripe' ),
38
+			'title'       => __('Test Secret Key', 'woocommerce-gateway-stripe'),
39 39
 			'type'        => 'text',
40
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
40
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
41 41
 			'default'     => '',
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.', 'woocommerce-gateway-stripe' ),
47
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
48 48
 			'default'     => '',
49 49
 			'desc_tip'    => true,
50 50
 		),
51 51
 		'secret_key' => array(
52
-			'title'       => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ),
52
+			'title'       => __('Live Secret Key', 'woocommerce-gateway-stripe'),
53 53
 			'type'        => 'text',
54
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
54
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
55 55
 			'default'     => '',
56 56
 			'desc_tip'    => true,
57 57
 		),
58 58
 		'publishable_key' => array(
59
-			'title'       => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ),
59
+			'title'       => __('Live Publishable Key', 'woocommerce-gateway-stripe'),
60 60
 			'type'        => 'text',
61
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
61
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
62 62
 			'default'     => '',
63 63
 			'desc_tip'    => true,
64 64
 		),
65 65
 		'capture' => array(
66
-			'title'       => __( 'Capture', 'woocommerce-gateway-stripe' ),
67
-			'label'       => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ),
66
+			'title'       => __('Capture', 'woocommerce-gateway-stripe'),
67
+			'label'       => __('Capture charge immediately', 'woocommerce-gateway-stripe'),
68 68
 			'type'        => 'checkbox',
69
-			'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' ),
69
+			'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'),
70 70
 			'default'     => 'yes',
71 71
 			'desc_tip'    => true,
72 72
 		),
73 73
 		'stripe_checkout' => array(
74
-			'title'       => __( 'Stripe Checkout', 'woocommerce-gateway-stripe' ),
75
-			'label'       => __( 'Enable Stripe Checkout', 'woocommerce-gateway-stripe' ),
74
+			'title'       => __('Stripe Checkout', 'woocommerce-gateway-stripe'),
75
+			'label'       => __('Enable Stripe Checkout', 'woocommerce-gateway-stripe'),
76 76
 			'type'        => 'checkbox',
77
-			'description' => __( 'If enabled, this option shows a "pay" button and modal credit card form on the checkout, instead of credit card fields directly on the page.', 'woocommerce-gateway-stripe' ),
77
+			'description' => __('If enabled, this option shows a "pay" button and modal credit card form on the checkout, instead of credit card fields directly on the page.', 'woocommerce-gateway-stripe'),
78 78
 			'default'     => 'no',
79 79
 			'desc_tip'    => true,
80 80
 		),
81 81
 		'allow_remember_me' => array(
82
-			'title'       => __( 'Allow Remember Me', 'woocommerce-gateway-stripe' ),
83
-			'label'       => __( 'Enable Remember Me', 'woocommerce-gateway-stripe' ),
82
+			'title'       => __('Allow Remember Me', 'woocommerce-gateway-stripe'),
83
+			'label'       => __('Enable Remember Me', 'woocommerce-gateway-stripe'),
84 84
 			'type'        => 'checkbox',
85
-			'description' => __( 'If enabled, this option shows a "Remember Me" checkbox which when checked by the customer will persist their details.', 'woocommerce-gateway-stripe' ),
85
+			'description' => __('If enabled, this option shows a "Remember Me" checkbox which when checked by the customer will persist their details.', 'woocommerce-gateway-stripe'),
86 86
 			'default'     => 'yes',
87 87
 			'desc_tip'    => true,
88 88
 		),
89 89
 		'stripe_checkout_locale' => array(
90
-			'title'       => __( 'Stripe Checkout locale', 'woocommerce-gateway-stripe' ),
90
+			'title'       => __('Stripe Checkout locale', 'woocommerce-gateway-stripe'),
91 91
 			'type'        => 'select',
92 92
 			'class'       => 'wc-enhanced-select',
93
-			'description' => __( 'Language to display in Stripe Checkout modal. Specify Auto to display Checkout in the user\'s preferred language, if available. English will be used by default.', 'woocommerce-gateway-stripe' ),
93
+			'description' => __('Language to display in Stripe Checkout modal. Specify Auto to display Checkout in the user\'s preferred language, if available. English will be used by default.', 'woocommerce-gateway-stripe'),
94 94
 			'default'     => 'en',
95 95
 			'desc_tip'    => true,
96 96
 			'options'     => array(
97
-				'auto' => __( 'Auto', 'woocommerce-gateway-stripe' ),
98
-				'zh'   => __( 'Simplified Chinese', 'woocommerce-gateway-stripe' ),
99
-				'da'   => __( 'Danish', 'woocommerce-gateway-stripe' ),
100
-				'nl'   => __( 'Dutch', 'woocommerce-gateway-stripe' ),
101
-				'en'   => __( 'English', 'woocommerce-gateway-stripe' ),
102
-				'fi'   => __( 'Finnish', 'woocommerce-gateway-stripe' ),
103
-				'fr'   => __( 'French', 'woocommerce-gateway-stripe' ),
104
-				'de'   => __( 'German', 'woocommerce-gateway-stripe' ),
105
-				'it'   => __( 'Italian', 'woocommerce-gateway-stripe' ),
106
-				'ja'   => __( 'Japanese', 'woocommerce-gateway-stripe' ),
107
-				'no'   => __( 'Norwegian', 'woocommerce-gateway-stripe' ),
108
-				'es'   => __( 'Spanish', 'woocommerce-gateway-stripe' ),
109
-				'sv'   => __( 'Swedish', 'woocommerce-gateway-stripe' ),
97
+				'auto' => __('Auto', 'woocommerce-gateway-stripe'),
98
+				'zh'   => __('Simplified Chinese', 'woocommerce-gateway-stripe'),
99
+				'da'   => __('Danish', 'woocommerce-gateway-stripe'),
100
+				'nl'   => __('Dutch', 'woocommerce-gateway-stripe'),
101
+				'en'   => __('English', 'woocommerce-gateway-stripe'),
102
+				'fi'   => __('Finnish', 'woocommerce-gateway-stripe'),
103
+				'fr'   => __('French', 'woocommerce-gateway-stripe'),
104
+				'de'   => __('German', 'woocommerce-gateway-stripe'),
105
+				'it'   => __('Italian', 'woocommerce-gateway-stripe'),
106
+				'ja'   => __('Japanese', 'woocommerce-gateway-stripe'),
107
+				'no'   => __('Norwegian', 'woocommerce-gateway-stripe'),
108
+				'es'   => __('Spanish', 'woocommerce-gateway-stripe'),
109
+				'sv'   => __('Swedish', 'woocommerce-gateway-stripe'),
110 110
 			),
111 111
 		),
112 112
 		'stripe_bitcoin' => array(
113
-			'title'       => __( 'Bitcoin Currency', 'woocommerce-gateway-stripe' ),
114
-			'label'       => __( 'Enable Bitcoin Currency', 'woocommerce-gateway-stripe' ),
113
+			'title'       => __('Bitcoin Currency', 'woocommerce-gateway-stripe'),
114
+			'label'       => __('Enable Bitcoin Currency', 'woocommerce-gateway-stripe'),
115 115
 			'type'        => 'checkbox',
116
-			'description' => __( 'If enabled, an option to accept bitcoin will show on the checkout modal. Note: Stripe Checkout needs to be enabled and store currency must be set to USD.', 'woocommerce-gateway-stripe' ),
116
+			'description' => __('If enabled, an option to accept bitcoin will show on the checkout modal. Note: Stripe Checkout needs to be enabled and store currency must be set to USD.', 'woocommerce-gateway-stripe'),
117 117
 			'default'     => 'no',
118 118
 			'desc_tip'    => true,
119 119
 		),
120 120
 		'stripe_checkout_image' => array(
121
-			'title'       => __( 'Stripe Checkout Image', 'woocommerce-gateway-stripe' ),
122
-			'description' => __( 'Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe' ),
121
+			'title'       => __('Stripe Checkout Image', 'woocommerce-gateway-stripe'),
122
+			'description' => __('Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe'),
123 123
 			'type'        => 'text',
124 124
 			'default'     => '',
125 125
 			'desc_tip'    => true,
126 126
 		),
127 127
 		'request_payment_api' => array(
128
-			'title'       => __( 'Payment Request API', 'woocommerce-gateway-stripe' ),
129
-			'label'       => __( 'Enable Payment Request API', 'woocommerce-gateway-stripe' ),
128
+			'title'       => __('Payment Request API', 'woocommerce-gateway-stripe'),
129
+			'label'       => __('Enable Payment Request API', 'woocommerce-gateway-stripe'),
130 130
 			'type'        => 'checkbox',
131
-			'description' => __( 'If enabled, users will be able to pay using the Payment Request API if supported by the browser.', 'woocommerce-gateway-stripe' ),
131
+			'description' => __('If enabled, users will be able to pay using the Payment Request API if supported by the browser.', 'woocommerce-gateway-stripe'),
132 132
 			'default'     => 'no',
133 133
 			'desc_tip'    => true,
134 134
 		),
135 135
 		'apple_pay' => array(
136
-			'title'       => __( 'Apple Pay', 'woocommerce-gateway-stripe' ),
137
-			'label'       => __( 'Enable Apple Pay', 'woocommerce-gateway-stripe' ),
136
+			'title'       => __('Apple Pay', 'woocommerce-gateway-stripe'),
137
+			'label'       => __('Enable Apple Pay', 'woocommerce-gateway-stripe'),
138 138
 			'type'        => 'checkbox',
139
-			'description' => __( 'If enabled, users will be able to pay with Apple Pay.', 'woocommerce-gateway-stripe' ),
139
+			'description' => __('If enabled, users will be able to pay with Apple Pay.', 'woocommerce-gateway-stripe'),
140 140
 			'default'     => 'no',
141 141
 			'desc_tip'    => true,
142 142
 		),
143 143
 		'apple_pay_button' => array(
144
-			'title'       => __( 'Apple Pay Button Style', 'woocommerce-gateway-stripe' ),
145
-			'label'       => __( 'Button Style', 'woocommerce-gateway-stripe' ),
144
+			'title'       => __('Apple Pay Button Style', 'woocommerce-gateway-stripe'),
145
+			'label'       => __('Button Style', 'woocommerce-gateway-stripe'),
146 146
 			'type'        => 'select',
147
-			'description' => __( 'Select the button style you would like to show.', 'woocommerce-gateway-stripe' ),
147
+			'description' => __('Select the button style you would like to show.', 'woocommerce-gateway-stripe'),
148 148
 			'default'     => 'black',
149 149
 			'desc_tip'    => true,
150 150
 			'options'     => array(
151
-				'black' => __( 'Black', 'woocommerce-gateway-stripe' ),
152
-				'white' => __( 'White', 'woocommerce-gateway-stripe' ),
151
+				'black' => __('Black', 'woocommerce-gateway-stripe'),
152
+				'white' => __('White', 'woocommerce-gateway-stripe'),
153 153
 			),
154 154
 		),
155 155
 		'saved_cards' => array(
156
-			'title'       => __( 'Saved Cards', 'woocommerce-gateway-stripe' ),
157
-			'label'       => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ),
156
+			'title'       => __('Saved Cards', 'woocommerce-gateway-stripe'),
157
+			'label'       => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'),
158 158
 			'type'        => 'checkbox',
159
-			'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' ),
159
+			'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'),
160 160
 			'default'     => 'no',
161 161
 			'desc_tip'    => true,
162 162
 		),
163 163
 		'logging' => array(
164
-			'title'       => __( 'Logging', 'woocommerce-gateway-stripe' ),
165
-			'label'       => __( 'Log debug messages', 'woocommerce-gateway-stripe' ),
164
+			'title'       => __('Logging', 'woocommerce-gateway-stripe'),
165
+			'label'       => __('Log debug messages', 'woocommerce-gateway-stripe'),
166 166
 			'type'        => 'checkbox',
167
-			'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ),
167
+			'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'),
168 168
 			'default'     => 'no',
169 169
 			'desc_tip'    => true,
170 170
 		),
Please login to merge, or discard this patch.