Completed
Push — master ( 7ec021...209228 )
by Roy
02:52
created

WC_Stripe::get_minimum_amount()   C

Complexity

Conditions 14
Paths 14

Size

Total Lines 37
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 5.0864
c 0
b 0
f 0
cc 14
eloc 33
nc 14
nop 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*
3
 * Plugin Name: WooCommerce Stripe Gateway
4
 * Plugin URI: https://wordpress.org/plugins/woocommerce-gateway-stripe/
5
 * Description: Take credit card payments on your store using Stripe.
6
 * Author: WooCommerce
7
 * Author URI: https://woocommerce.com/
8
 * Version: 3.0.6
9
 * Text Domain: woocommerce-gateway-stripe
10
 * Domain Path: /languages
11
 *
12
 * Copyright (c) 2017 WooCommerce
13
 *
14
 * This program is free software: you can redistribute it and/or modify
15
 * it under the terms of the GNU General Public License as published by
16
 * the Free Software Foundation, either version 3 of the License, or
17
 * (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26
*/
27
28
if ( ! defined( 'ABSPATH' ) ) {
29
	exit;
30
}
31
32
/**
33
 * Required minimums and constants
34
 */
35
define( 'WC_STRIPE_VERSION', '3.0.6' );
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
define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
41
42
if ( ! class_exists( 'WC_Stripe' ) ) :
43
44
	class WC_Stripe {
45
46
		/**
47
		 * @var Singleton The reference the *Singleton* instance of this class
48
		 */
49
		private static $instance;
50
51
		/**
52
		 * @var Reference to logging class.
53
		 */
54
		private static $log;
55
56
		/**
57
		 * Returns the *Singleton* instance of this class.
58
		 *
59
		 * @return Singleton The *Singleton* instance.
60
		 */
61
		public static function get_instance() {
62
			if ( null === self::$instance ) {
63
				self::$instance = new self();
0 ignored issues
show
Documentation Bug introduced by
It seems like new self() of type object<WC_Stripe> is incompatible with the declared type object<Singleton> of property $instance.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
64
			}
65
			return self::$instance;
0 ignored issues
show
Bug Compatibility introduced by
The expression self::$instance; of type WC_Stripe|Singleton adds the type WC_Stripe to the return on line 65 which is incompatible with the return type documented by WC_Stripe::get_instance of type Singleton.
Loading history...
66
		}
67
68
		/**
69
		 * Private clone method to prevent cloning of the instance of the
70
		 * *Singleton* instance.
71
		 *
72
		 * @return void
73
		 */
74
		private function __clone() {}
75
76
		/**
77
		 * Private unserialize method to prevent unserializing of the *Singleton*
78
		 * instance.
79
		 *
80
		 * @return void
81
		 */
82
		private function __wakeup() {}
83
84
		/**
85
		 * Flag to indicate whether or not we need to load code for / support subscriptions.
86
		 *
87
		 * @var bool
88
		 */
89
		private $subscription_support_enabled = false;
90
91
		/**
92
		 * Flag to indicate whether or not we need to load support for pre-orders.
93
		 *
94
		 * @since 3.0.3
95
		 *
96
		 * @var bool
97
		 */
98
		private $pre_order_enabled = false;
99
100
		/**
101
		 * Notices (array)
102
		 * @var array
103
		 */
104
		public $notices = array();
105
106
		/**
107
		 * Protected constructor to prevent creating a new instance of the
108
		 * *Singleton* via the `new` operator from outside of this class.
109
		 */
110
		protected function __construct() {
111
			add_action( 'admin_init', array( $this, 'check_environment' ) );
112
			add_action( 'admin_notices', array( $this, 'admin_notices' ), 15 );
113
			add_action( 'plugins_loaded', array( $this, 'init' ) );
114
		}
115
116
		/**
117
		 * Init the plugin after plugins_loaded so environment variables are set.
118
		 */
119
		public function init() {
120
			// Don't hook anything else in the plugin if we're in an incompatible environment
121
			if ( self::get_environment_warning() ) {
122
				return;
123
			}
124
125
			include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php' );
126
			include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php' );
127
128
			// Init the gateway itself
129
			$this->init_gateways();
130
131
			add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
132
			add_action( 'woocommerce_order_status_on-hold_to_processing', array( $this, 'capture_payment' ) );
133
			add_action( 'woocommerce_order_status_on-hold_to_completed', array( $this, 'capture_payment' ) );
134
			add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'cancel_payment' ) );
135
			add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'cancel_payment' ) );
