@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | |
3 | 3 | class WC_Stripe_Test extends WP_UnitTestCase { |
4 | 4 | public function test_constants_defined() { |
5 | - $this->assertTrue( defined( 'WC_STRIPE_VERSION' ) ); |
|
6 | - $this->assertTrue( defined( 'WC_STRIPE_MIN_PHP_VER' ) ); |
|
7 | - $this->assertTrue( defined( 'WC_STRIPE_MIN_WC_VER' ) ); |
|
8 | - $this->assertTrue( defined( 'WC_STRIPE_MAIN_FILE' ) ); |
|
9 | - $this->assertTrue( defined( 'WC_STRIPE_PLUGIN_URL' ) ); |
|
10 | - $this->assertTrue( defined( 'WC_STRIPE_PLUGIN_PATH' ) ); |
|
5 | + $this->assertTrue(defined('WC_STRIPE_VERSION')); |
|
6 | + $this->assertTrue(defined('WC_STRIPE_MIN_PHP_VER')); |
|
7 | + $this->assertTrue(defined('WC_STRIPE_MIN_WC_VER')); |
|
8 | + $this->assertTrue(defined('WC_STRIPE_MAIN_FILE')); |
|
9 | + $this->assertTrue(defined('WC_STRIPE_PLUGIN_URL')); |
|
10 | + $this->assertTrue(defined('WC_STRIPE_PLUGIN_PATH')); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * This test will see if we're indeed converting the price correctly. |
16 | 16 | */ |
17 | 17 | public function test_price_conversion_before_send_to_stripe() { |
18 | - $this->assertEquals( 10050, WC_Stripe_Helper::get_stripe_amount( 100.50, 'USD' ) ); |
|
19 | - $this->assertEquals( 10050, WC_Stripe_Helper::get_stripe_amount( 10050, 'JPY' ) ); |
|
20 | - $this->assertEquals( 100, WC_Stripe_Helper::get_stripe_amount( 100.50, 'JPY' ) ); |
|
21 | - $this->assertEquals( 10050, WC_Stripe_Helper::get_stripe_amount( 100.50 ) ); |
|
22 | - $this->assertInternalType( 'int', WC_Stripe_Helper::get_stripe_amount( 100.50, 'USD' ) ); |
|
18 | + $this->assertEquals(10050, WC_Stripe_Helper::get_stripe_amount(100.50, 'USD')); |
|
19 | + $this->assertEquals(10050, WC_Stripe_Helper::get_stripe_amount(10050, 'JPY')); |
|
20 | + $this->assertEquals(100, WC_Stripe_Helper::get_stripe_amount(100.50, 'JPY')); |
|
21 | + $this->assertEquals(10050, WC_Stripe_Helper::get_stripe_amount(100.50)); |
|
22 | + $this->assertInternalType('int', WC_Stripe_Helper::get_stripe_amount(100.50, 'USD')); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -33,37 +33,37 @@ discard block |
||
33 | 33 | $balance_fee1->net = 10000; |
34 | 34 | $balance_fee1->currency = 'USD'; |
35 | 35 | |
36 | - $this->assertEquals( 105.00, WC_Stripe_Helper::format_balance_fee( $balance_fee1, 'fee' ) ); |
|
36 | + $this->assertEquals(105.00, WC_Stripe_Helper::format_balance_fee($balance_fee1, 'fee')); |
|
37 | 37 | |
38 | 38 | $balance_fee2 = new stdClass(); |
39 | 39 | $balance_fee2->fee = 10500; |
40 | 40 | $balance_fee2->net = 10000; |
41 | 41 | $balance_fee2->currency = 'JPY'; |
42 | 42 | |
43 | - $this->assertEquals( 10500, WC_Stripe_Helper::format_balance_fee( $balance_fee2, 'fee' ) ); |
|
43 | + $this->assertEquals(10500, WC_Stripe_Helper::format_balance_fee($balance_fee2, 'fee')); |
|
44 | 44 | |
45 | 45 | $balance_fee3 = new stdClass(); |
46 | 46 | $balance_fee3->fee = 10500; |
47 | 47 | $balance_fee3->net = 10000; |
48 | 48 | $balance_fee3->currency = 'USD'; |
49 | 49 | |
50 | - $this->assertEquals( 100.00, WC_Stripe_Helper::format_balance_fee( $balance_fee3, 'net' ) ); |
|
50 | + $this->assertEquals(100.00, WC_Stripe_Helper::format_balance_fee($balance_fee3, 'net')); |
|
51 | 51 | |
52 | 52 | $balance_fee4 = new stdClass(); |
53 | 53 | $balance_fee4->fee = 10500; |
54 | 54 | $balance_fee4->net = 10000; |
55 | 55 | $balance_fee4->currency = 'JPY'; |
56 | 56 | |
57 | - $this->assertEquals( 10000, WC_Stripe_Helper::format_balance_fee( $balance_fee4, 'net' ) ); |
|
57 | + $this->assertEquals(10000, WC_Stripe_Helper::format_balance_fee($balance_fee4, 'net')); |
|
58 | 58 | |
59 | 59 | $balance_fee5 = new stdClass(); |
60 | 60 | $balance_fee5->fee = 10500; |
61 | 61 | $balance_fee5->net = 10000; |
62 | 62 | $balance_fee5->currency = 'USD'; |
63 | 63 | |
64 | - $this->assertEquals( 105.00, WC_Stripe_Helper::format_balance_fee( $balance_fee5 ) ); |
|
64 | + $this->assertEquals(105.00, WC_Stripe_Helper::format_balance_fee($balance_fee5)); |
|
65 | 65 | |
66 | - $this->assertInternalType( 'string', WC_Stripe_Helper::format_balance_fee( $balance_fee5 ) ); |
|
66 | + $this->assertInternalType('string', WC_Stripe_Helper::format_balance_fee($balance_fee5)); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -76,27 +76,27 @@ discard block |
||
76 | 76 | 'expected' => 'Tests Store', |
77 | 77 | ); |
78 | 78 | |
79 | - $this->assertEquals( $statement_descriptor1['expected'], WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor1['actual'] ) ); |
|
79 | + $this->assertEquals($statement_descriptor1['expected'], WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor1['actual'])); |
|
80 | 80 | |
81 | 81 | $statement_descriptor2 = array( |
82 | 82 | 'actual' => 'Test\'s Store > Driving Course Range', |
83 | 83 | 'expected' => 'Tests Store Driving C', |
84 | 84 | ); |
85 | 85 | |
86 | - $this->assertEquals( $statement_descriptor2['expected'], WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor2['actual'] ) ); |
|
86 | + $this->assertEquals($statement_descriptor2['expected'], WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor2['actual'])); |
|
87 | 87 | |
88 | 88 | $statement_descriptor3 = array( |
89 | 89 | 'actual' => 'Test\'s Store < Driving Course Range', |
90 | 90 | 'expected' => 'Tests Store Driving C', |
91 | 91 | ); |
92 | 92 | |
93 | - $this->assertEquals( $statement_descriptor3['expected'], WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor3['actual'] ) ); |
|
93 | + $this->assertEquals($statement_descriptor3['expected'], WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor3['actual'])); |
|
94 | 94 | |
95 | 95 | $statement_descriptor4 = array( |
96 | 96 | 'actual' => 'Test\'s Store " Driving Course Range', |
97 | 97 | 'expected' => 'Tests Store Driving C', |
98 | 98 | ); |
99 | 99 | |
100 | - $this->assertEquals( $statement_descriptor4['expected'], WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor4['actual'] ) ); |
|
100 | + $this->assertEquals($statement_descriptor4['expected'], WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor4['actual'])); |
|
101 | 101 | } |
102 | 102 | } |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$_tests_dir = getenv( 'WP_TESTS_DIR' ); |
|
4 | -if ( ! $_tests_dir ) { |
|
3 | +$_tests_dir = getenv('WP_TESTS_DIR'); |
|
4 | +if ( ! $_tests_dir) { |
|
5 | 5 | $_tests_dir = '/tmp/wordpress-tests-lib'; |
6 | 6 | } |
7 | 7 | |
8 | 8 | require_once $_tests_dir . '/includes/functions.php'; |
9 | 9 | |
10 | 10 | function _manually_load_plugin() { |
11 | - $plugin_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/'; |
|
11 | + $plugin_dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/'; |
|
12 | 12 | require $plugin_dir . 'woocommerce-gateway-stripe/woocommerce-gateway-stripe.php'; |
13 | 13 | require $plugin_dir . 'woocommerce/woocommerce.php'; |
14 | 14 | } |
@@ -17,20 +17,20 @@ discard block |
||
17 | 17 | return true; |
18 | 18 | } |
19 | 19 | |
20 | -function woothemes_queue_update( $file, $file_id, $product_id ) { |
|
20 | +function woothemes_queue_update($file, $file_id, $product_id) { |
|
21 | 21 | return true; |
22 | 22 | } |
23 | 23 | |
24 | -tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); |
|
24 | +tests_add_filter('muplugins_loaded', '_manually_load_plugin'); |
|
25 | 25 | |
26 | 26 | require $_tests_dir . '/includes/bootstrap.php'; |
27 | 27 | |
28 | -$wc_tests_framework_base_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/woocommerce/tests/framework/'; |
|
29 | -require_once( $wc_tests_framework_base_dir . 'class-wc-mock-session-handler.php' ); |
|
30 | -require_once( $wc_tests_framework_base_dir . 'class-wc-unit-test-case.php' ); |
|
31 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-product.php' ); |
|
32 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-coupon.php' ); |
|
33 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-fee.php' ); |
|
34 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-shipping.php' ); |
|
35 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-customer.php' ); |
|
36 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-order.php' ); |
|
28 | +$wc_tests_framework_base_dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/woocommerce/tests/framework/'; |
|
29 | +require_once($wc_tests_framework_base_dir . 'class-wc-mock-session-handler.php'); |
|
30 | +require_once($wc_tests_framework_base_dir . 'class-wc-unit-test-case.php'); |
|
31 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-product.php'); |
|
32 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-coupon.php'); |
|
33 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-fee.php'); |
|
34 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-shipping.php'); |
|
35 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-customer.php'); |
|
36 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-order.php'); |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
6 | 6 | // if uninstall not called from WordPress exit |
7 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
7 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
8 | 8 | exit; |
9 | 9 | } |
10 | 10 | |
@@ -13,20 +13,20 @@ discard block |
||
13 | 13 | * wp-config.php. This is to prevent data loss when deleting the plugin from the backend |
14 | 14 | * and to ensure only the site owner can perform this action. |
15 | 15 | */ |
16 | -if ( defined( 'WC_REMOVE_ALL_DATA' ) && true === WC_REMOVE_ALL_DATA ) { |
|
16 | +if (defined('WC_REMOVE_ALL_DATA') && true === WC_REMOVE_ALL_DATA) { |
|
17 | 17 | // Delete options. |
18 | - delete_option( 'woocommerce_stripe_settings' ); |
|
19 | - delete_option( 'wc_stripe_show_request_api_notice' ); |
|
20 | - delete_option( 'wc_stripe_show_apple_pay_notice' ); |
|
21 | - delete_option( 'wc_stripe_show_ssl_notice' ); |
|
22 | - delete_option( 'wc_stripe_show_keys_notice' ); |
|
23 | - delete_option( 'wc_stripe_version' ); |
|
24 | - delete_option( 'woocommerce_stripe_bancontact_settings' ); |
|
25 | - delete_option( 'woocommerce_stripe_alipay_settings' ); |
|
26 | - delete_option( 'woocommerce_stripe_bitcoin_settings' ); |
|
27 | - delete_option( 'woocommerce_stripe_ideal_settings' ); |
|
28 | - delete_option( 'woocommerce_stripe_p24_settings' ); |
|
29 | - delete_option( 'woocommerce_stripe_giropay_settings' ); |
|
30 | - delete_option( 'woocommerce_stripe_sepa_settings' ); |
|
31 | - delete_option( 'woocommerce_stripe_sofort_settings' ); |
|
18 | + delete_option('woocommerce_stripe_settings'); |
|
19 | + delete_option('wc_stripe_show_request_api_notice'); |
|
20 | + delete_option('wc_stripe_show_apple_pay_notice'); |
|
21 | + delete_option('wc_stripe_show_ssl_notice'); |
|
22 | + delete_option('wc_stripe_show_keys_notice'); |
|
23 | + delete_option('wc_stripe_version'); |
|
24 | + delete_option('woocommerce_stripe_bancontact_settings'); |
|
25 | + delete_option('woocommerce_stripe_alipay_settings'); |
|
26 | + delete_option('woocommerce_stripe_bitcoin_settings'); |
|
27 | + delete_option('woocommerce_stripe_ideal_settings'); |
|
28 | + delete_option('woocommerce_stripe_p24_settings'); |
|
29 | + delete_option('woocommerce_stripe_giropay_settings'); |
|
30 | + delete_option('woocommerce_stripe_sepa_settings'); |
|
31 | + delete_option('woocommerce_stripe_sofort_settings'); |
|
32 | 32 | } |
@@ -14,20 +14,20 @@ discard block |
||
14 | 14 | * |
15 | 15 | */ |
16 | 16 | |
17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
17 | +if ( ! defined('ABSPATH')) { |
|
18 | 18 | exit; |
19 | 19 | } |
20 | 20 | |
21 | -if ( ! class_exists( 'WC_Stripe' ) ) : |
|
21 | +if ( ! class_exists('WC_Stripe')) : |
|
22 | 22 | /** |
23 | 23 | * Required minimums and constants |
24 | 24 | */ |
25 | - define( 'WC_STRIPE_VERSION', '4.0.0' ); |
|
26 | - define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' ); |
|
27 | - define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' ); |
|
28 | - define( 'WC_STRIPE_MAIN_FILE', __FILE__ ); |
|
29 | - define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); |
|
30 | - define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
25 | + define('WC_STRIPE_VERSION', '4.0.0'); |
|
26 | + define('WC_STRIPE_MIN_PHP_VER', '5.6.0'); |
|
27 | + define('WC_STRIPE_MIN_WC_VER', '2.6.0'); |
|
28 | + define('WC_STRIPE_MAIN_FILE', __FILE__); |
|
29 | + define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__)))); |
|
30 | + define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__))); |
|
31 | 31 | |
32 | 32 | class WC_Stripe { |
33 | 33 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @return Singleton The *Singleton* instance. |
48 | 48 | */ |
49 | 49 | public static function get_instance() { |
50 | - if ( null === self::$instance ) { |
|
50 | + if (null === self::$instance) { |
|
51 | 51 | self::$instance = new self(); |
52 | 52 | } |
53 | 53 | return self::$instance; |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | * *Singleton* via the `new` operator from outside of this class. |
81 | 81 | */ |
82 | 82 | private function __construct() { |
83 | - add_action( 'admin_init', array( $this, 'check_environment' ) ); |
|
84 | - add_action( 'admin_notices', array( $this, 'admin_notices' ), 15 ); |
|
85 | - add_action( 'plugins_loaded', array( $this, 'init' ) ); |
|
86 | - add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
83 | + add_action('admin_init', array($this, 'check_environment')); |
|
84 | + add_action('admin_notices', array($this, 'admin_notices'), 15); |
|
85 | + add_action('plugins_loaded', array($this, 'init')); |
|
86 | + add_action('wp_loaded', array($this, 'hide_notices')); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -93,39 +93,39 @@ discard block |
||
93 | 93 | * @version 4.0.0 |
94 | 94 | */ |
95 | 95 | public function init() { |
96 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php' ); |
|
97 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php' ); |
|
98 | - include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php' ); |
|
96 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-logger.php'); |
|
97 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-helper.php'); |
|
98 | + include_once(dirname(__FILE__) . '/includes/class-wc-stripe-api.php'); |
|
99 | 99 | |
100 | 100 | // Don't hook anything else in the plugin if we're in an incompatible environment |
101 | - if ( self::get_environment_warning() ) { |
|
101 | + if (self::get_environment_warning()) { |
|
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
105 | - load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
|
106 | - |
|
107 | - require_once( dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php' ); |
|
108 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php' ); |
|
109 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php' ); |
|
110 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php' ); |
|
111 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php' ); |
|
112 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php' ); |
|
113 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php' ); |
|
114 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php' ); |
|
115 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php' ); |
|
116 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php' ); |
|
117 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php' ); |
|
118 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bitcoin.php' ); |
|
119 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php' ); |
|
120 | - require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-compat.php' ); |
|
121 | - require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-compat.php' ); |
|
122 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php' ); |
|
123 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php' ); |
|
124 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php' ); |
|
125 | - |
|
126 | - add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) ); |
|
127 | - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) ); |
|
128 | - add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) ); |
|
105 | + load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages'); |
|
106 | + |
|
107 | + require_once(dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'); |
|
108 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php'); |
|
109 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php'); |
|
110 | + require_once(dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php'); |
|
111 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'); |
|
112 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'); |
|
113 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'); |
|
114 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'); |
|
115 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'); |
|
116 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'); |
|
117 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'); |
|
118 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bitcoin.php'); |
|
119 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php'); |
|
120 | + require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-compat.php'); |
|
121 | + require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-compat.php'); |
|
122 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php'); |
|
123 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php'); |
|
124 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-customer.php'); |
|
125 | + |
|
126 | + add_filter('woocommerce_payment_gateways', array($this, 'add_gateways')); |
|
127 | + add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links')); |
|
128 | + add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin')); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -135,23 +135,23 @@ discard block |
||
135 | 135 | * @version 4.0.0 |
136 | 136 | */ |
137 | 137 | public function hide_notices() { |
138 | - if ( isset( $_GET['wc-stripe-hide-notice'] ) && isset( $_GET['_wc_stripe_notice_nonce'] ) ) { |
|
139 | - if ( ! wp_verify_nonce( $_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce' ) ) { |
|
140 | - wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe' ) ); |
|
138 | + if (isset($_GET['wc-stripe-hide-notice']) && isset($_GET['_wc_stripe_notice_nonce'])) { |
|
139 | + if ( ! wp_verify_nonce($_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce')) { |
|
140 | + wp_die(__('Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe')); |
|
141 | 141 | } |
142 | 142 | |
143 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
144 | - wp_die( __( 'Cheatin’ huh?', 'woocommerce-gateway-stripe' ) ); |
|
143 | + if ( ! current_user_can('manage_woocommerce')) { |
|
144 | + wp_die(__('Cheatin’ huh?', 'woocommerce-gateway-stripe')); |
|
145 | 145 | } |
146 | 146 | |
147 | - $notice = wc_clean( $_GET['wc-stripe-hide-notice'] ); |
|
147 | + $notice = wc_clean($_GET['wc-stripe-hide-notice']); |
|
148 | 148 | |
149 | - switch ( $notice ) { |
|
149 | + switch ($notice) { |
|
150 | 150 | case 'ssl': |
151 | - update_option( 'wc_stripe_show_ssl_notice', 'no' ); |
|
151 | + update_option('wc_stripe_show_ssl_notice', 'no'); |
|
152 | 152 | break; |
153 | 153 | case 'keys': |
154 | - update_option( 'wc_stripe_show_keys_notice', 'no' ); |
|
154 | + update_option('wc_stripe_show_keys_notice', 'no'); |
|
155 | 155 | break; |
156 | 156 | } |
157 | 157 | } |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | * @since 1.0.0 |
164 | 164 | * @version 4.0.0 |
165 | 165 | */ |
166 | - public function add_admin_notice( $slug, $class, $message, $dismissible = false ) { |
|
167 | - $this->notices[ $slug ] = array( |
|
166 | + public function add_admin_notice($slug, $class, $message, $dismissible = false) { |
|
167 | + $this->notices[$slug] = array( |
|
168 | 168 | 'class' => $class, |
169 | 169 | 'message' => $message, |
170 | 170 | 'dismissible' => $dismissible, |
@@ -178,21 +178,21 @@ discard block |
||
178 | 178 | * @version 4.0.0 |
179 | 179 | */ |
180 | 180 | public function admin_notices() { |
181 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
181 | + if ( ! current_user_can('manage_woocommerce')) { |
|
182 | 182 | return; |
183 | 183 | } |
184 | 184 | |
185 | - foreach ( (array) $this->notices as $notice_key => $notice ) { |
|
186 | - echo '<div class="' . esc_attr( $notice['class'] ) . '" style="position:relative;">'; |
|
185 | + foreach ((array) $this->notices as $notice_key => $notice) { |
|
186 | + echo '<div class="' . esc_attr($notice['class']) . '" style="position:relative;">'; |
|
187 | 187 | |
188 | - if ( $notice['dismissible'] ) { |
|
188 | + if ($notice['dismissible']) { |
|
189 | 189 | ?> |
190 | - <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-stripe-hide-notice', $notice_key ), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce' ) ); ?>" class="woocommerce-message-close notice-dismiss" style="position:absolute;right:1px;padding:9px;text-decoration:none;"></a> |
|
190 | + <a href="<?php echo esc_url(wp_nonce_url(add_query_arg('wc-stripe-hide-notice', $notice_key), 'wc_stripe_hide_notices_nonce', '_wc_stripe_notice_nonce')); ?>" class="woocommerce-message-close notice-dismiss" style="position:absolute;right:1px;padding:9px;text-decoration:none;"></a> |
|
191 | 191 | <?php |
192 | 192 | } |
193 | 193 | |
194 | 194 | echo '<p>'; |
195 | - echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) ); |
|
195 | + echo wp_kses($notice['message'], array('a' => array('href' => array()))); |
|
196 | 196 | echo '</p></div>'; |
197 | 197 | } |
198 | 198 | } |
@@ -205,26 +205,26 @@ discard block |
||
205 | 205 | * @version 4.0.0 |
206 | 206 | */ |
207 | 207 | public function get_environment_warning() { |
208 | - if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) { |
|
208 | + if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) { |
|
209 | 209 | /* translators: 1) int version 2) int version */ |
210 | - $message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
210 | + $message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
211 | 211 | |
212 | - return sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() ); |
|
212 | + return sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion()); |
|
213 | 213 | } |
214 | 214 | |
215 | - if ( ! defined( 'WC_VERSION' ) ) { |
|
216 | - return __( 'WooCommerce Stripe requires WooCommerce to be activated to work.', 'woocommerce-gateway-stripe' ); |
|
215 | + if ( ! defined('WC_VERSION')) { |
|
216 | + return __('WooCommerce Stripe requires WooCommerce to be activated to work.', 'woocommerce-gateway-stripe'); |
|
217 | 217 | } |
218 | 218 | |
219 | - if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) { |
|
219 | + if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) { |
|
220 | 220 | /* translators: 1) int version 2) int version */ |
221 | - $message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
221 | + $message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
222 | 222 | |
223 | - return sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION ); |
|
223 | + return sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION); |
|
224 | 224 | } |
225 | 225 | |
226 | - if ( ! function_exists( 'curl_init' ) ) { |
|
227 | - return __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' ); |
|
226 | + if ( ! function_exists('curl_init')) { |
|
227 | + return __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe'); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | return false; |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | * @return string Setting link |
239 | 239 | */ |
240 | 240 | public function get_setting_link() { |
241 | - $use_id_as_section = function_exists( 'WC' ) ? version_compare( WC()->version, '2.6', '>=' ) : false; |
|
241 | + $use_id_as_section = function_exists('WC') ? version_compare(WC()->version, '2.6', '>=') : false; |
|
242 | 242 | |
243 | - $section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' ); |
|
243 | + $section_slug = $use_id_as_section ? 'stripe' : strtolower('WC_Gateway_Stripe'); |
|
244 | 244 | |
245 | - return admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug ); |
|
245 | + return admin_url('admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -253,37 +253,37 @@ discard block |
||
253 | 253 | * @version 4.0.0 |
254 | 254 | */ |
255 | 255 | public function check_environment() { |
256 | - if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) { |
|
256 | + if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) { |
|
257 | 257 | $this->install(); |
258 | 258 | |
259 | - do_action( 'woocommerce_stripe_updated' ); |
|
259 | + do_action('woocommerce_stripe_updated'); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | $environment_warning = $this->get_environment_warning(); |
263 | 263 | |
264 | - if ( $environment_warning && is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
265 | - $this->add_admin_notice( 'bad_environment', 'error', $environment_warning ); |
|
264 | + if ($environment_warning && is_plugin_active(plugin_basename(__FILE__))) { |
|
265 | + $this->add_admin_notice('bad_environment', 'error', $environment_warning); |
|
266 | 266 | } |
267 | 267 | |
268 | - $show_ssl_notice = get_option( 'wc_stripe_show_ssl_notice' ); |
|
269 | - $show_keys_notice = get_option( 'wc_stripe_show_keys_notice' ); |
|
270 | - $options = get_option( 'woocommerce_stripe_settings' ); |
|
268 | + $show_ssl_notice = get_option('wc_stripe_show_ssl_notice'); |
|
269 | + $show_keys_notice = get_option('wc_stripe_show_keys_notice'); |
|
270 | + $options = get_option('woocommerce_stripe_settings'); |
|
271 | 271 | |
272 | - if ( isset( $options['enabled'] ) && 'yes' === $options['enabled'] && empty( $show_keys_notice ) ) { |
|
273 | - $secret = WC_Stripe_API::get_secret_key(); |
|
272 | + if (isset($options['enabled']) && 'yes' === $options['enabled'] && empty($show_keys_notice)) { |
|
273 | + $secret = WC_Stripe_API::get_secret_key(); |
|
274 | 274 | |
275 | - if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) { |
|
275 | + if (empty($secret) && ! (isset($_GET['page'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'])) { |
|
276 | 276 | $setting_link = $this->get_setting_link(); |
277 | 277 | /* translators: 1) link */ |
278 | - $this->add_admin_notice( 'keys', 'notice notice-warning', sprintf( __( 'Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), $setting_link ), true ); |
|
278 | + $this->add_admin_notice('keys', 'notice notice-warning', sprintf(__('Stripe is almost ready. To get started, <a href="%s">set your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), $setting_link), true); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
282 | - if ( empty( $show_ssl_notice ) && isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) { |
|
282 | + if (empty($show_ssl_notice) && isset($options['enabled']) && 'yes' === $options['enabled']) { |
|
283 | 283 | // Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected. |
284 | - if ( ( function_exists( 'wc_site_is_https' ) && ! wc_site_is_https() ) && ( 'no' === get_option( 'woocommerce_force_ssl_checkout' ) && ! class_exists( 'WordPressHTTPS' ) ) ) { |
|
284 | + if ((function_exists('wc_site_is_https') && ! wc_site_is_https()) && ('no' === get_option('woocommerce_force_ssl_checkout') && ! class_exists('WordPressHTTPS'))) { |
|
285 | 285 | /* translators: 1) link 2) link */ |
286 | - $this->add_admin_notice( 'ssl', 'notice notice-warning', sprintf( __( 'Stripe is enabled, but the <a href="%1$s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid <a href="%2$s" target="_blank">SSL certificate</a> - Stripe will only work in test mode.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout' ), 'https://en.wikipedia.org/wiki/Transport_Layer_Security' ), true ); |
|
286 | + $this->add_admin_notice('ssl', 'notice notice-warning', sprintf(__('Stripe is enabled, but the <a href="%1$s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid <a href="%2$s" target="_blank">SSL certificate</a> - Stripe will only work in test mode.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout'), 'https://en.wikipedia.org/wiki/Transport_Layer_Security'), true); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | } |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | * @version 4.0.0 |
296 | 296 | */ |
297 | 297 | public function update_plugin_version() { |
298 | - delete_option( 'wc_stripe_version' ); |
|
299 | - update_option( 'wc_stripe_version', WC_STRIPE_VERSION ); |
|
298 | + delete_option('wc_stripe_version'); |
|
299 | + update_option('wc_stripe_version', WC_STRIPE_VERSION); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | * @version 3.1.0 |
307 | 307 | */ |
308 | 308 | public function install() { |
309 | - if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) { |
|
310 | - define( 'WC_STRIPE_INSTALLING', true ); |
|
309 | + if ( ! defined('WC_STRIPE_INSTALLING')) { |
|
310 | + define('WC_STRIPE_INSTALLING', true); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | $this->update_plugin_version(); |
@@ -319,13 +319,13 @@ discard block |
||
319 | 319 | * @since 1.0.0 |
320 | 320 | * @version 4.0.0 |
321 | 321 | */ |
322 | - public function plugin_action_links( $links ) { |
|
322 | + public function plugin_action_links($links) { |
|
323 | 323 | $plugin_links = array( |
324 | - '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>', |
|
325 | - '<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>', |
|
326 | - '<a href="https://woocommerce.com/contact-us/">' . esc_html__( 'Support', 'woocommerce-gateway-stripe' ) . '</a>', |
|
324 | + '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>', |
|
325 | + '<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__('Docs', 'woocommerce-gateway-stripe') . '</a>', |
|
326 | + '<a href="https://woocommerce.com/contact-us/">' . esc_html__('Support', 'woocommerce-gateway-stripe') . '</a>', |
|
327 | 327 | ); |
328 | - return array_merge( $plugin_links, $links ); |
|
328 | + return array_merge($plugin_links, $links); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @since 1.0.0 |
335 | 335 | * @version 4.0.0 |
336 | 336 | */ |
337 | - public function add_gateways( $methods ) { |
|
338 | - if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) || class_exists( 'WC_Pre_Orders_Order' ) ) { |
|
337 | + public function add_gateways($methods) { |
|
338 | + if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order') || class_exists('WC_Pre_Orders_Order')) { |
|
339 | 339 | $methods[] = 'WC_Stripe_Compat'; |
340 | 340 | $methods[] = 'WC_Stripe_Sepa_Compat'; |
341 | 341 | } else { |
@@ -360,26 +360,26 @@ discard block |
||
360 | 360 | * @since 4.0.0 |
361 | 361 | * @version 4.0.0 |
362 | 362 | */ |
363 | - public function filter_gateway_order_admin( $sections ) { |
|
364 | - unset( $sections['stripe'] ); |
|
365 | - unset( $sections['stripe_bancontact'] ); |
|
366 | - unset( $sections['stripe_sofort'] ); |
|
367 | - unset( $sections['stripe_giropay'] ); |
|
368 | - unset( $sections['stripe_ideal'] ); |
|
369 | - unset( $sections['stripe_p24'] ); |
|
370 | - unset( $sections['stripe_alipay'] ); |
|
371 | - unset( $sections['stripe_sepa'] ); |
|
372 | - unset( $sections['stripe_bitcoin'] ); |
|
363 | + public function filter_gateway_order_admin($sections) { |
|
364 | + unset($sections['stripe']); |
|
365 | + unset($sections['stripe_bancontact']); |
|
366 | + unset($sections['stripe_sofort']); |
|
367 | + unset($sections['stripe_giropay']); |
|
368 | + unset($sections['stripe_ideal']); |
|
369 | + unset($sections['stripe_p24']); |
|
370 | + unset($sections['stripe_alipay']); |
|
371 | + unset($sections['stripe_sepa']); |
|
372 | + unset($sections['stripe_bitcoin']); |
|
373 | 373 | |
374 | 374 | $sections['stripe'] = 'Stripe'; |
375 | - $sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' ); |
|
376 | - $sections['stripe_sofort'] = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' ); |
|
377 | - $sections['stripe_giropay'] = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' ); |
|
378 | - $sections['stripe_ideal'] = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' ); |
|
379 | - $sections['stripe_p24'] = __( 'Stripe P24', 'woocommerce-gateway-stripe' ); |
|
380 | - $sections['stripe_alipay'] = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' ); |
|
381 | - $sections['stripe_sepa'] = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' ); |
|
382 | - $sections['stripe_bitcoin'] = __( 'Stripe Bitcoin', 'woocommerce-gateway-stripe' ); |
|
375 | + $sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe'); |
|
376 | + $sections['stripe_sofort'] = __('Stripe SOFORT', 'woocommerce-gateway-stripe'); |
|
377 | + $sections['stripe_giropay'] = __('Stripe Giropay', 'woocommerce-gateway-stripe'); |
|
378 | + $sections['stripe_ideal'] = __('Stripe iDeal', 'woocommerce-gateway-stripe'); |
|
379 | + $sections['stripe_p24'] = __('Stripe P24', 'woocommerce-gateway-stripe'); |
|
380 | + $sections['stripe_alipay'] = __('Stripe Alipay', 'woocommerce-gateway-stripe'); |
|
381 | + $sections['stripe_sepa'] = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe'); |
|
382 | + $sections['stripe_bitcoin'] = __('Stripe Bitcoin', 'woocommerce-gateway-stripe'); |
|
383 | 383 | |
384 | 384 | return $sections; |
385 | 385 | } |