@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function __construct() { |
115 | 115 | $this->id = 'stripe'; |
116 | - $this->method_title = __( 'Stripe', 'woocommerce-gateway-stripe' ); |
|
117 | - $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' ); |
|
116 | + $this->method_title = __('Stripe', 'woocommerce-gateway-stripe'); |
|
117 | + $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'); |
|
118 | 118 | $this->has_fields = true; |
119 | 119 | $this->view_transaction_url = 'https://dashboard.stripe.com/payments/%s'; |
120 | 120 | $this->supports = array( |
@@ -142,42 +142,42 @@ discard block |
||
142 | 142 | $this->init_settings(); |
143 | 143 | |
144 | 144 | // Get setting values. |
145 | - $this->title = $this->get_option( 'title' ); |
|
146 | - $this->description = $this->get_option( 'description' ); |
|
147 | - $this->enabled = $this->get_option( 'enabled' ); |
|
148 | - $this->testmode = 'yes' === $this->get_option( 'testmode' ); |
|
149 | - $this->capture = 'yes' === $this->get_option( 'capture', 'yes' ); |
|
150 | - $this->statement_descriptor = $this->get_option( 'statement_descriptor', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
151 | - $this->stripe_checkout = 'yes' === $this->get_option( 'stripe_checkout' ); |
|
152 | - $this->stripe_checkout_locale = $this->get_option( 'stripe_checkout_locale' ); |
|
153 | - $this->stripe_checkout_image = $this->get_option( 'stripe_checkout_image', '' ); |
|
154 | - $this->saved_cards = 'yes' === $this->get_option( 'saved_cards' ); |
|
155 | - $this->secret_key = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' ); |
|
156 | - $this->publishable_key = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' ); |
|
157 | - $this->bitcoin = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' ); |
|
158 | - $this->apple_pay = 'yes' === $this->get_option( 'apple_pay', 'yes' ); |
|
159 | - $this->apple_pay_domain_set = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' ); |
|
160 | - $this->apple_pay_button = $this->get_option( 'apple_pay_button', 'black' ); |
|
161 | - $this->logging = 'yes' === $this->get_option( 'logging' ); |
|
162 | - |
|
163 | - if ( $this->stripe_checkout ) { |
|
164 | - $this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' ); |
|
165 | - } |
|
166 | - |
|
167 | - if ( $this->testmode ) { |
|
168 | - $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' ); |
|
169 | - $this->description = trim( $this->description ); |
|
170 | - } |
|
171 | - |
|
172 | - WC_Stripe_API::set_secret_key( $this->secret_key ); |
|
145 | + $this->title = $this->get_option('title'); |
|
146 | + $this->description = $this->get_option('description'); |
|
147 | + $this->enabled = $this->get_option('enabled'); |
|
148 | + $this->testmode = 'yes' === $this->get_option('testmode'); |
|
149 | + $this->capture = 'yes' === $this->get_option('capture', 'yes'); |
|
150 | + $this->statement_descriptor = $this->get_option('statement_descriptor', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
151 | + $this->stripe_checkout = 'yes' === $this->get_option('stripe_checkout'); |
|
152 | + $this->stripe_checkout_locale = $this->get_option('stripe_checkout_locale'); |
|
153 | + $this->stripe_checkout_image = $this->get_option('stripe_checkout_image', ''); |
|
154 | + $this->saved_cards = 'yes' === $this->get_option('saved_cards'); |
|
155 | + $this->secret_key = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key'); |
|
156 | + $this->publishable_key = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key'); |
|
157 | + $this->bitcoin = 'USD' === strtoupper(get_woocommerce_currency()) && 'yes' === $this->get_option('stripe_bitcoin'); |
|
158 | + $this->apple_pay = 'yes' === $this->get_option('apple_pay', 'yes'); |
|
159 | + $this->apple_pay_domain_set = 'yes' === $this->get_option('apple_pay_domain_set', 'no'); |
|
160 | + $this->apple_pay_button = $this->get_option('apple_pay_button', 'black'); |
|
161 | + $this->logging = 'yes' === $this->get_option('logging'); |
|
162 | + |
|
163 | + if ($this->stripe_checkout) { |
|
164 | + $this->order_button_text = __('Continue to payment', 'woocommerce-gateway-stripe'); |
|
165 | + } |
|
166 | + |
|
167 | + if ($this->testmode) { |
|
168 | + $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'); |
|
169 | + $this->description = trim($this->description); |
|
170 | + } |
|
171 | + |
|
172 | + WC_Stripe_API::set_secret_key($this->secret_key); |
|
173 | 173 | |
174 | 174 | $this->init_apple_pay(); |
175 | 175 | |
176 | 176 | // Hooks. |
177 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
178 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); |
|
179 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
180 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
177 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
178 | + add_action('admin_enqueue_scripts', array($this, 'admin_scripts')); |
|
179 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
180 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -187,24 +187,24 @@ discard block |
||
187 | 187 | * @return string |
188 | 188 | */ |
189 | 189 | public function get_icon() { |
190 | - $ext = version_compare( WC()->version, '2.6', '>=' ) ? '.svg' : '.png'; |
|
191 | - $style = version_compare( WC()->version, '2.6', '>=' ) ? 'style="margin-left: 0.3em"' : ''; |
|
190 | + $ext = version_compare(WC()->version, '2.6', '>=') ? '.svg' : '.png'; |
|
191 | + $style = version_compare(WC()->version, '2.6', '>=') ? 'style="margin-left: 0.3em"' : ''; |
|
192 | 192 | |
193 | - $icon = '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/visa' . $ext ) . '" alt="Visa" width="32" ' . $style . ' />'; |
|
194 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard' . $ext ) . '" alt="Mastercard" width="32" ' . $style . ' />'; |
|
195 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/amex' . $ext ) . '" alt="Amex" width="32" ' . $style . ' />'; |
|
193 | + $icon = '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/visa' . $ext) . '" alt="Visa" width="32" ' . $style . ' />'; |
|
194 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard' . $ext) . '" alt="Mastercard" width="32" ' . $style . ' />'; |
|
195 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/amex' . $ext) . '" alt="Amex" width="32" ' . $style . ' />'; |
|
196 | 196 | |
197 | - if ( 'USD' === get_woocommerce_currency() ) { |
|
198 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/discover' . $ext ) . '" alt="Discover" width="32" ' . $style . ' />'; |
|
199 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb' . $ext ) . '" alt="JCB" width="32" ' . $style . ' />'; |
|
200 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/diners' . $ext ) . '" alt="Diners" width="32" ' . $style . ' />'; |
|
197 | + if ('USD' === get_woocommerce_currency()) { |
|
198 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/discover' . $ext) . '" alt="Discover" width="32" ' . $style . ' />'; |
|
199 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb' . $ext) . '" alt="JCB" width="32" ' . $style . ' />'; |
|
200 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/diners' . $ext) . '" alt="Diners" width="32" ' . $style . ' />'; |
|
201 | 201 | } |
202 | 202 | |
203 | - if ( $this->bitcoin && $this->stripe_checkout ) { |
|
204 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( plugins_url( '/assets/images/bitcoin' . $ext, WC_STRIPE_MAIN_FILE ) ) . '" alt="Bitcoin" width="24" ' . $style . ' />'; |
|
203 | + if ($this->bitcoin && $this->stripe_checkout) { |
|
204 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(plugins_url('/assets/images/bitcoin' . $ext, WC_STRIPE_MAIN_FILE)) . '" alt="Bitcoin" width="24" ' . $style . ' />'; |
|
205 | 205 | } |
206 | 206 | |
207 | - return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id ); |
|
207 | + return apply_filters('woocommerce_gateway_icon', $icon, $this->id); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return float|int |
217 | 217 | */ |
218 | - public function get_stripe_amount( $total, $currency = '' ) { |
|
219 | - if ( ! $currency ) { |
|
218 | + public function get_stripe_amount($total, $currency = '') { |
|
219 | + if ( ! $currency) { |
|
220 | 220 | $currency = get_woocommerce_currency(); |
221 | 221 | } |
222 | - switch ( strtoupper( $currency ) ) { |
|
222 | + switch (strtoupper($currency)) { |
|
223 | 223 | // Zero decimal currencies. |
224 | 224 | case 'BIF' : |
225 | 225 | case 'CLP' : |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | case 'XAF' : |
237 | 237 | case 'XOF' : |
238 | 238 | case 'XPF' : |
239 | - $total = absint( $total ); |
|
239 | + $total = absint($total); |
|
240 | 240 | break; |
241 | 241 | default : |
242 | - $total = round( $total, 2 ) * 100; // In cents. |
|
242 | + $total = round($total, 2) * 100; // In cents. |
|
243 | 243 | break; |
244 | 244 | } |
245 | 245 | return $total; |
@@ -254,9 +254,9 @@ discard block |
||
254 | 254 | public function init_apple_pay() { |
255 | 255 | if ( |
256 | 256 | is_admin() && |
257 | - isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] && |
|
258 | - isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'] && |
|
259 | - isset( $_GET['section'] ) && 'stripe' === $_GET['section'] |
|
257 | + isset($_GET['page']) && 'wc-settings' === $_GET['page'] && |
|
258 | + isset($_GET['tab']) && 'checkout' === $_GET['tab'] && |
|
259 | + isset($_GET['section']) && 'stripe' === $_GET['section'] |
|
260 | 260 | ) { |
261 | 261 | $this->process_apple_pay_verification(); |
262 | 262 | } |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | * @version 3.1.0 |
270 | 270 | * @param string $secret_key |
271 | 271 | */ |
272 | - private function _register_apple_pay_domain( $secret_key = '' ) { |
|
273 | - if ( empty( $secret_key ) ) { |
|
274 | - throw new Exception( __( 'Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe' ) ); |
|
272 | + private function _register_apple_pay_domain($secret_key = '') { |
|
273 | + if (empty($secret_key)) { |
|
274 | + throw new Exception(__('Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe')); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | $endpoint = 'https://api.stripe.com/v1/apple_pay/domains'; |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | 'Authorization' => 'Bearer ' . $secret_key, |
286 | 286 | ); |
287 | 287 | |
288 | - $response = wp_remote_post( $endpoint, array( |
|
288 | + $response = wp_remote_post($endpoint, array( |
|
289 | 289 | 'headers' => $headers, |
290 | - 'body' => http_build_query( $data ), |
|
291 | - ) ); |
|
290 | + 'body' => http_build_query($data), |
|
291 | + )); |
|
292 | 292 | |
293 | - if ( 200 !== $response['response']['code'] ) { |
|
294 | - throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response['response']['message'] ) ); |
|
293 | + if (200 !== $response['response']['code']) { |
|
294 | + throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $response['response']['message'])); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
@@ -302,48 +302,48 @@ discard block |
||
302 | 302 | * @version 3.1.0 |
303 | 303 | */ |
304 | 304 | public function process_apple_pay_verification() { |
305 | - $gateway_settings = get_option( 'woocommerce_stripe_settings', '' ); |
|
305 | + $gateway_settings = get_option('woocommerce_stripe_settings', ''); |
|
306 | 306 | |
307 | 307 | try { |
308 | - $path = untrailingslashit( preg_replace( "!${_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME'] ) ); |
|
308 | + $path = untrailingslashit(preg_replace("!${_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME'])); |
|
309 | 309 | $dir = '.well-known'; |
310 | 310 | $file = 'apple-developer-merchantid-domain-association'; |
311 | 311 | $fullpath = $path . '/' . $dir . '/' . $file; |
312 | 312 | |
313 | - if ( ! empty( $gateway_settings['apple_pay_domain_set'] ) && 'yes' === $gateway_settings['apple_pay_domain_set'] && file_exists( $fullpath ) ) { |
|
313 | + if ( ! empty($gateway_settings['apple_pay_domain_set']) && 'yes' === $gateway_settings['apple_pay_domain_set'] && file_exists($fullpath)) { |
|
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | - if ( ! file_exists( $path . '/' . $dir ) ) { |
|
318 | - if ( ! @mkdir( $path . '/' . $dir, 0755 ) ) { |
|
319 | - throw new Exception( __( 'Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe' ) ); |
|
317 | + if ( ! file_exists($path . '/' . $dir)) { |
|
318 | + if ( ! @mkdir($path . '/' . $dir, 0755)) { |
|
319 | + throw new Exception(__('Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe')); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - if ( ! file_exists( $fullpath ) ) { |
|
324 | - if ( ! @copy( WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath ) ) { |
|
325 | - throw new Exception( __( 'Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe' ) ); |
|
323 | + if ( ! file_exists($fullpath)) { |
|
324 | + if ( ! @copy(WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath)) { |
|
325 | + throw new Exception(__('Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe')); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | 329 | // At this point then the domain association folder and file should be available. |
330 | 330 | // Proceed to verify/and or verify again. |
331 | - $this->_register_apple_pay_domain( $this->secret_key ); |
|
331 | + $this->_register_apple_pay_domain($this->secret_key); |
|
332 | 332 | |
333 | 333 | // No errors to this point, verification success! |
334 | 334 | $gateway_settings['apple_pay_domain_set'] = 'yes'; |
335 | 335 | $this->apple_pay_domain_set = true; |
336 | 336 | |
337 | - update_option( 'woocommerce_stripe_settings', $gateway_settings ); |
|
337 | + update_option('woocommerce_stripe_settings', $gateway_settings); |
|
338 | 338 | |
339 | - $this->log( __( 'Your domain has been verified with Apple Pay!', 'woocommerce-gateway-stripe' ) ); |
|
339 | + $this->log(__('Your domain has been verified with Apple Pay!', 'woocommerce-gateway-stripe')); |
|
340 | 340 | |
341 | - } catch ( Exception $e ) { |
|
341 | + } catch (Exception $e) { |
|
342 | 342 | $gateway_settings['apple_pay_domain_set'] = 'no'; |
343 | 343 | |
344 | - update_option( 'woocommerce_stripe_settings', $gateway_settings ); |
|
344 | + update_option('woocommerce_stripe_settings', $gateway_settings); |
|
345 | 345 | |
346 | - $this->log( sprintf( __( 'Error: %s', 'woocommerce-gateway-stripe' ), $e->getMessage() ) ); |
|
346 | + $this->log(sprintf(__('Error: %s', 'woocommerce-gateway-stripe'), $e->getMessage())); |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * Check if SSL is enabled and notify the user |
352 | 352 | */ |
353 | 353 | public function admin_notices() { |
354 | - if ( 'no' === $this->enabled ) { |
|
354 | + if ('no' === $this->enabled) { |
|
355 | 355 | return; |
356 | 356 | } |
357 | 357 | |
@@ -360,13 +360,13 @@ discard block |
||
360 | 360 | * when setting screen is displayed. So if domain verification is not set, |
361 | 361 | * something went wrong so lets notify user. |
362 | 362 | */ |
363 | - if ( ! empty( $this->secret_key ) && $this->apple_pay && ! $this->apple_pay_domain_set ) { |
|
364 | - echo '<div class="error stripe-apple-pay-message"><p>' . sprintf( __( 'Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe' ), '<a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">', '</a>' ) . '</p></div>'; |
|
363 | + if ( ! empty($this->secret_key) && $this->apple_pay && ! $this->apple_pay_domain_set) { |
|
364 | + echo '<div class="error stripe-apple-pay-message"><p>' . sprintf(__('Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe'), '<a href="' . admin_url('admin.php?page=wc-status&tab=logs') . '">', '</a>') . '</p></div>'; |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | // Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected. |
368 | - if ( ( function_exists( 'wc_site_is_https' ) && ! wc_site_is_https() ) && ( 'no' === get_option( 'woocommerce_force_ssl_checkout' ) && ! class_exists( 'WordPressHTTPS' ) ) ) { |
|
369 | - 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>'; |
|
368 | + if ((function_exists('wc_site_is_https') && ! wc_site_is_https()) && ('no' === get_option('woocommerce_force_ssl_checkout') && ! class_exists('WordPressHTTPS'))) { |
|
369 | + 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>'; |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
@@ -374,11 +374,11 @@ discard block |
||
374 | 374 | * Check if this gateway is enabled |
375 | 375 | */ |
376 | 376 | public function is_available() { |
377 | - if ( 'yes' === $this->enabled ) { |
|
378 | - if ( ! $this->testmode && is_checkout() && ! is_ssl() ) { |
|
377 | + if ('yes' === $this->enabled) { |
|
378 | + if ( ! $this->testmode && is_checkout() && ! is_ssl()) { |
|
379 | 379 | return false; |
380 | 380 | } |
381 | - if ( ! $this->secret_key || ! $this->publishable_key ) { |
|
381 | + if ( ! $this->secret_key || ! $this->publishable_key) { |
|
382 | 382 | return false; |
383 | 383 | } |
384 | 384 | return true; |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * Initialise Gateway Settings Form Fields |
391 | 391 | */ |
392 | 392 | public function init_form_fields() { |
393 | - $this->form_fields = include( 'settings-stripe.php' ); |
|
393 | + $this->form_fields = include('settings-stripe.php'); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -398,54 +398,54 @@ discard block |
||
398 | 398 | */ |
399 | 399 | public function payment_fields() { |
400 | 400 | $user = wp_get_current_user(); |
401 | - $display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards; |
|
401 | + $display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards; |
|
402 | 402 | $total = WC()->cart->total; |
403 | 403 | |
404 | 404 | // If paying from order, we need to get total from order not cart. |
405 | - if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
406 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
405 | + if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
406 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
407 | 407 | $total = $order->get_total(); |
408 | 408 | } |
409 | 409 | |
410 | - if ( $user->ID ) { |
|
411 | - $user_email = get_user_meta( $user->ID, 'billing_email', true ); |
|
410 | + if ($user->ID) { |
|
411 | + $user_email = get_user_meta($user->ID, 'billing_email', true); |
|
412 | 412 | $user_email = $user_email ? $user_email : $user->user_email; |
413 | 413 | } else { |
414 | 414 | $user_email = ''; |
415 | 415 | } |
416 | 416 | |
417 | - if ( is_add_payment_method_page() ) { |
|
418 | - $pay_button_text = __( 'Add Card', 'woocommerce-gateway-stripe' ); |
|
417 | + if (is_add_payment_method_page()) { |
|
418 | + $pay_button_text = __('Add Card', 'woocommerce-gateway-stripe'); |
|
419 | 419 | } else { |
420 | 420 | $pay_button_text = ''; |
421 | 421 | } |
422 | 422 | |
423 | 423 | echo '<div |
424 | 424 | id="stripe-payment-data" |
425 | - data-panel-label="' . esc_attr( $pay_button_text ) . '" |
|
425 | + data-panel-label="' . esc_attr($pay_button_text) . '" |
|
426 | 426 | data-description="" |
427 | - data-email="' . esc_attr( $user_email ) . '" |
|
428 | - data-amount="' . esc_attr( $this->get_stripe_amount( $total ) ) . '" |
|
429 | - data-name="' . esc_attr( $this->statement_descriptor ) . '" |
|
430 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '" |
|
431 | - data-image="' . esc_attr( $this->stripe_checkout_image ) . '" |
|
432 | - data-bitcoin="' . esc_attr( $this->bitcoin ? 'true' : 'false' ) . '" |
|
433 | - data-locale="' . esc_attr( $this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en' ) . '" |
|
434 | - data-allow-remember-me="' . esc_attr( $this->saved_cards ? 'true' : 'false' ) . '">'; |
|
427 | + data-email="' . esc_attr($user_email) . '" |
|
428 | + data-amount="' . esc_attr($this->get_stripe_amount($total)) . '" |
|
429 | + data-name="' . esc_attr($this->statement_descriptor) . '" |
|
430 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '" |
|
431 | + data-image="' . esc_attr($this->stripe_checkout_image) . '" |
|
432 | + data-bitcoin="' . esc_attr($this->bitcoin ? 'true' : 'false') . '" |
|
433 | + data-locale="' . esc_attr($this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en') . '" |
|
434 | + data-allow-remember-me="' . esc_attr($this->saved_cards ? 'true' : 'false') . '">'; |
|
435 | 435 | |
436 | - if ( $this->description ) { |
|
437 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) ); |
|
436 | + if ($this->description) { |
|
437 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description))); |
|
438 | 438 | } |
439 | 439 | |
440 | - if ( $display_tokenization ) { |
|
440 | + if ($display_tokenization) { |
|
441 | 441 | $this->tokenization_script(); |
442 | 442 | $this->saved_payment_methods(); |
443 | 443 | } |
444 | 444 | |
445 | - if ( ! $this->stripe_checkout ) { |
|
445 | + if ( ! $this->stripe_checkout) { |
|
446 | 446 | $this->form(); |
447 | 447 | |
448 | - if ( $display_tokenization ) { |
|
448 | + if ($display_tokenization) { |
|
449 | 449 | $this->save_payment_method_checkbox(); |
450 | 450 | } |
451 | 451 | } |
@@ -461,20 +461,20 @@ discard block |
||
461 | 461 | * @return array |
462 | 462 | */ |
463 | 463 | public function get_localized_messages() { |
464 | - return apply_filters( 'wc_stripe_localized_messages', array( |
|
465 | - 'invalid_number' => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ), |
|
466 | - 'invalid_expiry_month' => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ), |
|
467 | - 'invalid_expiry_year' => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ), |
|
468 | - 'invalid_cvc' => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ), |
|
469 | - 'incorrect_number' => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ), |
|
470 | - 'expired_card' => __( 'The card has expired.', 'woocommerce-gateway-stripe' ), |
|
471 | - 'incorrect_cvc' => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ), |
|
472 | - 'incorrect_zip' => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ), |
|
473 | - 'card_declined' => __( 'The card was declined.', 'woocommerce-gateway-stripe' ), |
|
474 | - 'missing' => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ), |
|
475 | - 'processing_error' => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ), |
|
476 | - 'invalid_request_error' => __( 'Could not find payment information.', 'woocommerce-gateway-stripe' ), |
|
477 | - ) ); |
|
464 | + return apply_filters('wc_stripe_localized_messages', array( |
|
465 | + 'invalid_number' => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'), |
|
466 | + 'invalid_expiry_month' => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'), |
|
467 | + 'invalid_expiry_year' => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'), |
|
468 | + 'invalid_cvc' => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'), |
|
469 | + 'incorrect_number' => __('The card number is incorrect.', 'woocommerce-gateway-stripe'), |
|
470 | + 'expired_card' => __('The card has expired.', 'woocommerce-gateway-stripe'), |
|
471 | + 'incorrect_cvc' => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'), |
|
472 | + 'incorrect_zip' => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'), |
|
473 | + 'card_declined' => __('The card was declined.', 'woocommerce-gateway-stripe'), |
|
474 | + 'missing' => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'), |
|
475 | + 'processing_error' => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'), |
|
476 | + 'invalid_request_error' => __('Could not find payment information.', 'woocommerce-gateway-stripe'), |
|
477 | + )); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
@@ -484,28 +484,28 @@ discard block |
||
484 | 484 | * @version 3.1.0 |
485 | 485 | */ |
486 | 486 | public function admin_scripts() { |
487 | - if ( 'woocommerce_page_wc-settings' !== get_current_screen()->id ) { |
|
487 | + if ('woocommerce_page_wc-settings' !== get_current_screen()->id) { |
|
488 | 488 | return; |
489 | 489 | } |
490 | 490 | |
491 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
491 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
492 | 492 | |
493 | - wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true ); |
|
493 | + wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true); |
|
494 | 494 | |
495 | 495 | $stripe_admin_params = array( |
496 | 496 | 'localized_messages' => array( |
497 | - 'not_valid_live_key_msg' => __( 'This is not a valid live key. Live keys start with "sk_live_" and "pk_live_".', 'woocommerce-gateway-stripe' ), |
|
498 | - 'not_valid_test_key_msg' => __( 'This is not a valid test key. Test keys start with "sk_test_" and "pk_test_".', 'woocommerce-gateway-stripe' ), |
|
499 | - 're_verify_button_text' => __( 'Re-verify Domain', 'woocommerce-gateway-stripe' ), |
|
500 | - 'missing_secret_key' => __( 'Missing Secret Key. Please set the secret key field above and re-try.', 'woocommerce-gateway-stripe' ), |
|
497 | + 'not_valid_live_key_msg' => __('This is not a valid live key. Live keys start with "sk_live_" and "pk_live_".', 'woocommerce-gateway-stripe'), |
|
498 | + 'not_valid_test_key_msg' => __('This is not a valid test key. Test keys start with "sk_test_" and "pk_test_".', 'woocommerce-gateway-stripe'), |
|
499 | + 're_verify_button_text' => __('Re-verify Domain', 'woocommerce-gateway-stripe'), |
|
500 | + 'missing_secret_key' => __('Missing Secret Key. Please set the secret key field above and re-try.', 'woocommerce-gateway-stripe'), |
|
501 | 501 | ), |
502 | - 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
|
502 | + 'ajaxurl' => admin_url('admin-ajax.php'), |
|
503 | 503 | 'nonce' => array( |
504 | - 'apple_pay_domain_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_domain_nonce' ), |
|
504 | + 'apple_pay_domain_nonce' => wp_create_nonce('_wc_stripe_apple_pay_domain_nonce'), |
|
505 | 505 | ), |
506 | 506 | ); |
507 | 507 | |
508 | - wp_localize_script( 'woocommerce_stripe_admin', 'wc_stripe_admin_params', apply_filters( 'wc_stripe_admin_params', $stripe_admin_params ) ); |
|
508 | + wp_localize_script('woocommerce_stripe_admin', 'wc_stripe_admin_params', apply_filters('wc_stripe_admin_params', $stripe_admin_params)); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | /** |
@@ -516,49 +516,49 @@ discard block |
||
516 | 516 | * @access public |
517 | 517 | */ |
518 | 518 | public function payment_scripts() { |
519 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) { |
|
519 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) { |
|
520 | 520 | return; |
521 | 521 | } |
522 | 522 | |
523 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
523 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
524 | 524 | |
525 | - if ( $this->stripe_checkout ) { |
|
526 | - wp_enqueue_script( 'stripe_checkout', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true ); |
|
527 | - wp_enqueue_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe-checkout' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'stripe_checkout' ), WC_STRIPE_VERSION, true ); |
|
525 | + if ($this->stripe_checkout) { |
|
526 | + wp_enqueue_script('stripe_checkout', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true); |
|
527 | + wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe-checkout' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('stripe_checkout'), WC_STRIPE_VERSION, true); |
|
528 | 528 | } else { |
529 | - wp_enqueue_script( 'stripe', 'https://js.stripe.com/v2/', '', '1.0', true ); |
|
530 | - wp_enqueue_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripe' ), WC_STRIPE_VERSION, true ); |
|
529 | + wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', '', '1.0', true); |
|
530 | + wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripe'), WC_STRIPE_VERSION, true); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | $stripe_params = array( |
534 | 534 | 'key' => $this->publishable_key, |
535 | - 'i18n_terms' => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ), |
|
536 | - 'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ), |
|
535 | + 'i18n_terms' => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'), |
|
536 | + 'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'), |
|
537 | 537 | ); |
538 | 538 | |
539 | 539 | // If we're on the pay page we need to pass stripe.js the address of the order. |
540 | - if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) { |
|
541 | - $order_id = wc_get_order_id_by_order_key( urldecode( $_GET['key'] ) ); |
|
542 | - $order = wc_get_order( $order_id ); |
|
540 | + if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) { |
|
541 | + $order_id = wc_get_order_id_by_order_key(urldecode($_GET['key'])); |
|
542 | + $order = wc_get_order($order_id); |
|
543 | 543 | |
544 | - $stripe_params['billing_first_name'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_first_name : $order->get_billing_first_name(); |
|
545 | - $stripe_params['billing_last_name'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_last_name : $order->get_billing_last_name(); |
|
546 | - $stripe_params['billing_address_1'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_address_1 : $order->get_billing_address_1(); |
|
547 | - $stripe_params['billing_address_2'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_address_2 : $order->get_billing_address_2(); |
|
548 | - $stripe_params['billing_state'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_state : $order->get_billing_state(); |
|
549 | - $stripe_params['billing_city'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_city : $order->get_billing_city(); |
|
550 | - $stripe_params['billing_postcode'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_postcode : $order->get_billing_postcode(); |
|
551 | - $stripe_params['billing_country'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_country : $order->get_billing_country(); |
|
544 | + $stripe_params['billing_first_name'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_first_name : $order->get_billing_first_name(); |
|
545 | + $stripe_params['billing_last_name'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_last_name : $order->get_billing_last_name(); |
|
546 | + $stripe_params['billing_address_1'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_address_1 : $order->get_billing_address_1(); |
|
547 | + $stripe_params['billing_address_2'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_address_2 : $order->get_billing_address_2(); |
|
548 | + $stripe_params['billing_state'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_state : $order->get_billing_state(); |
|
549 | + $stripe_params['billing_city'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_city : $order->get_billing_city(); |
|
550 | + $stripe_params['billing_postcode'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_postcode : $order->get_billing_postcode(); |
|
551 | + $stripe_params['billing_country'] = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_country : $order->get_billing_country(); |
|
552 | 552 | } |
553 | 553 | |
554 | - $stripe_params['no_prepaid_card_msg'] = __( 'Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe' ); |
|
555 | - $stripe_params['allow_prepaid_card'] = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no'; |
|
556 | - $stripe_params['stripe_checkout_require_billing_address'] = apply_filters( 'wc_stripe_checkout_require_billing_address', false ) ? 'yes' : 'no'; |
|
554 | + $stripe_params['no_prepaid_card_msg'] = __('Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe'); |
|
555 | + $stripe_params['allow_prepaid_card'] = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no'; |
|
556 | + $stripe_params['stripe_checkout_require_billing_address'] = apply_filters('wc_stripe_checkout_require_billing_address', false) ? 'yes' : 'no'; |
|
557 | 557 | |
558 | 558 | // merge localized messages to be use in JS |
559 | - $stripe_params = array_merge( $stripe_params, $this->get_localized_messages() ); |
|
559 | + $stripe_params = array_merge($stripe_params, $this->get_localized_messages()); |
|
560 | 560 | |
561 | - wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) ); |
|
561 | + wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params)); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | /** |
@@ -567,35 +567,35 @@ discard block |
||
567 | 567 | * @param object $source |
568 | 568 | * @return array() |
569 | 569 | */ |
570 | - protected function generate_payment_request( $order, $source ) { |
|
570 | + protected function generate_payment_request($order, $source) { |
|
571 | 571 | $post_data = array(); |
572 | - $post_data['currency'] = strtolower( version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->get_order_currency() : $order->get_currency() ); |
|
573 | - $post_data['amount'] = $this->get_stripe_amount( $order->get_total(), $post_data['currency'] ); |
|
574 | - $post_data['description'] = sprintf( __( '%1$s - Order %2$s', 'woocommerce-gateway-stripe' ), $this->statement_descriptor, $order->get_order_number() ); |
|
572 | + $post_data['currency'] = strtolower(version_compare(WC_VERSION, '3.0.0', '<') ? $order->get_order_currency() : $order->get_currency()); |
|
573 | + $post_data['amount'] = $this->get_stripe_amount($order->get_total(), $post_data['currency']); |
|
574 | + $post_data['description'] = sprintf(__('%1$s - Order %2$s', 'woocommerce-gateway-stripe'), $this->statement_descriptor, $order->get_order_number()); |
|
575 | 575 | $post_data['capture'] = $this->capture ? 'true' : 'false'; |
576 | 576 | |
577 | - $billing_email = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_email : $order->get_billing_email(); |
|
578 | - $billing_first_name = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_first_name : $order->get_billing_first_name(); |
|
579 | - $billing_last_name = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->billing_last_name : $order->get_billing_last_name(); |
|
577 | + $billing_email = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_email : $order->get_billing_email(); |
|
578 | + $billing_first_name = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_first_name : $order->get_billing_first_name(); |
|
579 | + $billing_last_name = version_compare(WC_VERSION, '3.0.0', '<') ? $order->billing_last_name : $order->get_billing_last_name(); |
|
580 | 580 | |
581 | - if ( ! empty( $billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) { |
|
581 | + if ( ! empty($billing_email) && apply_filters('wc_stripe_send_stripe_receipt', false)) { |
|
582 | 582 | $post_data['receipt_email'] = $billing_email; |
583 | 583 | } |
584 | 584 | |
585 | - $post_data['expand[]'] = 'balance_transaction'; |
|
585 | + $post_data['expand[]'] = 'balance_transaction'; |
|
586 | 586 | |
587 | 587 | $metadata = array( |
588 | - __( 'Customer Name', 'woocommerce-gateway-stripe' ) => sanitize_text_field( $billing_first_name ) . ' ' . sanitize_text_field( $billing_last_name ), |
|
589 | - __( 'Customer Email', 'woocommerce-gateway-stripe' ) => sanitize_email( $billing_email ), |
|
588 | + __('Customer Name', 'woocommerce-gateway-stripe') => sanitize_text_field($billing_first_name) . ' ' . sanitize_text_field($billing_last_name), |
|
589 | + __('Customer Email', 'woocommerce-gateway-stripe') => sanitize_email($billing_email), |
|
590 | 590 | ); |
591 | 591 | |
592 | - $post_data['metadata'] = apply_filters( 'wc_stripe_payment_metadata', $metadata, $order, $source ); |
|
592 | + $post_data['metadata'] = apply_filters('wc_stripe_payment_metadata', $metadata, $order, $source); |
|
593 | 593 | |
594 | - if ( $source->customer ) { |
|
594 | + if ($source->customer) { |
|
595 | 595 | $post_data['customer'] = $source->customer; |
596 | 596 | } |
597 | 597 | |
598 | - if ( $source->source ) { |
|
598 | + if ($source->source) { |
|
599 | 599 | $post_data['source'] = $source->source; |
600 | 600 | } |
601 | 601 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * @param WC_Order $order |
608 | 608 | * @param object $source |
609 | 609 | */ |
610 | - return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order, $source ); |
|
610 | + return apply_filters('wc_stripe_generate_payment_request', $post_data, $order, $source); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -619,37 +619,37 @@ discard block |
||
619 | 619 | * @throws Exception When card was not added or for and invalid card. |
620 | 620 | * @return object |
621 | 621 | */ |
622 | - protected function get_source( $user_id, $force_customer = false ) { |
|
623 | - $stripe_customer = new WC_Stripe_Customer( $user_id ); |
|
622 | + protected function get_source($user_id, $force_customer = false) { |
|
623 | + $stripe_customer = new WC_Stripe_Customer($user_id); |
|
624 | 624 | $stripe_source = false; |
625 | 625 | $token_id = false; |
626 | 626 | |
627 | 627 | // New CC info was entered and we have a new token to process |
628 | - if ( isset( $_POST['stripe_token'] ) ) { |
|
629 | - $stripe_token = wc_clean( $_POST['stripe_token'] ); |
|
630 | - $maybe_saved_card = isset( $_POST['wc-stripe-new-payment-method'] ) && ! empty( $_POST['wc-stripe-new-payment-method'] ); |
|
628 | + if (isset($_POST['stripe_token'])) { |
|
629 | + $stripe_token = wc_clean($_POST['stripe_token']); |
|
630 | + $maybe_saved_card = isset($_POST['wc-stripe-new-payment-method']) && ! empty($_POST['wc-stripe-new-payment-method']); |
|
631 | 631 | |
632 | 632 | // This is true if the user wants to store the card to their account. |
633 | - if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_customer ) { |
|
634 | - $stripe_source = $stripe_customer->add_card( $stripe_token ); |
|
633 | + if (($user_id && $this->saved_cards && $maybe_saved_card) || $force_customer) { |
|
634 | + $stripe_source = $stripe_customer->add_card($stripe_token); |
|
635 | 635 | |
636 | - if ( is_wp_error( $stripe_source ) ) { |
|
637 | - throw new Exception( $stripe_source->get_error_message() ); |
|
636 | + if (is_wp_error($stripe_source)) { |
|
637 | + throw new Exception($stripe_source->get_error_message()); |
|
638 | 638 | } |
639 | 639 | } else { |
640 | 640 | // Not saving token, so don't define customer either. |
641 | 641 | $stripe_source = $stripe_token; |
642 | 642 | $stripe_customer = false; |
643 | 643 | } |
644 | - } elseif ( isset( $_POST['wc-stripe-payment-token'] ) && 'new' !== $_POST['wc-stripe-payment-token'] ) { |
|
644 | + } elseif (isset($_POST['wc-stripe-payment-token']) && 'new' !== $_POST['wc-stripe-payment-token']) { |
|
645 | 645 | // Use an existing token, and then process the payment |
646 | 646 | |
647 | - $token_id = wc_clean( $_POST['wc-stripe-payment-token'] ); |
|
648 | - $token = WC_Payment_Tokens::get( $token_id ); |
|
647 | + $token_id = wc_clean($_POST['wc-stripe-payment-token']); |
|
648 | + $token = WC_Payment_Tokens::get($token_id); |
|
649 | 649 | |
650 | - if ( ! $token || $token->get_user_id() !== get_current_user_id() ) { |
|
651 | - WC()->session->set( 'refresh_totals', true ); |
|
652 | - throw new Exception( __( 'Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe' ) ); |
|
650 | + if ( ! $token || $token->get_user_id() !== get_current_user_id()) { |
|
651 | + WC()->session->set('refresh_totals', true); |
|
652 | + throw new Exception(__('Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe')); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | $stripe_source = $token->get_token(); |
@@ -673,19 +673,19 @@ discard block |
||
673 | 673 | * @param object $order |
674 | 674 | * @return object |
675 | 675 | */ |
676 | - protected function get_order_source( $order = null ) { |
|
676 | + protected function get_order_source($order = null) { |
|
677 | 677 | $stripe_customer = new WC_Stripe_Customer(); |
678 | 678 | $stripe_source = false; |
679 | 679 | $token_id = false; |
680 | 680 | |
681 | - if ( $order ) { |
|
682 | - $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id(); |
|
681 | + if ($order) { |
|
682 | + $order_id = version_compare(WC_VERSION, '3.0.0', '<') ? $order->id : $order->get_id(); |
|
683 | 683 | |
684 | - if ( $meta_value = get_post_meta( $order_id, '_stripe_customer_id', true ) ) { |
|
685 | - $stripe_customer->set_id( $meta_value ); |
|
684 | + if ($meta_value = get_post_meta($order_id, '_stripe_customer_id', true)) { |
|
685 | + $stripe_customer->set_id($meta_value); |
|
686 | 686 | } |
687 | 687 | |
688 | - if ( $meta_value = get_post_meta( $order_id, '_stripe_card_id', true ) ) { |
|
688 | + if ($meta_value = get_post_meta($order_id, '_stripe_card_id', true)) { |
|
689 | 689 | $stripe_source = $meta_value; |
690 | 690 | } |
691 | 691 | } |
@@ -708,57 +708,57 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @return array|void |
710 | 710 | */ |
711 | - public function process_payment( $order_id, $retry = true, $force_customer = false ) { |
|
711 | + public function process_payment($order_id, $retry = true, $force_customer = false) { |
|
712 | 712 | try { |
713 | - $order = wc_get_order( $order_id ); |
|
714 | - $source = $this->get_source( get_current_user_id(), $force_customer ); |
|
713 | + $order = wc_get_order($order_id); |
|
714 | + $source = $this->get_source(get_current_user_id(), $force_customer); |
|
715 | 715 | |
716 | - if ( empty( $source->source ) && empty( $source->customer ) ) { |
|
717 | - $error_msg = __( 'Please enter your card details to make a payment.', 'woocommerce-gateway-stripe' ); |
|
718 | - $error_msg .= ' ' . __( 'Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce-gateway-stripe' ); |
|
719 | - throw new Exception( $error_msg ); |
|
716 | + if (empty($source->source) && empty($source->customer)) { |
|
717 | + $error_msg = __('Please enter your card details to make a payment.', 'woocommerce-gateway-stripe'); |
|
718 | + $error_msg .= ' ' . __('Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce-gateway-stripe'); |
|
719 | + throw new Exception($error_msg); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | // Store source to order meta. |
723 | - $this->save_source( $order, $source ); |
|
723 | + $this->save_source($order, $source); |
|
724 | 724 | |
725 | 725 | // Handle payment. |
726 | - if ( $order->get_total() > 0 ) { |
|
726 | + if ($order->get_total() > 0) { |
|
727 | 727 | |
728 | - if ( $order->get_total() * 100 < WC_Stripe::get_minimum_amount() ) { |
|
729 | - 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 ) ) ); |
|
728 | + if ($order->get_total() * 100 < WC_Stripe::get_minimum_amount()) { |
|
729 | + 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))); |
|
730 | 730 | } |
731 | 731 | |
732 | - $this->log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" ); |
|
732 | + $this->log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}"); |
|
733 | 733 | |
734 | 734 | // Make the request. |
735 | - $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source ) ); |
|
735 | + $response = WC_Stripe_API::request($this->generate_payment_request($order, $source)); |
|
736 | 736 | |
737 | - if ( is_wp_error( $response ) ) { |
|
737 | + if (is_wp_error($response)) { |
|
738 | 738 | // Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without. |
739 | - if ( 'customer' === $response->get_error_code() && $retry ) { |
|
740 | - delete_user_meta( get_current_user_id(), '_stripe_customer_id' ); |
|
741 | - return $this->process_payment( $order_id, false, $force_customer ); |
|
739 | + if ('customer' === $response->get_error_code() && $retry) { |
|
740 | + delete_user_meta(get_current_user_id(), '_stripe_customer_id'); |
|
741 | + return $this->process_payment($order_id, false, $force_customer); |
|
742 | 742 | // Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message. |
743 | - } elseif ( 'source' === $response->get_error_code() && $source->token_id ) { |
|
744 | - $token = WC_Payment_Tokens::get( $source->token_id ); |
|
743 | + } elseif ('source' === $response->get_error_code() && $source->token_id) { |
|
744 | + $token = WC_Payment_Tokens::get($source->token_id); |
|
745 | 745 | $token->delete(); |
746 | - $message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' ); |
|
747 | - $order->add_order_note( $message ); |
|
748 | - throw new Exception( $message ); |
|
746 | + $message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe'); |
|
747 | + $order->add_order_note($message); |
|
748 | + throw new Exception($message); |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | $localized_messages = $this->get_localized_messages(); |
752 | 752 | |
753 | - $message = isset( $localized_messages[ $response->get_error_code() ] ) ? $localized_messages[ $response->get_error_code() ] : $response->get_error_message(); |
|
753 | + $message = isset($localized_messages[$response->get_error_code()]) ? $localized_messages[$response->get_error_code()] : $response->get_error_message(); |
|
754 | 754 | |
755 | - $order->add_order_note( $message ); |
|
755 | + $order->add_order_note($message); |
|
756 | 756 | |
757 | - throw new Exception( $message ); |
|
757 | + throw new Exception($message); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | // Process valid response. |
761 | - $this->process_response( $response, $order ); |
|
761 | + $this->process_response($response, $order); |
|
762 | 762 | } else { |
763 | 763 | $order->payment_complete(); |
764 | 764 | } |
@@ -766,23 +766,23 @@ discard block |
||
766 | 766 | // Remove cart. |
767 | 767 | WC()->cart->empty_cart(); |
768 | 768 | |
769 | - do_action( 'wc_gateway_stripe_process_payment', $response, $order ); |
|
769 | + do_action('wc_gateway_stripe_process_payment', $response, $order); |
|
770 | 770 | |
771 | 771 | // Return thank you page redirect. |
772 | 772 | return array( |
773 | 773 | 'result' => 'success', |
774 | - 'redirect' => $this->get_return_url( $order ), |
|
774 | + 'redirect' => $this->get_return_url($order), |
|
775 | 775 | ); |
776 | 776 | |
777 | - } catch ( Exception $e ) { |
|
778 | - wc_add_notice( $e->getMessage(), 'error' ); |
|
779 | - $this->log( sprintf( __( 'Error: %s', 'woocommerce-gateway-stripe' ), $e->getMessage() ) ); |
|
777 | + } catch (Exception $e) { |
|
778 | + wc_add_notice($e->getMessage(), 'error'); |
|
779 | + $this->log(sprintf(__('Error: %s', 'woocommerce-gateway-stripe'), $e->getMessage())); |
|
780 | 780 | |
781 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
782 | - $this->send_failed_order_email( $order_id ); |
|
781 | + if ($order->has_status(array('pending', 'failed'))) { |
|
782 | + $this->send_failed_order_email($order_id); |
|
783 | 783 | } |
784 | 784 | |
785 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
785 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
786 | 786 | |
787 | 787 | return array( |
788 | 788 | 'result' => 'fail', |
@@ -797,56 +797,56 @@ discard block |
||
797 | 797 | * @param WC_Order $order For to which the source applies. |
798 | 798 | * @param stdClass $source Source information. |
799 | 799 | */ |
800 | - protected function save_source( $order, $source ) { |
|
801 | - $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id(); |
|
800 | + protected function save_source($order, $source) { |
|
801 | + $order_id = version_compare(WC_VERSION, '3.0.0', '<') ? $order->id : $order->get_id(); |
|
802 | 802 | |
803 | 803 | // Store source in the order. |
804 | - if ( $source->customer ) { |
|
805 | - update_post_meta( $order_id, '_stripe_customer_id', $source->customer ); |
|
804 | + if ($source->customer) { |
|
805 | + update_post_meta($order_id, '_stripe_customer_id', $source->customer); |
|
806 | 806 | } |
807 | - if ( $source->source ) { |
|
808 | - update_post_meta( $order_id, '_stripe_card_id', $source->source ); |
|
807 | + if ($source->source) { |
|
808 | + update_post_meta($order_id, '_stripe_card_id', $source->source); |
|
809 | 809 | } |
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
813 | 813 | * Store extra meta data for an order from a Stripe Response. |
814 | 814 | */ |
815 | - public function process_response( $response, $order ) { |
|
816 | - $this->log( 'Processing response: ' . print_r( $response, true ) ); |
|
815 | + public function process_response($response, $order) { |
|
816 | + $this->log('Processing response: ' . print_r($response, true)); |
|
817 | 817 | |
818 | - $order_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->id : $order->get_id(); |
|
818 | + $order_id = version_compare(WC_VERSION, '3.0.0', '<') ? $order->id : $order->get_id(); |
|
819 | 819 | |
820 | 820 | // Store charge data |
821 | - update_post_meta( $order_id, '_stripe_charge_id', $response->id ); |
|
822 | - update_post_meta( $order_id, '_stripe_charge_captured', $response->captured ? 'yes' : 'no' ); |
|
821 | + update_post_meta($order_id, '_stripe_charge_id', $response->id); |
|
822 | + update_post_meta($order_id, '_stripe_charge_captured', $response->captured ? 'yes' : 'no'); |
|
823 | 823 | |
824 | 824 | // Store other data such as fees |
825 | - if ( isset( $response->balance_transaction ) && isset( $response->balance_transaction->fee ) ) { |
|
825 | + if (isset($response->balance_transaction) && isset($response->balance_transaction->fee)) { |
|
826 | 826 | // Fees and Net needs to both come from Stripe to be accurate as the returned |
827 | 827 | // values are in the local currency of the Stripe account, not from WC. |
828 | - $fee = ! empty( $response->balance_transaction->fee ) ? WC_Stripe::format_number( $response->balance_transaction, 'fee' ) : 0; |
|
829 | - $net = ! empty( $response->balance_transaction->net ) ? WC_Stripe::format_number( $response->balance_transaction, 'net' ) : 0; |
|
830 | - update_post_meta( $order_id, 'Stripe Fee', $fee ); |
|
831 | - update_post_meta( $order_id, 'Net Revenue From Stripe', $net ); |
|
828 | + $fee = ! empty($response->balance_transaction->fee) ? WC_Stripe::format_number($response->balance_transaction, 'fee') : 0; |
|
829 | + $net = ! empty($response->balance_transaction->net) ? WC_Stripe::format_number($response->balance_transaction, 'net') : 0; |
|
830 | + update_post_meta($order_id, 'Stripe Fee', $fee); |
|
831 | + update_post_meta($order_id, 'Net Revenue From Stripe', $net); |
|
832 | 832 | } |
833 | 833 | |
834 | - if ( $response->captured ) { |
|
835 | - $order->payment_complete( $response->id ); |
|
834 | + if ($response->captured) { |
|
835 | + $order->payment_complete($response->id); |
|
836 | 836 | |
837 | - $message = sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $response->id ); |
|
838 | - $order->add_order_note( $message ); |
|
839 | - $this->log( 'Success: ' . $message ); |
|
837 | + $message = sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $response->id); |
|
838 | + $order->add_order_note($message); |
|
839 | + $this->log('Success: ' . $message); |
|
840 | 840 | |
841 | 841 | } else { |
842 | - add_post_meta( $order_id, '_transaction_id', $response->id, true ); |
|
842 | + add_post_meta($order_id, '_transaction_id', $response->id, true); |
|
843 | 843 | |
844 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
845 | - version_compare( WC_VERSION, '3.0.0', '<' ) ? $order->reduce_order_stock() : wc_reduce_stock_levels( $order_id ); |
|
844 | + if ($order->has_status(array('pending', 'failed'))) { |
|
845 | + version_compare(WC_VERSION, '3.0.0', '<') ? $order->reduce_order_stock() : wc_reduce_stock_levels($order_id); |
|
846 | 846 | } |
847 | 847 | |
848 | - $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 ) ); |
|
849 | - $this->log( "Successful auth: $response->id" ); |
|
848 | + $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)); |
|
849 | + $this->log("Successful auth: $response->id"); |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | return $response; |
@@ -858,32 +858,32 @@ discard block |
||
858 | 858 | * @since 3.0.0 |
859 | 859 | */ |
860 | 860 | public function add_payment_method() { |
861 | - if ( empty( $_POST['stripe_token'] ) || ! is_user_logged_in() ) { |
|
862 | - wc_add_notice( __( 'There was a problem adding the card.', 'woocommerce-gateway-stripe' ), 'error' ); |
|
861 | + if (empty($_POST['stripe_token']) || ! is_user_logged_in()) { |
|
862 | + wc_add_notice(__('There was a problem adding the card.', 'woocommerce-gateway-stripe'), 'error'); |
|
863 | 863 | return; |
864 | 864 | } |
865 | 865 | |
866 | - $stripe_customer = new WC_Stripe_Customer( get_current_user_id() ); |
|
867 | - $card = $stripe_customer->add_card( wc_clean( $_POST['stripe_token'] ) ); |
|
866 | + $stripe_customer = new WC_Stripe_Customer(get_current_user_id()); |
|
867 | + $card = $stripe_customer->add_card(wc_clean($_POST['stripe_token'])); |
|
868 | 868 | |
869 | - if ( is_wp_error( $card ) ) { |
|
869 | + if (is_wp_error($card)) { |
|
870 | 870 | $localized_messages = $this->get_localized_messages(); |
871 | - $error_msg = __( 'There was a problem adding the card.', 'woocommerce-gateway-stripe' ); |
|
871 | + $error_msg = __('There was a problem adding the card.', 'woocommerce-gateway-stripe'); |
|
872 | 872 | |
873 | 873 | // loop through the errors to find matching localized message |
874 | - foreach ( $card->errors as $error => $msg ) { |
|
875 | - if ( isset( $localized_messages[ $error ] ) ) { |
|
876 | - $error_msg = $localized_messages[ $error ]; |
|
874 | + foreach ($card->errors as $error => $msg) { |
|
875 | + if (isset($localized_messages[$error])) { |
|
876 | + $error_msg = $localized_messages[$error]; |
|
877 | 877 | } |
878 | 878 | } |
879 | 879 | |
880 | - wc_add_notice( $error_msg, 'error' ); |
|
880 | + wc_add_notice($error_msg, 'error'); |
|
881 | 881 | return; |
882 | 882 | } |
883 | 883 | |
884 | 884 | return array( |
885 | 885 | 'result' => 'success', |
886 | - 'redirect' => wc_get_endpoint_url( 'payment-methods' ), |
|
886 | + 'redirect' => wc_get_endpoint_url('payment-methods'), |
|
887 | 887 | ); |
888 | 888 | } |
889 | 889 | |
@@ -893,36 +893,36 @@ discard block |
||
893 | 893 | * @param float $amount |
894 | 894 | * @return bool |
895 | 895 | */ |
896 | - public function process_refund( $order_id, $amount = null, $reason = '' ) { |
|
897 | - $order = wc_get_order( $order_id ); |
|
896 | + public function process_refund($order_id, $amount = null, $reason = '') { |
|
897 | + $order = wc_get_order($order_id); |
|
898 | 898 | |
899 | - if ( ! $order || ! $order->get_transaction_id() ) { |
|
899 | + if ( ! $order || ! $order->get_transaction_id()) { |
|
900 | 900 | return false; |
901 | 901 | } |
902 | 902 | |
903 | 903 | $body = array(); |
904 | 904 | |
905 | - if ( ! is_null( $amount ) ) { |
|
906 | - $body['amount'] = $this->get_stripe_amount( $amount ); |
|
905 | + if ( ! is_null($amount)) { |
|
906 | + $body['amount'] = $this->get_stripe_amount($amount); |
|
907 | 907 | } |
908 | 908 | |
909 | - if ( $reason ) { |
|
909 | + if ($reason) { |
|
910 | 910 | $body['metadata'] = array( |
911 | 911 | 'reason' => $reason, |
912 | 912 | ); |
913 | 913 | } |
914 | 914 | |
915 | - $this->log( "Info: Beginning refund for order $order_id for the amount of {$amount}" ); |
|
915 | + $this->log("Info: Beginning refund for order $order_id for the amount of {$amount}"); |
|
916 | 916 | |
917 | - $response = WC_Stripe_API::request( $body, 'charges/' . $order->get_transaction_id() . '/refunds' ); |
|
917 | + $response = WC_Stripe_API::request($body, 'charges/' . $order->get_transaction_id() . '/refunds'); |
|
918 | 918 | |
919 | - if ( is_wp_error( $response ) ) { |
|
920 | - $this->log( 'Error: ' . $response->get_error_message() ); |
|
919 | + if (is_wp_error($response)) { |
|
920 | + $this->log('Error: ' . $response->get_error_message()); |
|
921 | 921 | return $response; |
922 | - } elseif ( ! empty( $response->id ) ) { |
|
923 | - $refund_message = sprintf( __( 'Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe' ), wc_price( $response->amount / 100 ), $response->id, $reason ); |
|
924 | - $order->add_order_note( $refund_message ); |
|
925 | - $this->log( 'Success: ' . html_entity_decode( strip_tags( $refund_message ) ) ); |
|
922 | + } elseif ( ! empty($response->id)) { |
|
923 | + $refund_message = sprintf(__('Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe'), wc_price($response->amount / 100), $response->id, $reason); |
|
924 | + $order->add_order_note($refund_message); |
|
925 | + $this->log('Success: ' . html_entity_decode(strip_tags($refund_message))); |
|
926 | 926 | return true; |
927 | 927 | } |
928 | 928 | } |
@@ -935,10 +935,10 @@ discard block |
||
935 | 935 | * @param int $order_id |
936 | 936 | * @return null |
937 | 937 | */ |
938 | - public function send_failed_order_email( $order_id ) { |
|
938 | + public function send_failed_order_email($order_id) { |
|
939 | 939 | $emails = WC()->mailer()->get_emails(); |
940 | - if ( ! empty( $emails ) && ! empty( $order_id ) ) { |
|
941 | - $emails['WC_Email_Failed_Order']->trigger( $order_id ); |
|
940 | + if ( ! empty($emails) && ! empty($order_id)) { |
|
941 | + $emails['WC_Email_Failed_Order']->trigger($order_id); |
|
942 | 942 | } |
943 | 943 | } |
944 | 944 | |
@@ -950,9 +950,9 @@ discard block |
||
950 | 950 | * |
951 | 951 | * @param string $message |
952 | 952 | */ |
953 | - public function log( $message ) { |
|
954 | - if ( $this->logging ) { |
|
955 | - WC_Stripe::log( $message ); |
|
953 | + public function log($message) { |
|
954 | + if ($this->logging) { |
|
955 | + WC_Stripe::log($message); |
|
956 | 956 | } |
957 | 957 | } |
958 | 958 | } |