136
			add_filter( 'woocommerce_get_customer_payment_tokens', array( $this, 'woocommerce_get_customer_payment_tokens' ), 10, 3 );
137
			add_action( 'woocommerce_payment_token_deleted', array( $this, 'woocommerce_payment_token_deleted' ), 10, 2 );
138
			add_action( 'woocommerce_payment_token_set_default', array( $this, 'woocommerce_payment_token_set_default' ) );
139
			add_action( 'wp_ajax_stripe_dismiss_request_api_notice', array( $this, 'dismiss_request_api_notice' ) );
140
			add_action( 'wp_ajax_stripe_dismiss_apple_pay_notice', array( $this, 'dismiss_apple_pay_notice' ) );
141
142
			include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-request.php' );
143
		}
144
145
		/**
146
		 * Allow this class and other classes to add slug keyed notices (to avoid duplication)
147
		 */
148
		public function add_admin_notice( $slug, $class, $message ) {
149
			$this->notices[ $slug ] = array(
150
				'class'   => $class,
151
				'message' => $message,
152
			);
153
		}
154
155
		/**
156
		 * The backup sanity check, in case the plugin is activated in a weird way,
157
		 * or the environment changes after activation. Also handles upgrade routines.
158
		 */
159
		public function check_environment() {
160
			if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'woocommerce_stripe_version' ) ) ) {
161
				$this->install();
162
163
				do_action( 'woocommerce_stripe_updated' );
164
			}
165
166
			$environment_warning = self::get_environment_warning();
167
168
			if ( $environment_warning && is_plugin_active( plugin_basename( __FILE__ ) ) ) {
169
				$this->add_admin_notice( 'bad_environment', 'error', $environment_warning );
170
			}
171
172
			// Check if secret key present. Otherwise prompt, via notice, to go to
173
			// setting.
174
			if ( ! class_exists( 'WC_Stripe_API' ) ) {
175
				include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php' );
176
			}
177
178
			$secret = WC_Stripe_API::get_secret_key();
179
180
			if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) {
181
				$setting_link = $this->get_setting_link();
182
				$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 ) );
183
			}
184
		}
185
186
		/**
187
		 * Updates the plugin version in db
188
		 *
189
		 * @since 3.1.0
190
		 * @version 3.1.0
191
		 * @return bool
192
		 */
193
		private static function _update_plugin_version() {
194
			delete_option( 'wc_stripe_version' );
195
			add_option( 'wc_stripe_version', WC_STRIPE_VERSION );
196
197
			return true;
198
		}
199
200
		/**
201
		 * Dismiss the Google Payment Request API Feature notice.
202
		 *
203
		 * @since 3.1.0
204
		 * @version 3.1.0
205
		 */
206
		public function dismiss_request_api_notice() {
207
			add_option( 'wc_stripe_show_request_api_notice', 'no' );
208
		}
209
210
		/**
211
		 * Dismiss the Apple Pay Feature notice.
212
		 *
213
		 * @since 3.1.0
214
		 * @version 3.1.0
215
		 */
216
		public function dismiss_apple_pay_notice() {
217
			add_option( 'wc_stripe_show_apple_pay_notice', 'no' );
218
		}
219
220
		/**
221
		 * Handles upgrade routines.
222
		 *
223
		 * @since 3.1.0
224
		 * @version 3.1.0
225
		 */
226
		public function install() {
227
			if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) {
228
				define( 'WC_STRIPE_INSTALLING', true );
229
			}
230
231
			$this->_update_plugin_version();
232
		}
233
234
		/**
235
		 * Checks the environment for compatibility problems.  Returns a string with the first incompatibility
236
		 * found or false if the environment has no problems.
237
		 */
238
		static function get_environment_warning() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
239 View Code Duplication
			if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
240
				$message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' );
241
242
				return sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() );
243
			}
