@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if ( ! defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | * @param string $deprecated Deprecated since WooCommerce 3.0 |
36 | 36 | * @return string |
37 | 37 | */ |
38 | - public function get_display_name( $deprecated = '' ) { |
|
38 | + public function get_display_name($deprecated = '') { |
|
39 | 39 | $display = sprintf( |
40 | 40 | /* translators: last 4 digits of IBAN account */ |
41 | - __( 'SEPA IBAN ending in %s', 'woocommerce-gateway-stripe' ), |
|
41 | + __('SEPA IBAN ending in %s', 'woocommerce-gateway-stripe'), |
|
42 | 42 | $this->get_last4() |
43 | 43 | ); |
44 | 44 | |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | * @return boolean True if the passed data is valid |
67 | 67 | */ |
68 | 68 | public function validate() { |
69 | - if ( false === parent::validate() ) { |
|
69 | + if (false === parent::validate()) { |
|
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
73 | - if ( ! $this->get_last4( 'edit' ) ) { |
|
73 | + if ( ! $this->get_last4('edit')) { |
|
74 | 74 | return false; |
75 | 75 | } |
76 | 76 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * @param string $context |
86 | 86 | * @return string Last 4 digits |
87 | 87 | */ |
88 | - public function get_last4( $context = 'view' ) { |
|
89 | - return $this->get_prop( 'last4', $context ); |
|
88 | + public function get_last4($context = 'view') { |
|
89 | + return $this->get_prop('last4', $context); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @version 4.0.0 |
96 | 96 | * @param string $last4 |
97 | 97 | */ |
98 | - public function set_last4( $last4 ) { |
|
99 | - $this->set_prop( 'last4', $last4 ); |
|
98 | + public function set_last4($last4) { |
|
99 | + $this->set_prop('last4', $last4); |
|
100 | 100 | } |
101 | 101 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @since 4.0.2 |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if ( ! defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | * @param string $error_message Full response |
24 | 24 | * @param string $localized_message user-friendly translated error message |
25 | 25 | */ |
26 | - public function __construct( $error_message = '', $localized_message = '' ) { |
|
26 | + public function __construct($error_message = '', $localized_message = '') { |
|
27 | 27 | $this->localized_message = $localized_message; |
28 | - parent::__construct( $error_message ); |
|
28 | + parent::__construct($error_message); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -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,28 +76,28 @@ 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 | |
103 | 103 | /** |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | $source = new stdClass(); |
110 | 110 | $source->type = 'three_d_secure'; |
111 | 111 | |
112 | - $this->assertEquals( true, $stripe->is_3ds_card( $source ) ); |
|
112 | + $this->assertEquals(true, $stripe->is_3ds_card($source)); |
|
113 | 113 | |
114 | 114 | $source = new stdClass(); |
115 | 115 | $source->type = 'card'; |
116 | 116 | |
117 | - $this->assertEquals( false, $stripe->is_3ds_card( $source ) ); |
|
117 | + $this->assertEquals(false, $stripe->is_3ds_card($source)); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -128,20 +128,20 @@ discard block |
||
128 | 128 | $source->card = new stdClass(); |
129 | 129 | $source->card->three_d_secure = 'required'; |
130 | 130 | |
131 | - $this->assertEquals( true, $stripe->is_3ds_required( $source ) ); |
|
131 | + $this->assertEquals(true, $stripe->is_3ds_required($source)); |
|
132 | 132 | |
133 | 133 | $source = new stdClass(); |
134 | 134 | $source->type = 'card'; |
135 | 135 | $source->card = new stdClass(); |
136 | 136 | $source->card->three_d_secure = 'optional'; |
137 | 137 | |
138 | - $this->assertEquals( false, $stripe->is_3ds_required( $source ) ); |
|
138 | + $this->assertEquals(false, $stripe->is_3ds_required($source)); |
|
139 | 139 | |
140 | 140 | $source = new stdClass(); |
141 | 141 | $source->type = 'card'; |
142 | 142 | $source->card = new stdClass(); |
143 | 143 | $source->card->three_d_secure = 'not_supported'; |
144 | 144 | |
145 | - $this->assertEquals( false, $stripe->is_3ds_required( $source ) ); |
|
145 | + $this->assertEquals(false, $stripe->is_3ds_required($source)); |
|
146 | 146 | } |
147 | 147 | } |
@@ -1,28 +1,28 @@ |
||
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 | } |
15 | 15 | |
16 | -tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); |
|
16 | +tests_add_filter('muplugins_loaded', '_manually_load_plugin'); |
|
17 | 17 | |
18 | 18 | require $_tests_dir . '/includes/bootstrap.php'; |
19 | 19 | |
20 | -$wc_tests_framework_base_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/woocommerce/tests/framework/'; |
|
21 | -require_once( $wc_tests_framework_base_dir . 'class-wc-mock-session-handler.php' ); |
|
22 | -require_once( $wc_tests_framework_base_dir . 'class-wc-unit-test-case.php' ); |
|
23 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-product.php' ); |
|
24 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-coupon.php' ); |
|
25 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-fee.php' ); |
|
26 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-shipping.php' ); |
|
27 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-customer.php' ); |
|
28 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-order.php' ); |
|
20 | +$wc_tests_framework_base_dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/woocommerce/tests/framework/'; |
|
21 | +require_once($wc_tests_framework_base_dir . 'class-wc-mock-session-handler.php'); |
|
22 | +require_once($wc_tests_framework_base_dir . 'class-wc-unit-test-case.php'); |
|
23 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-product.php'); |
|
24 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-coupon.php'); |
|
25 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-fee.php'); |
|
26 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-shipping.php'); |
|
27 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-customer.php'); |
|
28 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-order.php'); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * Set secret API Key. |
27 | 27 | * @param string $key |
28 | 28 | */ |
29 | - public static function set_secret_key( $secret_key ) { |
|
29 | + public static function set_secret_key($secret_key) { |
|
30 | 30 | self::$secret_key = $secret_key; |
31 | 31 | } |
32 | 32 | |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | * @return string |
36 | 36 | */ |
37 | 37 | public static function get_secret_key() { |
38 | - if ( ! self::$secret_key ) { |
|
39 | - $options = get_option( 'woocommerce_stripe_settings' ); |
|
38 | + if ( ! self::$secret_key) { |
|
39 | + $options = get_option('woocommerce_stripe_settings'); |
|
40 | 40 | |
41 | - if ( isset( $options['testmode'], $options['secret_key'], $options['test_secret_key'] ) ) { |
|
42 | - self::set_secret_key( 'yes' === $options['testmode'] ? $options['test_secret_key'] : $options['secret_key'] ); |
|
41 | + if (isset($options['testmode'], $options['secret_key'], $options['test_secret_key'])) { |
|
42 | + self::set_secret_key('yes' === $options['testmode'] ? $options['test_secret_key'] : $options['secret_key']); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | return self::$secret_key; |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $user_agent = self::get_user_agent(); |
79 | 79 | $app_info = $user_agent['application']; |
80 | 80 | |
81 | - return apply_filters( 'woocommerce_stripe_request_headers', array( |
|
82 | - 'Authorization' => 'Basic ' . base64_encode( self::get_secret_key() . ':' ), |
|
81 | + return apply_filters('woocommerce_stripe_request_headers', array( |
|
82 | + 'Authorization' => 'Basic ' . base64_encode(self::get_secret_key() . ':'), |
|
83 | 83 | 'Stripe-Version' => self::STRIPE_API_VERSION, |
84 | 84 | 'User-Agent' => $app_info['name'] . '/' . $app_info['version'] . ' (' . $app_info['url'] . ')', |
85 | - 'X-Stripe-Client-User-Agent' => json_encode( $user_agent ), |
|
86 | - ) ); |
|
85 | + 'X-Stripe-Client-User-Agent' => json_encode($user_agent), |
|
86 | + )); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | * @param bool $with_headers To get the response with headers. |
97 | 97 | * @return array|WP_Error |
98 | 98 | */ |
99 | - public static function request( $request, $api = 'charges', $method = 'POST', $with_headers = false ) { |
|
100 | - WC_Stripe_Logger::log( "{$api} request: " . print_r( $request, true ) ); |
|
99 | + public static function request($request, $api = 'charges', $method = 'POST', $with_headers = false) { |
|
100 | + WC_Stripe_Logger::log("{$api} request: " . print_r($request, true)); |
|
101 | 101 | |
102 | 102 | $headers = self::get_headers(); |
103 | 103 | |
104 | - if ( 'charges' === $api && 'POST' === $method ) { |
|
105 | - $customer = ! empty( $request['customer'] ) ? $request['customer'] : ''; |
|
106 | - $source = ! empty( $request['source'] ) ? $request['source'] : $customer; |
|
104 | + if ('charges' === $api && 'POST' === $method) { |
|
105 | + $customer = ! empty($request['customer']) ? $request['customer'] : ''; |
|
106 | + $source = ! empty($request['source']) ? $request['source'] : $customer; |
|
107 | 107 | |
108 | - $headers['Idempotency-Key'] = apply_filters( 'wc_stripe_idempotency_key', $request['metadata']['order_id'] . '-' . $source, $request ); |
|
108 | + $headers['Idempotency-Key'] = apply_filters('wc_stripe_idempotency_key', $request['metadata']['order_id'] . '-' . $source, $request); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | $response = wp_safe_remote_post( |
@@ -113,21 +113,21 @@ discard block |
||
113 | 113 | array( |
114 | 114 | 'method' => $method, |
115 | 115 | 'headers' => $headers, |
116 | - 'body' => apply_filters( 'woocommerce_stripe_request_body', $request, $api ), |
|
116 | + 'body' => apply_filters('woocommerce_stripe_request_body', $request, $api), |
|
117 | 117 | 'timeout' => 70, |
118 | 118 | ) |
119 | 119 | ); |
120 | 120 | |
121 | - if ( is_wp_error( $response ) || empty( $response['body'] ) ) { |
|
122 | - WC_Stripe_Logger::log( 'Error Response: ' . print_r( $response, true ) ); |
|
123 | - throw new WC_Stripe_Exception( print_r( $response, true ), __( 'There was a problem connecting to the Stripe API endpoint.', 'woocommerce-gateway-stripe' ) ); |
|
121 | + if (is_wp_error($response) || empty($response['body'])) { |
|
122 | + WC_Stripe_Logger::log('Error Response: ' . print_r($response, true)); |
|
123 | + throw new WC_Stripe_Exception(print_r($response, true), __('There was a problem connecting to the Stripe API endpoint.', 'woocommerce-gateway-stripe')); |
|
124 | 124 | } |
125 | 125 | |
126 | - if ( $with_headers ) { |
|
127 | - return array( 'headers' => wp_remote_retrieve_headers( $response ), 'body' => json_decode( $response['body'] ) ); |
|
126 | + if ($with_headers) { |
|
127 | + return array('headers' => wp_remote_retrieve_headers($response), 'body' => json_decode($response['body'])); |
|
128 | 128 | } |
129 | 129 | |
130 | - return json_decode( $response['body'] ); |
|
130 | + return json_decode($response['body']); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | * @version 4.0.0 |
138 | 138 | * @param string $api |
139 | 139 | */ |
140 | - public static function retrieve( $api ) { |
|
141 | - WC_Stripe_Logger::log( "{$api}" ); |
|
140 | + public static function retrieve($api) { |
|
141 | + WC_Stripe_Logger::log("{$api}"); |
|
142 | 142 | |
143 | 143 | $response = wp_safe_remote_get( |
144 | 144 | self::ENDPOINT . $api, |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | ) |
150 | 150 | ); |
151 | 151 | |
152 | - if ( is_wp_error( $response ) || empty( $response['body'] ) ) { |
|
153 | - WC_Stripe_Logger::log( 'Error Response: ' . print_r( $response, true ) ); |
|
154 | - return new WP_Error( 'stripe_error', __( 'There was a problem connecting to the Stripe API endpoint.', 'woocommerce-gateway-stripe' ) ); |
|
152 | + if (is_wp_error($response) || empty($response['body'])) { |
|
153 | + WC_Stripe_Logger::log('Error Response: ' . print_r($response, true)); |
|
154 | + return new WP_Error('stripe_error', __('There was a problem connecting to the Stripe API endpoint.', 'woocommerce-gateway-stripe')); |
|
155 | 155 | } |
156 | 156 | |
157 | - return json_decode( $response['body'] ); |
|
157 | + return json_decode($response['body']); |
|
158 | 158 | } |
159 | 159 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @since 4.0.6 |
6 | 6 | */ |
7 | 7 | |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if ( ! defined('ABSPATH')) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | 11 | |
@@ -60,21 +60,21 @@ discard block |
||
60 | 60 | public $apple_pay_verify_notice; |
61 | 61 | |
62 | 62 | public function __construct() { |
63 | - $this->stripe_settings = get_option( 'woocommerce_stripe_settings', array() ); |
|
64 | - $this->stripe_enabled = $this->get_option( 'enabled' ); |
|
65 | - $this->payment_request = 'yes' === $this->get_option( 'payment_request', 'yes' ); |
|
66 | - $this->apple_pay_domain_set = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' ); |
|
63 | + $this->stripe_settings = get_option('woocommerce_stripe_settings', array()); |
|
64 | + $this->stripe_enabled = $this->get_option('enabled'); |
|
65 | + $this->payment_request = 'yes' === $this->get_option('payment_request', 'yes'); |
|
66 | + $this->apple_pay_domain_set = 'yes' === $this->get_option('apple_pay_domain_set', 'no'); |
|
67 | 67 | $this->apple_pay_verify_notice = ''; |
68 | - $this->testmode = 'yes' === $this->get_option( 'testmode', 'no' ); |
|
69 | - $this->secret_key = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' ); |
|
68 | + $this->testmode = 'yes' === $this->get_option('testmode', 'no'); |
|
69 | + $this->secret_key = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key'); |
|
70 | 70 | |
71 | - if ( empty( $this->stripe_settings ) ) { |
|
71 | + if (empty($this->stripe_settings)) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | 75 | $this->init_apple_pay(); |
76 | 76 | |
77 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
77 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | * @param string default |
86 | 86 | * @return string $setting_value |
87 | 87 | */ |
88 | - public function get_option( $setting = '', $default = '' ) { |
|
89 | - if ( empty( $this->stripe_settings ) ) { |
|
88 | + public function get_option($setting = '', $default = '') { |
|
89 | + if (empty($this->stripe_settings)) { |
|
90 | 90 | return $default; |
91 | 91 | } |
92 | 92 | |
93 | - if ( ! empty( $this->stripe_settings[ $setting ] ) ) { |
|
94 | - return $this->stripe_settings[ $setting ]; |
|
93 | + if ( ! empty($this->stripe_settings[$setting])) { |
|
94 | + return $this->stripe_settings[$setting]; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | return $default; |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | public function init_apple_pay() { |
107 | 107 | if ( |
108 | 108 | is_admin() && |
109 | - isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] && |
|
110 | - isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'] && |
|
111 | - isset( $_GET['section'] ) && 'stripe' === $_GET['section'] && |
|
109 | + isset($_GET['page']) && 'wc-settings' === $_GET['page'] && |
|
110 | + isset($_GET['tab']) && 'checkout' === $_GET['tab'] && |
|
111 | + isset($_GET['section']) && 'stripe' === $_GET['section'] && |
|
112 | 112 | $this->payment_request |
113 | 113 | ) { |
114 | 114 | $this->process_apple_pay_verification(); |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | * @version 3.1.0 |
123 | 123 | * @param string $secret_key |
124 | 124 | */ |
125 | - private function register_apple_pay_domain( $secret_key = '' ) { |
|
126 | - if ( empty( $secret_key ) ) { |
|
127 | - throw new Exception( __( 'Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe' ) ); |
|
125 | + private function register_apple_pay_domain($secret_key = '') { |
|
126 | + if (empty($secret_key)) { |
|
127 | + throw new Exception(__('Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe')); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | $endpoint = 'https://api.stripe.com/v1/apple_pay/domains'; |
@@ -138,23 +138,23 @@ discard block |
||
138 | 138 | 'Authorization' => 'Bearer ' . $secret_key, |
139 | 139 | ); |
140 | 140 | |
141 | - $response = wp_remote_post( $endpoint, array( |
|
141 | + $response = wp_remote_post($endpoint, array( |
|
142 | 142 | 'headers' => $headers, |
143 | - 'body' => http_build_query( $data ), |
|
144 | - ) ); |
|
143 | + 'body' => http_build_query($data), |
|
144 | + )); |
|
145 | 145 | |
146 | - if ( is_wp_error( $response ) ) { |
|
146 | + if (is_wp_error($response)) { |
|
147 | 147 | /* translators: error message */ |
148 | - throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) ); |
|
148 | + throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $response->get_error_message())); |
|
149 | 149 | } |
150 | 150 | |
151 | - if ( 200 !== $response['response']['code'] ) { |
|
152 | - $parsed_response = json_decode( $response['body'] ); |
|
151 | + if (200 !== $response['response']['code']) { |
|
152 | + $parsed_response = json_decode($response['body']); |
|
153 | 153 | |
154 | 154 | $this->apple_pay_verify_notice = $parsed_response->error->message; |
155 | 155 | |
156 | 156 | /* translators: error message */ |
157 | - throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $parsed_response->error->message ) ); |
|
157 | + throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $parsed_response->error->message)); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
@@ -166,45 +166,45 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function process_apple_pay_verification() { |
168 | 168 | try { |
169 | - $path = untrailingslashit( $_SERVER['DOCUMENT_ROOT'] ); |
|
169 | + $path = untrailingslashit($_SERVER['DOCUMENT_ROOT']); |
|
170 | 170 | $dir = '.well-known'; |
171 | 171 | $file = 'apple-developer-merchantid-domain-association'; |
172 | 172 | $fullpath = $path . '/' . $dir . '/' . $file; |
173 | 173 | |
174 | - if ( $this->apple_pay_domain_set && file_exists( $fullpath ) ) { |
|
174 | + if ($this->apple_pay_domain_set && file_exists($fullpath)) { |
|
175 | 175 | return; |
176 | 176 | } |
177 | 177 | |
178 | - if ( ! file_exists( $path . '/' . $dir ) ) { |
|
179 | - if ( ! @mkdir( $path . '/' . $dir, 0755 ) ) { // @codingStandardsIgnoreLine |
|
180 | - throw new Exception( __( 'Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe' ) ); |
|
178 | + if ( ! file_exists($path . '/' . $dir)) { |
|
179 | + if ( ! @mkdir($path . '/' . $dir, 0755)) { // @codingStandardsIgnoreLine |
|
180 | + throw new Exception(__('Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe')); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - if ( ! file_exists( $fullpath ) ) { |
|
185 | - if ( ! @copy( WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath ) ) { // @codingStandardsIgnoreLine |
|
186 | - throw new Exception( __( 'Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe' ) ); |
|
184 | + if ( ! file_exists($fullpath)) { |
|
185 | + if ( ! @copy(WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath)) { // @codingStandardsIgnoreLine |
|
186 | + throw new Exception(__('Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe')); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | // At this point then the domain association folder and file should be available. |
191 | 191 | // Proceed to verify/and or verify again. |
192 | - $this->register_apple_pay_domain( $this->secret_key ); |
|
192 | + $this->register_apple_pay_domain($this->secret_key); |
|
193 | 193 | |
194 | 194 | // No errors to this point, verification success! |
195 | 195 | $this->stripe_settings['apple_pay_domain_set'] = 'yes'; |
196 | 196 | $this->apple_pay_domain_set = true; |
197 | 197 | |
198 | - update_option( 'woocommerce_stripe_settings', $this->stripe_settings ); |
|
198 | + update_option('woocommerce_stripe_settings', $this->stripe_settings); |
|
199 | 199 | |
200 | - WC_Stripe_Logger::log( 'Your domain has been verified with Apple Pay!' ); |
|
200 | + WC_Stripe_Logger::log('Your domain has been verified with Apple Pay!'); |
|
201 | 201 | |
202 | - } catch ( Exception $e ) { |
|
202 | + } catch (Exception $e) { |
|
203 | 203 | $this->stripe_settings['apple_pay_domain_set'] = 'no'; |
204 | 204 | |
205 | - update_option( 'woocommerce_stripe_settings', $this->stripe_settings ); |
|
205 | + update_option('woocommerce_stripe_settings', $this->stripe_settings); |
|
206 | 206 | |
207 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
207 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
@@ -214,11 +214,11 @@ discard block |
||
214 | 214 | * @since 4.0.6 |
215 | 215 | */ |
216 | 216 | public function admin_notices() { |
217 | - if ( ! $this->stripe_enabled ) { |
|
217 | + if ( ! $this->stripe_enabled) { |
|
218 | 218 | return; |
219 | 219 | } |
220 | 220 | |
221 | - if ( $this->payment_request && ! empty( $this->apple_pay_verify_notice ) ) { |
|
221 | + if ($this->payment_request && ! empty($this->apple_pay_verify_notice)) { |
|
222 | 222 | $allowed_html = array( |
223 | 223 | 'a' => array( |
224 | 224 | 'href' => array(), |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | ), |
227 | 227 | ); |
228 | 228 | |
229 | - echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses( make_clickable( $this->apple_pay_verify_notice ), $allowed_html ) . '</p></div>'; |
|
229 | + echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses(make_clickable($this->apple_pay_verify_notice), $allowed_html) . '</p></div>'; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -234,9 +234,9 @@ discard block |
||
234 | 234 | * when setting screen is displayed. So if domain verification is not set, |
235 | 235 | * something went wrong so lets notify user. |
236 | 236 | */ |
237 | - if ( ! empty( $this->secret_key ) && $this->payment_request && ! $this->apple_pay_domain_set ) { |
|
237 | + if ( ! empty($this->secret_key) && $this->payment_request && ! $this->apple_pay_domain_set) { |
|
238 | 238 | /* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */ |
239 | - 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>'; |
|
239 | + 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>'; |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
@@ -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,30 +13,30 @@ 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_show_alipay_notice' ); |
|
24 | - delete_option( 'wc_stripe_show_bancontact_notice' ); |
|
25 | - delete_option( 'wc_stripe_show_bitcoin_notice' ); |
|
26 | - delete_option( 'wc_stripe_show_eps_notice' ); |
|
27 | - delete_option( 'wc_stripe_show_giropay_notice' ); |
|
28 | - delete_option( 'wc_stripe_show_ideal_notice' ); |
|
29 | - delete_option( 'wc_stripe_show_multibanco_notice' ); |
|
30 | - delete_option( 'wc_stripe_show_p24_notice' ); |
|
31 | - delete_option( 'wc_stripe_show_sepa_notice' ); |
|
32 | - delete_option( 'wc_stripe_show_sofort_notice' ); |
|
33 | - delete_option( 'wc_stripe_version' ); |
|
34 | - delete_option( 'woocommerce_stripe_bancontact_settings' ); |
|
35 | - delete_option( 'woocommerce_stripe_alipay_settings' ); |
|
36 | - delete_option( 'woocommerce_stripe_bitcoin_settings' ); |
|
37 | - delete_option( 'woocommerce_stripe_ideal_settings' ); |
|
38 | - delete_option( 'woocommerce_stripe_p24_settings' ); |
|
39 | - delete_option( 'woocommerce_stripe_giropay_settings' ); |
|
40 | - delete_option( 'woocommerce_stripe_sepa_settings' ); |
|
41 | - 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_show_alipay_notice'); |
|
24 | + delete_option('wc_stripe_show_bancontact_notice'); |
|
25 | + delete_option('wc_stripe_show_bitcoin_notice'); |
|
26 | + delete_option('wc_stripe_show_eps_notice'); |
|
27 | + delete_option('wc_stripe_show_giropay_notice'); |
|
28 | + delete_option('wc_stripe_show_ideal_notice'); |
|
29 | + delete_option('wc_stripe_show_multibanco_notice'); |
|
30 | + delete_option('wc_stripe_show_p24_notice'); |
|
31 | + delete_option('wc_stripe_show_sepa_notice'); |
|
32 | + delete_option('wc_stripe_show_sofort_notice'); |
|
33 | + delete_option('wc_stripe_version'); |
|
34 | + delete_option('woocommerce_stripe_bancontact_settings'); |
|
35 | + delete_option('woocommerce_stripe_alipay_settings'); |
|
36 | + delete_option('woocommerce_stripe_bitcoin_settings'); |
|
37 | + delete_option('woocommerce_stripe_ideal_settings'); |
|
38 | + delete_option('woocommerce_stripe_p24_settings'); |
|
39 | + delete_option('woocommerce_stripe_giropay_settings'); |
|
40 | + delete_option('woocommerce_stripe_sepa_settings'); |
|
41 | + delete_option('woocommerce_stripe_sofort_settings'); |
|
42 | 42 | } |
@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | * |
16 | 16 | */ |
17 | 17 | |
18 | -if ( ! defined( 'ABSPATH' ) ) { |
|
18 | +if ( ! defined('ABSPATH')) { |
|
19 | 19 | exit; |
20 | 20 | } |
21 | 21 | |
22 | -if ( ! class_exists( 'WC_Stripe' ) ) : |
|
22 | +if ( ! class_exists('WC_Stripe')) : |
|
23 | 23 | /** |
24 | 24 | * Required minimums and constants |
25 | 25 | */ |
26 | - define( 'WC_STRIPE_VERSION', '4.1.0-beta-1' ); |
|
27 | - define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' ); |
|
28 | - define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' ); |
|
29 | - define( 'WC_STRIPE_MAIN_FILE', __FILE__ ); |
|
30 | - define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); |
|
31 | - define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
26 | + define('WC_STRIPE_VERSION', '4.1.0-beta-1'); |
|
27 | + define('WC_STRIPE_MIN_PHP_VER', '5.6.0'); |
|
28 | + define('WC_STRIPE_MIN_WC_VER', '2.6.0'); |
|
29 | + define('WC_STRIPE_MAIN_FILE', __FILE__); |
|
30 | + define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__)))); |
|
31 | + define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__))); |
|
32 | 32 | |
33 | 33 | class WC_Stripe { |
34 | 34 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return Singleton The *Singleton* instance. |
49 | 49 | */ |
50 | 50 | public static function get_instance() { |
51 | - if ( null === self::$instance ) { |
|
51 | + if (null === self::$instance) { |
|
52 | 52 | self::$instance = new self(); |
53 | 53 | } |
54 | 54 | return self::$instance; |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * *Singleton* via the `new` operator from outside of this class. |
76 | 76 | */ |
77 | 77 | private function __construct() { |
78 | - add_action( 'admin_init', array( $this, 'install' ) ); |
|
79 | - add_action( 'plugins_loaded', array( $this, 'init' ) ); |
|
78 | + add_action('admin_init', array($this, 'install')); |
|
79 | + add_action('plugins_loaded', array($this, 'init')); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -86,51 +86,51 @@ discard block |
||
86 | 86 | * @version 4.0.0 |
87 | 87 | */ |
88 | 88 | public function init() { |
89 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php' ); |
|
90 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php' ); |
|
91 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php' ); |
|
92 | - include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php' ); |
|
89 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-exception.php'); |
|
90 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-logger.php'); |
|
91 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-helper.php'); |
|
92 | + include_once(dirname(__FILE__) . '/includes/class-wc-stripe-api.php'); |
|
93 | 93 | |
94 | 94 | // Don't hook anything else in the plugin if we're in an incompatible environment. |
95 | - if ( $this->get_environment_warning() && is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
95 | + if ($this->get_environment_warning() && is_plugin_active(plugin_basename(__FILE__))) { |
|
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
99 | - load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
|
100 | - |
|
101 | - require_once( dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php' ); |
|
102 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php' ); |
|
103 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php' ); |
|
104 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php' ); |
|
105 | - require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php' ); |
|
106 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php' ); |
|
107 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php' ); |
|
108 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php' ); |
|
109 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php' ); |
|
110 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php' ); |
|
111 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php' ); |
|
112 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php' ); |
|
113 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php' ); |
|
114 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php' ); |
|
115 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bitcoin.php' ); |
|
116 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php' ); |
|
117 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php' ); |
|
118 | - require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php' ); |
|
119 | - require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php' ); |
|
120 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php' ); |
|
121 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php' ); |
|
122 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php' ); |
|
123 | - |
|
124 | - if ( is_admin() ) { |
|
125 | - require_once( dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php' ); |
|
99 | + load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages'); |
|
100 | + |
|
101 | + require_once(dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'); |
|
102 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php'); |
|
103 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php'); |
|
104 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php'); |
|
105 | + require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php'); |
|
106 | + require_once(dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php'); |
|
107 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'); |
|
108 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'); |
|
109 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'); |
|
110 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'); |
|
111 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'); |
|
112 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'); |
|
113 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'); |
|
114 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'); |
|
115 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bitcoin.php'); |
|
116 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'); |
|
117 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php'); |
|
118 | + require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php'); |
|
119 | + require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php'); |
|
120 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php'); |
|
121 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php'); |
|
122 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-customer.php'); |
|
123 | + |
|
124 | + if (is_admin()) { |
|
125 | + require_once(dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php'); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // REMOVE IN THE FUTURE. |
129 | - require_once( dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php' ); |
|
129 | + require_once(dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php'); |
|
130 | 130 | |
131 | - add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) ); |
|
132 | - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) ); |
|
133 | - add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) ); |
|
131 | + add_filter('woocommerce_payment_gateways', array($this, 'add_gateways')); |
|
132 | + add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links')); |
|
133 | + add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin')); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -142,26 +142,26 @@ discard block |
||
142 | 142 | * @version 4.0.0 |
143 | 143 | */ |
144 | 144 | public function get_environment_warning() { |
145 | - if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) { |
|
145 | + if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) { |
|
146 | 146 | /* translators: 1) int version 2) int version */ |
147 | - $message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
147 | + $message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
148 | 148 | |
149 | - return sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() ); |
|
149 | + return sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion()); |
|
150 | 150 | } |
151 | 151 | |
152 | - if ( ! defined( 'WC_VERSION' ) ) { |
|
153 | - return __( 'WooCommerce Stripe requires WooCommerce to be activated to work.', 'woocommerce-gateway-stripe' ); |
|
152 | + if ( ! defined('WC_VERSION')) { |
|
153 | + return __('WooCommerce Stripe requires WooCommerce to be activated to work.', 'woocommerce-gateway-stripe'); |
|
154 | 154 | } |
155 | 155 | |
156 | - if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) { |
|
156 | + if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) { |
|
157 | 157 | /* translators: 1) int version 2) int version */ |
158 | - $message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
158 | + $message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
159 | 159 | |
160 | - return sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION ); |
|
160 | + return sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION); |
|
161 | 161 | } |
162 | 162 | |
163 | - if ( ! function_exists( 'curl_init' ) ) { |
|
164 | - return __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' ); |
|
163 | + if ( ! function_exists('curl_init')) { |
|
164 | + return __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe'); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | return false; |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @version 4.0.0 |
175 | 175 | */ |
176 | 176 | public function update_plugin_version() { |
177 | - delete_option( 'wc_stripe_version' ); |
|
178 | - update_option( 'wc_stripe_version', WC_STRIPE_VERSION ); |
|
177 | + delete_option('wc_stripe_version'); |
|
178 | + update_option('wc_stripe_version', WC_STRIPE_VERSION); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | * @version 3.1.0 |
186 | 186 | */ |
187 | 187 | public function install() { |
188 | - if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) { |
|
189 | - do_action( 'woocommerce_stripe_updated' ); |
|
188 | + if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) { |
|
189 | + do_action('woocommerce_stripe_updated'); |
|
190 | 190 | |
191 | - if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) { |
|
192 | - define( 'WC_STRIPE_INSTALLING', true ); |
|
191 | + if ( ! defined('WC_STRIPE_INSTALLING')) { |
|
192 | + define('WC_STRIPE_INSTALLING', true); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | $this->update_plugin_version(); |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | * @since 1.0.0 |
203 | 203 | * @version 4.0.0 |
204 | 204 | */ |
205 | - public function plugin_action_links( $links ) { |
|
205 | + public function plugin_action_links($links) { |
|
206 | 206 | $plugin_links = array( |
207 | - '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>', |
|
208 | - '<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>', |
|
209 | - '<a href="https://woocommerce.com/contact-us/">' . esc_html__( 'Support', 'woocommerce-gateway-stripe' ) . '</a>', |
|
207 | + '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>', |
|
208 | + '<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__('Docs', 'woocommerce-gateway-stripe') . '</a>', |
|
209 | + '<a href="https://woocommerce.com/contact-us/">' . esc_html__('Support', 'woocommerce-gateway-stripe') . '</a>', |
|
210 | 210 | ); |
211 | - return array_merge( $plugin_links, $links ); |
|
211 | + return array_merge($plugin_links, $links); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | * @since 1.0.0 |
218 | 218 | * @version 4.0.0 |
219 | 219 | */ |
220 | - public function add_gateways( $methods ) { |
|
221 | - if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) { |
|
220 | + public function add_gateways($methods) { |
|
221 | + if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) { |
|
222 | 222 | $methods[] = 'WC_Stripe_Subs_Compat'; |
223 | 223 | $methods[] = 'WC_Stripe_Sepa_Subs_Compat'; |
224 | 224 | } else { |
@@ -245,30 +245,30 @@ discard block |
||
245 | 245 | * @since 4.0.0 |
246 | 246 | * @version 4.0.0 |
247 | 247 | */ |
248 | - public function filter_gateway_order_admin( $sections ) { |
|
249 | - unset( $sections['stripe'] ); |
|
250 | - unset( $sections['stripe_bancontact'] ); |
|
251 | - unset( $sections['stripe_sofort'] ); |
|
252 | - unset( $sections['stripe_giropay'] ); |
|
253 | - unset( $sections['stripe_eps'] ); |
|
254 | - unset( $sections['stripe_ideal'] ); |
|
255 | - unset( $sections['stripe_p24'] ); |
|
256 | - unset( $sections['stripe_alipay'] ); |
|
257 | - unset( $sections['stripe_sepa'] ); |
|
258 | - unset( $sections['stripe_bitcoin'] ); |
|
259 | - unset( $sections['stripe_multibanco'] ); |
|
248 | + public function filter_gateway_order_admin($sections) { |
|
249 | + unset($sections['stripe']); |
|
250 | + unset($sections['stripe_bancontact']); |
|
251 | + unset($sections['stripe_sofort']); |
|
252 | + unset($sections['stripe_giropay']); |
|
253 | + unset($sections['stripe_eps']); |
|
254 | + unset($sections['stripe_ideal']); |
|
255 | + unset($sections['stripe_p24']); |
|
256 | + unset($sections['stripe_alipay']); |
|
257 | + unset($sections['stripe_sepa']); |
|
258 | + unset($sections['stripe_bitcoin']); |
|
259 | + unset($sections['stripe_multibanco']); |
|
260 | 260 | |
261 | 261 | $sections['stripe'] = 'Stripe'; |
262 | - $sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' ); |
|
263 | - $sections['stripe_sofort'] = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' ); |
|
264 | - $sections['stripe_giropay'] = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' ); |
|
265 | - $sections['stripe_eps'] = __( 'Stripe EPS', 'woocommerce-gateway-stripe' ); |
|
266 | - $sections['stripe_ideal'] = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' ); |
|
267 | - $sections['stripe_p24'] = __( 'Stripe P24', 'woocommerce-gateway-stripe' ); |
|
268 | - $sections['stripe_alipay'] = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' ); |
|
269 | - $sections['stripe_sepa'] = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' ); |
|
270 | - $sections['stripe_bitcoin'] = __( 'Stripe Bitcoin', 'woocommerce-gateway-stripe' ); |
|
271 | - $sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' ); |
|
262 | + $sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe'); |
|
263 | + $sections['stripe_sofort'] = __('Stripe SOFORT', 'woocommerce-gateway-stripe'); |
|
264 | + $sections['stripe_giropay'] = __('Stripe Giropay', 'woocommerce-gateway-stripe'); |
|
265 | + $sections['stripe_eps'] = __('Stripe EPS', 'woocommerce-gateway-stripe'); |
|
266 | + $sections['stripe_ideal'] = __('Stripe iDeal', 'woocommerce-gateway-stripe'); |
|
267 | + $sections['stripe_p24'] = __('Stripe P24', 'woocommerce-gateway-stripe'); |
|
268 | + $sections['stripe_alipay'] = __('Stripe Alipay', 'woocommerce-gateway-stripe'); |
|
269 | + $sections['stripe_sepa'] = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe'); |
|
270 | + $sections['stripe_bitcoin'] = __('Stripe Bitcoin', 'woocommerce-gateway-stripe'); |
|
271 | + $sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe'); |
|
272 | 272 | |
273 | 273 | return $sections; |
274 | 274 | } |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
7 | 7 | * DEPRECATED DO NOT USE!! |
8 | 8 | */ |
9 | -if ( ! class_exists( 'WC_Stripe_Apple_Pay' ) ) { |
|
9 | +if ( ! class_exists('WC_Stripe_Apple_Pay')) { |
|
10 | 10 | class WC_Stripe_Apple_Pay { |
11 | 11 | /** |
12 | 12 | * This Instance. |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | public static function instance() { |
23 | - WC_Stripe_Logger::log( 'DEPRECATED! WC_Stripe_Apple_Pay class has been hard deprecated. Please remove any code that references this class or instance. This class will be removed by version 4.2' ); |
|
23 | + WC_Stripe_Logger::log('DEPRECATED! WC_Stripe_Apple_Pay class has been hard deprecated. Please remove any code that references this class or instance. This class will be removed by version 4.2'); |
|
24 | 24 | return self::$_this; |
25 | 25 | } |
26 | 26 | |
27 | - public function __get( $var ) { |
|
27 | + public function __get($var) { |
|
28 | 28 | return null; |
29 | 29 | } |
30 | 30 | |
31 | - public function __call( $name, $arguments ) { |
|
31 | + public function __call($name, $arguments) { |
|
32 | 32 | return null; |
33 | 33 | } |
34 | 34 | } |