Completed
Pull Request — master (#1267)
by
unknown
01:55
created
includes/connect/class-wc-stripe-connect-rest-oauth-connect-controller.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if ( ! defined('ABSPATH')) {
4 4
 	exit;
5 5
 }
6 6
 
7
-if ( ! class_exists( 'WC_Stripe_Connect_REST_Oauth_Connect_Controller' ) ) {
7
+if ( ! class_exists('WC_Stripe_Connect_REST_Oauth_Connect_Controller')) {
8 8
 	/**
9 9
 	 * Stripe Connect Oauth Connect controller class.
10 10
 	 */
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 		 * @param WC_Stripe_Connect     $connect stripe connect.
31 31
 		 * @param WC_Stripe_Connect_API $api     stripe connect api.
32 32
 		 */
33
-		public function __construct( WC_Stripe_Connect $connect, WC_Stripe_Connect_API $api ) {
33
+		public function __construct(WC_Stripe_Connect $connect, WC_Stripe_Connect_API $api) {
34 34
 
35
-			parent::__construct( $api );
35
+			parent::__construct($api);
36 36
 
37 37
 			$this->connect = $connect;
38 38
 		}
@@ -44,19 +44,19 @@  discard block
 block discarded – undo
44 44
 		 *
45 45
 		 * @return array|WP_Error
46 46
 		 */
47
-		public function post( $request ) {
47
+		public function post($request) {
48 48
 
49 49
 			$data     = $request->get_json_params();
50
-			$response = $this->connect->connect_oauth( $data['state'], $data['code'] );
50
+			$response = $this->connect->connect_oauth($data['state'], $data['code']);
51 51
 
52
-			if ( is_wp_error( $response ) ) {
52
+			if (is_wp_error($response)) {
53 53
 
54
-				WC_Stripe_Logger::log( $response, __CLASS__ );
54
+				WC_Stripe_Logger::log($response, __CLASS__);
55 55
 
56 56
 				return new WP_Error(
57 57
 					$response->get_error_code(),
58 58
 					$response->get_error_message(),
59
-					array( 'status' => 400 )
59
+					array('status' => 400)
60 60
 				);
61 61
 			}
62 62
 
Please login to merge, or discard this patch.
includes/connect/class-wc-stripe-connect-rest-controller.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if ( ! defined('ABSPATH')) {
4 4
 	exit;
5 5
 }
6 6
 
7
-if ( ! class_exists( 'WC_Stripe_Connect_REST_Controller' ) ) {
7
+if ( ! class_exists('WC_Stripe_Connect_REST_Controller')) {
8 8
 	/**
9 9
 	 * Stripe Connect base REST controller class.
10 10
 	 */
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		 *
30 30
 		 * @param WC_Stripe_Connect_API $api stripe connect api.
31 31
 		 */
32
-		public function __construct( WC_Stripe_Connect_API $api ) {
32
+		public function __construct(WC_Stripe_Connect_API $api) {
33 33
 
34 34
 			$this->api = $api;
35 35
 		}
@@ -39,43 +39,43 @@  discard block
 block discarded – undo
39 39
 		 */
40 40
 		public function register_routes() {
41 41
 
42
-			if ( method_exists( $this, 'get' ) ) {
42
+			if (method_exists($this, 'get')) {
43 43
 				register_rest_route(
44 44
 					$this->namespace,
45 45
 					'/' . $this->rest_base,
46 46
 					array(
47 47
 						array(
48 48
 							'methods'             => 'GET',
49
-							'callback'            => array( $this, 'get_internal' ),
50
-							'permission_callback' => array( $this, 'check_permission' ),
49
+							'callback'            => array($this, 'get_internal'),
50
+							'permission_callback' => array($this, 'check_permission'),
51 51
 						),
52 52
 					)
53 53
 				);
54 54
 			}
55 55
 
56
-			if ( method_exists( $this, 'post' ) ) {
56
+			if (method_exists($this, 'post')) {
57 57
 				register_rest_route(
58 58
 					$this->namespace,
59 59
 					'/' . $this->rest_base,
60 60
 					array(
61 61
 						array(
62 62
 							'methods'             => 'POST',
63
-							'callback'            => array( $this, 'post_internal' ),
64
-							'permission_callback' => array( $this, 'check_permission' ),
63
+							'callback'            => array($this, 'post_internal'),
64
+							'permission_callback' => array($this, 'check_permission'),
65 65
 						),
66 66
 					)
67 67
 				);
68 68
 			}
69 69
 
70
-			if ( method_exists( $this, 'delete' ) ) {
70
+			if (method_exists($this, 'delete')) {
71 71
 				register_rest_route(
72 72
 					$this->namespace,
73 73
 					'/' . $this->rest_base,
74 74
 					array(
75 75
 						array(
76 76
 							'methods'             => 'DELETE',
77
-							'callback'            => array( $this, 'delete_internal' ),
78
-							'permission_callback' => array( $this, 'check_permission' ),
77
+							'callback'            => array($this, 'delete_internal'),
78
+							'permission_callback' => array($this, 'check_permission'),
79 79
 						),
80 80
 					)
81 81
 				);
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 		 *
90 90
 		 * @return array
91 91
 		 */
92
-		public function get_internal( $request ) {
92
+		public function get_internal($request) {
93 93
 
94 94
 			$this->prevent_route_caching();
95 95
 
96
-			return $this->get( $request );
96
+			return $this->get($request);
97 97
 		}
98 98
 
99 99
 		/**
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 		 *
104 104
 		 * @return array
105 105
 		 */
106
-		public function post_internal( $request ) {
106
+		public function post_internal($request) {
107 107
 
108 108
 			$this->prevent_route_caching();
109 109
 
110
-			return $this->post( $request );
110
+			return $this->post($request);
111 111
 		}
112 112
 
113 113
 		/**
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 		 *
118 118
 		 * @return array
119 119
 		 */
120
-		public function delete_internal( $request ) {
120
+		public function delete_internal($request) {
121 121
 
122 122
 			$this->prevent_route_caching();
123 123
 
124
-			return $this->delete( $request );
124
+			return $this->delete($request);
125 125
 		}
126 126
 
127 127
 		/**
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 		 *
132 132
 		 * @return bool
133 133
 		 */
134
-		public function check_permission( $request ) {
134
+		public function check_permission($request) {
135 135
 
136
-			return current_user_can( 'manage_woocommerce' );
136
+			return current_user_can('manage_woocommerce');
137 137
 		}
138 138
 
139 139
 		/**
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
 		 */
142 142
 		public function prevent_route_caching() {
143 143
 
144
-			if ( ! defined( 'DONOTCACHEPAGE' ) ) {
145
-				define( 'DONOTCACHEPAGE', true ); // Play nice with WP-Super-Cache.
144
+			if ( ! defined('DONOTCACHEPAGE')) {
145
+				define('DONOTCACHEPAGE', true); // Play nice with WP-Super-Cache.
146 146
 			}
147 147
 
148 148
 			// Prevent our REST API endpoint responses from being added to browser cache.
149
-			add_filter( 'rest_post_dispatch', array( $this, 'send_nocache_header' ), PHP_INT_MAX, 2 );
149
+			add_filter('rest_post_dispatch', array($this, 'send_nocache_header'), PHP_INT_MAX, 2);
150 150
 		}
151 151
 
152 152
 		/**
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 		 *
161 161
 		 * @return WP_REST_Response passthrough $response parameter
162 162
 		 */
163
-		public function send_nocache_header( $response, $server ) {
163
+		public function send_nocache_header($response, $server) {
164 164
 
165
-			$server->send_header( 'Cache-Control', 'no-cache, must-revalidate, max-age=0' );
165
+			$server->send_header('Cache-Control', 'no-cache, must-revalidate, max-age=0');
166 166
 
167 167
 			return $response;
168 168
 		}
Please login to merge, or discard this patch.
includes/connect/class-wc-stripe-connect-rest-oauth-init-controller.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if ( ! defined('ABSPATH')) {
4 4
 	exit;
5 5
 }
6 6
 
7
-if ( ! class_exists( 'WC_Stripe_Connect_REST_Oauth_Init_Controller' ) ) {
7
+if ( ! class_exists('WC_Stripe_Connect_REST_Oauth_Init_Controller')) {
8 8
 	/**
9 9
 	 * Stripe Connect Oauth Init controller class.
10 10
 	 */
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 		 * @param WC_Stripe_Connect     $connect stripe connect.
31 31
 		 * @param WC_Stripe_Connect_API $api     stripe connect api.
32 32
 		 */
33
-		public function __construct( WC_Stripe_Connect $connect, WC_Stripe_Connect_API $api ) {
33
+		public function __construct(WC_Stripe_Connect $connect, WC_Stripe_Connect_API $api) {
34 34
 
35
-			parent::__construct( $api );
35
+			parent::__construct($api);
36 36
 
37 37
 			$this->connect = $connect;
38 38
 		}
@@ -44,19 +44,19 @@  discard block
 block discarded – undo
44 44
 		 *
45 45
 		 * @return array|WP_Error
46 46
 		 */
47
-		public function post( $request ) {
47
+		public function post($request) {
48 48
 
49 49
 			$data     = $request->get_json_params();
50
-			$response = $this->connect->get_oauth_url( isset( $data['returnUrl'] ) ? $data['returnUrl'] : '' );
50
+			$response = $this->connect->get_oauth_url(isset($data['returnUrl']) ? $data['returnUrl'] : '');
51 51
 
52
-			if ( is_wp_error( $response ) ) {
52
+			if (is_wp_error($response)) {
53 53
 
54
-				WC_Stripe_Logger::log( $response, __CLASS__ );
54
+				WC_Stripe_Logger::log($response, __CLASS__);
55 55
 
56 56
 				return new WP_Error(
57 57
 					$response->get_error_code(),
58 58
 					$response->get_error_message(),
59
-					array( 'status' => 400 )
59
+					array('status' => 400)
60 60
 				);
61 61
 			}
62 62
 
Please login to merge, or discard this patch.
includes/connect/class-wc-stripe-connect-api.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6
-if ( ! defined( 'WOOCOMMERCE_CONNECT_SERVER_URL' ) ) {
7
-	define( 'WOOCOMMERCE_CONNECT_SERVER_URL', 'https://api.woocommerce.com/' );
6
+if ( ! defined('WOOCOMMERCE_CONNECT_SERVER_URL')) {
7
+	define('WOOCOMMERCE_CONNECT_SERVER_URL', 'https://api.woocommerce.com/');
8 8
 }
9 9
 
10
-if ( ! class_exists( 'WC_Stripe_Connect_API' ) ) {
10
+if ( ! class_exists('WC_Stripe_Connect_API')) {
11 11
 	/**
12 12
 	 * Stripe Connect API class.
13 13
 	 */
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 		 * @return array
22 22
 		 */
23 23
 		public function get_stripe_account_details() {
24
-			return $this->request( 'GET', '/stripe/account' );
24
+			return $this->request('GET', '/stripe/account');
25 25
 		}
26 26
 
27 27
 		/**
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 		 *
32 32
 		 * @return array
33 33
 		 */
34
-		public function get_stripe_oauth_init( $return_url ) {
34
+		public function get_stripe_oauth_init($return_url) {
35 35
 
36 36
 			$current_user                   = wp_get_current_user();
37 37
 			$business_data                  = array();
38 38
 			$business_data['url']           = get_site_url();
39
-			$business_data['business_name'] = html_entity_decode( get_bloginfo( 'name' ), ENT_QUOTES );
39
+			$business_data['business_name'] = html_entity_decode(get_bloginfo('name'), ENT_QUOTES);
40 40
 			$business_data['first_name']    = $current_user->user_firstname;
41 41
 			$business_data['last_name']     = $current_user->user_lastname;
42 42
 			$business_data['phone']         = '';
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 			$wc_countries = WC()->countries;
46 46
 
47
-			if ( method_exists( $wc_countries, 'get_base_address' ) ) {
47
+			if (method_exists($wc_countries, 'get_base_address')) {
48 48
 				$business_data['country']        = $wc_countries->get_base_country();
49 49
 				$business_data['street_address'] = $wc_countries->get_base_address();
50 50
 				$business_data['city']           = $wc_countries->get_base_city();
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 				'businessData' => $business_data,
65 65
 			);
66 66
 
67
-			return $this->request( 'POST', '/stripe/oauth-init', $request );
67
+			return $this->request('POST', '/stripe/oauth-init', $request);
68 68
 		}
69 69
 
70 70
 		/**
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
 		 *
75 75
 		 * @return array
76 76
 		 */
77
-		public function get_stripe_oauth_keys( $code ) {
77
+		public function get_stripe_oauth_keys($code) {
78 78
 
79
-			$request = array( 'code' => $code );
79
+			$request = array('code' => $code);
80 80
 
81
-			return $this->request( 'POST', '/stripe/oauth-keys', $request );
81
+			return $this->request('POST', '/stripe/oauth-keys', $request);
82 82
 		}
83 83
 
84 84
 		/**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		 */
89 89
 		public function deauthorize_stripe_account() {
90 90
 
91
-			return $this->request( 'POST', '/stripe/account/deauthorize' );
91
+			return $this->request('POST', '/stripe/account/deauthorize');
92 92
 		}
93 93
 
94 94
 		/**
@@ -100,54 +100,54 @@  discard block
 block discarded – undo
100 100
 		 *
101 101
 		 * @return array|WP_Error
102 102
 		 */
103
-		protected function request( $method, $path, $body = array() ) {
103
+		protected function request($method, $path, $body = array()) {
104 104
 
105
-			if ( ! class_exists( 'Jetpack_Data' ) ) {
105
+			if ( ! class_exists('Jetpack_Data')) {
106 106
 				return new WP_Error(
107 107
 					'jetpack_data_class_not_found',
108
-					__( 'Unable to send request to WooCommerce Connect server. Jetpack_Data was not found.', 'woocommerce-gateway-stripe' )
108
+					__('Unable to send request to WooCommerce Connect server. Jetpack_Data was not found.', 'woocommerce-gateway-stripe')
109 109
 				);
110 110
 			}
111 111
 
112
-			if ( ! method_exists( 'Jetpack_Data', 'get_access_token' ) ) {
112
+			if ( ! method_exists('Jetpack_Data', 'get_access_token')) {
113 113
 				return new WP_Error(
114 114
 					'jetpack_data_get_access_token_not_found',
115
-					__( 'Unable to send request to WooCommerce Connect server. Jetpack_Data does not implement get_access_token.', 'woocommerce-gateway-stripe' )
115
+					__('Unable to send request to WooCommerce Connect server. Jetpack_Data does not implement get_access_token.', 'woocommerce-gateway-stripe')
116 116
 				);
117 117
 			}
118 118
 
119
-			if ( ! is_array( $body ) ) {
119
+			if ( ! is_array($body)) {
120 120
 				return new WP_Error(
121 121
 					'request_body_should_be_array',
122
-					__( 'Unable to send request to WooCommerce Connect server. Body must be an array.', 'woocommerce-gateway-stripe' )
122
+					__('Unable to send request to WooCommerce Connect server. Body must be an array.', 'woocommerce-gateway-stripe')
123 123
 				);
124 124
 			}
125 125
 
126
-			$url = trailingslashit( WOOCOMMERCE_CONNECT_SERVER_URL );
127
-			$url = apply_filters( 'wc_connect_server_url', $url );
128
-			$url = trailingslashit( $url ) . ltrim( $path, '/' );
126
+			$url = trailingslashit(WOOCOMMERCE_CONNECT_SERVER_URL);
127
+			$url = apply_filters('wc_connect_server_url', $url);
128
+			$url = trailingslashit($url) . ltrim($path, '/');
129 129
 
130 130
 			// Add useful system information to requests that contain bodies.
131
-			if ( in_array( $method, array( 'POST', 'PUT' ), true ) ) {
132
-				$body = $this->request_body( $body );
133
-				$body = wp_json_encode( apply_filters( 'wc_connect_api_client_body', $body ) );
131
+			if (in_array($method, array('POST', 'PUT'), true)) {
132
+				$body = $this->request_body($body);
133
+				$body = wp_json_encode(apply_filters('wc_connect_api_client_body', $body));
134 134
 
135
-				if ( ! $body ) {
135
+				if ( ! $body) {
136 136
 					return new WP_Error(
137 137
 						'unable_to_json_encode_body',
138
-						__( 'Unable to encode body for request to WooCommerce Connect server.', 'woocommerce-gateway-stripe' )
138
+						__('Unable to encode body for request to WooCommerce Connect server.', 'woocommerce-gateway-stripe')
139 139
 					);
140 140
 				}
141 141
 			}
142 142
 
143 143
 			$headers = $this->request_headers();
144
-			if ( is_wp_error( $headers ) ) {
144
+			if (is_wp_error($headers)) {
145 145
 				return $headers;
146 146
 			}
147 147
 
148 148
 			$http_timeout = 60; // 1 minute
149
-			if ( function_exists( 'wc_set_time_limit' ) ) {
150
-				wc_set_time_limit( $http_timeout + 10 );
149
+			if (function_exists('wc_set_time_limit')) {
150
+				wc_set_time_limit($http_timeout + 10);
151 151
 			}
152 152
 			$args = array(
153 153
 				'headers'     => $headers,
@@ -158,18 +158,18 @@  discard block
 block discarded – undo
158 158
 				'timeout'     => $http_timeout,
159 159
 			);
160 160
 
161
-			$args          = apply_filters( 'wc_connect_request_args', $args );
162
-			$response      = wp_remote_request( $url, $args );
163
-			$response_code = wp_remote_retrieve_response_code( $response );
164
-			$content_type  = wp_remote_retrieve_header( $response, 'content-type' );
161
+			$args          = apply_filters('wc_connect_request_args', $args);
162
+			$response      = wp_remote_request($url, $args);
163
+			$response_code = wp_remote_retrieve_response_code($response);
164
+			$content_type  = wp_remote_retrieve_header($response, 'content-type');
165 165
 
166
-			if ( false === strpos( $content_type, 'application/json' ) ) {
167
-				if ( 200 !== $response_code ) {
166
+			if (false === strpos($content_type, 'application/json')) {
167
+				if (200 !== $response_code) {
168 168
 					return new WP_Error(
169 169
 						'wcc_server_error',
170 170
 						sprintf(
171 171
 							// Translators: HTTP error code.
172
-							__( 'Error: The WooCommerce Connect server returned HTTP code: %d', 'woocommerce-gateway-stripe' ),
172
+							__('Error: The WooCommerce Connect server returned HTTP code: %d', 'woocommerce-gateway-stripe'),
173 173
 							$response_code
174 174
 						)
175 175
 					);
@@ -177,32 +177,32 @@  discard block
 block discarded – undo
177 177
 				return $response;
178 178
 			}
179 179
 
180
-			$response_body = wp_remote_retrieve_body( $response );
181
-			if ( ! empty( $response_body ) ) {
182
-				$response_body = json_decode( $response_body );
180
+			$response_body = wp_remote_retrieve_body($response);
181
+			if ( ! empty($response_body)) {
182
+				$response_body = json_decode($response_body);
183 183
 			}
184 184
 
185
-			if ( 200 !== $response_code ) {
186
-				if ( empty( $response_body ) ) {
185
+			if (200 !== $response_code) {
186
+				if (empty($response_body)) {
187 187
 					return new WP_Error(
188 188
 						'wcc_server_empty_response',
189 189
 						sprintf(
190 190
 							// Translators: HTTP error code.
191
-							__( 'Error: The WooCommerce Connect server returned ( %d ) and an empty response body.', 'woocommerce-gateway-stripe' ),
191
+							__('Error: The WooCommerce Connect server returned ( %d ) and an empty response body.', 'woocommerce-gateway-stripe'),
192 192
 							$response_code
193 193
 						)
194 194
 					);
195 195
 				}
196 196
 
197
-				$error   = property_exists( $response_body, 'error' ) ? $response_body->error : '';
198
-				$message = property_exists( $response_body, 'message' ) ? $response_body->message : '';
199
-				$data    = property_exists( $response_body, 'data' ) ? $response_body->data : '';
197
+				$error   = property_exists($response_body, 'error') ? $response_body->error : '';
198
+				$message = property_exists($response_body, 'message') ? $response_body->message : '';
199
+				$data    = property_exists($response_body, 'data') ? $response_body->data : '';
200 200
 
201 201
 				return new WP_Error(
202 202
 					'wcc_server_error_response',
203 203
 					sprintf(
204 204
 						/* translators: %1$s: error code, %2$s: error message, %3$d: HTTP response code */
205
-						__( 'Error: The WooCommerce Connect server returned: %1$s %2$s ( %3$d )', 'woocommerce-gateway-stripe' ),
205
+						__('Error: The WooCommerce Connect server returned: %1$s %2$s ( %3$d )', 'woocommerce-gateway-stripe'),
206 206
 						$error,
207 207
 						$message,
208 208
 						$response_code
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 		 *
222 222
 		 * @return array
223 223
 		 */
224
-		protected function request_body( $initial_body = array() ) {
224
+		protected function request_body($initial_body = array()) {
225 225
 
226 226
 			$default_body = array(
227 227
 				'settings' => array(),
228 228
 			);
229 229
 
230
-			$body = array_merge( $default_body, $initial_body );
230
+			$body = array_merge($default_body, $initial_body);
231 231
 
232 232
 			// Add interesting fields to the body of each request.
233 233
 			$body['settings'] = wp_parse_args(
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 					'stripe_version'  => WC_STRIPE_VERSION,
242 242
 					'jetpack_version' => JETPACK__VERSION,
243 243
 					'wc_version'      => WC()->version,
244
-					'wp_version'      => get_bloginfo( 'version' ),
244
+					'wp_version'      => get_bloginfo('version'),
245 245
 				)
246 246
 			);
247 247
 
@@ -257,13 +257,13 @@  discard block
 block discarded – undo
257 257
 
258 258
 			$authorization = $this->authorization_header();
259 259
 
260
-			if ( is_wp_error( $authorization ) ) {
260
+			if (is_wp_error($authorization)) {
261 261
 				return $authorization;
262 262
 			}
263 263
 
264 264
 			$headers                    = array();
265
-			$locale                     = strtolower( str_replace( '_', '-', get_locale() ) );
266
-			$locale_elements            = explode( '-', $locale );
265
+			$locale                     = strtolower(str_replace('_', '-', get_locale()));
266
+			$locale_elements            = explode('-', $locale);
267 267
 			$lang                       = $locale_elements[0];
268 268
 			$headers['Accept-Language'] = $locale . ',' . $lang;
269 269
 			$headers['Content-Type']    = 'application/json; charset=utf-8';
@@ -280,32 +280,32 @@  discard block
 block discarded – undo
280 280
 		 */
281 281
 		protected function authorization_header() {
282 282
 
283
-			$token = Jetpack_Data::get_access_token( 0 );
284
-			$token = apply_filters( 'wc_connect_jetpack_access_token', $token );
283
+			$token = Jetpack_Data::get_access_token(0);
284
+			$token = apply_filters('wc_connect_jetpack_access_token', $token);
285 285
 
286
-			if ( ! $token || empty( $token->secret ) ) {
286
+			if ( ! $token || empty($token->secret)) {
287 287
 				return new WP_Error(
288 288
 					'missing_token',
289
-					__( 'Unable to send request to WooCommerce Connect server. Jetpack Token is missing', 'woocommerce-gateway-stripe' )
289
+					__('Unable to send request to WooCommerce Connect server. Jetpack Token is missing', 'woocommerce-gateway-stripe')
290 290
 				);
291 291
 			}
292 292
 
293
-			if ( false === strpos( $token->secret, '.' ) ) {
293
+			if (false === strpos($token->secret, '.')) {
294 294
 				return new WP_Error(
295 295
 					'invalid_token',
296
-					__( 'Unable to send request to WooCommerce Connect server. Jetpack Token is malformed.', 'woocommerce-gateway-stripe' )
296
+					__('Unable to send request to WooCommerce Connect server. Jetpack Token is malformed.', 'woocommerce-gateway-stripe')
297 297
 				);
298 298
 			}
299 299
 
300
-			list( $token_key, $token_secret ) = explode( '.', $token->secret );
300
+			list($token_key, $token_secret) = explode('.', $token->secret);
301 301
 
302
-			$token_key = sprintf( '%s:%d:%d', $token_key, JETPACK__API_VERSION, $token->external_user_id );
303
-			$time_diff = (int) Jetpack_Options::get_option( 'time_diff' );
302
+			$token_key = sprintf('%s:%d:%d', $token_key, JETPACK__API_VERSION, $token->external_user_id);
303
+			$time_diff = (int) Jetpack_Options::get_option('time_diff');
304 304
 			$timestamp = time() + $time_diff;
305
-			$nonce     = wp_generate_password( 10, false );
306
-			$signature = $this->request_signature( $token_key, $token_secret, $timestamp, $nonce, $time_diff );
305
+			$nonce     = wp_generate_password(10, false);
306
+			$signature = $this->request_signature($token_key, $token_secret, $timestamp, $nonce, $time_diff);
307 307
 
308
-			if ( is_wp_error( $signature ) ) {
308
+			if (is_wp_error($signature)) {
309 309
 				return $signature;
310 310
 			}
311 311
 
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
 
319 319
 			$header_pieces = array();
320 320
 
321
-			foreach ( $auth as $key => $value ) {
322
-				$header_pieces[] = sprintf( '%s="%s"', $key, $value );
321
+			foreach ($auth as $key => $value) {
322
+				$header_pieces[] = sprintf('%s="%s"', $key, $value);
323 323
 			}
324 324
 
325
-			$authorization = 'X_JP_Auth ' . join( ' ', $header_pieces );
325
+			$authorization = 'X_JP_Auth ' . join(' ', $header_pieces);
326 326
 
327 327
 			return $authorization;
328 328
 		}
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 		 *
339 339
 		 * @return string|WP_Error
340 340
 		 */
341
-		protected function request_signature( $token_key, $token_secret, $timestamp, $nonce, $time_diff ) {
341
+		protected function request_signature($token_key, $token_secret, $timestamp, $nonce, $time_diff) {
342 342
 
343 343
 			$local_time = $timestamp - $time_diff;
344 344
 
345
-			if ( $local_time < time() - 600 || $local_time > time() + 300 ) {
345
+			if ($local_time < time() - 600 || $local_time > time() + 300) {
346 346
 				return new WP_Error(
347 347
 					'invalid_signature',
348
-					__( 'Unable to send request to WooCommerce Connect server. The timestamp generated for the signature is too old.', 'woocommerce-gateway-stripe' )
348
+					__('Unable to send request to WooCommerce Connect server. The timestamp generated for the signature is too old.', 'woocommerce-gateway-stripe')
349 349
 				);
350 350
 			}
351 351
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 				)
359 359
 			) . "\n";
360 360
 
361
-			return base64_encode( hash_hmac( 'sha1', $normalized_request_string, $token_secret, true ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
361
+			return base64_encode(hash_hmac('sha1', $normalized_request_string, $token_secret, true)); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
362 362
 		}
363 363
 
364 364
 	}
Please login to merge, or discard this patch.
includes/connect/class-wc-stripe-connect-rest-deauthorize-controller.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if ( ! defined('ABSPATH')) {
4 4
 	exit;
5 5
 }
6 6
 
7
-if ( ! class_exists( 'WC_Stripe_Connect_REST_Deauthorize_Controller' ) ) {
7
+if ( ! class_exists('WC_Stripe_Connect_REST_Deauthorize_Controller')) {
8 8
 	/**
9 9
 	 * Stripe Connect deauthorize controller class.
10 10
 	 */
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 		 * @param WC_Stripe_Connect     $connect stripe connect.
31 31
 		 * @param WC_Stripe_Connect_API $api     stripe connect api.
32 32
 		 */
33
-		public function __construct( WC_Stripe_Connect $connect, WC_Stripe_Connect_API $api ) {
33
+		public function __construct(WC_Stripe_Connect $connect, WC_Stripe_Connect_API $api) {
34 34
 
35
-			parent::__construct( $api );
35
+			parent::__construct($api);
36 36
 
37 37
 			$this->connect = $connect;
38 38
 		}
@@ -44,18 +44,18 @@  discard block
 block discarded – undo
44 44
 		 *
45 45
 		 * @return array|WP_Error
46 46
 		 */
47
-		public function post( $request ) {
47
+		public function post($request) {
48 48
 
49 49
 			$response = $connect->deauthorize_account();
50 50
 
51
-			if ( is_wp_error( $response ) ) {
51
+			if (is_wp_error($response)) {
52 52
 
53
-				WC_Stripe_Logger::log( $response, __CLASS__ );
53
+				WC_Stripe_Logger::log($response, __CLASS__);
54 54
 
55 55
 				return new WP_Error(
56 56
 					$response->get_error_code(),
57 57
 					$response->get_error_message(),
58
-					array( 'status' => 400 )
58
+					array('status' => 400)
59 59
 				);
60 60
 			}
61 61
 
Please login to merge, or discard this patch.
includes/connect/class-wc-stripe-connect.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if ( ! defined('ABSPATH')) {
4 4
 	exit;
5 5
 }
6 6
 
7
-if ( ! class_exists( 'WC_Stripe_Connect' ) ) {
7
+if ( ! class_exists('WC_Stripe_Connect')) {
8 8
 	/**
9 9
 	 * Stripe Connect class.
10 10
 	 */
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		 *
25 25
 		 * @param WC_Stripe_Connect_API $api stripe connect api.
26 26
 		 */
27
-		public function __construct( WC_Stripe_Connect_API $api ) {
27
+		public function __construct(WC_Stripe_Connect_API $api) {
28 28
 
29 29
 			$this->api = $api;
30 30
 		}
@@ -36,23 +36,23 @@  discard block
 block discarded – undo
36 36
 		 *
37 37
 		 * @return string|WP_Error
38 38
 		 */
39
-		public function get_oauth_url( $return_url = '' ) {
39
+		public function get_oauth_url($return_url = '') {
40 40
 
41
-			if ( empty( $return_url ) ) {
42
-				$return_url = admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' );
41
+			if (empty($return_url)) {
42
+				$return_url = admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe');
43 43
 			}
44 44
 
45
-			if ( substr( $return_url, 0, 8 ) !== 'https://' ) {
46
-				return new WP_Error( 'invalid_url_protocol', __( 'Your site must be served over HTTPS in order to connect your Stripe account automatically.', 'woocommerce-gateway-stripe' ) );
45
+			if (substr($return_url, 0, 8) !== 'https://') {
46
+				return new WP_Error('invalid_url_protocol', __('Your site must be served over HTTPS in order to connect your Stripe account automatically.', 'woocommerce-gateway-stripe'));
47 47
 			}
48 48
 
49
-			$result = $this->api->get_stripe_oauth_init( $return_url );
49
+			$result = $this->api->get_stripe_oauth_init($return_url);
50 50
 
51
-			if ( is_wp_error( $result ) ) {
51
+			if (is_wp_error($result)) {
52 52
 				return $result;
53 53
 			}
54 54
 
55
-			update_option( 'stripe_state', $result->state );
55
+			update_option('stripe_state', $result->state);
56 56
 
57 57
 			return $result->oauthUrl; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
58 58
 		}
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
 			$response = $this->api->deauthorize_stripe_account();
68 68
 
69
-			if ( is_wp_error( $response ) ) {
69
+			if (is_wp_error($response)) {
70 70
 				return $response;
71 71
 			}
72 72
 
@@ -83,21 +83,21 @@  discard block
 block discarded – undo
83 83
 		 *
84 84
 		 * @return string|WP_Error
85 85
 		 */
86
-		public function connect_oauth( $state, $code ) {
86
+		public function connect_oauth($state, $code) {
87 87
 
88
-			if ( get_option( 'stripe_state', false ) !== $state ) {
89
-				return new WP_Error( 'Invalid stripe state' );
88
+			if (get_option('stripe_state', false) !== $state) {
89
+				return new WP_Error('Invalid stripe state');
90 90
 			}
91 91
 
92
-			$response = $this->api->get_stripe_oauth_keys( $code );
92
+			$response = $this->api->get_stripe_oauth_keys($code);
93 93
 
94
-			if ( is_wp_error( $response ) ) {
94
+			if (is_wp_error($response)) {
95 95
 				return $response;
96 96
 			}
97 97
 
98
-			delete_option( 'stripe_state' );
98
+			delete_option('stripe_state');
99 99
 
100
-			return $this->save_stripe_keys( $response );
100
+			return $this->save_stripe_keys($response);
101 101
 		}
102 102
 
103 103
 		/**
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 		 */
106 106
 		public function maybe_connect_oauth() {
107 107
 
108
-			if ( isset( $_GET['wcs_stripe_code'], $_GET['wcs_stripe_state'] ) ) {
109
-				$response = $this->connect_oauth( $_GET['wcs_stripe_state'], $_GET['wcs_stripe_code'] );
108
+			if (isset($_GET['wcs_stripe_code'], $_GET['wcs_stripe_state'])) {
109
+				$response = $this->connect_oauth($_GET['wcs_stripe_state'], $_GET['wcs_stripe_code']);
110 110
 
111
-				wp_safe_redirect( remove_query_arg( array( 'wcs_stripe_state', 'wcs_stripe_code' ) ) );
111
+				wp_safe_redirect(remove_query_arg(array('wcs_stripe_state', 'wcs_stripe_code')));
112 112
 				exit;
113 113
 			}
114 114
 		}
@@ -121,28 +121,28 @@  discard block
 block discarded – undo
121 121
 		 *
122 122
 		 * @return array|WP_Error
123 123
 		 */
124
-		private function save_stripe_keys( $result ) {
124
+		private function save_stripe_keys($result) {
125 125
 
126
-			if ( ! isset( $result->publishableKey, $result->secretKey ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
127
-				return new WP_Error( 'Invalid credentials received from WooCommerce Connect server' );
126
+			if ( ! isset($result->publishableKey, $result->secretKey)) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
127
+				return new WP_Error('Invalid credentials received from WooCommerce Connect server');
128 128
 			}
129 129
 
130
-			$is_test         = false !== strpos( $result->publishableKey, '_test_' ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
130
+			$is_test         = false !== strpos($result->publishableKey, '_test_'); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
131 131
 			$prefix          = $is_test ? 'test_' : '';
132 132
 			$default_options = array();
133 133
 
134
-			$options                                = array_merge( $default_options, get_option( self::SETTINGS_OPTION, array() ) );
134
+			$options                                = array_merge($default_options, get_option(self::SETTINGS_OPTION, array()));
135 135
 			$options['enabled']                     = 'yes';
136 136
 			$options['testmode']                    = $is_test ? 'yes' : 'no';
137
-			$options[ $prefix . 'publishable_key' ] = $result->publishableKey; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
138
-			$options[ $prefix . 'secret_key' ]      = $result->secretKey; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
137
+			$options[$prefix . 'publishable_key'] = $result->publishableKey; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
138
+			$options[$prefix . 'secret_key']      = $result->secretKey; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
139 139
 
140 140
 			// While we are at it, let's also clear the account_id and
141 141
 			// test_account_id if present.
142
-			unset( $options['account_id'] );
143
-			unset( $options['test_account_id'] );
142
+			unset($options['account_id']);
143
+			unset($options['test_account_id']);
144 144
 
145
-			update_option( self::SETTINGS_OPTION, $options );
145
+			update_option(self::SETTINGS_OPTION, $options);
146 146
 
147 147
 			return $result;
148 148
 		}
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
 		private function clear_stripe_keys() {
154 154
 
155 155
 			$default_options = $this->get_default_config();
156
-			$options         = array_merge( $default_options, get_option( self::SETTINGS_OPTION, array() ) );
156
+			$options         = array_merge($default_options, get_option(self::SETTINGS_OPTION, array()));
157 157
 
158
-			if ( 'yes' === $options['testmode'] ) {
158
+			if ('yes' === $options['testmode']) {
159 159
 				$options['test_publishable_key'] = '';
160 160
 				$options['test_secret_key']      = '';
161 161
 			} else {
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 
166 166
 			// While we are at it, let's also clear the account_id and
167 167
 			// test_account_id if present.
168
-			unset( $options['account_id'] );
169
-			unset( $options['test_account_id'] );
168
+			unset($options['account_id']);
169
+			unset($options['test_account_id']);
170 170
 
171
-			update_option( self::SETTINGS_OPTION, $options );
171
+			update_option(self::SETTINGS_OPTION, $options);
172 172
 
173 173
 		}
174 174
 	}
Please login to merge, or discard this patch.
woocommerce-gateway-stripe.php 1 patch
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
  *
16 16
  */
17 17
 
18
-if ( ! defined( 'ABSPATH' ) ) {
18
+if ( ! defined('ABSPATH')) {
19 19
 	exit;
20 20
 }
21 21
 
22 22
 /**
23 23
  * Required minimums and constants
24 24
  */
25
-define( 'WC_STRIPE_VERSION', '4.5.0' );
26
-define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
27
-define( 'WC_STRIPE_MIN_WC_VER', '3.0' );
28
-define( 'WC_STRIPE_FUTURE_MIN_WC_VER', '3.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__ ) ) );
25
+define('WC_STRIPE_VERSION', '4.5.0');
26
+define('WC_STRIPE_MIN_PHP_VER', '5.6.0');
27
+define('WC_STRIPE_MIN_WC_VER', '3.0');
28
+define('WC_STRIPE_FUTURE_MIN_WC_VER', '3.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
 // phpcs:disable WordPress.Files.FileName
34 34
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
  */
41 41
 function woocommerce_stripe_missing_wc_notice() {
42 42
 	/* translators: 1. URL link. */
43
-	echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'Stripe requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-gateway-stripe' ), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>' ) . '</strong></p></div>';
43
+	echo '<div class="error"><p><strong>' . sprintf(esc_html__('Stripe requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-gateway-stripe'), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>') . '</strong></p></div>';
44 44
 }
45 45
 
46 46
 /**
@@ -51,25 +51,25 @@  discard block
 block discarded – undo
51 51
  */
52 52
 function woocommerce_stripe_wc_not_supported() {
53 53
 	/* translators: $1. Minimum WooCommerce version. $2. Current WooCommerce version. */
54
-	echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'Stripe requires WooCommerce %1$s or greater to be installed and active. WooCommerce %2$s is no longer supported.', 'woocommerce-gateway-stripe' ), WC_STRIPE_MIN_WC_VER, WC_VERSION ) . '</strong></p></div>';
54
+	echo '<div class="error"><p><strong>' . sprintf(esc_html__('Stripe requires WooCommerce %1$s or greater to be installed and active. WooCommerce %2$s is no longer supported.', 'woocommerce-gateway-stripe'), WC_STRIPE_MIN_WC_VER, WC_VERSION) . '</strong></p></div>';
55 55
 }
56 56
 
57
-add_action( 'plugins_loaded', 'woocommerce_gateway_stripe_init' );
57
+add_action('plugins_loaded', 'woocommerce_gateway_stripe_init');
58 58
 
59 59
 function woocommerce_gateway_stripe_init() {
60
-	load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
60
+	load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages');
61 61
 
62
-	if ( ! class_exists( 'WooCommerce' ) ) {
63
-		add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' );
62
+	if ( ! class_exists('WooCommerce')) {
63
+		add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice');
64 64
 		return;
65 65
 	}
66 66
 
67
-	if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) {
68
-		add_action( 'admin_notices', 'woocommerce_stripe_wc_not_supported' );
67
+	if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) {
68
+		add_action('admin_notices', 'woocommerce_stripe_wc_not_supported');
69 69
 		return;
70 70
 	}
71 71
 
72
-	if ( ! class_exists( 'WC_Stripe' ) ) :
72
+	if ( ! class_exists('WC_Stripe')) :
73 73
 
74 74
 		class WC_Stripe {
75 75
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 			 * @return Singleton The *Singleton* instance.
85 85
 			 */
86 86
 			public static function get_instance() {
87
-				if ( null === self::$instance ) {
87
+				if (null === self::$instance) {
88 88
 					self::$instance = new self();
89 89
 				}
90 90
 				return self::$instance;
@@ -125,17 +125,17 @@  discard block
 block discarded – undo
125 125
 			 * *Singleton* via the `new` operator from outside of this class.
126 126
 			 */
127 127
 			private function __construct() {
128
-				add_action( 'admin_init', array( $this, 'install' ) );
128
+				add_action('admin_init', array($this, 'install'));
129 129
 
130 130
 				$this->init();
131 131
 
132 132
 				$this->api     = new WC_Stripe_Connect_API();
133
-				$this->connect = new WC_Stripe_Connect( $this->api );
133
+				$this->connect = new WC_Stripe_Connect($this->api);
134 134
 
135
-				add_action( 'rest_api_init', array( $this, 'register_connect_routes' ) );
135
+				add_action('rest_api_init', array($this, 'register_connect_routes'));
136 136
 
137
-				if ( get_option( 'stripe_state', false ) ) {
138
-					add_action( 'admin_enqueue_scripts', array( $this->connect, 'maybe_connect_oauth' ) );
137
+				if (get_option('stripe_state', false)) {
138
+					add_action('admin_enqueue_scripts', array($this->connect, 'maybe_connect_oauth'));
139 139
 				}
140 140
 			}
141 141
 
@@ -146,57 +146,57 @@  discard block
 block discarded – undo
146 146
 			 * @version 4.0.0
147 147
 			 */
148 148
 			public function init() {
149
-				if ( is_admin() ) {
150
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php';
149
+				if (is_admin()) {
150
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php';
151 151
 				}
152 152
 
153
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php';
154
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php';
155
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php';
156
-				include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php';
157
-				require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
158
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php';
159
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php';
160
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php';
161
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
162
-				require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php';
163
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
164
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
165
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
166
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
167
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
168
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
169
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
170
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
171
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
172
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
173
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php';
174
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
175
-				require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect.php';
176
-				require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect-api.php';
177
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php';
178
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php';
179
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php';
180
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-intent-controller.php';
181
-
182
-				if ( is_admin() ) {
183
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php';
184
-					require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect.php';
185
-					require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect-api.php';
153
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-exception.php';
154
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-logger.php';
155
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-helper.php';
156
+				include_once dirname(__FILE__) . '/includes/class-wc-stripe-api.php';
157
+				require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
158
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php';
159
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php';
160
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php';
161
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
162
+				require_once dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php';
163
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
164
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
165
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
166
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
167
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
168
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
169
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
170
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
171
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
172
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
173
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php';
174
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
175
+				require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect.php';
176
+				require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect-api.php';
177
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php';
178
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php';
179
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-customer.php';
180
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-intent-controller.php';
181
+
182
+				if (is_admin()) {
183
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php';
184
+					require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect.php';
185
+					require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect-api.php';
186 186
 				}
187 187
 
188 188
 				// REMOVE IN THE FUTURE.
189
-				require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
189
+				require_once dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
190 190
 
191
-				add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) );
192
-				add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
193
-				add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
191
+				add_filter('woocommerce_payment_gateways', array($this, 'add_gateways'));
192
+				add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
193
+				add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2);
194 194
 
195 195
 				// Modify emails emails.
196
-				add_filter( 'woocommerce_email_classes', array( $this, 'add_emails' ), 20 );
196
+				add_filter('woocommerce_email_classes', array($this, 'add_emails'), 20);
197 197
 
198
-				if ( version_compare( WC_VERSION, '3.4', '<' ) ) {
199
-					add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) );
198
+				if (version_compare(WC_VERSION, '3.4', '<')) {
199
+					add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin'));
200 200
 				}
201 201
 			}
202 202
 
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 			 * @version 4.0.0
208 208
 			 */
209 209
 			public function update_plugin_version() {
210
-				delete_option( 'wc_stripe_version' );
211
-				update_option( 'wc_stripe_version', WC_STRIPE_VERSION );
210
+				delete_option('wc_stripe_version');
211
+				update_option('wc_stripe_version', WC_STRIPE_VERSION);
212 212
 			}
213 213
 
214 214
 			/**
@@ -218,15 +218,15 @@  discard block
 block discarded – undo
218 218
 			 * @version 3.1.0
219 219
 			 */
220 220
 			public function install() {
221
-				if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) {
221
+				if ( ! is_plugin_active(plugin_basename(__FILE__))) {
222 222
 					return;
223 223
 				}
224 224
 
225
-				if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) {
226
-					do_action( 'woocommerce_stripe_updated' );
225
+				if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) {
226
+					do_action('woocommerce_stripe_updated');
227 227
 
228
-					if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) {
229
-						define( 'WC_STRIPE_INSTALLING', true );
228
+					if ( ! defined('WC_STRIPE_INSTALLING')) {
229
+						define('WC_STRIPE_INSTALLING', true);
230 230
 					}
231 231
 
232 232
 					$this->update_plugin_version();
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
 			 * @since 1.0.0
240 240
 			 * @version 4.0.0
241 241
 			 */
242
-			public function plugin_action_links( $links ) {
242
+			public function plugin_action_links($links) {
243 243
 				$plugin_links = array(
244
-					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
244
+					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>',
245 245
 				);
246
-				return array_merge( $plugin_links, $links );
246
+				return array_merge($plugin_links, $links);
247 247
 			}
248 248
 
249 249
 			/**
@@ -254,13 +254,13 @@  discard block
 block discarded – undo
254 254
 			 * @param  string $file  Name of current file.
255 255
 			 * @return array  $links Update list of plugin links.
256 256
 			 */
257
-			public function plugin_row_meta( $links, $file ) {
258
-				if ( plugin_basename( __FILE__ ) === $file ) {
257
+			public function plugin_row_meta($links, $file) {
258
+				if (plugin_basename(__FILE__) === $file) {
259 259
 					$row_meta = array(
260
-						'docs'    => '<a href="' . esc_url( apply_filters( 'woocommerce_gateway_stripe_docs_url', 'https://docs.woocommerce.com/document/stripe/' ) ) . '" title="' . esc_attr( __( 'View Documentation', 'woocommerce-gateway-stripe' ) ) . '">' . __( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>',
261
-						'support' => '<a href="' . esc_url( apply_filters( 'woocommerce_gateway_stripe_support_url', 'https://woocommerce.com/my-account/create-a-ticket?select=18627' ) ) . '" title="' . esc_attr( __( 'Open a support request at WooCommerce.com', 'woocommerce-gateway-stripe' ) ) . '">' . __( 'Support', 'woocommerce-gateway-stripe' ) . '</a>',
260
+						'docs'    => '<a href="' . esc_url(apply_filters('woocommerce_gateway_stripe_docs_url', 'https://docs.woocommerce.com/document/stripe/')) . '" title="' . esc_attr(__('View Documentation', 'woocommerce-gateway-stripe')) . '">' . __('Docs', 'woocommerce-gateway-stripe') . '</a>',
261
+						'support' => '<a href="' . esc_url(apply_filters('woocommerce_gateway_stripe_support_url', 'https://woocommerce.com/my-account/create-a-ticket?select=18627')) . '" title="' . esc_attr(__('Open a support request at WooCommerce.com', 'woocommerce-gateway-stripe')) . '">' . __('Support', 'woocommerce-gateway-stripe') . '</a>',
262 262
 					);
263
-					return array_merge( $links, $row_meta );
263
+					return array_merge($links, $row_meta);
264 264
 				}
265 265
 				return (array) $links;
266 266
 			}
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 			 * @since 1.0.0
272 272
 			 * @version 4.0.0
273 273
 			 */
274
-			public function add_gateways( $methods ) {
275
-				if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) {
274
+			public function add_gateways($methods) {
275
+				if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) {
276 276
 					$methods[] = 'WC_Stripe_Subs_Compat';
277 277
 					$methods[] = 'WC_Stripe_Sepa_Subs_Compat';
278 278
 				} else {
@@ -298,28 +298,28 @@  discard block
 block discarded – undo
298 298
 			 * @since 4.0.0
299 299
 			 * @version 4.0.0
300 300
 			 */
301
-			public function filter_gateway_order_admin( $sections ) {
302
-				unset( $sections['stripe'] );
303
-				unset( $sections['stripe_bancontact'] );
304
-				unset( $sections['stripe_sofort'] );
305
-				unset( $sections['stripe_giropay'] );
306
-				unset( $sections['stripe_eps'] );
307
-				unset( $sections['stripe_ideal'] );
308
-				unset( $sections['stripe_p24'] );
309
-				unset( $sections['stripe_alipay'] );
310
-				unset( $sections['stripe_sepa'] );
311
-				unset( $sections['stripe_multibanco'] );
301
+			public function filter_gateway_order_admin($sections) {
302
+				unset($sections['stripe']);
303
+				unset($sections['stripe_bancontact']);
304
+				unset($sections['stripe_sofort']);
305
+				unset($sections['stripe_giropay']);
306
+				unset($sections['stripe_eps']);
307
+				unset($sections['stripe_ideal']);
308
+				unset($sections['stripe_p24']);
309
+				unset($sections['stripe_alipay']);
310
+				unset($sections['stripe_sepa']);
311
+				unset($sections['stripe_multibanco']);
312 312
 
313 313
 				$sections['stripe']            = 'Stripe';
314
-				$sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' );
315
-				$sections['stripe_sofort']     = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' );
316
-				$sections['stripe_giropay']    = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' );
317
-				$sections['stripe_eps']        = __( 'Stripe EPS', 'woocommerce-gateway-stripe' );
318
-				$sections['stripe_ideal']      = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' );
319
-				$sections['stripe_p24']        = __( 'Stripe P24', 'woocommerce-gateway-stripe' );
320
-				$sections['stripe_alipay']     = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' );
321
-				$sections['stripe_sepa']       = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' );
322
-				$sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' );
314
+				$sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe');
315
+				$sections['stripe_sofort']     = __('Stripe SOFORT', 'woocommerce-gateway-stripe');
316
+				$sections['stripe_giropay']    = __('Stripe Giropay', 'woocommerce-gateway-stripe');
317
+				$sections['stripe_eps']        = __('Stripe EPS', 'woocommerce-gateway-stripe');
318
+				$sections['stripe_ideal']      = __('Stripe iDeal', 'woocommerce-gateway-stripe');
319
+				$sections['stripe_p24']        = __('Stripe P24', 'woocommerce-gateway-stripe');
320
+				$sections['stripe_alipay']     = __('Stripe Alipay', 'woocommerce-gateway-stripe');
321
+				$sections['stripe_sepa']       = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe');
322
+				$sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe');
323 323
 
324 324
 				return $sections;
325 325
 			}
@@ -330,16 +330,16 @@  discard block
 block discarded – undo
330 330
 			 * @param WC_Email[] $email_classes All existing emails.
331 331
 			 * @return WC_Email[]
332 332
 			 */
333
-			public function add_emails( $email_classes ) {
333
+			public function add_emails($email_classes) {
334 334
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication.php';
335 335
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-renewal-authentication.php';
336 336
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-preorder-authentication.php';
337 337
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication-retry.php';
338 338
 
339 339
 				// Add all emails, generated by the gateway.
340
-				$email_classes['WC_Stripe_Email_Failed_Renewal_Authentication']  = new WC_Stripe_Email_Failed_Renewal_Authentication( $email_classes );
341
-				$email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication( $email_classes );
342
-				$email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry( $email_classes );
340
+				$email_classes['WC_Stripe_Email_Failed_Renewal_Authentication']  = new WC_Stripe_Email_Failed_Renewal_Authentication($email_classes);
341
+				$email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication($email_classes);
342
+				$email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry($email_classes);
343 343
 
344 344
 				return $email_classes;
345 345
 			}
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/connect/class-wc-stripe-connect-rest-oauth-connect-controller.php';
355 355
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/connect/class-wc-stripe-connect-rest-deauthorize-controller.php';
356 356
 
357
-				$oauth_init    = new WC_Stripe_Connect_REST_Oauth_Init_Controller( $this->connect, $this->api );
358
-				$oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller( $this->connect, $this->api );
359
-				$deauthorize   = new WC_Stripe_Connect_REST_Deauthorize_Controller( $this->connect, $this->api );
357
+				$oauth_init    = new WC_Stripe_Connect_REST_Oauth_Init_Controller($this->connect, $this->api);
358
+				$oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller($this->connect, $this->api);
359
+				$deauthorize   = new WC_Stripe_Connect_REST_Deauthorize_Controller($this->connect, $this->api);
360 360
 
361 361
 				$oauth_init->register_routes();
362 362
 				$oauth_connect->register_routes();
Please login to merge, or discard this patch.