Completed
Pull Request — master (#104)
by Dwain
02:11
created
includes/legacy/class-wc-gateway-stripe.php 1 patch
Spacing   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 	 */
16 16
 	public function __construct() {
17 17
 		$this->id                   = 'stripe';
18
-		$this->method_title         = __( 'Stripe', 'woocommerce-gateway-stripe' );
19
-		$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' );
18
+		$this->method_title         = __('Stripe', 'woocommerce-gateway-stripe');
19
+		$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');
20 20
 		$this->has_fields           = true;
21 21
 		$this->view_transaction_url = 'https://dashboard.stripe.com/payments/%s';
22 22
 		$this->supports             = array(
@@ -42,35 +42,35 @@  discard block
 block discarded – undo
42 42
 		$this->init_settings();
43 43
 
44 44
 		// Get setting values.
45
-		$this->title                  = $this->get_option( 'title' );
46
-		$this->description            = $this->get_option( 'description' );
47
-		$this->enabled                = $this->get_option( 'enabled' );
48
-		$this->testmode               = 'yes' === $this->get_option( 'testmode' );
49
-		$this->capture                = 'yes' === $this->get_option( 'capture', 'yes' );
50
-		$this->stripe_checkout        = 'yes' === $this->get_option( 'stripe_checkout' );
51
-		$this->stripe_checkout_locale = $this->get_option( 'stripe_checkout_locale' );
52
-		$this->stripe_checkout_image  = $this->get_option( 'stripe_checkout_image', '' );
53
-		$this->saved_cards            = 'yes' === $this->get_option( 'saved_cards' );
54
-		$this->secret_key             = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
55
-		$this->publishable_key        = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' );
56
-		$this->bitcoin                = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' );
57
-		$this->logging                = 'yes' === $this->get_option( 'logging' );
58
-
59
-		if ( $this->stripe_checkout ) {
60
-			$this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' );
45
+		$this->title                  = $this->get_option('title');
46
+		$this->description            = $this->get_option('description');
47
+		$this->enabled                = $this->get_option('enabled');
48
+		$this->testmode               = 'yes' === $this->get_option('testmode');
49
+		$this->capture                = 'yes' === $this->get_option('capture', 'yes');
50
+		$this->stripe_checkout        = 'yes' === $this->get_option('stripe_checkout');
51
+		$this->stripe_checkout_locale = $this->get_option('stripe_checkout_locale');
52
+		$this->stripe_checkout_image  = $this->get_option('stripe_checkout_image', '');
53
+		$this->saved_cards            = 'yes' === $this->get_option('saved_cards');
54
+		$this->secret_key             = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
55
+		$this->publishable_key        = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key');
56
+		$this->bitcoin                = 'USD' === strtoupper(get_woocommerce_currency()) && 'yes' === $this->get_option('stripe_bitcoin');
57
+		$this->logging                = 'yes' === $this->get_option('logging');
58
+
59
+		if ($this->stripe_checkout) {
60
+			$this->order_button_text = __('Continue to payment', 'woocommerce-gateway-stripe');
61 61
 		}
62 62
 
63
-		if ( $this->testmode ) {
64
-			$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' );
65
-			$this->description  = trim( $this->description );
63
+		if ($this->testmode) {
64
+			$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');
65
+			$this->description  = trim($this->description);
66 66
 		}
67 67
 
68
-		WC_Stripe_API::set_secret_key( $this->secret_key );
68
+		WC_Stripe_API::set_secret_key($this->secret_key);
69 69
 
70 70
 		// Hooks
71
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
72
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
73
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
71
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
72
+		add_action('admin_notices', array($this, 'admin_notices'));
73
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
74 74
 	}
75 75
 
76 76
 	/**
@@ -80,35 +80,35 @@  discard block
 block discarded – undo
80 80
 	 * @return string
81 81
 	 */
82 82
 	public function get_icon() {
83
-		$ext   = version_compare( WC()->version, '2.6', '>=' ) ? '.svg' : '.png';
84
-		$style = version_compare( WC()->version, '2.6', '>=' ) ? 'style="margin-left: 0.3em"' : '';
83
+		$ext   = version_compare(WC()->version, '2.6', '>=') ? '.svg' : '.png';
84
+		$style = version_compare(WC()->version, '2.6', '>=') ? 'style="margin-left: 0.3em"' : '';
85 85
 
86
-		$icon  = '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/visa' . $ext ) . '" alt="Visa" width="32" ' . $style . ' />';
87
-		$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard' . $ext ) . '" alt="Mastercard" width="32" ' . $style . ' />';
88
-		$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/amex' . $ext ) . '" alt="Amex" width="32" ' . $style . ' />';
86
+		$icon  = '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/visa' . $ext) . '" alt="Visa" width="32" ' . $style . ' />';
87
+		$icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard' . $ext) . '" alt="Mastercard" width="32" ' . $style . ' />';
88
+		$icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/amex' . $ext) . '" alt="Amex" width="32" ' . $style . ' />';
89 89
 
90
-		if ( 'USD' === get_woocommerce_currency() ) {
91
-			$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/discover' . $ext ) . '" alt="Discover" width="32" ' . $style . ' />';
92
-			$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb' . $ext ) . '" alt="JCB" width="32" ' . $style . ' />';
93
-			$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/diners' . $ext ) . '" alt="Diners" width="32" ' . $style . ' />';
90
+		if ('USD' === get_woocommerce_currency()) {
91
+			$icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/discover' . $ext) . '" alt="Discover" width="32" ' . $style . ' />';
92
+			$icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb' . $ext) . '" alt="JCB" width="32" ' . $style . ' />';
93
+			$icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/diners' . $ext) . '" alt="Diners" width="32" ' . $style . ' />';
94 94
 		}
95 95
 
96
-		if ( $this->bitcoin ) {
97
-			$icon .= '<img src="' . WC_HTTPS::force_https_url( plugins_url( '/assets/images/bitcoin' . $ext, WC_STRIPE_MAIN_FILE ) ) . '" alt="Bitcoin" width="32" ' . $style . ' />';
96
+		if ($this->bitcoin) {
97
+			$icon .= '<img src="' . WC_HTTPS::force_https_url(plugins_url('/assets/images/bitcoin' . $ext, WC_STRIPE_MAIN_FILE)) . '" alt="Bitcoin" width="32" ' . $style . ' />';
98 98
 		}
99 99
 
100
-		return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id );
100
+		return apply_filters('woocommerce_gateway_icon', $icon, $this->id);
101 101
 	}
102 102
 
103 103
 	/**
104 104
 	 * Get Stripe amount to pay
105 105
 	 * @return float
106 106
 	 */
107
-	public function get_stripe_amount( $total, $currency = '' ) {
108
-		if ( ! $currency ) {
107
+	public function get_stripe_amount($total, $currency = '') {
108
+		if ( ! $currency) {
109 109
 			$currency = get_woocommerce_currency();
110 110
 		}
111
-		switch ( strtoupper( $currency ) ) {
111
+		switch (strtoupper($currency)) {
112 112
 			// Zero decimal currencies
113 113
 			case 'BIF' :
114 114
 			case 'CLP' :
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
 			case 'XAF' :
126 126
 			case 'XOF' :
127 127
 			case 'XPF' :
128
-				$total = absint( $total );
128
+				$total = absint($total);
129 129
 				break;
130 130
 			default :
131
-				$total = round( $total, 2 ) * 100; // In cents
131
+				$total = round($total, 2) * 100; // In cents
132 132
 				break;
133 133
 		}
134 134
 		return $total;
@@ -138,31 +138,31 @@  discard block
 block discarded – undo
138 138
 	 * Check if SSL is enabled and notify the user
139 139
 	 */
140 140
 	public function admin_notices() {
141
-		if ( $this->enabled == 'no' ) {
141
+		if ($this->enabled == 'no') {
142 142
 			return;
143 143
 		}
144 144
 
145
-		$addons = ( class_exists( 'WC_Subscriptions_Order' ) || class_exists( 'WC_Pre_Orders_Order' ) ) ? '_addons' : '';
145
+		$addons = (class_exists('WC_Subscriptions_Order') || class_exists('WC_Pre_Orders_Order')) ? '_addons' : '';
146 146
 
147 147
 		// Check required fields
148
-		if ( ! $this->secret_key ) {
149
-			echo '<div class="error"><p>' . sprintf( __( 'Stripe error: Please enter your secret key <a href="%s">here</a>', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=wc_gateway_stripe' . $addons ) ) . '</p></div>';
148
+		if ( ! $this->secret_key) {
149
+			echo '<div class="error"><p>' . sprintf(__('Stripe error: Please enter your secret key <a href="%s">here</a>', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=wc_gateway_stripe' . $addons)) . '</p></div>';
150 150
 			return;
151 151
 
152
-		} elseif ( ! $this->publishable_key ) {
153
-			echo '<div class="error"><p>' . sprintf( __( 'Stripe error: Please enter your publishable key <a href="%s">here</a>', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=wc_gateway_stripe' . $addons ) ) . '</p></div>';
152
+		} elseif ( ! $this->publishable_key) {
153
+			echo '<div class="error"><p>' . sprintf(__('Stripe error: Please enter your publishable key <a href="%s">here</a>', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=wc_gateway_stripe' . $addons)) . '</p></div>';
154 154
 			return;
155 155
 		}
156 156
 
157 157
 		// Simple check for duplicate keys
158
-		if ( $this->secret_key == $this->publishable_key ) {
159
-			echo '<div class="error"><p>' . sprintf( __( 'Stripe error: Your secret and publishable keys match. Please check and re-enter.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=wc_gateway_stripe' . $addons ) ) . '</p></div>';
158
+		if ($this->secret_key == $this->publishable_key) {
159
+			echo '<div class="error"><p>' . sprintf(__('Stripe error: Your secret and publishable keys match. Please check and re-enter.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=wc_gateway_stripe' . $addons)) . '</p></div>';
160 160
 			return;
161 161
 		}
162 162
 
163 163
 		// Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected
164
-		if ( ( function_exists( 'wc_site_is_https' ) && ! wc_site_is_https() ) && ( 'no' === get_option( 'woocommerce_force_ssl_checkout' ) && ! class_exists( 'WordPressHTTPS' ) ) ) {
165
-			echo '<div class="error"><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>';
164
+		if ((function_exists('wc_site_is_https') && ! wc_site_is_https()) && ('no' === get_option('woocommerce_force_ssl_checkout') && ! class_exists('WordPressHTTPS'))) {
165
+			echo '<div class="error"><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>';
166 166
 		}
167 167
 	}
168 168
 
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 	 * Check if this gateway is enabled
171 171
 	 */
172 172
 	public function is_available() {
173
-		if ( 'yes' === $this->enabled ) {
174
-			if ( ! $this->testmode && is_checkout() && ! is_ssl() ) {
173
+		if ('yes' === $this->enabled) {
174
+			if ( ! $this->testmode && is_checkout() && ! is_ssl()) {
175 175
 				return false;
176 176
 			}
177
-			if ( ! $this->secret_key || ! $this->publishable_key ) {
177
+			if ( ! $this->secret_key || ! $this->publishable_key) {
178 178
 				return false;
179 179
 			}
180 180
 			return true;
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
 	 * Initialise Gateway Settings Form Fields
187 187
 	 */
188 188
 	public function init_form_fields() {
189
-		$this->form_fields = include( untrailingslashit( plugin_dir_path( WC_STRIPE_MAIN_FILE ) ) . '/includes/settings-stripe.php' );
189
+		$this->form_fields = include(untrailingslashit(plugin_dir_path(WC_STRIPE_MAIN_FILE)) . '/includes/settings-stripe.php');
190 190
 
191
-		wc_enqueue_js( "
191
+		wc_enqueue_js("
192 192
 			jQuery( function( $ ) {
193 193
 				$( '#woocommerce_stripe_stripe_checkout' ).change(function(){
194 194
 					if ( $( this ).is( ':checked' ) ) {
@@ -208,25 +208,25 @@  discard block
 block discarded – undo
208 208
 		?>
209 209
 		<fieldset class="stripe-legacy-payment-fields">
210 210
 			<?php
211
-				if ( $this->description ) {
212
-					echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) );
211
+				if ($this->description) {
212
+					echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description)));
213 213
 				}
214
-				if ( $this->saved_cards && is_user_logged_in() ) {
215
-					$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
214
+				if ($this->saved_cards && is_user_logged_in()) {
215
+					$stripe_customer = new WC_Stripe_Customer(get_current_user_id());
216 216
 					?>
217 217
 					<p class="form-row form-row-wide">
218
-						<a class="<?php echo apply_filters( 'wc_stripe_manage_saved_cards_class', 'button' ); ?>" style="float:right;" href="<?php echo apply_filters( 'wc_stripe_manage_saved_cards_url', get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) ); ?>#saved-cards"><?php esc_html_e( 'Manage cards', 'woocommerce-gateway-stripe' ); ?></a>
218
+						<a class="<?php echo apply_filters('wc_stripe_manage_saved_cards_class', 'button'); ?>" style="float:right;" href="<?php echo apply_filters('wc_stripe_manage_saved_cards_url', get_permalink(get_option('woocommerce_myaccount_page_id'))); ?>#saved-cards"><?php esc_html_e('Manage cards', 'woocommerce-gateway-stripe'); ?></a>
219 219
 						<?php
220
-						if ( $cards = $stripe_customer->get_cards() ) {
220
+						if ($cards = $stripe_customer->get_cards()) {
221 221
 							$default_card = $cards[0]->id;
222
-							foreach ( (array) $cards as $card ) {
223
-								if ( 'card' !== $card->object ) {
222
+							foreach ((array) $cards as $card) {
223
+								if ('card' !== $card->object) {
224 224
 									continue;
225 225
 								}
226 226
 								?>
227
-								<label for="stripe_card_<?php echo $card->id; ?>" class="brand-<?php echo esc_attr( strtolower( $card->brand ) ); ?>">
228
-									<input type="radio" id="stripe_card_<?php echo $card->id; ?>" name="wc-stripe-payment-token" value="<?php echo $card->id; ?>" <?php checked( $default_card, $card->id ) ?> />
229
-									<?php printf( __( '%s card ending in %s (Expires %s/%s)', 'woocommerce-gateway-stripe' ), $card->brand, $card->last4, $card->exp_month, $card->exp_year ); ?>
227
+								<label for="stripe_card_<?php echo $card->id; ?>" class="brand-<?php echo esc_attr(strtolower($card->brand)); ?>">
228
+									<input type="radio" id="stripe_card_<?php echo $card->id; ?>" name="wc-stripe-payment-token" value="<?php echo $card->id; ?>" <?php checked($default_card, $card->id) ?> />
229
+									<?php printf(__('%s card ending in %s (Expires %s/%s)', 'woocommerce-gateway-stripe'), $card->brand, $card->last4, $card->exp_month, $card->exp_year); ?>
230 230
 								</label>
231 231
 								<?php
232 232
 							}
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 						?>
235 235
 						<label for="new">
236 236
 							<input type="radio" id="new" name="wc-stripe-payment-token" value="new" />
237
-							<?php _e( 'Use a new credit card', 'woocommerce-gateway-stripe' ); ?>
237
+							<?php _e('Use a new credit card', 'woocommerce-gateway-stripe'); ?>
238 238
 						</label>
239 239
 					</p>
240 240
 					<?php
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
 
243 243
 				$user = wp_get_current_user();
244 244
 
245
-				if ( $user ) {
246
-					$user_email = get_user_meta( $user->ID, 'billing_email', true );
245
+				if ($user) {
246
+					$user_email = get_user_meta($user->ID, 'billing_email', true);
247 247
 					$user_email = $user_email ? $user_email : $user->user_email;
248 248
 				} else {
249 249
 					$user_email = '';
@@ -251,22 +251,22 @@  discard block
 block discarded – undo
251 251
 
252 252
 				$display = '';
253 253
 
254
-				if ( $this->stripe_checkout || $this->saved_cards && ! empty( $cards ) ) {
254
+				if ($this->stripe_checkout || $this->saved_cards && ! empty($cards)) {
255 255
 					$display = 'style="display:none;"';
256 256
 				}
257 257
 
258 258
 				echo '<div ' . $display . ' id="stripe-payment-data"
259 259
 					data-description=""
260
-					data-email="' . esc_attr( $user_email ) . '"
261
-					data-amount="' . esc_attr( $this->get_stripe_amount( WC()->cart->total ) ) . '"
262
-					data-name="' . esc_attr( get_bloginfo( 'name', 'display' ) ) . '"
263
-					data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '"
264
-					data-image="' . esc_attr( $this->stripe_checkout_image ) . '"
265
-					data-bitcoin="' . esc_attr( $this->bitcoin ? 'true' : 'false' ) . '"
266
-					data-locale="' . esc_attr( $this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en' ) . '">';
267
-
268
-				if ( ! $this->stripe_checkout ) {
269
-					$this->credit_card_form( array( 'fields_have_names' => false ) );
260
+					data-email="' . esc_attr($user_email) . '"
261
+					data-amount="' . esc_attr($this->get_stripe_amount(WC()->cart->total)) . '"
262
+					data-name="' . esc_attr(get_bloginfo('name', 'display')) . '"
263
+					data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '"
264
+					data-image="' . esc_attr($this->stripe_checkout_image) . '"
265
+					data-bitcoin="' . esc_attr($this->bitcoin ? 'true' : 'false') . '"
266
+					data-locale="' . esc_attr($this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en') . '">';
267
+
268
+				if ( ! $this->stripe_checkout) {
269
+					$this->credit_card_form(array('fields_have_names' => false));
270 270
 				}
271 271
 
272 272
 				echo '</div>';
@@ -283,27 +283,27 @@  discard block
 block discarded – undo
283 283
 	 * @access public
284 284
 	 */
285 285
 	public function payment_scripts() {
286
-		if ( $this->stripe_checkout ) {
287
-			wp_enqueue_script( 'stripe', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true );
288
-			wp_enqueue_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe_checkout.js', WC_STRIPE_MAIN_FILE ), array( 'stripe' ), WC_STRIPE_VERSION, true );
286
+		if ($this->stripe_checkout) {
287
+			wp_enqueue_script('stripe', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true);
288
+			wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe_checkout.js', WC_STRIPE_MAIN_FILE), array('stripe'), WC_STRIPE_VERSION, true);
289 289
 		} else {
290
-			wp_enqueue_script( 'stripe', 'https://js.stripe.com/v2/', '', '1.0', true );
291
-			wp_enqueue_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripe' ), WC_STRIPE_VERSION, true );
290
+			wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', '', '1.0', true);
291
+			wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripe'), WC_STRIPE_VERSION, true);
292 292
 		}
293 293
 
294 294
 		$stripe_params = array(
295 295
 			'key'                  => $this->publishable_key,
296
-			'i18n_terms'           => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ),
297
-			'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ),
296
+			'i18n_terms'           => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'),
297
+			'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'),
298 298
 		);
299 299
 
300 300
 		// If we're on the pay page we need to pass stripe.js the address of the order.
301
-		if ( is_checkout_pay_page() && isset( $_GET['order'] ) && isset( $_GET['order_id'] ) ) {
302
-			$order_key = urldecode( $_GET['order'] );
303
-			$order_id  = absint( $_GET['order_id'] );
304
-			$order     = wc_get_order( $order_id );
301
+		if (is_checkout_pay_page() && isset($_GET['order']) && isset($_GET['order_id'])) {
302
+			$order_key = urldecode($_GET['order']);
303
+			$order_id  = absint($_GET['order_id']);
304
+			$order     = wc_get_order($order_id);
305 305
 
306
-			if ( $order->id === $order_id && $order->order_key === $order_key ) {
306
+			if ($order->id === $order_id && $order->order_key === $order_key) {
307 307
 				$stripe_params['billing_first_name'] = $order->billing_first_name;
308 308
 				$stripe_params['billing_last_name']  = $order->billing_last_name;
309 309
 				$stripe_params['billing_address_1']  = $order->billing_address_1;
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 			}
316 316
 		}
317 317
 
318
-		wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
318
+		wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
319 319
 	}
320 320
 
321 321
 	/**
@@ -324,36 +324,36 @@  discard block
 block discarded – undo
324 324
 	 * @param  object $source
325 325
 	 * @return array()
326 326
 	 */
327
-	protected function generate_payment_request( $order, $source ) {
327
+	protected function generate_payment_request($order, $source) {
328 328
 		$post_data                = array();
329 329
 
330 330
 		$post_data['capture']     = $this->capture ? 'true' : 'false';
331
-		if ( 'true' == $post_data['capture'] ) {
332
-			if ( ! defined( 'WOOCOMMERCE_STRIPE_DOING_CAPTURE' ) ) {
331
+		if ('true' == $post_data['capture']) {
332
+			if ( ! defined('WOOCOMMERCE_STRIPE_DOING_CAPTURE')) {
333 333
 				// Allow other extensions hooking the process to know that we're capturing.
334
-				define( 'WOOCOMMERCE_STRIPE_DOING_CAPTURE', true );
334
+				define('WOOCOMMERCE_STRIPE_DOING_CAPTURE', true);
335 335
 			}
336 336
 		}
337 337
 
338
-		$post_data['description'] = sprintf( __( '%s - Order %s', 'woocommerce-gateway-stripe' ), wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $order->get_order_number() );
339
-		$post_data['currency']    = strtolower( $order->get_order_currency() ? $order->get_order_currency() : get_woocommerce_currency() );
340
-		$post_data['amount']      = $this->get_stripe_amount( $order->get_total(), $post_data['currency'] );
338
+		$post_data['description'] = sprintf(__('%s - Order %s', 'woocommerce-gateway-stripe'), wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES), $order->get_order_number());
339
+		$post_data['currency']    = strtolower($order->get_order_currency() ? $order->get_order_currency() : get_woocommerce_currency());
340
+		$post_data['amount']      = $this->get_stripe_amount($order->get_total(), $post_data['currency']);
341 341
 
342
-		if ( ! empty( $order->billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) {
342
+		if ( ! empty($order->billing_email) && apply_filters('wc_stripe_send_stripe_receipt', false)) {
343 343
 			$post_data['receipt_email'] = $order->billing_email;
344 344
 		}
345 345
 
346
-		$post_data['expand[]']    = 'balance_transaction';
346
+		$post_data['expand[]'] = 'balance_transaction';
347 347
 
348
-		if ( $source->customer ) {
348
+		if ($source->customer) {
349 349
 			$post_data['customer'] = $source->customer;
350 350
 		}
351 351
 
352
-		if ( $source->source ) {
352
+		if ($source->source) {
353 353
 			$post_data['source'] = $source->source;
354 354
 		}
355 355
 
356
-		return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order, $source );
356
+		return apply_filters('wc_stripe_generate_payment_request', $post_data, $order, $source);
357 357
 	}
358 358
 
359 359
 	/**
@@ -361,22 +361,22 @@  discard block
 block discarded – undo
361 361
 	 * @param  bool $force_customer Should we force customer creation?
362 362
 	 * @return object
363 363
 	 */
364
-	protected function get_source( $user_id, $force_customer = false ) {
365
-		$stripe_customer = new WC_Stripe_Customer( $user_id );
364
+	protected function get_source($user_id, $force_customer = false) {
365
+		$stripe_customer = new WC_Stripe_Customer($user_id);
366 366
 		$stripe_source   = false;
367 367
 		$token_id        = false;
368 368
 
369 369
 		// New CC info was entered and we have a new token to process
370
-		if ( isset( $_POST['stripe_token'] ) ) {
371
-			$stripe_token     = wc_clean( $_POST['stripe_token'] );
372
-			$maybe_saved_card = isset( $_POST['wc-stripe-new-payment-method'] ) && ! empty( $_POST['wc-stripe-new-payment-method'] );
370
+		if (isset($_POST['stripe_token'])) {
371
+			$stripe_token     = wc_clean($_POST['stripe_token']);
372
+			$maybe_saved_card = isset($_POST['wc-stripe-new-payment-method']) && ! empty($_POST['wc-stripe-new-payment-method']);
373 373
 
374 374
 			// This is true if the user wants to store the card to their account.
375
-			if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_customer ) {
376
-				$stripe_source = $stripe_customer->add_card( $stripe_token );
375
+			if (($user_id && $this->saved_cards && $maybe_saved_card) || $force_customer) {
376
+				$stripe_source = $stripe_customer->add_card($stripe_token);
377 377
 
378
-				if ( is_wp_error( $stripe_source ) ) {
379
-					throw new Exception( $stripe_source->get_error_message() );
378
+				if (is_wp_error($stripe_source)) {
379
+					throw new Exception($stripe_source->get_error_message());
380 380
 				}
381 381
 
382 382
 			} else {
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 		}
388 388
 
389 389
 		// Use an existing token, and then process the payment
390
-		elseif ( isset( $_POST['wc-stripe-payment-token'] ) && 'new' !== $_POST['wc-stripe-payment-token'] ) {
391
-			$stripe_source = wc_clean( $_POST['wc-stripe-payment-token'] );
390
+		elseif (isset($_POST['wc-stripe-payment-token']) && 'new' !== $_POST['wc-stripe-payment-token']) {
391
+			$stripe_source = wc_clean($_POST['wc-stripe-payment-token']);
392 392
 		}
393 393
 
394 394
 		return (object) array(
@@ -409,16 +409,16 @@  discard block
 block discarded – undo
409 409
 	 * @param object $order
410 410
 	 * @return object
411 411
 	 */
412
-	protected function get_order_source( $order = null ) {
412
+	protected function get_order_source($order = null) {
413 413
 		$stripe_customer = new WC_Stripe_Customer();
414 414
 		$stripe_source   = false;
415 415
 		$token_id        = false;
416 416
 
417
-		if ( $order ) {
418
-			if ( $meta_value = get_post_meta( $order->id, '_stripe_customer_id', true ) ) {
419
-				$stripe_customer->set_id( $meta_value );
417
+		if ($order) {
418
+			if ($meta_value = get_post_meta($order->id, '_stripe_customer_id', true)) {
419
+				$stripe_customer->set_id($meta_value);
420 420
 			}
421
-			if ( $meta_value = get_post_meta( $order->id, '_stripe_card_id', true ) ) {
421
+			if ($meta_value = get_post_meta($order->id, '_stripe_card_id', true)) {
422 422
 				$stripe_source = $meta_value;
423 423
 			}
424 424
 		}
@@ -433,43 +433,43 @@  discard block
 block discarded – undo
433 433
 	/**
434 434
 	 * Process the payment
435 435
 	 */
436
-	public function process_payment( $order_id, $retry = true, $force_customer = false ) {
436
+	public function process_payment($order_id, $retry = true, $force_customer = false) {
437 437
 		try {
438
-			$order  = wc_get_order( $order_id );
439
-			$source = $this->get_source( get_current_user_id(), $force_customer );
438
+			$order  = wc_get_order($order_id);
439
+			$source = $this->get_source(get_current_user_id(), $force_customer);
440 440
 
441
-			if ( empty( $source->source ) && empty( $source->customer ) ) {
442
-				$error_msg = __( 'Please enter your card details to make a payment.', 'woocommerce-gateway-stripe' );
443
-				$error_msg .= ' ' . __( 'Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce-gateway-stripe' );
444
-				throw new Exception( $error_msg );
441
+			if (empty($source->source) && empty($source->customer)) {
442
+				$error_msg = __('Please enter your card details to make a payment.', 'woocommerce-gateway-stripe');
443
+				$error_msg .= ' ' . __('Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce-gateway-stripe');
444
+				throw new Exception($error_msg);
445 445
 			}
446 446
 
447 447
 			// Store source to order meta
448
-			$this->save_source( $order, $source );
448
+			$this->save_source($order, $source);
449 449
 
450 450
 			// Handle payment
451
-			if ( $order->get_total() > 0 ) {
451
+			if ($order->get_total() > 0) {
452 452
 
453
-				if ( $order->get_total() * 100 < 50 ) {
454
-					throw new Exception( __( 'Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce-gateway-stripe' ) );
453
+				if ($order->get_total() * 100 < 50) {
454
+					throw new Exception(__('Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce-gateway-stripe'));
455 455
 				}
456 456
 
457
-				WC_Stripe::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
457
+				WC_Stripe::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}");
458 458
 
459 459
 				// Make the request
460
-				$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source ) );
460
+				$response = WC_Stripe_API::request($this->generate_payment_request($order, $source));
461 461
 
462
-				if ( is_wp_error( $response ) ) {
462
+				if (is_wp_error($response)) {
463 463
 					// Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without.
464
-					if ( 'customer' === $response->get_error_code() && $retry ) {
465
-						delete_user_meta( get_current_user_id(), '_stripe_customer_id' );
466
-						return $this->process_payment( $order_id, false, $force_customer );
464
+					if ('customer' === $response->get_error_code() && $retry) {
465
+						delete_user_meta(get_current_user_id(), '_stripe_customer_id');
466
+						return $this->process_payment($order_id, false, $force_customer);
467 467
 					}
468
-					throw new Exception( $response->get_error_code() . ': ' . $response->get_error_message() );
468
+					throw new Exception($response->get_error_code() . ': ' . $response->get_error_message());
469 469
 				}
470 470
 
471 471
 				// Process valid response
472
-				$this->process_response( $response, $order );
472
+				$this->process_response($response, $order);
473 473
 			} else {
474 474
 				$order->payment_complete();
475 475
 			}
@@ -480,13 +480,13 @@  discard block
 block discarded – undo
480 480
 			// Return thank you page redirect
481 481
 			return array(
482 482
 				'result'   => 'success',
483
-				'redirect' => $this->get_return_url( $order )
483
+				'redirect' => $this->get_return_url($order)
484 484
 			);
485 485
 
486
-		} catch ( Exception $e ) {
487
-			wc_add_notice( $e->getMessage(), 'error' );
488
-			WC()->session->set( 'refresh_totals', true );
489
-			WC_Stripe::log( sprintf( __( 'Error: %s', 'woocommerce-gateway-stripe' ), $e->getMessage() ) );
486
+		} catch (Exception $e) {
487
+			wc_add_notice($e->getMessage(), 'error');
488
+			WC()->session->set('refresh_totals', true);
489
+			WC_Stripe::log(sprintf(__('Error: %s', 'woocommerce-gateway-stripe'), $e->getMessage()));
490 490
 			return;
491 491
 		}
492 492
 	}
@@ -494,45 +494,45 @@  discard block
 block discarded – undo
494 494
 	/**
495 495
 	 * Save source to order.
496 496
 	 */
497
-	protected function save_source( $order, $source ) {
497
+	protected function save_source($order, $source) {
498 498
 		// Store source in the order
499
-		if ( $source->customer ) {
500
-			update_post_meta( $order->id, '_stripe_customer_id', $source->customer );
499
+		if ($source->customer) {
500
+			update_post_meta($order->id, '_stripe_customer_id', $source->customer);
501 501
 		}
502
-		if ( $source->source ) {
503
-			update_post_meta( $order->id, '_stripe_card_id', $source->source->id );
502
+		if ($source->source) {
503
+			update_post_meta($order->id, '_stripe_card_id', $source->source->id);
504 504
 		}
505 505
 	}
506 506
 
507 507
 	/**
508 508
 	 * Store extra meta data for an order from a Stripe Response.
509 509
 	 */
510
-	public function process_response( $response, $order ) {
511
-		WC_Stripe::log( "Processing response: " . print_r( $response, true ) );
510
+	public function process_response($response, $order) {
511
+		WC_Stripe::log("Processing response: " . print_r($response, true));
512 512
 
513 513
 		// Store charge data
514
-		update_post_meta( $order->id, '_stripe_charge_id', $response->id );
515
-		update_post_meta( $order->id, '_stripe_charge_captured', $response->captured ? 'yes' : 'no' );
514
+		update_post_meta($order->id, '_stripe_charge_id', $response->id);
515
+		update_post_meta($order->id, '_stripe_charge_captured', $response->captured ? 'yes' : 'no');
516 516
 
517 517
 		// Store other data such as fees
518
-		if ( isset( $response->balance_transaction ) && isset( $response->balance_transaction->fee ) ) {
519
-			$fee = number_format( $response->balance_transaction->fee / 100, 2, '.', '' );
520
-			update_post_meta( $order->id, 'Stripe Fee', $fee );
521
-			update_post_meta( $order->id, 'Net Revenue From Stripe', $order->get_total() - $fee );
518
+		if (isset($response->balance_transaction) && isset($response->balance_transaction->fee)) {
519
+			$fee = number_format($response->balance_transaction->fee / 100, 2, '.', '');
520
+			update_post_meta($order->id, 'Stripe Fee', $fee);
521
+			update_post_meta($order->id, 'Net Revenue From Stripe', $order->get_total() - $fee);
522 522
 		}
523 523
 
524
-		if ( $response->captured ) {
525
-			$order->payment_complete( $response->id );
526
-			WC_Stripe::log( "Successful charge: $response->id" );
524
+		if ($response->captured) {
525
+			$order->payment_complete($response->id);
526
+			WC_Stripe::log("Successful charge: $response->id");
527 527
 		} else {
528
-			add_post_meta( $order->id, '_transaction_id', $response->id, true );
528
+			add_post_meta($order->id, '_transaction_id', $response->id, true);
529 529
 
530
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
530
+			if ($order->has_status(array('pending', 'failed'))) {
531 531
 				$order->reduce_order_stock();
532 532
 			}
533 533
 
534
-			$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 ) );
535
-			WC_Stripe::log( "Successful auth: $response->id" );
534
+			$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));
535
+			WC_Stripe::log("Successful auth: $response->id");
536 536
 		}
537 537
 
538 538
 		return $response;
@@ -544,21 +544,21 @@  discard block
 block discarded – undo
544 544
 	 * @since 3.0.0
545 545
 	 */
546 546
 	public function add_payment_method() {
547
-		if ( empty( $_POST['stripe_token'] ) || ! is_user_logged_in() ) {
548
-			wc_add_notice( __( 'There was a problem adding the card.', 'woocommerce-gateway-stripe' ), 'error' );
547
+		if (empty($_POST['stripe_token']) || ! is_user_logged_in()) {
548
+			wc_add_notice(__('There was a problem adding the card.', 'woocommerce-gateway-stripe'), 'error');
549 549
 			return;
550 550
 		}
551 551
 
552
-		$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
553
-		$result          = $stripe_customer->add_card( wc_clean( $_POST['stripe_token'] ) );
552
+		$stripe_customer = new WC_Stripe_Customer(get_current_user_id());
553
+		$result          = $stripe_customer->add_card(wc_clean($_POST['stripe_token']));
554 554
 
555
-		if ( is_wp_error( $result ) ) {
556
-			throw new Exception( $result->get_error_message() );
555
+		if (is_wp_error($result)) {
556
+			throw new Exception($result->get_error_message());
557 557
 		}
558 558
 
559 559
 		return array(
560 560
 			'result'   => 'success',
561
-			'redirect' => wc_get_endpoint_url( 'payment-methods' ),
561
+			'redirect' => wc_get_endpoint_url('payment-methods'),
562 562
 		);
563 563
 	}
564 564
 
@@ -568,36 +568,36 @@  discard block
 block discarded – undo
568 568
 	 * @param  float $amount
569 569
 	 * @return bool
570 570
 	 */
571
-	public function process_refund( $order_id, $amount = null, $reason = '' ) {
572
-		$order = wc_get_order( $order_id );
571
+	public function process_refund($order_id, $amount = null, $reason = '') {
572
+		$order = wc_get_order($order_id);
573 573
 
574
-		if ( ! $order || ! $order->get_transaction_id() ) {
574
+		if ( ! $order || ! $order->get_transaction_id()) {
575 575
 			return false;
576 576
 		}
577 577
 
578 578
 		$body = array();
579 579
 
580
-		if ( ! is_null( $amount ) ) {
581
-			$body['amount']	= $this->get_stripe_amount( $amount );
580
+		if ( ! is_null($amount)) {
581
+			$body['amount'] = $this->get_stripe_amount($amount);
582 582
 		}
583 583
 
584
-		if ( $reason ) {
584
+		if ($reason) {
585 585
 			$body['metadata'] = array(
586 586
 				'reason'	=> $reason,
587 587
 			);
588 588
 		}
589 589
 
590
-		WC_Stripe::log( "Info: Beginning refund for order $order_id for the amount of {$amount}" );
590
+		WC_Stripe::log("Info: Beginning refund for order $order_id for the amount of {$amount}");
591 591
 
592
-		$response = WC_Stripe_API::request( $body, 'charges/' . $order->get_transaction_id() . '/refunds' );
592
+		$response = WC_Stripe_API::request($body, 'charges/' . $order->get_transaction_id() . '/refunds');
593 593
 
594
-		if ( is_wp_error( $response ) ) {
595
-			WC_Stripe::log( "Error: " . $response->get_error_message() );
594
+		if (is_wp_error($response)) {
595
+			WC_Stripe::log("Error: " . $response->get_error_message());
596 596
 			return $response;
597
-		} elseif ( ! empty( $response->id ) ) {
598
-			$refund_message = sprintf( __( 'Refunded %s - Refund ID: %s - Reason: %s', 'woocommerce-gateway-stripe' ), wc_price( $response->amount / 100 ), $response->id, $reason );
599
-			$order->add_order_note( $refund_message );
600
-			WC_Stripe::log( "Success: " . html_entity_decode( strip_tags( $refund_message ) ) );
597
+		} elseif ( ! empty($response->id)) {
598
+			$refund_message = sprintf(__('Refunded %s - Refund ID: %s - Reason: %s', 'woocommerce-gateway-stripe'), wc_price($response->amount / 100), $response->id, $reason);
599
+			$order->add_order_note($refund_message);
600
+			WC_Stripe::log("Success: " . html_entity_decode(strip_tags($refund_message)));
601 601
 			return true;
602 602
 		}
603 603
 	}
Please login to merge, or discard this patch.
woocommerce-gateway-stripe.php 1 patch
Spacing   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -25,20 +25,20 @@  discard block
 block discarded – undo
25 25
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 26
 */
27 27
 
28
-if ( ! defined( 'ABSPATH' ) ) {
28
+if ( ! defined('ABSPATH')) {
29 29
 	exit;
30 30
 }
31 31
 
32 32
 /**
33 33
  * Required minimums and constants
34 34
  */
35
-define( 'WC_STRIPE_VERSION', '3.0.5' );
36
-define( 'WC_STRIPE_MIN_PHP_VER', '5.3.0' );
37
-define( 'WC_STRIPE_MIN_WC_VER', '2.5.0' );
38
-define( 'WC_STRIPE_MAIN_FILE', __FILE__ );
39
-define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
35
+define('WC_STRIPE_VERSION', '3.0.5');
36
+define('WC_STRIPE_MIN_PHP_VER', '5.3.0');
37
+define('WC_STRIPE_MIN_WC_VER', '2.5.0');
38
+define('WC_STRIPE_MAIN_FILE', __FILE__);
39
+define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__))));
40 40
 
41
-if ( ! class_exists( 'WC_Stripe' ) ) :
41
+if ( ! class_exists('WC_Stripe')) :
42 42
 
43 43
 class WC_Stripe {
44 44
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * @return Singleton The *Singleton* instance.
59 59
 	 */
60 60
 	public static function get_instance() {
61
-		if ( null === self::$instance ) {
61
+		if (null === self::$instance) {
62 62
 			self::$instance = new self();
63 63
 		}
64 64
 		return self::$instance;
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 	 * *Singleton* via the `new` operator from outside of this class.
108 108
 	 */
109 109
 	protected function __construct() {
110
-		add_action( 'admin_init', array( $this, 'check_environment' ) );
111
-		add_action( 'admin_notices', array( $this, 'admin_notices' ), 15 );
112
-		add_action( 'plugins_loaded', array( $this, 'init' ) );
110
+		add_action('admin_init', array($this, 'check_environment'));
111
+		add_action('admin_notices', array($this, 'admin_notices'), 15);
112
+		add_action('plugins_loaded', array($this, 'init'));
113 113
 	}
114 114
 
115 115
 	/**
@@ -117,31 +117,31 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function init() {
119 119
 		// Don't hook anything else in the plugin if we're in an incompatible environment
120
-		if ( self::get_environment_warning() ) {
120
+		if (self::get_environment_warning()) {
121 121
 			return;
122 122
 		}
123 123
 
124
-		include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php' );
125
-		include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php' );
124
+		include_once(dirname(__FILE__) . '/includes/class-wc-stripe-api.php');
125
+		include_once(dirname(__FILE__) . '/includes/class-wc-stripe-customer.php');
126 126
 
127 127
 		// Init the gateway itself
128 128
 		$this->init_gateways();
129 129
 
130
-		add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
131
-		add_action( 'woocommerce_order_status_on-hold_to_processing', array( $this, 'capture_payment' ) );
132
-		add_action( 'woocommerce_order_status_on-hold_to_completed', array( $this, 'capture_payment' ) );
133
-		add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'cancel_payment' ) );
134
-		add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'cancel_payment' ) );
135
-		add_filter( 'woocommerce_get_customer_payment_tokens', array( $this, 'woocommerce_get_customer_payment_tokens' ), 10, 3 );
136
-		add_action( 'woocommerce_payment_token_deleted', array( $this, 'woocommerce_payment_token_deleted' ), 10, 2 );
137
-		add_action( 'woocommerce_payment_token_set_default', array( $this, 'woocommerce_payment_token_set_default' ) );
130
+		add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
131
+		add_action('woocommerce_order_status_on-hold_to_processing', array($this, 'capture_payment'));
132
+		add_action('woocommerce_order_status_on-hold_to_completed', array($this, 'capture_payment'));
133
+		add_action('woocommerce_order_status_on-hold_to_cancelled', array($this, 'cancel_payment'));
134
+		add_action('woocommerce_order_status_on-hold_to_refunded', array($this, 'cancel_payment'));
135
+		add_filter('woocommerce_get_customer_payment_tokens', array($this, 'woocommerce_get_customer_payment_tokens'), 10, 3);
136
+		add_action('woocommerce_payment_token_deleted', array($this, 'woocommerce_payment_token_deleted'), 10, 2);
137
+		add_action('woocommerce_payment_token_set_default', array($this, 'woocommerce_payment_token_set_default'));
138 138
 	}
139 139
 
140 140
 	/**
141 141
 	 * Allow this class and other classes to add slug keyed notices (to avoid duplication)
142 142
 	 */
143
-	public function add_admin_notice( $slug, $class, $message ) {
144
-		$this->notices[ $slug ] = array(
143
+	public function add_admin_notice($slug, $class, $message) {
144
+		$this->notices[$slug] = array(
145 145
 			'class'   => $class,
146 146
 			'message' => $message
147 147
 		);
@@ -154,21 +154,21 @@  discard block
 block discarded – undo
154 154
 	public function check_environment() {
155 155
 		$environment_warning = self::get_environment_warning();
156 156
 
157
-		if ( $environment_warning && is_plugin_active( plugin_basename( __FILE__ ) ) ) {
158
-			$this->add_admin_notice( 'bad_environment', 'error', $environment_warning );
157
+		if ($environment_warning && is_plugin_active(plugin_basename(__FILE__))) {
158
+			$this->add_admin_notice('bad_environment', 'error', $environment_warning);
159 159
 		}
160 160
 
161 161
 		// Check if secret key present. Otherwise prompt, via notice, to go to
162 162
 		// setting.
163
-		if ( ! class_exists( 'WC_Stripe_API' ) ) {
164
-			include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php' );
163
+		if ( ! class_exists('WC_Stripe_API')) {
164
+			include_once(dirname(__FILE__) . '/includes/class-wc-stripe-api.php');
165 165
 		}
166 166
 
167 167
 		$secret = WC_Stripe_API::get_secret_key();
168 168
 
169
-		if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) {
169
+		if (empty($secret) && ! (isset($_GET['page'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'])) {
170 170
 			$setting_link = $this->get_setting_link();
171
-			$this->add_admin_notice( 'prompt_connect', 'notice notice-warning', sprintf( __( 'Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ) );
171
+			$this->add_admin_notice('prompt_connect', 'notice notice-warning', sprintf(__('Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link));
172 172
 		}
173 173
 	}
174 174
 
@@ -177,24 +177,24 @@  discard block
 block discarded – undo
177 177
 	 * found or false if the environment has no problems.
178 178
 	 */
179 179
 	static function get_environment_warning() {
180
-		if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) {
181
-			$message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe', 'woocommerce-gateway-stripe' );
180
+		if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) {
181
+			$message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe', 'woocommerce-gateway-stripe');
182 182
 
183
-			return sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() );
183
+			return sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion());
184 184
 		}
185 185
 		
186
-		if ( ! defined( 'WC_VERSION' ) ) {
187
-			return __( 'WooCommerce Stripe requires WooCommerce to be activated to work.', 'woocommerce-gateway-stripe' );
186
+		if ( ! defined('WC_VERSION')) {
187
+			return __('WooCommerce Stripe requires WooCommerce to be activated to work.', 'woocommerce-gateway-stripe');
188 188
 		} 
189 189
 
190
-		if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) {
191
-			$message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe', 'woocommerce-gateway-stripe' );
190
+		if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) {
191
+			$message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe', 'woocommerce-gateway-stripe');
192 192
 
193
-			return sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION );
193
+			return sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION);
194 194
 		}
195 195
 
196
-		if ( ! function_exists( 'curl_init' ) ) {
197
-			return __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' );
196
+		if ( ! function_exists('curl_init')) {
197
+			return __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe');
198 198
 		}
199 199
 
200 200
 		return false;
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @since 1.0.0
207 207
 	 */
208
-	public function plugin_action_links( $links ) {
208
+	public function plugin_action_links($links) {
209 209
 		$setting_link = $this->get_setting_link();
210 210
 
211 211
 		$plugin_links = array(
212
-			'<a href="' . $setting_link . '">' . __( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
213
-			'<a href="https://docs.woothemes.com/document/stripe/">' . __( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>',
214
-			'<a href="http://support.woothemes.com/">' . __( 'Support', 'woocommerce-gateway-stripe' ) . '</a>',
212
+			'<a href="' . $setting_link . '">' . __('Settings', 'woocommerce-gateway-stripe') . '</a>',
213
+			'<a href="https://docs.woothemes.com/document/stripe/">' . __('Docs', 'woocommerce-gateway-stripe') . '</a>',
214
+			'<a href="http://support.woothemes.com/">' . __('Support', 'woocommerce-gateway-stripe') . '</a>',
215 215
 		);
216
-		return array_merge( $plugin_links, $links );
216
+		return array_merge($plugin_links, $links);
217 217
 	}
218 218
 
219 219
 	/**
@@ -224,20 +224,20 @@  discard block
 block discarded – undo
224 224
 	 * @return string Setting link
225 225
 	 */
226 226
 	public function get_setting_link() {
227
-		$use_id_as_section = version_compare( WC()->version, '2.6', '>=' );
227
+		$use_id_as_section = version_compare(WC()->version, '2.6', '>=');
228 228
 
229
-		$section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' );
229
+		$section_slug = $use_id_as_section ? 'stripe' : strtolower('WC_Gateway_Stripe');
230 230
 
231
-		return admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . $section_slug );
231
+		return admin_url('admin.php?page=wc-settings&tab=checkout&section=' . $section_slug);
232 232
 	}
233 233
 
234 234
 	/**
235 235
 	 * Display any notices we've collected thus far (e.g. for connection, disconnection)
236 236
 	 */
237 237
 	public function admin_notices() {
238
-		foreach ( (array) $this->notices as $notice_key => $notice ) {
239
-			echo "<div class='" . esc_attr( $notice['class'] ) . "'><p>";
240
-			echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) );
238
+		foreach ((array) $this->notices as $notice_key => $notice) {
239
+			echo "<div class='" . esc_attr($notice['class']) . "'><p>";
240
+			echo wp_kses($notice['message'], array('a' => array('href' => array())));
241 241
 			echo "</p></div>";
242 242
 		}
243 243
 	}
@@ -248,27 +248,27 @@  discard block
 block discarded – undo
248 248
 	 * @since 1.0.0
249 249
 	 */
250 250
 	public function init_gateways() {
251
-		if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) {
251
+		if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) {
252 252
 			$this->subscription_support_enabled = true;
253 253
 		}
254 254
 
255
-		if ( class_exists( 'WC_Pre_Orders_Order' ) ) {
255
+		if (class_exists('WC_Pre_Orders_Order')) {
256 256
 			$this->pre_order_enabled = true;
257 257
 		}
258 258
 
259
-		if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
259
+		if ( ! class_exists('WC_Payment_Gateway')) {
260 260
 			return;
261 261
 		}
262 262
 
263
-		if ( class_exists( 'WC_Payment_Gateway_CC' ) ) {
264
-			include_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php' );
263
+		if (class_exists('WC_Payment_Gateway_CC')) {
264
+			include_once(dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php');
265 265
 		} else {
266
-			include_once( dirname( __FILE__ ) . '/includes/legacy/class-wc-gateway-stripe.php' );
267
-			include_once( dirname( __FILE__ ) . '/includes/legacy/class-wc-gateway-stripe-saved-cards.php' );
266
+			include_once(dirname(__FILE__) . '/includes/legacy/class-wc-gateway-stripe.php');
267
+			include_once(dirname(__FILE__) . '/includes/legacy/class-wc-gateway-stripe-saved-cards.php');
268 268
 		}
269 269
 
270
-		load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
271
-		add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) );
270
+		load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages');
271
+		add_filter('woocommerce_payment_gateways', array($this, 'add_gateways'));
272 272
 
273 273
 		$load_addons = (
274 274
 			$this->subscription_support_enabled
@@ -276,8 +276,8 @@  discard block
 block discarded – undo
276 276
 			$this->pre_order_enabled
277 277
 		);
278 278
 
279
-		if ( $load_addons ) {
280
-			require_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe-addons.php' );
279
+		if ($load_addons) {
280
+			require_once(dirname(__FILE__) . '/includes/class-wc-gateway-stripe-addons.php');
281 281
 		}
282 282
 	}
283 283
 
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
 	 *
287 287
 	 * @since 1.0.0
288 288
 	 */
289
-	public function add_gateways( $methods ) {
290
-		if ( $this->subscription_support_enabled || $this->pre_order_enabled ) {
289
+	public function add_gateways($methods) {
290
+		if ($this->subscription_support_enabled || $this->pre_order_enabled) {
291 291
 			$methods[] = 'WC_Gateway_Stripe_Addons';
292 292
 		} else {
293 293
 			$methods[] = 'WC_Gateway_Stripe';
@@ -300,39 +300,39 @@  discard block
 block discarded – undo
300 300
 	 *
301 301
 	 * @param  int $order_id
302 302
 	 */
303
-	public function capture_payment( $order_id ) {
304
-		$order = wc_get_order( $order_id );
303
+	public function capture_payment($order_id) {
304
+		$order = wc_get_order($order_id);
305 305
 
306
-		if ( 'stripe' === $order->payment_method ) {
307
-			$charge   = get_post_meta( $order_id, '_stripe_charge_id', true );
308
-			$captured = get_post_meta( $order_id, '_stripe_charge_captured', true );
306
+		if ('stripe' === $order->payment_method) {
307
+			$charge   = get_post_meta($order_id, '_stripe_charge_id', true);
308
+			$captured = get_post_meta($order_id, '_stripe_charge_captured', true);
309 309
 
310
-			if ( $charge && 'no' === $captured ) {
311
-				if ( ! defined( 'WOOCOMMERCE_STRIPE_DOING_CAPTURE' ) ) {
310
+			if ($charge && 'no' === $captured) {
311
+				if ( ! defined('WOOCOMMERCE_STRIPE_DOING_CAPTURE')) {
312 312
 					// Allow other extensions hooking the process to know that we're capturing.
313
-					define( 'WOOCOMMERCE_STRIPE_DOING_CAPTURE', true );
313
+					define('WOOCOMMERCE_STRIPE_DOING_CAPTURE', true);
314 314
 				}
315
-				$result = WC_Stripe_API::request( array(
315
+				$result = WC_Stripe_API::request(array(
316 316
 					'amount'   => $order->get_total() * 100,
317 317
 					'expand[]' => 'balance_transaction'
318
-				), 'charges/' . $charge . '/capture' );
318
+				), 'charges/' . $charge . '/capture');
319 319
 
320
-				if ( is_wp_error( $result ) ) {
321
-					$order->add_order_note( __( 'Unable to capture charge!', 'woocommerce-gateway-stripe' ) . ' ' . $result->get_error_message() );
320
+				if (is_wp_error($result)) {
321
+					$order->add_order_note(__('Unable to capture charge!', 'woocommerce-gateway-stripe') . ' ' . $result->get_error_message());
322 322
 				} else {
323
-					$order->add_order_note( sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $result->id ) );
324
-					update_post_meta( $order->id, '_stripe_charge_captured', 'yes' );
323
+					$order->add_order_note(sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $result->id));
324
+					update_post_meta($order->id, '_stripe_charge_captured', 'yes');
325 325
 
326 326
 					// Store other data such as fees
327
-					update_post_meta( $order->id, 'Stripe Payment ID', $result->id );
327
+					update_post_meta($order->id, 'Stripe Payment ID', $result->id);
328 328
 
329
-					if ( isset( $result->balance_transaction ) && isset( $result->balance_transaction->fee ) ) {
329
+					if (isset($result->balance_transaction) && isset($result->balance_transaction->fee)) {
330 330
 						// Fees and Net needs to both come from Stripe to be accurate as the returned
331 331
 						// values are in the local currency of the Stripe account, not from WC.
332
-						$fee = ! empty( $result->balance_transaction->fee ) ? number_format( $result->balance_transaction->fee / 100, 2, '.', '' ) : 0;
333
-						$net = ! empty( $result->balance_transaction->net ) ? number_format( $result->balance_transaction->net / 100, 2, '.', '' ) : 0;
334
-						update_post_meta( $order->id, 'Stripe Fee', $fee );
335
-						update_post_meta( $order->id, 'Net Revenue From Stripe', $net );
332
+						$fee = ! empty($result->balance_transaction->fee) ? number_format($result->balance_transaction->fee / 100, 2, '.', '') : 0;
333
+						$net = ! empty($result->balance_transaction->net) ? number_format($result->balance_transaction->net / 100, 2, '.', '') : 0;
334
+						update_post_meta($order->id, 'Stripe Fee', $fee);
335
+						update_post_meta($order->id, 'Net Revenue From Stripe', $net);
336 336
 					}
337 337
 				}
338 338
 			}
@@ -344,23 +344,23 @@  discard block
 block discarded – undo
344 344
 	 *
345 345
 	 * @param  int $order_id
346 346
 	 */
347
-	public function cancel_payment( $order_id ) {
348
-		$order = wc_get_order( $order_id );
347
+	public function cancel_payment($order_id) {
348
+		$order = wc_get_order($order_id);
349 349
 
350
-		if ( 'stripe' === $order->payment_method ) {
351
-			$charge   = get_post_meta( $order_id, '_stripe_charge_id', true );
350
+		if ('stripe' === $order->payment_method) {
351
+			$charge = get_post_meta($order_id, '_stripe_charge_id', true);
352 352
 
353
-			if ( $charge ) {
354
-				$result = WC_Stripe_API::request( array(
353
+			if ($charge) {
354
+				$result = WC_Stripe_API::request(array(
355 355
 					'amount' => $order->get_total() * 100,
356
-				), 'charges/' . $charge . '/refund' );
356
+				), 'charges/' . $charge . '/refund');
357 357
 
358
-				if ( is_wp_error( $result ) ) {
359
-					$order->add_order_note( __( 'Unable to refund charge!', 'woocommerce-gateway-stripe' ) . ' ' . $result->get_error_message() );
358
+				if (is_wp_error($result)) {
359
+					$order->add_order_note(__('Unable to refund charge!', 'woocommerce-gateway-stripe') . ' ' . $result->get_error_message());
360 360
 				} else {
361
-					$order->add_order_note( sprintf( __( 'Stripe charge refunded (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $result->id ) );
362
-					delete_post_meta( $order->id, '_stripe_charge_captured' );
363
-					delete_post_meta( $order->id, '_stripe_charge_id' );
361
+					$order->add_order_note(sprintf(__('Stripe charge refunded (Charge ID: %s)', 'woocommerce-gateway-stripe'), $result->id));
362
+					delete_post_meta($order->id, '_stripe_charge_captured');
363
+					delete_post_meta($order->id, '_stripe_charge_id');
364 364
 				}
365 365
 			}
366 366
 		}
@@ -371,28 +371,28 @@  discard block
 block discarded – undo
371 371
 	 * @param array $tokens
372 372
 	 * @return array
373 373
 	 */
374
-	public function woocommerce_get_customer_payment_tokens( $tokens, $customer_id, $gateway_id ) {
375
-		if ( is_user_logged_in() && 'stripe' === $gateway_id && class_exists( 'WC_Payment_Token_CC' ) ) {
376
-			$stripe_customer = new WC_Stripe_Customer( $customer_id );
374
+	public function woocommerce_get_customer_payment_tokens($tokens, $customer_id, $gateway_id) {
375
+		if (is_user_logged_in() && 'stripe' === $gateway_id && class_exists('WC_Payment_Token_CC')) {
376
+			$stripe_customer = new WC_Stripe_Customer($customer_id);
377 377
 			$stripe_cards    = $stripe_customer->get_cards();
378 378
 			$stored_tokens   = array();
379 379
 
380
-			foreach ( $tokens as $token ) {
380
+			foreach ($tokens as $token) {
381 381
 				$stored_tokens[] = $token->get_token();
382 382
 			}
383 383
 
384
-			foreach ( $stripe_cards as $card ) {
385
-				if ( ! in_array( $card->id, $stored_tokens ) ) {
384
+			foreach ($stripe_cards as $card) {
385
+				if ( ! in_array($card->id, $stored_tokens)) {
386 386
 					$token = new WC_Payment_Token_CC();
387
-					$token->set_token( $card->id );
388
-					$token->set_gateway_id( 'stripe' );
389
-					$token->set_card_type( strtolower( $card->brand ) );
390
-					$token->set_last4( $card->last4 );
391
-					$token->set_expiry_month( $card->exp_month  );
392
-					$token->set_expiry_year( $card->exp_year );
393
-					$token->set_user_id( $customer_id );
387
+					$token->set_token($card->id);
388
+					$token->set_gateway_id('stripe');
389
+					$token->set_card_type(strtolower($card->brand));
390
+					$token->set_last4($card->last4);
391
+					$token->set_expiry_month($card->exp_month);
392
+					$token->set_expiry_year($card->exp_year);
393
+					$token->set_user_id($customer_id);
394 394
 					$token->save();
395
-					$tokens[ $token->get_id() ] = $token;
395
+					$tokens[$token->get_id()] = $token;
396 396
 				}
397 397
 			}
398 398
 		}
@@ -402,21 +402,21 @@  discard block
 block discarded – undo
402 402
 	/**
403 403
 	 * Delete token from Stripe
404 404
 	 */
405
-	public function woocommerce_payment_token_deleted( $token_id, $token ) {
406
-		if ( 'stripe' === $token->get_gateway_id() ) {
407
-			$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
408
-			$stripe_customer->delete_card( $token->get_token() );
405
+	public function woocommerce_payment_token_deleted($token_id, $token) {
406
+		if ('stripe' === $token->get_gateway_id()) {
407
+			$stripe_customer = new WC_Stripe_Customer(get_current_user_id());
408
+			$stripe_customer->delete_card($token->get_token());
409 409
 		}
410 410
 	}
411 411
 
412 412
 	/**
413 413
 	 * Set as default in Stripe
414 414
 	 */
415
-	public function woocommerce_payment_token_set_default( $token_id ) {
416
-		$token = WC_Payment_Tokens::get( $token_id );
417
-		if ( 'stripe' === $token->get_gateway_id() ) {
418
-			$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
419
-			$stripe_customer->set_default_card( $token->get_token() );
415
+	public function woocommerce_payment_token_set_default($token_id) {
416
+		$token = WC_Payment_Tokens::get($token_id);
417
+		if ('stripe' === $token->get_gateway_id()) {
418
+			$stripe_customer = new WC_Stripe_Customer(get_current_user_id());
419
+			$stripe_customer->set_default_card($token->get_token());
420 420
 		}
421 421
 	}
422 422
 
@@ -428,15 +428,15 @@  discard block
 block discarded – undo
428 428
 	 * And fits on your back?
429 429
 	 * It's log, log, log
430 430
 	 */
431
-	public static function log( $message ) {
432
-		if ( empty( self::$log ) ) {
431
+	public static function log($message) {
432
+		if (empty(self::$log)) {
433 433
 			self::$log = new WC_Logger();
434 434
 		}
435 435
 
436
-		self::$log->add( 'woocommerce-gateway-stripe', $message );
436
+		self::$log->add('woocommerce-gateway-stripe', $message);
437 437
 
438
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
439
-			error_log( $message );
438
+		if (defined('WP_DEBUG') && WP_DEBUG) {
439
+			error_log($message);
440 440
 		}
441 441
 	}
442 442
 }
Please login to merge, or discard this patch.