244
245
			if ( ! defined( 'WC_VERSION' ) ) {
246
				return __( 'WooCommerce Stripe requires WooCommerce to be activated to work.', 'woocommerce-gateway-stripe' );
247
			}
248
249 View Code Duplication
			if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
250
				$message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' );
251
252
				return sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION );
253
			}
254
255
			if ( ! function_exists( 'curl_init' ) ) {
256
				return __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' );
257
			}
258
259
			return false;
260
		}
261
262
		/**
263
		 * Adds plugin action links
264
		 *
265
		 * @since 1.0.0
266
		 */
267
		public function plugin_action_links( $links ) {
268
			$setting_link = $this->get_setting_link();
269
270
			$plugin_links = array(
271
				'<a href="' . $setting_link . '">' . __( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
272
				'<a href="https://docs.woothemes.com/document/stripe/">' . __( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>',
273
				'<a href="http://support.woothemes.com/">' . __( 'Support', 'woocommerce-gateway-stripe' ) . '</a>',
274
			);
275
			return array_merge( $plugin_links, $links );
276
		}
277
278
		/**
279
		 * Get setting link.
280
		 *
281
		 * @since 1.0.0
282
		 *
283
		 * @return string Setting link
284
		 */
285
		public function get_setting_link() {
286
			$use_id_as_section = function_exists( 'WC' ) ? version_compare( WC()->version, '2.6', '>=' ) : false;
287
288
			$section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' );
289
290
			return admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . $section_slug );
291
		}
292
293
		/**
294
		 * Display any notices we've collected thus far (e.g. for connection, disconnection)
295
		 */
296
		public function admin_notices() {
297
			$show_request_api_notice = get_option( 'wc_stripe_show_request_api_notice' );
298
			$show_apple_pay_notice   = get_option( 'wc_stripe_show_apple_pay_notice' );
299
300
			if ( empty( $show_apple_pay_notice ) ) {
301
				// @TODO remove this notice in the future.
302
				?>
303
				<div class="notice notice-warning wc-stripe-apple-pay-notice is-dismissible"><p><?php esc_html_e( 'New Feature! Stripe now supports Apple Pay. Your customers can now purchase your products even faster. Apple Pay has been enabled by default.', 'woocommerce-gateway-stripe' ); ?></p></div>
304
305
				<script type="application/javascript">
306
					jQuery( '.wc-stripe-apple-pay-notice' ).on( 'click', '.notice-dismiss', function() {
307
						var data = {
308
							action: 'stripe_dismiss_apple_pay_notice'
309
						};
310
311
						jQuery.post( '<?php echo admin_url( 'admin-ajax.php' ); ?>', data );
312
					});
313
				</script>
314
315
				<?php
316
			}
317
318
			if ( empty( $show_request_api_notice ) ) {
319
				// @TODO remove this notice in the future.
320
				?>
321
				<div class="notice notice-warning wc-stripe-request-api-notice is-dismissible"><p><?php esc_html_e( 'New Feature! Stripe now supports Google Payment Request. Your customers can now use mobile phones with supported browsers such as Chrome to make purchases easier and faster.', 'woocommerce-gateway-stripe' ); ?></p></div>
322
				
323
				<script type="application/javascript">
324
					jQuery( '.wc-stripe-request-api-notice' ).on( 'click', '.notice-dismiss', function() {
325
						var data = {
326
							action: 'stripe_dismiss_request_api_notice'
327
						};
328
329
						jQuery.post( '<?php echo admin_url( 'admin-ajax.php' ); ?>', data );
330
					});
331
				</script>
332
333
				<?php
334
			}
335
			
336
			foreach ( (array) $this->notices as $notice_key => $notice ) {
337
				echo "<div class='" . esc_attr( $notice['class'] ) . "'><p>";
338
				echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) );
339
				echo '</p></div>';
340
			}
341
		}
342
343
		/**
344
		 * Initialize the gateway. Called very early - in the context of the plugins_loaded action
345
		 *
346
		 * @since 1.0.0
347
		 */
348
		public function init_gateways() {
349
			if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) {
350
				$this->subscription_support_enabled = true;
351
			}
352
353
			if ( class_exists( 'WC_Pre_Orders_Order' ) ) {
354
				$this->pre_order_enabled = true;
355
			}
356
357
			if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
358
				return;
359
			}
360
361
			if ( class_exists( 'WC_Payment_Gateway_CC' ) ) {
362
				include_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php' );
363
				include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay.php' );
364
			} else {
365
				include_once( dirname( __FILE__ ) . '/includes/legacy/class-wc-gateway-stripe.php' );
366
				include_once( dirname( __FILE__ ) . '/includes/legacy/class-wc-gateway-stripe-saved-cards.php' );
367
			}
368
369
			load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
370
			add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) );
371
			
372
			$load_addons = (
373
				$this->subscription_support_enabled
374
				||
375
				$this->pre_order_enabled
376
			);
377
378
			if ( $load_addons ) {
379
				require_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe-addons.php' );
380
			}
381
		}
382
383
		/**
384
		 * Add the gateways to WooCommerce
385
		 *
386
		 * @since 1.0.0
387
		 */
388
		public function add_gateways( $methods ) {
389
			if ( $this->subscription_support_enabled || $this->pre_order_enabled ) {
390
				$methods[] = 'WC_Gateway_Stripe_Addons';
391
			} else {
392
				$methods[] = 'WC_Gateway_Stripe';
393
			}
394
			return $methods;
395
		}
396
397
		/**
398
		 * Capture payment when the order is changed from on-hold to complete or processing
399
		 *
400
		 * @param  int $order_id
401
		 */
402
		public function capture_payment( $order_id ) {
403
			$order = wc_get_order( $order_id );
404
405
			if ( 'stripe' === $order->payment_method ) {
406
				$charge   = get_post_meta( $order_id, '_stripe_charge_id', true );
407
				$captured = get_post_meta( $order_id, '_stripe_charge_captured', true );
408
409
				if ( $charge && 'no' === $captured ) {
410
					$result = WC_Stripe_API::request( array(
411
						'amount'   => $order->get_total() * 100,
412
						'expand[]' => 'balance_transaction',
413
					), 'charges/' . $charge . '/capture' );
414
415
					if ( is_wp_error( $result ) ) {
416
						$order->add_order_note( __( 'Unable to capture charge!', 'woocommerce-gateway-stripe' ) . ' ' . $result->get_error_message() );
417
					} else {
418
						$order->add_order_note( sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $result->id ) );
419
						update_post_meta( $order->id, '_stripe_charge_captured', 'yes' );
420
421
						// Store other data such as fees
422
						update_post_meta( $order->id, 'Stripe Payment ID', $result->id );
423
424 View Code Duplication
						if ( isset( $result->balance_transaction ) && isset( $result->balance_transaction->fee ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
425
							// Fees and Net needs to both come from Stripe to be accurate as the returned
426
							// values are in the local currency of the Stripe account, not from WC.
427
							$fee = ! empty( $result->balance_transaction->fee ) ? number_format( $result->balance_transaction->fee / 100, 2, '.', '' ) : 0;
428
							$net = ! empty( $result->balance_transaction->net ) ? number_format( $result->balance_transaction->net / 100, 2, '.', '' ) : 0;
429
							update_post_meta( $order->id, 'Stripe Fee', $fee );
430
							update_post_meta( $order->id, 'Net Revenue From Stripe', $net );
431
						}
432
					}
433
				}
434
			}
435
		}
436
437
		/**
438
		 * Cancel pre-auth on refund/cancellation
439
		 *
440
		 * @param  int $order_id
441
		 */
442
		public function cancel_payment( $order_id ) {
443
			$order = wc_get_order( $order_id );
444
445
			if ( 'stripe' === $order->payment_method ) {
446
				$charge   = get_post_meta( $order_id, '_stripe_charge_id', true );
447
448
				if ( $charge ) {
449
					$result = WC_Stripe_API::request( array(
450
						'amount' => $order->get_total() * 100,
451
					), 'charges/' . $charge . '/refund' );
452
453
					if ( is_wp_error( $result ) ) {
454
						$order->add_order_note( __( 'Unable to refund charge!', 'woocommerce-gateway-stripe' ) . ' ' . $result->get_error_message() );
455
					} else {
456
						$order->add_order_note( sprintf( __( 'Stripe charge refunded (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $result->id ) );
457
						delete_post_meta( $order->id, '_stripe_charge_captured' );
458
						delete_post_meta( $order->id, '_stripe_charge_id' );
459
					}
460
				}
461
			}
462
		}
463
464
		/**
465
		 * Gets saved tokens from API if they don't already exist in WooCommerce.
466
		 * @param array $tokens
467
		 * @return array
468
		 */
469
		public function woocommerce_get_customer_payment_tokens( $tokens, $customer_id, $gateway_id ) {
470
			if ( is_user_logged_in() && 'stripe' === $gateway_id && class_exists( 'WC_Payment_Token_CC' ) ) {
471
				$stripe_customer = new WC_Stripe_Customer( $customer_id );
472
				$stripe_cards    = $stripe_customer->get_cards();
473
				$stored_tokens   = array();
474
475
				foreach ( $tokens as $token ) {
476
					$stored_tokens[] = $token->get_token();
477
				}
478
479
				foreach ( $stripe_cards as $card ) {
480
					if ( ! in_array( $card->id, $stored_tokens ) ) {
481
						$token = new WC_Payment_Token_CC();
482
						$token->set_token( $card->id );
483
						$token->set_gateway_id( 'stripe' );
484
						$token->set_card_type( strtolower( $card->brand ) );
485
						$token->set_last4( $card->last4 );
486
						$token->set_expiry_month( $card->exp_month );
487
						$token->set_expiry_year( $card->exp_year );
488
						$token->set_user_id( $customer_id );
489
						$token->save();
490
						$tokens[ $token->get_id() ] = $token;
491
					}
492
				}
493
			}
494
			return $tokens;
495
		}
496
497
		/**
498
		 * Delete token from Stripe
499
		 */
500
		public function woocommerce_payment_token_deleted( $token_id, $token ) {
501
			if ( 'stripe' === $token->get_gateway_id() ) {
502
				$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
503
				$stripe_customer->delete_card( $token->get_token() );
504
			}
505
		}
506
507
		/**
508
		 * Set as default in Stripe
509
		 */
510
		public function woocommerce_payment_token_set_default( $token_id ) {
511
			$token = WC_Payment_Tokens::get( $token_id );
512
			if ( 'stripe' === $token->get_gateway_id() ) {
513
				$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
514
				$stripe_customer->set_default_card( $token->get_token() );
515
			}
516
		}
517
518
		/**
519
		 * Checks Stripe minimum order value authorized per currency
520
		 */
521
		public static function get_minimum_amount() {
522
			// Check order amount
523
			switch ( get_woocommerce_currency() ) {
524
				case 'USD':
525
				case 'CAD':
526
				case 'EUR':
527
				case 'CHF':
528
				case 'AUD':
529
				case 'SGD':
530
					$minimum_amount = 50;
531
					break;
532
				case 'GBP':
533
					$minimum_amount = 30;
534
					break;
535
				case 'DKK':
536
					$minimum_amount = 250;
537
					break;
538
				case 'NOK':
539
				case 'SEK':
540
					$minimum_amount = 300;
541
					break;
542
				case 'JPY':
543
					$minimum_amount = 5000;
544
					break;
545
				case 'MXN':
546
					$minimum_amount = 1000;
547
					break;
548
				case 'HKD':
549
					$minimum_amount = 400;
550
					break;
551
				default:
552
					$minimum_amount = 50;
553
					break;
554
			}
555
556
			return $minimum_amount;
557
		}
558
559
		/**
560
		 * What rolls down stairs
561
		 * alone or in pairs,
562
		 * and over your neighbor's dog?
563
		 * What's great for a snack,
564
		 * And fits on your back?
565
		 * It's log, log, log
566
		 */
567
		public static function log( $message ) {
568
			if ( empty( self::$log ) ) {
569
				self::$log = new WC_Logger();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \WC_Logger() of type object<WC_Logger> is incompatible with the declared type object<Reference> of property $log.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
570
			}
571
572
			self::$log->add( 'woocommerce-gateway-stripe', $message );
573
		}
574
	}
575
576
	$GLOBALS['wc_stripe'] = WC_Stripe::get_instance();
577
578
endif;
579