Completed
Pull Request — master (#1267)
by
unknown
01:45
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.
woocommerce-gateway-stripe.php 1 patch
Spacing   +112 added lines, -112 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,7 +51,7 @@  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 57
 /**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
  * @return string
62 62
  */
63 63
 function woocommerce_stripe_wc_country_not_supported() {
64
-	echo '<div class="error"><p><strong>' . __( 'Stripe is not available in your store\'s country and will not be available for buyers to choose during checkout.', 'woocommerce-gateway-stripe' ) . '</strong></p></div>';
64
+	echo '<div class="error"><p><strong>' . __('Stripe is not available in your store\'s country and will not be available for buyers to choose during checkout.', 'woocommerce-gateway-stripe') . '</strong></p></div>';
65 65
 }
66 66
 
67 67
 /**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
  * @return bool
73 73
  */
74 74
 function woocommerce_stripe_wc_country_is_supported_country() {
75
-	$wc_default_country = substr( get_option( 'woocommerce_default_country' ), 0, 2 );
75
+	$wc_default_country = substr(get_option('woocommerce_default_country'), 0, 2);
76 76
 
77 77
 	$supported_countries = apply_filters(
78 78
 		'wc_stripe_supported_countries',
@@ -118,30 +118,30 @@  discard block
 block discarded – undo
118 118
 		)
119 119
 	);
120 120
 
121
-	return in_array( $wc_default_country, $supported_countries );
121
+	return in_array($wc_default_country, $supported_countries);
122 122
 }
123 123
 
124
-add_action( 'plugins_loaded', 'woocommerce_gateway_stripe_init' );
124
+add_action('plugins_loaded', 'woocommerce_gateway_stripe_init');
125 125
 
126 126
 function woocommerce_gateway_stripe_init() {
127
-	load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
127
+	load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages');
128 128
 
129
-	if ( ! class_exists( 'WooCommerce' ) ) {
130
-		add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' );
129
+	if ( ! class_exists('WooCommerce')) {
130
+		add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice');
131 131
 		return;
132 132
 	}
133 133
 
134
-	if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) {
135
-		add_action( 'admin_notices', 'woocommerce_stripe_wc_not_supported' );
134
+	if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) {
135
+		add_action('admin_notices', 'woocommerce_stripe_wc_not_supported');
136 136
 		return;
137 137
 	}
138 138
 
139
-	if ( ! woocommerce_stripe_wc_country_is_supported_country() ) {
140
-		add_action( 'admin_notices', 'woocommerce_stripe_wc_country_not_supported' );
139
+	if ( ! woocommerce_stripe_wc_country_is_supported_country()) {
140
+		add_action('admin_notices', 'woocommerce_stripe_wc_country_not_supported');
141 141
 		return;
142 142
 	}
143 143
 
144
-	if ( ! class_exists( 'WC_Stripe' ) ) :
144
+	if ( ! class_exists('WC_Stripe')) :
145 145
 
146 146
 		class WC_Stripe {
147 147
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			 * @return Singleton The *Singleton* instance.
157 157
 			 */
158 158
 			public static function get_instance() {
159
-				if ( null === self::$instance ) {
159
+				if (null === self::$instance) {
160 160
 					self::$instance = new self();
161 161
 				}
162 162
 				return self::$instance;
@@ -197,17 +197,17 @@  discard block
 block discarded – undo
197 197
 			 * *Singleton* via the `new` operator from outside of this class.
198 198
 			 */
199 199
 			private function __construct() {
200
-				add_action( 'admin_init', array( $this, 'install' ) );
200
+				add_action('admin_init', array($this, 'install'));
201 201
 
202 202
 				$this->init();
203 203
 
204 204
 				$this->api     = new WC_Stripe_Connect_API();
205
-				$this->connect = new WC_Stripe_Connect( $this->api );
205
+				$this->connect = new WC_Stripe_Connect($this->api);
206 206
 
207
-				add_action( 'rest_api_init', array( $this, 'register_connect_routes' ) );
207
+				add_action('rest_api_init', array($this, 'register_connect_routes'));
208 208
 
209
-				if ( get_option( 'stripe_state', false ) ) {
210
-					add_action( 'admin_enqueue_scripts', array( $this->connect, 'maybe_connect_oauth' ) );
209
+				if (get_option('stripe_state', false)) {
210
+					add_action('admin_enqueue_scripts', array($this->connect, 'maybe_connect_oauth'));
211 211
 				}
212 212
 			}
213 213
 
@@ -218,55 +218,55 @@  discard block
 block discarded – undo
218 218
 			 * @version 4.0.0
219 219
 			 */
220 220
 			public function init() {
221
-				if ( is_admin() ) {
222
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php';
221
+				if (is_admin()) {
222
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php';
223 223
 				}
224 224
 
225
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php';
226
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php';
227
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php';
228
-				include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php';
229
-				require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
230
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php';
231
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php';
232
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php';
233
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
234
-				require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php';
235
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
236
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
237
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
238
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
239
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
240
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
241
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
242
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
243
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
244
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
245
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php';
246
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
247
-				require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect.php';
248
-				require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect-api.php';
249
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php';
250
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php';
251
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php';
252
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-intent-controller.php';
253
-
254
-				if ( is_admin() ) {
255
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php';
225
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-exception.php';
226
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-logger.php';
227
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-helper.php';
228
+				include_once dirname(__FILE__) . '/includes/class-wc-stripe-api.php';
229
+				require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
230
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php';
231
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php';
232
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php';
233
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
234
+				require_once dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php';
235
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
236
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
237
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
238
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
239
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
240
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
241
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
242
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
243
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
244
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
245
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php';
246
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
247
+				require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect.php';
248
+				require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect-api.php';
249
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php';
250
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php';
251
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-customer.php';
252
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-intent-controller.php';
253
+
254
+				if (is_admin()) {
255
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php';
256 256
 				}
257 257
 
258 258
 				// REMOVE IN THE FUTURE.
259
-				require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
259
+				require_once dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
260 260
 
261
-				add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) );
262
-				add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
263
-				add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
261
+				add_filter('woocommerce_payment_gateways', array($this, 'add_gateways'));
262
+				add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
263
+				add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2);
264 264
 
265 265
 				// Modify emails emails.
266
-				add_filter( 'woocommerce_email_classes', array( $this, 'add_emails' ), 20 );
266
+				add_filter('woocommerce_email_classes', array($this, 'add_emails'), 20);
267 267
 
268
-				if ( version_compare( WC_VERSION, '3.4', '<' ) ) {
269
-					add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) );
268
+				if (version_compare(WC_VERSION, '3.4', '<')) {
269
+					add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin'));
270 270
 				}
271 271
 			}
272 272
 
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 			 * @version 4.0.0
278 278
 			 */
279 279
 			public function update_plugin_version() {
280
-				delete_option( 'wc_stripe_version' );
281
-				update_option( 'wc_stripe_version', WC_STRIPE_VERSION );
280
+				delete_option('wc_stripe_version');
281
+				update_option('wc_stripe_version', WC_STRIPE_VERSION);
282 282
 			}
283 283
 
284 284
 			/**
@@ -288,15 +288,15 @@  discard block
 block discarded – undo
288 288
 			 * @version 3.1.0
289 289
 			 */
290 290
 			public function install() {
291
-				if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) {
291
+				if ( ! is_plugin_active(plugin_basename(__FILE__))) {
292 292
 					return;
293 293
 				}
294 294
 
295
-				if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) {
296
-					do_action( 'woocommerce_stripe_updated' );
295
+				if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) {
296
+					do_action('woocommerce_stripe_updated');
297 297
 
298
-					if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) {
299
-						define( 'WC_STRIPE_INSTALLING', true );
298
+					if ( ! defined('WC_STRIPE_INSTALLING')) {
299
+						define('WC_STRIPE_INSTALLING', true);
300 300
 					}
301 301
 
302 302
 					$this->update_plugin_version();
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
 			 * @since 1.0.0
310 310
 			 * @version 4.0.0
311 311
 			 */
312
-			public function plugin_action_links( $links ) {
312
+			public function plugin_action_links($links) {
313 313
 				$plugin_links = array(
314
-					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
314
+					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>',
315 315
 				);
316
-				return array_merge( $plugin_links, $links );
316
+				return array_merge($plugin_links, $links);
317 317
 			}
318 318
 
319 319
 			/**
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
 			 * @param  string $file  Name of current file.
325 325
 			 * @return array  $links Update list of plugin links.
326 326
 			 */
327
-			public function plugin_row_meta( $links, $file ) {
328
-				if ( plugin_basename( __FILE__ ) === $file ) {
327
+			public function plugin_row_meta($links, $file) {
328
+				if (plugin_basename(__FILE__) === $file) {
329 329
 					$row_meta = array(
330
-						'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>',
331
-						'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>',
330
+						'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>',
331
+						'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>',
332 332
 					);
333
-					return array_merge( $links, $row_meta );
333
+					return array_merge($links, $row_meta);
334 334
 				}
335 335
 				return (array) $links;
336 336
 			}
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 			 * @since 1.0.0
342 342
 			 * @version 4.0.0
343 343
 			 */
344
-			public function add_gateways( $methods ) {
345
-				if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) {
344
+			public function add_gateways($methods) {
345
+				if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) {
346 346
 					$methods[] = 'WC_Stripe_Subs_Compat';
347 347
 					$methods[] = 'WC_Stripe_Sepa_Subs_Compat';
348 348
 				} else {
@@ -368,28 +368,28 @@  discard block
 block discarded – undo
368 368
 			 * @since 4.0.0
369 369
 			 * @version 4.0.0
370 370
 			 */
371
-			public function filter_gateway_order_admin( $sections ) {
372
-				unset( $sections['stripe'] );
373
-				unset( $sections['stripe_bancontact'] );
374
-				unset( $sections['stripe_sofort'] );
375
-				unset( $sections['stripe_giropay'] );
376
-				unset( $sections['stripe_eps'] );
377
-				unset( $sections['stripe_ideal'] );
378
-				unset( $sections['stripe_p24'] );
379
-				unset( $sections['stripe_alipay'] );
380
-				unset( $sections['stripe_sepa'] );
381
-				unset( $sections['stripe_multibanco'] );
371
+			public function filter_gateway_order_admin($sections) {
372
+				unset($sections['stripe']);
373
+				unset($sections['stripe_bancontact']);
374
+				unset($sections['stripe_sofort']);
375
+				unset($sections['stripe_giropay']);
376
+				unset($sections['stripe_eps']);
377
+				unset($sections['stripe_ideal']);
378
+				unset($sections['stripe_p24']);
379
+				unset($sections['stripe_alipay']);
380
+				unset($sections['stripe_sepa']);
381
+				unset($sections['stripe_multibanco']);
382 382
 
383 383
 				$sections['stripe']            = 'Stripe';
384
-				$sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' );
385
-				$sections['stripe_sofort']     = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' );
386
-				$sections['stripe_giropay']    = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' );
387
-				$sections['stripe_eps']        = __( 'Stripe EPS', 'woocommerce-gateway-stripe' );
388
-				$sections['stripe_ideal']      = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' );
389
-				$sections['stripe_p24']        = __( 'Stripe P24', 'woocommerce-gateway-stripe' );
390
-				$sections['stripe_alipay']     = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' );
391
-				$sections['stripe_sepa']       = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' );
392
-				$sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' );
384
+				$sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe');
385
+				$sections['stripe_sofort']     = __('Stripe SOFORT', 'woocommerce-gateway-stripe');
386
+				$sections['stripe_giropay']    = __('Stripe Giropay', 'woocommerce-gateway-stripe');
387
+				$sections['stripe_eps']        = __('Stripe EPS', 'woocommerce-gateway-stripe');
388
+				$sections['stripe_ideal']      = __('Stripe iDeal', 'woocommerce-gateway-stripe');
389
+				$sections['stripe_p24']        = __('Stripe P24', 'woocommerce-gateway-stripe');
390
+				$sections['stripe_alipay']     = __('Stripe Alipay', 'woocommerce-gateway-stripe');
391
+				$sections['stripe_sepa']       = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe');
392
+				$sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe');
393 393
 
394 394
 				return $sections;
395 395
 			}
@@ -400,16 +400,16 @@  discard block
 block discarded – undo
400 400
 			 * @param WC_Email[] $email_classes All existing emails.
401 401
 			 * @return WC_Email[]
402 402
 			 */
403
-			public function add_emails( $email_classes ) {
403
+			public function add_emails($email_classes) {
404 404
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication.php';
405 405
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-renewal-authentication.php';
406 406
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-preorder-authentication.php';
407 407
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication-retry.php';
408 408
 
409 409
 				// Add all emails, generated by the gateway.
410
-				$email_classes['WC_Stripe_Email_Failed_Renewal_Authentication']  = new WC_Stripe_Email_Failed_Renewal_Authentication( $email_classes );
411
-				$email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication( $email_classes );
412
-				$email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry( $email_classes );
410
+				$email_classes['WC_Stripe_Email_Failed_Renewal_Authentication']  = new WC_Stripe_Email_Failed_Renewal_Authentication($email_classes);
411
+				$email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication($email_classes);
412
+				$email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry($email_classes);
413 413
 
414 414
 				return $email_classes;
415 415
 			}
@@ -424,9 +424,9 @@  discard block
 block discarded – undo
424 424
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/connect/class-wc-stripe-connect-rest-oauth-connect-controller.php';
425 425
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/connect/class-wc-stripe-connect-rest-deauthorize-controller.php';
426 426
 
427
-				$oauth_init    = new WC_Stripe_Connect_REST_Oauth_Init_Controller( $this->connect, $this->api );
428
-				$oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller( $this->connect, $this->api );
429
-				$deauthorize   = new WC_Stripe_Connect_REST_Deauthorize_Controller( $this->connect, $this->api );
427
+				$oauth_init    = new WC_Stripe_Connect_REST_Oauth_Init_Controller($this->connect, $this->api);
428
+				$oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller($this->connect, $this->api);
429
+				$deauthorize   = new WC_Stripe_Connect_REST_Deauthorize_Controller($this->connect, $this->api);
430 430
 
431 431
 				$oauth_init->register_routes();
432 432
 				$oauth_connect->register_routes();
Please login to merge, or discard this patch.
includes/class-wc-gateway-stripe.php 1 patch
Spacing   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	public function __construct() {
86 86
 		$this->retry_interval = 1;
87 87
 		$this->id             = 'stripe';
88
-		$this->method_title   = __( 'Stripe', 'woocommerce-gateway-stripe' );
88
+		$this->method_title   = __('Stripe', 'woocommerce-gateway-stripe');
89 89
 		/* translators: 1) link to Stripe register page 2) link to Stripe api keys page */
90
-		$this->method_description = __( 'Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification.', 'woocommerce-gateway-stripe' );
90
+		$this->method_description = __('Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification.', 'woocommerce-gateway-stripe');
91 91
 		$this->has_fields         = true;
92 92
 		$this->supports           = array(
93 93
 			'products',
@@ -114,40 +114,40 @@  discard block
 block discarded – undo
114 114
 		$this->init_settings();
115 115
 
116 116
 		// Get setting values.
117
-		$this->title                = $this->get_option( 'title' );
118
-		$this->description          = $this->get_option( 'description' );
119
-		$this->enabled              = $this->get_option( 'enabled' );
120
-		$this->testmode             = 'yes' === $this->get_option( 'testmode' );
121
-		$this->inline_cc_form       = 'yes' === $this->get_option( 'inline_cc_form' );
122
-		$this->capture              = 'yes' === $this->get_option( 'capture', 'yes' );
123
-		$this->statement_descriptor = WC_Stripe_Helper::clean_statement_descriptor( $this->get_option( 'statement_descriptor' ) );
124
-		$this->saved_cards          = 'yes' === $this->get_option( 'saved_cards' );
125
-		$this->secret_key           = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
126
-		$this->publishable_key      = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' );
127
-		$this->payment_request      = 'yes' === $this->get_option( 'payment_request', 'yes' );
128
-
129
-		WC_Stripe_API::set_secret_key( $this->secret_key );
117
+		$this->title                = $this->get_option('title');
118
+		$this->description          = $this->get_option('description');
119
+		$this->enabled              = $this->get_option('enabled');
120
+		$this->testmode             = 'yes' === $this->get_option('testmode');
121
+		$this->inline_cc_form       = 'yes' === $this->get_option('inline_cc_form');
122
+		$this->capture              = 'yes' === $this->get_option('capture', 'yes');
123
+		$this->statement_descriptor = WC_Stripe_Helper::clean_statement_descriptor($this->get_option('statement_descriptor'));
124
+		$this->saved_cards          = 'yes' === $this->get_option('saved_cards');
125
+		$this->secret_key           = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
126
+		$this->publishable_key      = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key');
127
+		$this->payment_request      = 'yes' === $this->get_option('payment_request', 'yes');
128
+
129
+		WC_Stripe_API::set_secret_key($this->secret_key);
130 130
 
131 131
 		// Hooks.
132
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
133
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
134
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
135
-		add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_fee' ) );
136
-		add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_payout' ), 20 );
137
-		add_action( 'woocommerce_customer_save_address', array( $this, 'show_update_card_notice' ), 10, 2 );
138
-		add_filter( 'woocommerce_available_payment_gateways', array( $this, 'prepare_order_pay_page' ) );
139
-		add_action( 'woocommerce_account_view-order_endpoint', array( $this, 'check_intent_status_on_order_page' ), 1 );
140
-		add_filter( 'woocommerce_payment_successful_result', array( $this, 'modify_successful_payment_result' ), 99999, 2 );
141
-		add_action( 'set_logged_in_cookie', array( $this, 'set_cookie_on_current_request' ) );
142
-		add_filter( 'woocommerce_get_checkout_payment_url', array( $this, 'get_checkout_payment_url' ), 10, 2 );
132
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
133
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'));
134
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
135
+		add_action('woocommerce_admin_order_totals_after_total', array($this, 'display_order_fee'));
136
+		add_action('woocommerce_admin_order_totals_after_total', array($this, 'display_order_payout'), 20);
137
+		add_action('woocommerce_customer_save_address', array($this, 'show_update_card_notice'), 10, 2);
138
+		add_filter('woocommerce_available_payment_gateways', array($this, 'prepare_order_pay_page'));
139
+		add_action('woocommerce_account_view-order_endpoint', array($this, 'check_intent_status_on_order_page'), 1);
140
+		add_filter('woocommerce_payment_successful_result', array($this, 'modify_successful_payment_result'), 99999, 2);
141
+		add_action('set_logged_in_cookie', array($this, 'set_cookie_on_current_request'));
142
+		add_filter('woocommerce_get_checkout_payment_url', array($this, 'get_checkout_payment_url'), 10, 2);
143 143
 
144 144
 		// Note: display error is in the parent class.
145
-		add_action( 'admin_notices', array( $this, 'display_errors' ), 9999 );
145
+		add_action('admin_notices', array($this, 'display_errors'), 9999);
146 146
 
147
-		if ( WC_Stripe_Helper::is_pre_orders_exists() ) {
147
+		if (WC_Stripe_Helper::is_pre_orders_exists()) {
148 148
 			$this->pre_orders = new WC_Stripe_Pre_Orders_Compat();
149 149
 
150
-			add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this->pre_orders, 'process_pre_order_release_payment' ) );
150
+			add_action('wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array($this->pre_orders, 'process_pre_order_release_payment'));
151 151
 		}
152 152
 	}
153 153
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @since 4.0.2
158 158
 	 */
159 159
 	public function is_available() {
160
-		if ( is_add_payment_method_page() && ! $this->saved_cards ) {
160
+		if (is_add_payment_method_page() && ! $this->saved_cards) {
161 161
 			return false;
162 162
 		}
163 163
 
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 	 * @param int    $user_id      The ID of the current user.
172 172
 	 * @param string $load_address The address to load.
173 173
 	 */
174
-	public function show_update_card_notice( $user_id, $load_address ) {
175
-		if ( ! $this->saved_cards || ! WC_Stripe_Payment_Tokens::customer_has_saved_methods( $user_id ) || 'billing' !== $load_address ) {
174
+	public function show_update_card_notice($user_id, $load_address) {
175
+		if ( ! $this->saved_cards || ! WC_Stripe_Payment_Tokens::customer_has_saved_methods($user_id) || 'billing' !== $load_address) {
176 176
 			return;
177 177
 		}
178 178
 
179 179
 		/* translators: 1) Opening anchor tag 2) closing anchor tag */
180
-		wc_add_notice( sprintf( __( 'If your billing address has been changed for saved payment methods, be sure to remove any %1$ssaved payment methods%2$s on file and re-add them.', 'woocommerce-gateway-stripe' ), '<a href="' . esc_url( wc_get_endpoint_url( 'payment-methods' ) ) . '" class="wc-stripe-update-card-notice" style="text-decoration:underline;">', '</a>' ), 'notice' );
180
+		wc_add_notice(sprintf(__('If your billing address has been changed for saved payment methods, be sure to remove any %1$ssaved payment methods%2$s on file and re-add them.', 'woocommerce-gateway-stripe'), '<a href="' . esc_url(wc_get_endpoint_url('payment-methods')) . '" class="wc-stripe-update-card-notice" style="text-decoration:underline;">', '</a>'), 'notice');
181 181
 	}
182 182
 
183 183
 	/**
@@ -192,24 +192,24 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$icons_str = '';
194 194
 
195
-		$icons_str .= isset( $icons['visa'] ) ? $icons['visa'] : '';
196
-		$icons_str .= isset( $icons['amex'] ) ? $icons['amex'] : '';
197
-		$icons_str .= isset( $icons['mastercard'] ) ? $icons['mastercard'] : '';
195
+		$icons_str .= isset($icons['visa']) ? $icons['visa'] : '';
196
+		$icons_str .= isset($icons['amex']) ? $icons['amex'] : '';
197
+		$icons_str .= isset($icons['mastercard']) ? $icons['mastercard'] : '';
198 198
 
199
-		if ( 'USD' === get_woocommerce_currency() ) {
200
-			$icons_str .= isset( $icons['discover'] ) ? $icons['discover'] : '';
201
-			$icons_str .= isset( $icons['jcb'] ) ? $icons['jcb'] : '';
202
-			$icons_str .= isset( $icons['diners'] ) ? $icons['diners'] : '';
199
+		if ('USD' === get_woocommerce_currency()) {
200
+			$icons_str .= isset($icons['discover']) ? $icons['discover'] : '';
201
+			$icons_str .= isset($icons['jcb']) ? $icons['jcb'] : '';
202
+			$icons_str .= isset($icons['diners']) ? $icons['diners'] : '';
203 203
 		}
204 204
 
205
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
205
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
206 206
 	}
207 207
 
208 208
 	/**
209 209
 	 * Initialise Gateway Settings Form Fields
210 210
 	 */
211 211
 	public function init_form_fields() {
212
-		$this->form_fields = require( dirname( __FILE__ ) . '/admin/stripe-settings.php' );
212
+		$this->form_fields = require(dirname(__FILE__) . '/admin/stripe-settings.php');
213 213
 	}
214 214
 
215 215
 	/**
@@ -218,27 +218,27 @@  discard block
 block discarded – undo
218 218
 	public function payment_fields() {
219 219
 		global $wp;
220 220
 		$user                 = wp_get_current_user();
221
-		$display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards;
221
+		$display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards;
222 222
 		$total                = WC()->cart->total;
223 223
 		$user_email           = '';
224 224
 		$description          = $this->get_description();
225
-		$description          = ! empty( $description ) ? $description : '';
225
+		$description          = ! empty($description) ? $description : '';
226 226
 		$firstname            = '';
227 227
 		$lastname             = '';
228 228
 
229 229
 		// If paying from order, we need to get total from order not cart.
230
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { // wpcs: csrf ok.
231
-			$order      = wc_get_order( wc_clean( $wp->query_vars['order-pay'] ) ); // wpcs: csrf ok, sanitization ok.
230
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { // wpcs: csrf ok.
231
+			$order      = wc_get_order(wc_clean($wp->query_vars['order-pay'])); // wpcs: csrf ok, sanitization ok.
232 232
 			$total      = $order->get_total();
233 233
 			$user_email = $order->get_billing_email();
234 234
 		} else {
235
-			if ( $user->ID ) {
236
-				$user_email = get_user_meta( $user->ID, 'billing_email', true );
235
+			if ($user->ID) {
236
+				$user_email = get_user_meta($user->ID, 'billing_email', true);
237 237
 				$user_email = $user_email ? $user_email : $user->user_email;
238 238
 			}
239 239
 		}
240 240
 
241
-		if ( is_add_payment_method_page() ) {
241
+		if (is_add_payment_method_page()) {
242 242
 			$firstname       = $user->user_firstname;
243 243
 			$lastname        = $user->user_lastname;
244 244
 		}
@@ -247,33 +247,33 @@  discard block
 block discarded – undo
247 247
 
248 248
 		echo '<div
249 249
 			id="stripe-payment-data"
250
-			data-email="' . esc_attr( $user_email ) . '"
251
-			data-full-name="' . esc_attr( $firstname . ' ' . $lastname ) . '"
252
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '"
250
+			data-email="' . esc_attr($user_email) . '"
251
+			data-full-name="' . esc_attr($firstname . ' ' . $lastname) . '"
252
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '"
253 253
 		>';
254 254
 
255
-		if ( $this->testmode ) {
255
+		if ($this->testmode) {
256 256
 			/* translators: link to Stripe testing page */
257
-			$description .= ' ' . sprintf( __( 'TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the <a href="%s" target="_blank">Testing Stripe documentation</a> for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' );
257
+			$description .= ' ' . sprintf(__('TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the <a href="%s" target="_blank">Testing Stripe documentation</a> for more card numbers.', 'woocommerce-gateway-stripe'), 'https://stripe.com/docs/testing');
258 258
 		}
259 259
 
260
-		$description = trim( $description );
260
+		$description = trim($description);
261 261
 
262
-		echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id ); // wpcs: xss ok.
262
+		echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id); // wpcs: xss ok.
263 263
 
264
-		if ( $display_tokenization ) {
264
+		if ($display_tokenization) {
265 265
 			$this->tokenization_script();
266 266
 			$this->saved_payment_methods();
267 267
 		}
268 268
 
269 269
 		$this->elements_form();
270 270
 
271
-		if ( apply_filters( 'wc_stripe_display_save_payment_method_checkbox', $display_tokenization ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) { // wpcs: csrf ok.
271
+		if (apply_filters('wc_stripe_display_save_payment_method_checkbox', $display_tokenization) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) { // wpcs: csrf ok.
272 272
 
273 273
 			$this->save_payment_method_checkbox();
274 274
 		}
275 275
 
276
-		do_action( 'wc_stripe_cards_payment_fields', $this->id );
276
+		do_action('wc_stripe_cards_payment_fields', $this->id);
277 277
 
278 278
 		echo '</div>';
279 279
 
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
 	 */
289 289
 	public function elements_form() {
290 290
 		?>
291
-		<fieldset id="wc-<?php echo esc_attr( $this->id ); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
292
-			<?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?>
291
+		<fieldset id="wc-<?php echo esc_attr($this->id); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
292
+			<?php do_action('woocommerce_credit_card_form_start', $this->id); ?>
293 293
 
294
-			<?php if ( $this->inline_cc_form ) { ?>
294
+			<?php if ($this->inline_cc_form) { ?>
295 295
 				<label for="card-element">
296
-					<?php esc_html_e( 'Credit or debit card', 'woocommerce-gateway-stripe' ); ?>
296
+					<?php esc_html_e('Credit or debit card', 'woocommerce-gateway-stripe'); ?>
297 297
 				</label>
298 298
 
299 299
 				<div id="stripe-card-element" class="wc-stripe-elements-field">
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 				</div>
302 302
 			<?php } else { ?>
303 303
 				<div class="form-row form-row-wide">
304
-					<label for="stripe-card-element"><?php esc_html_e( 'Card Number', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
304
+					<label for="stripe-card-element"><?php esc_html_e('Card Number', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
305 305
 					<div class="stripe-card-group">
306 306
 						<div id="stripe-card-element" class="wc-stripe-elements-field">
307 307
 						<!-- a Stripe Element will be inserted here. -->
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 				</div>
313 313
 
314 314
 				<div class="form-row form-row-first">
315
-					<label for="stripe-exp-element"><?php esc_html_e( 'Expiry Date', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
315
+					<label for="stripe-exp-element"><?php esc_html_e('Expiry Date', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
316 316
 
317 317
 					<div id="stripe-exp-element" class="wc-stripe-elements-field">
318 318
 					<!-- a Stripe Element will be inserted here. -->
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 				</div>
321 321
 
322 322
 				<div class="form-row form-row-last">
323
-					<label for="stripe-cvc-element"><?php esc_html_e( 'Card Code (CVC)', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
323
+					<label for="stripe-cvc-element"><?php esc_html_e('Card Code (CVC)', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
324 324
 				<div id="stripe-cvc-element" class="wc-stripe-elements-field">
325 325
 				<!-- a Stripe Element will be inserted here. -->
326 326
 				</div>
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 			<!-- Used to display form errors -->
332 332
 			<div class="stripe-source-errors" role="alert"></div>
333 333
 			<br />
334
-			<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
334
+			<?php do_action('woocommerce_credit_card_form_end', $this->id); ?>
335 335
 			<div class="clear"></div>
336 336
 		</fieldset>
337 337
 		<?php
@@ -344,24 +344,24 @@  discard block
 block discarded – undo
344 344
 	 * @version 3.1.0
345 345
 	 */
346 346
 	public function admin_scripts() {
347
-		if ( 'woocommerce_page_wc-settings' !== get_current_screen()->id ) {
347
+		if ('woocommerce_page_wc-settings' !== get_current_screen()->id) {
348 348
 			return;
349 349
 		}
350 350
 
351
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
351
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
352 352
 
353
-		wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true );
353
+		wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true);
354 354
 		wp_localize_script(
355 355
 			'woocommerce_stripe_admin',
356 356
 			'woocommerce_stripe_admin',
357 357
 			array(
358
-				'ajax_url'              => WC_AJAX::get_endpoint( 'wc_stripe_oauth_init' ),
359
-				'wc_stripe_oauth_nonce' => wp_create_nonce( '_wc_stripe_oauth_nonce' ),
360
-				'wc_stripe_oauth_init'  => ! $this->secret_key && ! $this->publishable_key && ! get_option( 'stripe_state', false ),
358
+				'ajax_url'              => WC_AJAX::get_endpoint('wc_stripe_oauth_init'),
359
+				'wc_stripe_oauth_nonce' => wp_create_nonce('_wc_stripe_oauth_nonce'),
360
+				'wc_stripe_oauth_init'  => ! $this->secret_key && ! $this->publishable_key && ! get_option('stripe_state', false),
361 361
 				'i18n'                  => array(
362 362
 					'wc_stripe_oauth_text' => sprintf(
363 363
 						/* translators: 1) opening anchor tag 2) closing anchor tag */
364
-						__( '%1$sClick here%2$s to automatically copy your Stripe account keys.', 'woocommerce-gateway-stripe' ),
364
+						__('%1$sClick here%2$s to automatically copy your Stripe account keys.', 'woocommerce-gateway-stripe'),
365 365
 						'<a href="#" id="oauth-init">',
366 366
 						'</a>'
367 367
 					),
@@ -384,54 +384,54 @@  discard block
 block discarded – undo
384 384
 			! is_product()
385 385
 			&& ! is_cart()
386 386
 			&& ! is_checkout()
387
-			&& ! isset( $_GET['pay_for_order'] ) // wpcs: csrf ok.
387
+			&& ! isset($_GET['pay_for_order']) // wpcs: csrf ok.
388 388
 			&& ! is_add_payment_method_page()
389
-			&& ! isset( $_GET['change_payment_method'] ) // wpcs: csrf ok.
390
-			&& ! ( ! empty( get_query_var( 'view-subscription' ) ) && is_callable( 'WCS_Early_Renewal_Manager::is_early_renewal_via_modal_enabled' ) && WCS_Early_Renewal_Manager::is_early_renewal_via_modal_enabled() )
391
-			|| ( is_order_received_page() )
389
+			&& ! isset($_GET['change_payment_method']) // wpcs: csrf ok.
390
+			&& ! ( ! empty(get_query_var('view-subscription')) && is_callable('WCS_Early_Renewal_Manager::is_early_renewal_via_modal_enabled') && WCS_Early_Renewal_Manager::is_early_renewal_via_modal_enabled())
391
+			|| (is_order_received_page())
392 392
 		) {
393 393
 			return;
394 394
 		}
395 395
 
396 396
 		// If Stripe is not enabled bail.
397
-		if ( 'no' === $this->enabled ) {
397
+		if ('no' === $this->enabled) {
398 398
 			return;
399 399
 		}
400 400
 
401 401
 		// If keys are not set bail.
402
-		if ( ! $this->are_keys_set() ) {
403
-			WC_Stripe_Logger::log( 'Keys are not set correctly.' );
402
+		if ( ! $this->are_keys_set()) {
403
+			WC_Stripe_Logger::log('Keys are not set correctly.');
404 404
 			return;
405 405
 		}
406 406
 
407 407
 		// If no SSL bail.
408
-		if ( ! $this->testmode && ! is_ssl() ) {
409
-			WC_Stripe_Logger::log( 'Stripe live mode requires SSL.' );
408
+		if ( ! $this->testmode && ! is_ssl()) {
409
+			WC_Stripe_Logger::log('Stripe live mode requires SSL.');
410 410
 			return;
411 411
 		}
412 412
 
413 413
 		$current_theme = wp_get_theme();
414 414
 
415
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
415
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
416 416
 
417
-		wp_register_style( 'stripe_styles', plugins_url( 'assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION );
418
-		wp_enqueue_style( 'stripe_styles' );
417
+		wp_register_style('stripe_styles', plugins_url('assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION);
418
+		wp_enqueue_style('stripe_styles');
419 419
 
420
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
421
-		wp_register_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripe' ), WC_STRIPE_VERSION, true );
420
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
421
+		wp_register_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripe'), WC_STRIPE_VERSION, true);
422 422
 
423 423
 		$stripe_params = array(
424 424
 			'key'                  => $this->publishable_key,
425
-			'i18n_terms'           => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ),
426
-			'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ),
425
+			'i18n_terms'           => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'),
426
+			'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'),
427 427
 		);
428 428
 
429 429
 		// If we're on the pay page we need to pass stripe.js the address of the order.
430
-		if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) { // wpcs: csrf ok.
431
-			$order_id = wc_clean( $wp->query_vars['order-pay'] ); // wpcs: csrf ok, sanitization ok, xss ok.
432
-			$order    = wc_get_order( $order_id );
430
+		if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) { // wpcs: csrf ok.
431
+			$order_id = wc_clean($wp->query_vars['order-pay']); // wpcs: csrf ok, sanitization ok, xss ok.
432
+			$order    = wc_get_order($order_id);
433 433
 
434
-			if ( is_a( $order, 'WC_Order' ) ) {
434
+			if (is_a($order, 'WC_Order')) {
435 435
 				$stripe_params['billing_first_name'] = $order->get_billing_first_name();
436 436
 				$stripe_params['billing_last_name']  = $order->get_billing_last_name();
437 437
 				$stripe_params['billing_address_1']  = $order->get_billing_address_1();
@@ -446,40 +446,40 @@  discard block
 block discarded – undo
446 446
 		$sepa_elements_options = apply_filters(
447 447
 			'wc_stripe_sepa_elements_options',
448 448
 			array(
449
-				'supportedCountries' => array( 'SEPA' ),
449
+				'supportedCountries' => array('SEPA'),
450 450
 				'placeholderCountry' => WC()->countries->get_base_country(),
451
-				'style'              => array( 'base' => array( 'fontSize' => '15px' ) ),
451
+				'style'              => array('base' => array('fontSize' => '15px')),
452 452
 			)
453 453
 		);
454 454
 
455
-		$stripe_params['no_prepaid_card_msg']       = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
456
-		$stripe_params['no_sepa_owner_msg']         = __( 'Please enter your IBAN account name.', 'woocommerce-gateway-stripe' );
457
-		$stripe_params['no_sepa_iban_msg']          = __( 'Please enter your IBAN account number.', 'woocommerce-gateway-stripe' );
458
-		$stripe_params['payment_intent_error']      = __( 'We couldn\'t initiate the payment. Please try again.', 'woocommerce-gateway-stripe' );
459
-		$stripe_params['sepa_mandate_notification'] = apply_filters( 'wc_stripe_sepa_mandate_notification', 'email' );
460
-		$stripe_params['allow_prepaid_card']        = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no';
455
+		$stripe_params['no_prepaid_card_msg']       = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
456
+		$stripe_params['no_sepa_owner_msg']         = __('Please enter your IBAN account name.', 'woocommerce-gateway-stripe');
457
+		$stripe_params['no_sepa_iban_msg']          = __('Please enter your IBAN account number.', 'woocommerce-gateway-stripe');
458
+		$stripe_params['payment_intent_error']      = __('We couldn\'t initiate the payment. Please try again.', 'woocommerce-gateway-stripe');
459
+		$stripe_params['sepa_mandate_notification'] = apply_filters('wc_stripe_sepa_mandate_notification', 'email');
460
+		$stripe_params['allow_prepaid_card']        = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no';
461 461
 		$stripe_params['inline_cc_form']            = $this->inline_cc_form ? 'yes' : 'no';
462
-		$stripe_params['is_checkout']               = ( is_checkout() && empty( $_GET['pay_for_order'] ) ) ? 'yes' : 'no'; // wpcs: csrf ok.
462
+		$stripe_params['is_checkout']               = (is_checkout() && empty($_GET['pay_for_order'])) ? 'yes' : 'no'; // wpcs: csrf ok.
463 463
 		$stripe_params['return_url']                = $this->get_stripe_return_url();
464
-		$stripe_params['ajaxurl']                   = WC_AJAX::get_endpoint( '%%endpoint%%' );
465
-		$stripe_params['stripe_nonce']              = wp_create_nonce( '_wc_stripe_nonce' );
464
+		$stripe_params['ajaxurl']                   = WC_AJAX::get_endpoint('%%endpoint%%');
465
+		$stripe_params['stripe_nonce']              = wp_create_nonce('_wc_stripe_nonce');
466 466
 		$stripe_params['statement_descriptor']      = $this->statement_descriptor;
467
-		$stripe_params['elements_options']          = apply_filters( 'wc_stripe_elements_options', array() );
467
+		$stripe_params['elements_options']          = apply_filters('wc_stripe_elements_options', array());
468 468
 		$stripe_params['sepa_elements_options']     = $sepa_elements_options;
469
-		$stripe_params['invalid_owner_name']        = __( 'Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe' );
470
-		$stripe_params['is_change_payment_page']    = isset( $_GET['change_payment_method'] ) ? 'yes' : 'no'; // wpcs: csrf ok.
471
-		$stripe_params['is_add_payment_page']       = is_wc_endpoint_url( 'add-payment-method' ) ? 'yes' : 'no';
472
-		$stripe_params['is_pay_for_order_page']     = is_wc_endpoint_url( 'order-pay' ) ? 'yes' : 'no';
473
-		$stripe_params['elements_styling']          = apply_filters( 'wc_stripe_elements_styling', false );
474
-		$stripe_params['elements_classes']          = apply_filters( 'wc_stripe_elements_classes', false );
469
+		$stripe_params['invalid_owner_name']        = __('Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe');
470
+		$stripe_params['is_change_payment_page']    = isset($_GET['change_payment_method']) ? 'yes' : 'no'; // wpcs: csrf ok.
471
+		$stripe_params['is_add_payment_page']       = is_wc_endpoint_url('add-payment-method') ? 'yes' : 'no';
472
+		$stripe_params['is_pay_for_order_page']     = is_wc_endpoint_url('order-pay') ? 'yes' : 'no';
473
+		$stripe_params['elements_styling']          = apply_filters('wc_stripe_elements_styling', false);
474
+		$stripe_params['elements_classes']          = apply_filters('wc_stripe_elements_classes', false);
475 475
 
476 476
 		// Merge localized messages to be use in JS.
477
-		$stripe_params = array_merge( $stripe_params, WC_Stripe_Helper::get_localized_messages() );
477
+		$stripe_params = array_merge($stripe_params, WC_Stripe_Helper::get_localized_messages());
478 478
 
479
-		wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
479
+		wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
480 480
 
481 481
 		$this->tokenization_script();
482
-		wp_enqueue_script( 'woocommerce_stripe' );
482
+		wp_enqueue_script('woocommerce_stripe');
483 483
 	}
484 484
 
485 485
 	/**
@@ -490,14 +490,14 @@  discard block
 block discarded – undo
490 490
 	 * @param object $prepared_source The object with source details.
491 491
 	 * @throws WC_Stripe_Exception An exception if the card is prepaid, but prepaid cards are not allowed.
492 492
 	 */
493
-	public function maybe_disallow_prepaid_card( $prepared_source ) {
493
+	public function maybe_disallow_prepaid_card($prepared_source) {
494 494
 		// Check if we don't allow prepaid credit cards.
495
-		if ( apply_filters( 'wc_stripe_allow_prepaid_card', true ) || ! $this->is_prepaid_card( $prepared_source->source_object ) ) {
495
+		if (apply_filters('wc_stripe_allow_prepaid_card', true) || ! $this->is_prepaid_card($prepared_source->source_object)) {
496 496
 			return;
497 497
 		}
498 498
 
499
-		$localized_message = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
500
-		throw new WC_Stripe_Exception( print_r( $prepared_source->source_object, true ), $localized_message );
499
+		$localized_message = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charged. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
500
+		throw new WC_Stripe_Exception(print_r($prepared_source->source_object, true), $localized_message);
501 501
 	}
502 502
 
503 503
 	/**
@@ -507,10 +507,10 @@  discard block
 block discarded – undo
507 507
 	 * @param  object $prepared_source The source that should be verified.
508 508
 	 * @throws WC_Stripe_Exception     An exception if the source ID is missing.
509 509
 	 */
510
-	public function check_source( $prepared_source ) {
511
-		if ( empty( $prepared_source->source ) ) {
512
-			$localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
513
-			throw new WC_Stripe_Exception( print_r( $prepared_source, true ), $localized_message );
510
+	public function check_source($prepared_source) {
511
+		if (empty($prepared_source->source)) {
512
+			$localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
513
+			throw new WC_Stripe_Exception(print_r($prepared_source, true), $localized_message);
514 514
 		}
515 515
 	}
516 516
 
@@ -522,13 +522,13 @@  discard block
 block discarded – undo
522 522
 	 * @param WC_Order $order The order those payment is being processed.
523 523
 	 * @return bool           A flag that indicates that the customer does not exist and should be removed.
524 524
 	 */
525
-	public function maybe_remove_non_existent_customer( $error, $order ) {
526
-		if ( ! $this->is_no_such_customer_error( $error ) ) {
525
+	public function maybe_remove_non_existent_customer($error, $order) {
526
+		if ( ! $this->is_no_such_customer_error($error)) {
527 527
 			return false;
528 528
 		}
529 529
 
530
-		delete_user_option( $order->get_customer_id(), '_stripe_customer_id' );
531
-		$order->delete_meta_data( '_stripe_customer_id' );
530
+		delete_user_option($order->get_customer_id(), '_stripe_customer_id');
531
+		$order->delete_meta_data('_stripe_customer_id');
532 532
 		$order->save();
533 533
 
534 534
 		return true;
@@ -543,15 +543,15 @@  discard block
 block discarded – undo
543 543
 	 * @param boolean  $force_save_source Whether the payment source must be saved, like when dealing with a Subscription setup.
544 544
 	 * @return array                      Redirection data for `process_payment`.
545 545
 	 */
546
-	public function complete_free_order( $order, $prepared_source, $force_save_source ) {
547
-		if ( $force_save_source ) {
548
-			$intent_secret = $this->setup_intent( $order, $prepared_source );
546
+	public function complete_free_order($order, $prepared_source, $force_save_source) {
547
+		if ($force_save_source) {
548
+			$intent_secret = $this->setup_intent($order, $prepared_source);
549 549
 
550
-			if ( ! empty( $intent_secret ) ) {
550
+			if ( ! empty($intent_secret)) {
551 551
 				// `get_return_url()` must be called immediately before returning a value.
552 552
 				return array(
553 553
 					'result'              => 'success',
554
-					'redirect'            => $this->get_return_url( $order ),
554
+					'redirect'            => $this->get_return_url($order),
555 555
 					'setup_intent_secret' => $intent_secret,
556 556
 				);
557 557
 			}
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		// Return thank you page redirect.
566 566
 		return array(
567 567
 			'result'   => 'success',
568
-			'redirect' => $this->get_return_url( $order ),
568
+			'redirect' => $this->get_return_url($order),
569 569
 		);
570 570
 	}
571 571
 
@@ -583,81 +583,81 @@  discard block
 block discarded – undo
583 583
 	 * @throws Exception If payment will not be accepted.
584 584
 	 * @return array|void
585 585
 	 */
586
-	public function process_payment( $order_id, $retry = true, $force_save_source = false, $previous_error = false, $use_order_source = false ) {
586
+	public function process_payment($order_id, $retry = true, $force_save_source = false, $previous_error = false, $use_order_source = false) {
587 587
 		try {
588
-			$order = wc_get_order( $order_id );
588
+			$order = wc_get_order($order_id);
589 589
 
590 590
 			// ToDo: `process_pre_order` saves the source to the order for a later payment.
591 591
 			// This might not work well with PaymentIntents.
592
-			if ( $this->maybe_process_pre_orders( $order_id ) ) {
593
-				return $this->pre_orders->process_pre_order( $order_id );
592
+			if ($this->maybe_process_pre_orders($order_id)) {
593
+				return $this->pre_orders->process_pre_order($order_id);
594 594
 			}
595 595
 
596 596
 			// Check whether there is an existing intent.
597
-			$intent = $this->get_intent_from_order( $order );
598
-			if ( isset( $intent->object ) && 'setup_intent' === $intent->object ) {
597
+			$intent = $this->get_intent_from_order($order);
598
+			if (isset($intent->object) && 'setup_intent' === $intent->object) {
599 599
 				$intent = false; // This function can only deal with *payment* intents
600 600
 			}
601 601
 
602 602
 			$stripe_customer_id = null;
603
-			if ( $intent && ! empty( $intent->customer ) ) {
603
+			if ($intent && ! empty($intent->customer)) {
604 604
 				$stripe_customer_id = $intent->customer;
605 605
 			}
606 606
 
607 607
 			// For some payments the source should already be present in the order.
608
-			if ( $use_order_source ) {
609
-				$prepared_source = $this->prepare_order_source( $order );
608
+			if ($use_order_source) {
609
+				$prepared_source = $this->prepare_order_source($order);
610 610
 			} else {
611
-				$prepared_source = $this->prepare_source( get_current_user_id(), $force_save_source, $stripe_customer_id );
611
+				$prepared_source = $this->prepare_source(get_current_user_id(), $force_save_source, $stripe_customer_id);
612 612
 			}
613 613
 
614
-			$this->maybe_disallow_prepaid_card( $prepared_source );
615
-			$this->check_source( $prepared_source );
616
-			$this->save_source_to_order( $order, $prepared_source );
614
+			$this->maybe_disallow_prepaid_card($prepared_source);
615
+			$this->check_source($prepared_source);
616
+			$this->save_source_to_order($order, $prepared_source);
617 617
 
618
-			if ( 0 >= $order->get_total() ) {
619
-				return $this->complete_free_order( $order, $prepared_source, $force_save_source );
618
+			if (0 >= $order->get_total()) {
619
+				return $this->complete_free_order($order, $prepared_source, $force_save_source);
620 620
 			}
621 621
 
622 622
 			// This will throw exception if not valid.
623
-			$this->validate_minimum_order_amount( $order );
623
+			$this->validate_minimum_order_amount($order);
624 624
 
625
-			WC_Stripe_Logger::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
625
+			WC_Stripe_Logger::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}");
626 626
 
627
-			if ( $intent ) {
628
-				$intent = $this->update_existing_intent( $intent, $order, $prepared_source );
627
+			if ($intent) {
628
+				$intent = $this->update_existing_intent($intent, $order, $prepared_source);
629 629
 			} else {
630
-				$intent = $this->create_intent( $order, $prepared_source );
630
+				$intent = $this->create_intent($order, $prepared_source);
631 631
 			}
632 632
 
633 633
 			// Confirm the intent after locking the order to make sure webhooks will not interfere.
634
-			if ( empty( $intent->error ) ) {
635
-				$this->lock_order_payment( $order, $intent );
636
-				$intent = $this->confirm_intent( $intent, $order, $prepared_source );
634
+			if (empty($intent->error)) {
635
+				$this->lock_order_payment($order, $intent);
636
+				$intent = $this->confirm_intent($intent, $order, $prepared_source);
637 637
 			}
638 638
 
639
-			if ( ! empty( $intent->error ) ) {
640
-				$this->maybe_remove_non_existent_customer( $intent->error, $order );
639
+			if ( ! empty($intent->error)) {
640
+				$this->maybe_remove_non_existent_customer($intent->error, $order);
641 641
 
642 642
 				// We want to retry.
643
-				if ( $this->is_retryable_error( $intent->error ) ) {
644
-					return $this->retry_after_error( $intent, $order, $retry, $force_save_source, $previous_error, $use_order_source );
643
+				if ($this->is_retryable_error($intent->error)) {
644
+					return $this->retry_after_error($intent, $order, $retry, $force_save_source, $previous_error, $use_order_source);
645 645
 				}
646 646
 
647
-				$this->unlock_order_payment( $order );
648
-				$this->throw_localized_message( $intent, $order );
647
+				$this->unlock_order_payment($order);
648
+				$this->throw_localized_message($intent, $order);
649 649
 			}
650 650
 
651
-			if ( ! empty( $intent ) ) {
651
+			if ( ! empty($intent)) {
652 652
 				// Use the last charge within the intent to proceed.
653
-				$response = end( $intent->charges->data );
653
+				$response = end($intent->charges->data);
654 654
 
655 655
 				// If the intent requires a 3DS flow, redirect to it.
656
-				if ( 'requires_action' === $intent->status ) {
657
-					$this->unlock_order_payment( $order );
656
+				if ('requires_action' === $intent->status) {
657
+					$this->unlock_order_payment($order);
658 658
 
659
-					if ( is_wc_endpoint_url( 'order-pay' ) ) {
660
-						$redirect_url = add_query_arg( 'wc-stripe-confirmation', 1, $order->get_checkout_payment_url( false ) );
659
+					if (is_wc_endpoint_url('order-pay')) {
660
+						$redirect_url = add_query_arg('wc-stripe-confirmation', 1, $order->get_checkout_payment_url(false));
661 661
 
662 662
 						return array(
663 663
 							'result'   => 'success',
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 
673 673
 						return array(
674 674
 							'result'                => 'success',
675
-							'redirect'              => $this->get_return_url( $order ),
675
+							'redirect'              => $this->get_return_url($order),
676 676
 							'payment_intent_secret' => $intent->client_secret,
677 677
 						);
678 678
 					}
@@ -680,30 +680,30 @@  discard block
 block discarded – undo
680 680
 			}
681 681
 
682 682
 			// Process valid response.
683
-			$this->process_response( $response, $order );
683
+			$this->process_response($response, $order);
684 684
 
685 685
 			// Remove cart.
686
-			if ( isset( WC()->cart ) ) {
686
+			if (isset(WC()->cart)) {
687 687
 				WC()->cart->empty_cart();
688 688
 			}
689 689
 
690 690
 			// Unlock the order.
691
-			$this->unlock_order_payment( $order );
691
+			$this->unlock_order_payment($order);
692 692
 
693 693
 			// Return thank you page redirect.
694 694
 			return array(
695 695
 				'result'   => 'success',
696
-				'redirect' => $this->get_return_url( $order ),
696
+				'redirect' => $this->get_return_url($order),
697 697
 			);
698 698
 
699
-		} catch ( WC_Stripe_Exception $e ) {
700
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
701
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
699
+		} catch (WC_Stripe_Exception $e) {
700
+			wc_add_notice($e->getLocalizedMessage(), 'error');
701
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
702 702
 
703
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
703
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
704 704
 
705 705
 			/* translators: error message */
706
-			$order->update_status( 'failed' );
706
+			$order->update_status('failed');
707 707
 
708 708
 			return array(
709 709
 				'result'   => 'fail',
@@ -719,17 +719,17 @@  discard block
 block discarded – undo
719 719
 	 *
720 720
 	 * @param int $order_id The ID of the order.
721 721
 	 */
722
-	public function display_order_fee( $order_id ) {
723
-		if ( apply_filters( 'wc_stripe_hide_display_order_fee', false, $order_id ) ) {
722
+	public function display_order_fee($order_id) {
723
+		if (apply_filters('wc_stripe_hide_display_order_fee', false, $order_id)) {
724 724
 			return;
725 725
 		}
726 726
 
727
-		$order = wc_get_order( $order_id );
727
+		$order = wc_get_order($order_id);
728 728
 
729
-		$fee      = WC_Stripe_Helper::get_stripe_fee( $order );
730
-		$currency = WC_Stripe_Helper::get_stripe_currency( $order );
729
+		$fee      = WC_Stripe_Helper::get_stripe_fee($order);
730
+		$currency = WC_Stripe_Helper::get_stripe_currency($order);
731 731
 
732
-		if ( ! $fee || ! $currency ) {
732
+		if ( ! $fee || ! $currency) {
733 733
 			return;
734 734
 		}
735 735
 
@@ -737,12 +737,12 @@  discard block
 block discarded – undo
737 737
 
738 738
 		<tr>
739 739
 			<td class="label stripe-fee">
740
-				<?php echo wc_help_tip( __( 'This represents the fee Stripe collects for the transaction.', 'woocommerce-gateway-stripe' ) ); // wpcs: xss ok. ?>
741
-				<?php esc_html_e( 'Stripe Fee:', 'woocommerce-gateway-stripe' ); ?>
740
+				<?php echo wc_help_tip(__('This represents the fee Stripe collects for the transaction.', 'woocommerce-gateway-stripe')); // wpcs: xss ok. ?>
741
+				<?php esc_html_e('Stripe Fee:', 'woocommerce-gateway-stripe'); ?>
742 742
 			</td>
743 743
 			<td width="1%"></td>
744 744
 			<td class="total">
745
-				-&nbsp;<?php echo wc_price( $fee, array( 'currency' => $currency ) ); // wpcs: xss ok. ?>
745
+				-&nbsp;<?php echo wc_price($fee, array('currency' => $currency)); // wpcs: xss ok. ?>
746 746
 			</td>
747 747
 		</tr>
748 748
 
@@ -756,17 +756,17 @@  discard block
 block discarded – undo
756 756
 	 *
757 757
 	 * @param int $order_id The ID of the order.
758 758
 	 */
759
-	public function display_order_payout( $order_id ) {
760
-		if ( apply_filters( 'wc_stripe_hide_display_order_payout', false, $order_id ) ) {
759
+	public function display_order_payout($order_id) {
760
+		if (apply_filters('wc_stripe_hide_display_order_payout', false, $order_id)) {
761 761
 			return;
762 762
 		}
763 763
 
764
-		$order = wc_get_order( $order_id );
764
+		$order = wc_get_order($order_id);
765 765
 
766
-		$net      = WC_Stripe_Helper::get_stripe_net( $order );
767
-		$currency = WC_Stripe_Helper::get_stripe_currency( $order );
766
+		$net      = WC_Stripe_Helper::get_stripe_net($order);
767
+		$currency = WC_Stripe_Helper::get_stripe_currency($order);
768 768
 
769
-		if ( ! $net || ! $currency ) {
769
+		if ( ! $net || ! $currency) {
770 770
 			return;
771 771
 		}
772 772
 
@@ -774,12 +774,12 @@  discard block
 block discarded – undo
774 774
 
775 775
 		<tr>
776 776
 			<td class="label stripe-payout">
777
-				<?php echo wc_help_tip( __( 'This represents the net total that will be credited to your Stripe bank account. This may be in the currency that is set in your Stripe account.', 'woocommerce-gateway-stripe' ) ); // wpcs: xss ok. ?>
778
-				<?php esc_html_e( 'Stripe Payout:', 'woocommerce-gateway-stripe' ); ?>
777
+				<?php echo wc_help_tip(__('This represents the net total that will be credited to your Stripe bank account. This may be in the currency that is set in your Stripe account.', 'woocommerce-gateway-stripe')); // wpcs: xss ok. ?>
778
+				<?php esc_html_e('Stripe Payout:', 'woocommerce-gateway-stripe'); ?>
779 779
 			</td>
780 780
 			<td width="1%"></td>
781 781
 			<td class="total">
782
-				<?php echo wc_price( $net, array( 'currency' => $currency ) ); // wpcs: xss ok. ?>
782
+				<?php echo wc_price($net, array('currency' => $currency)); // wpcs: xss ok. ?>
783 783
 			</td>
784 784
 		</tr>
785 785
 
@@ -795,13 +795,13 @@  discard block
 block discarded – undo
795 795
 	 *
796 796
 	 * @return string The localized error message.
797 797
 	 */
798
-	public function get_localized_error_message_from_response( $response ) {
798
+	public function get_localized_error_message_from_response($response) {
799 799
 		$localized_messages = WC_Stripe_Helper::get_localized_messages();
800 800
 
801
-		if ( 'card_error' === $response->error->type ) {
802
-			$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
801
+		if ('card_error' === $response->error->type) {
802
+			$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
803 803
 		} else {
804
-			$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
804
+			$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
805 805
 		}
806 806
 
807 807
 		return $localized_message;
@@ -815,12 +815,12 @@  discard block
 block discarded – undo
815 815
 	 * @param  WC_Order $order     The order to add a note to.
816 816
 	 * @throws WC_Stripe_Exception An exception with the right message.
817 817
 	 */
818
-	public function throw_localized_message( $response, $order ) {
819
-		$localized_message = $this->get_localized_error_message_from_response( $response );
818
+	public function throw_localized_message($response, $order) {
819
+		$localized_message = $this->get_localized_error_message_from_response($response);
820 820
 
821
-		$order->add_order_note( $localized_message );
821
+		$order->add_order_note($localized_message);
822 822
 
823
-		throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
823
+		throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
824 824
 	}
825 825
 
826 826
 	/**
@@ -836,22 +836,22 @@  discard block
 block discarded – undo
836 836
 	 * @throws WC_Stripe_Exception        If the payment is not accepted.
837 837
 	 * @return array|void
838 838
 	 */
839
-	public function retry_after_error( $response, $order, $retry, $force_save_source, $previous_error, $use_order_source ) {
840
-		if ( ! $retry ) {
841
-			$localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' );
842
-			$order->add_order_note( $localized_message );
843
-			throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.
839
+	public function retry_after_error($response, $order, $retry, $force_save_source, $previous_error, $use_order_source) {
840
+		if ( ! $retry) {
841
+			$localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe');
842
+			$order->add_order_note($localized_message);
843
+			throw new WC_Stripe_Exception(print_r($response, true), $localized_message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.
844 844
 		}
845 845
 
846 846
 		// Don't do anymore retries after this.
847
-		if ( 5 <= $this->retry_interval ) {
848
-			return $this->process_payment( $order->get_id(), false, $force_save_source, $response->error, $previous_error );
847
+		if (5 <= $this->retry_interval) {
848
+			return $this->process_payment($order->get_id(), false, $force_save_source, $response->error, $previous_error);
849 849
 		}
850 850
 
851
-		sleep( $this->retry_interval );
851
+		sleep($this->retry_interval);
852 852
 		$this->retry_interval++;
853 853
 
854
-		return $this->process_payment( $order->get_id(), true, $force_save_source, $response->error, $previous_error, $use_order_source );
854
+		return $this->process_payment($order->get_id(), true, $force_save_source, $response->error, $previous_error, $use_order_source);
855 855
 	}
856 856
 
857 857
 	/**
@@ -862,23 +862,23 @@  discard block
 block discarded – undo
862 862
 	 * @param WC_Payment_Gateway[] $gateways A list of all available gateways.
863 863
 	 * @return WC_Payment_Gateway[]          Either the same list or an empty one in the right conditions.
864 864
 	 */
865
-	public function prepare_order_pay_page( $gateways ) {
866
-		if ( ! is_wc_endpoint_url( 'order-pay' ) || ! isset( $_GET['wc-stripe-confirmation'] ) ) { // wpcs: csrf ok.
865
+	public function prepare_order_pay_page($gateways) {
866
+		if ( ! is_wc_endpoint_url('order-pay') || ! isset($_GET['wc-stripe-confirmation'])) { // wpcs: csrf ok.
867 867
 			return $gateways;
868 868
 		}
869 869
 
870 870
 		try {
871 871
 			$this->prepare_intent_for_order_pay_page();
872
-		} catch ( WC_Stripe_Exception $e ) {
872
+		} catch (WC_Stripe_Exception $e) {
873 873
 			// Just show the full order pay page if there was a problem preparing the Payment Intent
874 874
 			return $gateways;
875 875
 		}
876 876
 
877
-		add_filter( 'woocommerce_checkout_show_terms', '__return_false' );
878
-		add_filter( 'woocommerce_pay_order_button_html', '__return_false' );
879
-		add_filter( 'woocommerce_available_payment_gateways', '__return_empty_array' );
880
-		add_filter( 'woocommerce_no_available_payment_methods_message', array( $this, 'change_no_available_methods_message' ) );
881
-		add_action( 'woocommerce_pay_order_after_submit', array( $this, 'render_payment_intent_inputs' ) );
877
+		add_filter('woocommerce_checkout_show_terms', '__return_false');
878
+		add_filter('woocommerce_pay_order_button_html', '__return_false');
879
+		add_filter('woocommerce_available_payment_gateways', '__return_empty_array');
880
+		add_filter('woocommerce_no_available_payment_methods_message', array($this, 'change_no_available_methods_message'));
881
+		add_action('woocommerce_pay_order_after_submit', array($this, 'render_payment_intent_inputs'));
882 882
 
883 883
 		return array();
884 884
 	}
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 	 * @return string the new message.
892 892
 	 */
893 893
 	public function change_no_available_methods_message() {
894
-		return wpautop( __( "Almost there!\n\nYour order has already been created, the only thing that still needs to be done is for you to authorize the payment with your bank.", 'woocommerce-gateway-stripe' ) );
894
+		return wpautop(__("Almost there!\n\nYour order has already been created, the only thing that still needs to be done is for you to authorize the payment with your bank.", 'woocommerce-gateway-stripe'));
895 895
 	}
896 896
 
897 897
 	/**
@@ -902,19 +902,19 @@  discard block
 block discarded – undo
902 902
 	 * @throws WC_Stripe_Exception
903 903
 	 * @since 4.3
904 904
 	 */
905
-	public function prepare_intent_for_order_pay_page( $order = null ) {
906
-		if ( ! isset( $order ) || empty( $order ) ) {
907
-			$order = wc_get_order( absint( get_query_var( 'order-pay' ) ) );
905
+	public function prepare_intent_for_order_pay_page($order = null) {
906
+		if ( ! isset($order) || empty($order)) {
907
+			$order = wc_get_order(absint(get_query_var('order-pay')));
908 908
 		}
909
-		$intent = $this->get_intent_from_order( $order );
909
+		$intent = $this->get_intent_from_order($order);
910 910
 
911
-		if ( ! $intent ) {
912
-			throw new WC_Stripe_Exception( 'Payment Intent not found', __( 'Payment Intent not found for order #' . $order->get_id(), 'woocommerce-gateway-stripe' ) );
911
+		if ( ! $intent) {
912
+			throw new WC_Stripe_Exception('Payment Intent not found', __('Payment Intent not found for order #' . $order->get_id(), 'woocommerce-gateway-stripe'));
913 913
 		}
914 914
 
915
-		if ( 'requires_payment_method' === $intent->status && isset( $intent->last_payment_error )
916
-		     && 'authentication_required' === $intent->last_payment_error->code ) {
917
-			$level3_data = $this->get_level3_data_from_order( $order );
915
+		if ('requires_payment_method' === $intent->status && isset($intent->last_payment_error)
916
+		     && 'authentication_required' === $intent->last_payment_error->code) {
917
+			$level3_data = $this->get_level3_data_from_order($order);
918 918
 			$intent      = WC_Stripe_API::request_with_level3_data(
919 919
 				array(
920 920
 					'payment_method' => $intent->last_payment_error->source->id,
@@ -924,8 +924,8 @@  discard block
 block discarded – undo
924 924
 				$order
925 925
 			);
926 926
 
927
-			if ( isset( $intent->error ) ) {
928
-				throw new WC_Stripe_Exception( print_r( $intent, true ), $intent->error->message );
927
+			if (isset($intent->error)) {
928
+				throw new WC_Stripe_Exception(print_r($intent, true), $intent->error->message);
929 929
 			}
930 930
 		}
931 931
 
@@ -940,26 +940,26 @@  discard block
 block discarded – undo
940 940
 	 * @throws WC_Stripe_Exception
941 941
 	 * @since 4.2
942 942
 	 */
943
-	public function render_payment_intent_inputs( $order = null ) {
944
-		if ( ! isset( $order ) || empty( $order ) ) {
945
-			$order = wc_get_order( absint( get_query_var( 'order-pay' ) ) );
943
+	public function render_payment_intent_inputs($order = null) {
944
+		if ( ! isset($order) || empty($order)) {
945
+			$order = wc_get_order(absint(get_query_var('order-pay')));
946 946
 		}
947
-		if ( ! isset( $this->order_pay_intent ) ) {
948
-			$this->prepare_intent_for_order_pay_page( $order );
947
+		if ( ! isset($this->order_pay_intent)) {
948
+			$this->prepare_intent_for_order_pay_page($order);
949 949
 		}
950 950
 
951 951
 		$verification_url = add_query_arg(
952 952
 			array(
953 953
 				'order'            => $order->get_id(),
954
-				'nonce'            => wp_create_nonce( 'wc_stripe_confirm_pi' ),
955
-				'redirect_to'      => rawurlencode( $this->get_return_url( $order ) ),
954
+				'nonce'            => wp_create_nonce('wc_stripe_confirm_pi'),
955
+				'redirect_to'      => rawurlencode($this->get_return_url($order)),
956 956
 				'is_pay_for_order' => true,
957 957
 			),
958
-			WC_AJAX::get_endpoint( 'wc_stripe_verify_intent' )
958
+			WC_AJAX::get_endpoint('wc_stripe_verify_intent')
959 959
 		);
960 960
 
961
-		echo '<input type="hidden" id="stripe-intent-id" value="' . esc_attr( $this->order_pay_intent->client_secret ) . '" />';
962
-		echo '<input type="hidden" id="stripe-intent-return" value="' . esc_attr( $verification_url ) . '" />';
961
+		echo '<input type="hidden" id="stripe-intent-id" value="' . esc_attr($this->order_pay_intent->client_secret) . '" />';
962
+		echo '<input type="hidden" id="stripe-intent-return" value="' . esc_attr($verification_url) . '" />';
963 963
 	}
964 964
 
965 965
 	/**
@@ -969,11 +969,11 @@  discard block
 block discarded – undo
969 969
 	 * @param WC_Payment_Token $token Payment Token.
970 970
 	 * @return string                 Generated payment method HTML
971 971
 	 */
972
-	public function get_saved_payment_method_option_html( $token ) {
973
-		$html          = parent::get_saved_payment_method_option_html( $token );
972
+	public function get_saved_payment_method_option_html($token) {
973
+		$html          = parent::get_saved_payment_method_option_html($token);
974 974
 		$error_wrapper = '<div class="stripe-source-errors" role="alert"></div>';
975 975
 
976
-		return preg_replace( '~</(\w+)>\s*$~', "$error_wrapper</$1>", $html );
976
+		return preg_replace('~</(\w+)>\s*$~', "$error_wrapper</$1>", $html);
977 977
 	}
978 978
 
979 979
 	/**
@@ -983,18 +983,18 @@  discard block
 block discarded – undo
983 983
 	 * @since 4.2.0
984 984
 	 * @param int $order_id The ID that will be used for the thank you page.
985 985
 	 */
986
-	public function check_intent_status_on_order_page( $order_id ) {
987
-		if ( empty( $order_id ) || absint( $order_id ) <= 0 ) {
986
+	public function check_intent_status_on_order_page($order_id) {
987
+		if (empty($order_id) || absint($order_id) <= 0) {
988 988
 			return;
989 989
 		}
990 990
 
991
-		$order = wc_get_order( absint( $order_id ) );
991
+		$order = wc_get_order(absint($order_id));
992 992
 
993
-		if ( ! $order ) {
993
+		if ( ! $order) {
994 994
 			return;
995 995
 		}
996 996
 
997
-		$this->verify_intent_after_checkout( $order );
997
+		$this->verify_intent_after_checkout($order);
998 998
 	}
999 999
 
1000 1000
 	/**
@@ -1008,8 +1008,8 @@  discard block
 block discarded – undo
1008 1008
 	 * @param int   $order_id The ID of the order which is being paid for.
1009 1009
 	 * @return array
1010 1010
 	 */
1011
-	public function modify_successful_payment_result( $result, $order_id ) {
1012
-		if ( ! isset( $result['payment_intent_secret'] ) && ! isset( $result['setup_intent_secret'] ) ) {
1011
+	public function modify_successful_payment_result($result, $order_id) {
1012
+		if ( ! isset($result['payment_intent_secret']) && ! isset($result['setup_intent_secret'])) {
1013 1013
 			// Only redirects with intents need to be modified.
1014 1014
 			return $result;
1015 1015
 		}
@@ -1018,16 +1018,16 @@  discard block
 block discarded – undo
1018 1018
 		$verification_url = add_query_arg(
1019 1019
 			array(
1020 1020
 				'order'       => $order_id,
1021
-				'nonce'       => wp_create_nonce( 'wc_stripe_confirm_pi' ),
1022
-				'redirect_to' => rawurlencode( $result['redirect'] ),
1021
+				'nonce'       => wp_create_nonce('wc_stripe_confirm_pi'),
1022
+				'redirect_to' => rawurlencode($result['redirect']),
1023 1023
 			),
1024
-			WC_AJAX::get_endpoint( 'wc_stripe_verify_intent' )
1024
+			WC_AJAX::get_endpoint('wc_stripe_verify_intent')
1025 1025
 		);
1026 1026
 
1027
-		if ( isset( $result['payment_intent_secret'] ) ) {
1028
-			$redirect = sprintf( '#confirm-pi-%s:%s', $result['payment_intent_secret'], rawurlencode( $verification_url ) );
1029
-		} else if ( isset( $result['setup_intent_secret'] ) ) {
1030
-			$redirect = sprintf( '#confirm-si-%s:%s', $result['setup_intent_secret'], rawurlencode( $verification_url ) );
1027
+		if (isset($result['payment_intent_secret'])) {
1028
+			$redirect = sprintf('#confirm-pi-%s:%s', $result['payment_intent_secret'], rawurlencode($verification_url));
1029
+		} else if (isset($result['setup_intent_secret'])) {
1030
+			$redirect = sprintf('#confirm-si-%s:%s', $result['setup_intent_secret'], rawurlencode($verification_url));
1031 1031
 		}
1032 1032
 
1033 1033
 		return array(
@@ -1039,8 +1039,8 @@  discard block
 block discarded – undo
1039 1039
 	/**
1040 1040
 	 * Proceed with current request using new login session (to ensure consistent nonce).
1041 1041
 	 */
1042
-	public function set_cookie_on_current_request( $cookie ) {
1043
-		$_COOKIE[ LOGGED_IN_COOKIE ] = $cookie;
1042
+	public function set_cookie_on_current_request($cookie) {
1043
+		$_COOKIE[LOGGED_IN_COOKIE] = $cookie;
1044 1044
 	}
1045 1045
 
1046 1046
 	/**
@@ -1050,48 +1050,48 @@  discard block
 block discarded – undo
1050 1050
 	 * @since 4.2.0
1051 1051
 	 * @param WC_Order $order The order which is in a transitional state.
1052 1052
 	 */
1053
-	public function verify_intent_after_checkout( $order ) {
1053
+	public function verify_intent_after_checkout($order) {
1054 1054
 		$payment_method = $order->get_payment_method();
1055
-		if ( $payment_method !== $this->id ) {
1055
+		if ($payment_method !== $this->id) {
1056 1056
 			// If this is not the payment method, an intent would not be available.
1057 1057
 			return;
1058 1058
 		}
1059 1059
 
1060
-		$intent = $this->get_intent_from_order( $order );
1061
-		if ( ! $intent ) {
1060
+		$intent = $this->get_intent_from_order($order);
1061
+		if ( ! $intent) {
1062 1062
 			// No intent, redirect to the order received page for further actions.
1063 1063
 			return;
1064 1064
 		}
1065 1065
 
1066 1066
 		// A webhook might have modified or locked the order while the intent was retreived. This ensures we are reading the right status.
1067
-		clean_post_cache( $order->get_id() );
1068
-		$order = wc_get_order( $order->get_id() );
1067
+		clean_post_cache($order->get_id());
1068
+		$order = wc_get_order($order->get_id());
1069 1069
 
1070
-		if ( ! $order->has_status( array( 'pending', 'failed' ) ) ) {
1070
+		if ( ! $order->has_status(array('pending', 'failed'))) {
1071 1071
 			// If payment has already been completed, this function is redundant.
1072 1072
 			return;
1073 1073
 		}
1074 1074
 
1075
-		if ( $this->lock_order_payment( $order, $intent ) ) {
1075
+		if ($this->lock_order_payment($order, $intent)) {
1076 1076
 			return;
1077 1077
 		}
1078 1078
 
1079
-		if ( 'setup_intent' === $intent->object && 'succeeded' === $intent->status ) {
1079
+		if ('setup_intent' === $intent->object && 'succeeded' === $intent->status) {
1080 1080
 			WC()->cart->empty_cart();
1081
-			if ( WC_Stripe_Helper::is_pre_orders_exists() && WC_Pre_Orders_Order::order_contains_pre_order( $order ) ) {
1082
-				WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order );
1081
+			if (WC_Stripe_Helper::is_pre_orders_exists() && WC_Pre_Orders_Order::order_contains_pre_order($order)) {
1082
+				WC_Pre_Orders_Order::mark_order_as_pre_ordered($order);
1083 1083
 			} else {
1084 1084
 				$order->payment_complete();
1085 1085
 			}
1086
-		} else if ( 'succeeded' === $intent->status || 'requires_capture' === $intent->status ) {
1086
+		} else if ('succeeded' === $intent->status || 'requires_capture' === $intent->status) {
1087 1087
 			// Proceed with the payment completion.
1088
-			$this->handle_intent_verification_success( $order, $intent );
1089
-		} else if ( 'requires_payment_method' === $intent->status ) {
1088
+			$this->handle_intent_verification_success($order, $intent);
1089
+		} else if ('requires_payment_method' === $intent->status) {
1090 1090
 			// `requires_payment_method` means that SCA got denied for the current payment method.
1091
-			$this->handle_intent_verification_failure( $order, $intent );
1091
+			$this->handle_intent_verification_failure($order, $intent);
1092 1092
 		}
1093 1093
 
1094
-		$this->unlock_order_payment( $order );
1094
+		$this->unlock_order_payment($order);
1095 1095
 	}
1096 1096
 
1097 1097
 	/**
@@ -1101,8 +1101,8 @@  discard block
 block discarded – undo
1101 1101
 	 * @param WC_Order $order The order whose verification succeeded.
1102 1102
 	 * @param stdClass $intent The Payment Intent object.
1103 1103
 	 */
1104
-	protected function handle_intent_verification_success( $order, $intent ) {
1105
-		$this->process_response( end( $intent->charges->data ), $order );
1104
+	protected function handle_intent_verification_success($order, $intent) {
1105
+		$this->process_response(end($intent->charges->data), $order);
1106 1106
 	}
1107 1107
 
1108 1108
 	/**
@@ -1112,8 +1112,8 @@  discard block
 block discarded – undo
1112 1112
 	 * @param WC_Order $order The order whose verification failed.
1113 1113
 	 * @param stdClass $intent The Payment Intent object.
1114 1114
 	 */
1115
-	protected function handle_intent_verification_failure( $order, $intent ) {
1116
-		$this->failed_sca_auth( $order, $intent );
1115
+	protected function handle_intent_verification_failure($order, $intent) {
1116
+		$this->failed_sca_auth($order, $intent);
1117 1117
 	}
1118 1118
 
1119 1119
 	/**
@@ -1123,18 +1123,18 @@  discard block
 block discarded – undo
1123 1123
 	 * @param WC_Order $order  The order which should be checked.
1124 1124
 	 * @param object   $intent The intent, associated with the order.
1125 1125
 	 */
1126
-	public function failed_sca_auth( $order, $intent ) {
1126
+	public function failed_sca_auth($order, $intent) {
1127 1127
 		// If the order has already failed, do not repeat the same message.
1128
-		if ( $order->has_status( 'failed' ) ) {
1128
+		if ($order->has_status('failed')) {
1129 1129
 			return;
1130 1130
 		}
1131 1131
 
1132 1132
 		// Load the right message and update the status.
1133
-		$status_message = isset( $intent->last_payment_error )
1133
+		$status_message = isset($intent->last_payment_error)
1134 1134
 			/* translators: 1) The error message that was received from Stripe. */
1135
-			? sprintf( __( 'Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe' ), $intent->last_payment_error->message )
1136
-			: __( 'Stripe SCA authentication failed.', 'woocommerce-gateway-stripe' );
1137
-		$order->update_status( 'failed', $status_message );
1135
+			? sprintf(__('Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe'), $intent->last_payment_error->message)
1136
+			: __('Stripe SCA authentication failed.', 'woocommerce-gateway-stripe');
1137
+		$order->update_status('failed', $status_message);
1138 1138
 	}
1139 1139
 
1140 1140
 	/**
@@ -1145,10 +1145,10 @@  discard block
 block discarded – undo
1145 1145
 	 *
1146 1146
 	 * @return string Checkout URL for the given order.
1147 1147
 	 */
1148
-	public function get_checkout_payment_url( $pay_url, $order ) {
1148
+	public function get_checkout_payment_url($pay_url, $order) {
1149 1149
 		global $wp;
1150
-		if ( isset( $_GET['wc-stripe-confirmation'] ) && isset( $wp->query_vars['order-pay'] ) && $wp->query_vars['order-pay'] == $order->get_id() ) {
1151
-			$pay_url = add_query_arg( 'wc-stripe-confirmation', 1, $pay_url );
1150
+		if (isset($_GET['wc-stripe-confirmation']) && isset($wp->query_vars['order-pay']) && $wp->query_vars['order-pay'] == $order->get_id()) {
1151
+			$pay_url = add_query_arg('wc-stripe-confirmation', 1, $pay_url);
1152 1152
 		}
1153 1153
 		return $pay_url;
1154 1154
 	}
@@ -1158,63 +1158,63 @@  discard block
 block discarded – undo
1158 1158
 	 */
1159 1159
 	public function process_admin_options() {
1160 1160
 		// Load all old values before the new settings get saved.
1161
-		$old_publishable_key      = $this->get_option( 'publishable_key' );
1162
-		$old_secret_key           = $this->get_option( 'secret_key' );
1163
-		$old_test_publishable_key = $this->get_option( 'test_publishable_key' );
1164
-		$old_test_secret_key      = $this->get_option( 'test_secret_key' );
1161
+		$old_publishable_key      = $this->get_option('publishable_key');
1162
+		$old_secret_key           = $this->get_option('secret_key');
1163
+		$old_test_publishable_key = $this->get_option('test_publishable_key');
1164
+		$old_test_secret_key      = $this->get_option('test_secret_key');
1165 1165
 
1166 1166
 		parent::process_admin_options();
1167 1167
 
1168 1168
 		// Load all old values after the new settings have been saved.
1169
-		$new_publishable_key      = $this->get_option( 'publishable_key' );
1170
-		$new_secret_key           = $this->get_option( 'secret_key' );
1171
-		$new_test_publishable_key = $this->get_option( 'test_publishable_key' );
1172
-		$new_test_secret_key      = $this->get_option( 'test_secret_key' );
1169
+		$new_publishable_key      = $this->get_option('publishable_key');
1170
+		$new_secret_key           = $this->get_option('secret_key');
1171
+		$new_test_publishable_key = $this->get_option('test_publishable_key');
1172
+		$new_test_secret_key      = $this->get_option('test_secret_key');
1173 1173
 
1174 1174
 		// Checks whether a value has transitioned from a non-empty value to a new one.
1175
-		$has_changed = function( $old_value, $new_value ) {
1176
-			return ! empty( $old_value ) && ( $old_value !== $new_value );
1175
+		$has_changed = function($old_value, $new_value) {
1176
+			return ! empty($old_value) && ($old_value !== $new_value);
1177 1177
 		};
1178 1178
 
1179 1179
 		// Look for updates.
1180 1180
 		if (
1181
-			$has_changed( $old_publishable_key, $new_publishable_key )
1182
-			|| $has_changed( $old_secret_key, $new_secret_key )
1183
-			|| $has_changed( $old_test_publishable_key, $new_test_publishable_key )
1184
-			|| $has_changed( $old_test_secret_key, $new_test_secret_key )
1181
+			$has_changed($old_publishable_key, $new_publishable_key)
1182
+			|| $has_changed($old_secret_key, $new_secret_key)
1183
+			|| $has_changed($old_test_publishable_key, $new_test_publishable_key)
1184
+			|| $has_changed($old_test_secret_key, $new_test_secret_key)
1185 1185
 		) {
1186
-			update_option( 'wc_stripe_show_changed_keys_notice', 'yes' );
1186
+			update_option('wc_stripe_show_changed_keys_notice', 'yes');
1187 1187
 		}
1188 1188
 	}
1189 1189
 
1190
-	public function validate_publishable_key_field( $key, $value ) {
1191
-		$value = $this->validate_text_field( $key, $value );
1192
-		if ( ! empty( $value ) && ! preg_match( '/^pk_live_/', $value ) ) {
1193
-			throw new Exception( __( 'The "Live Publishable Key" should start with "pk_live", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1190
+	public function validate_publishable_key_field($key, $value) {
1191
+		$value = $this->validate_text_field($key, $value);
1192
+		if ( ! empty($value) && ! preg_match('/^pk_live_/', $value)) {
1193
+			throw new Exception(__('The "Live Publishable Key" should start with "pk_live", enter the correct key.', 'woocommerce-gateway-stripe'));
1194 1194
 		}
1195 1195
 		return $value;
1196 1196
 	}
1197 1197
 
1198
-	public function validate_secret_key_field( $key, $value ) {
1199
-		$value = $this->validate_text_field( $key, $value );
1200
-		if ( ! empty( $value ) && ! preg_match( '/^[rs]k_live_/', $value ) ) {
1201
-			throw new Exception( __( 'The "Live Secret Key" should start with "sk_live" or "rk_live", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1198
+	public function validate_secret_key_field($key, $value) {
1199
+		$value = $this->validate_text_field($key, $value);
1200
+		if ( ! empty($value) && ! preg_match('/^[rs]k_live_/', $value)) {
1201
+			throw new Exception(__('The "Live Secret Key" should start with "sk_live" or "rk_live", enter the correct key.', 'woocommerce-gateway-stripe'));
1202 1202
 		}
1203 1203
 		return $value;
1204 1204
 	}
1205 1205
 
1206
-	public function validate_test_publishable_key_field( $key, $value ) {
1207
-		$value = $this->validate_text_field( $key, $value );
1208
-		if ( ! empty( $value ) && ! preg_match( '/^pk_test_/', $value ) ) {
1209
-			throw new Exception( __( 'The "Test Publishable Key" should start with "pk_test", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1206
+	public function validate_test_publishable_key_field($key, $value) {
1207
+		$value = $this->validate_text_field($key, $value);
1208
+		if ( ! empty($value) && ! preg_match('/^pk_test_/', $value)) {
1209
+			throw new Exception(__('The "Test Publishable Key" should start with "pk_test", enter the correct key.', 'woocommerce-gateway-stripe'));
1210 1210
 		}
1211 1211
 		return $value;
1212 1212
 	}
1213 1213
 
1214
-	public function validate_test_secret_key_field( $key, $value ) {
1215
-		$value = $this->validate_text_field( $key, $value );
1216
-		if ( ! empty( $value ) && ! preg_match( '/^[rs]k_test_/', $value ) ) {
1217
-			throw new Exception( __( 'The "Test Secret Key" should start with "sk_test" or "rk_test", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1214
+	public function validate_test_secret_key_field($key, $value) {
1215
+		$value = $this->validate_text_field($key, $value);
1216
+		if ( ! empty($value) && ! preg_match('/^[rs]k_test_/', $value)) {
1217
+			throw new Exception(__('The "Test Secret Key" should start with "sk_test" or "rk_test", enter the correct key.', 'woocommerce-gateway-stripe'));
1218 1218
 		}
1219 1219
 		return $value;
1220 1220
 	}
Please login to merge, or discard this patch.
includes/connect/class-wc-stripe-connect.php 1 patch
Spacing   +43 added lines, -43 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,11 +24,11 @@  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
 
31
-			add_action( 'wc_ajax_wc_stripe_oauth_init', array( $this, 'wc_ajax_oauth_init' ) );
31
+			add_action('wc_ajax_wc_stripe_oauth_init', array($this, 'wc_ajax_oauth_init'));
32 32
 		}
33 33
 
34 34
 		/**
@@ -38,23 +38,23 @@  discard block
 block discarded – undo
38 38
 		 *
39 39
 		 * @return string|WP_Error
40 40
 		 */
41
-		public function get_oauth_url( $return_url = '' ) {
41
+		public function get_oauth_url($return_url = '') {
42 42
 
43
-			if ( empty( $return_url ) ) {
44
-				$return_url = admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' );
43
+			if (empty($return_url)) {
44
+				$return_url = admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe');
45 45
 			}
46 46
 
47
-			if ( substr( $return_url, 0, 8 ) !== 'https://' ) {
48
-				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
+			if (substr($return_url, 0, 8) !== 'https://') {
48
+				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'));
49 49
 			}
50 50
 
51
-			$result = $this->api->get_stripe_oauth_init( $return_url );
51
+			$result = $this->api->get_stripe_oauth_init($return_url);
52 52
 
53
-			if ( is_wp_error( $result ) ) {
53
+			if (is_wp_error($result)) {
54 54
 				return $result;
55 55
 			}
56 56
 
57
-			update_option( 'stripe_state', $result->state );
57
+			update_option('stripe_state', $result->state);
58 58
 
59 59
 			return $result->oauthUrl; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
60 60
 		}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
 			$response = $this->api->deauthorize_stripe_account();
70 70
 
71
-			if ( is_wp_error( $response ) ) {
71
+			if (is_wp_error($response)) {
72 72
 				return $response;
73 73
 			}
74 74
 
@@ -85,21 +85,21 @@  discard block
 block discarded – undo
85 85
 		 *
86 86
 		 * @return string|WP_Error
87 87
 		 */
88
-		public function connect_oauth( $state, $code ) {
88
+		public function connect_oauth($state, $code) {
89 89
 
90
-			if ( get_option( 'stripe_state', false ) !== $state ) {
91
-				return new WP_Error( 'Invalid stripe state' );
90
+			if (get_option('stripe_state', false) !== $state) {
91
+				return new WP_Error('Invalid stripe state');
92 92
 			}
93 93
 
94
-			$response = $this->api->get_stripe_oauth_keys( $code );
94
+			$response = $this->api->get_stripe_oauth_keys($code);
95 95
 
96
-			if ( is_wp_error( $response ) ) {
96
+			if (is_wp_error($response)) {
97 97
 				return $response;
98 98
 			}
99 99
 
100
-			delete_option( 'stripe_state' );
100
+			delete_option('stripe_state');
101 101
 
102
-			return $this->save_stripe_keys( $response );
102
+			return $this->save_stripe_keys($response);
103 103
 		}
104 104
 
105 105
 		/**
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 		 */
108 108
 		public function maybe_connect_oauth() {
109 109
 
110
-			if ( isset( $_GET['wcs_stripe_code'], $_GET['wcs_stripe_state'] ) ) {
111
-				$response = $this->connect_oauth( $_GET['wcs_stripe_state'], $_GET['wcs_stripe_code'] );
110
+			if (isset($_GET['wcs_stripe_code'], $_GET['wcs_stripe_state'])) {
111
+				$response = $this->connect_oauth($_GET['wcs_stripe_state'], $_GET['wcs_stripe_code']);
112 112
 
113
-				wp_safe_redirect( remove_query_arg( array( 'wcs_stripe_state', 'wcs_stripe_code' ) ) );
113
+				wp_safe_redirect(remove_query_arg(array('wcs_stripe_state', 'wcs_stripe_code')));
114 114
 				exit;
115 115
 			}
116 116
 		}
@@ -123,28 +123,28 @@  discard block
 block discarded – undo
123 123
 		 *
124 124
 		 * @return array|WP_Error
125 125
 		 */
126
-		private function save_stripe_keys( $result ) {
126
+		private function save_stripe_keys($result) {
127 127
 
128
-			if ( ! isset( $result->publishableKey, $result->secretKey ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
129
-				return new WP_Error( 'Invalid credentials received from WooCommerce Connect server' );
128
+			if ( ! isset($result->publishableKey, $result->secretKey)) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
129
+				return new WP_Error('Invalid credentials received from WooCommerce Connect server');
130 130
 			}
131 131
 
132
-			$is_test         = false !== strpos( $result->publishableKey, '_test_' ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
132
+			$is_test         = false !== strpos($result->publishableKey, '_test_'); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
133 133
 			$prefix          = $is_test ? 'test_' : '';
134 134
 			$default_options = array();
135 135
 
136
-			$options                                = array_merge( $default_options, get_option( self::SETTINGS_OPTION, array() ) );
136
+			$options                                = array_merge($default_options, get_option(self::SETTINGS_OPTION, array()));
137 137
 			$options['enabled']                     = 'yes';
138 138
 			$options['testmode']                    = $is_test ? 'yes' : 'no';
139
-			$options[ $prefix . 'publishable_key' ] = $result->publishableKey; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
140
-			$options[ $prefix . 'secret_key' ]      = $result->secretKey; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
139
+			$options[$prefix . 'publishable_key'] = $result->publishableKey; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
140
+			$options[$prefix . 'secret_key']      = $result->secretKey; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
141 141
 
142 142
 			// While we are at it, let's also clear the account_id and
143 143
 			// test_account_id if present.
144
-			unset( $options['account_id'] );
145
-			unset( $options['test_account_id'] );
144
+			unset($options['account_id']);
145
+			unset($options['test_account_id']);
146 146
 
147
-			update_option( self::SETTINGS_OPTION, $options );
147
+			update_option(self::SETTINGS_OPTION, $options);
148 148
 
149 149
 			return $result;
150 150
 		}
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 		private function clear_stripe_keys() {
156 156
 
157 157
 			$default_options = $this->get_default_config();
158
-			$options         = array_merge( $default_options, get_option( self::SETTINGS_OPTION, array() ) );
158
+			$options         = array_merge($default_options, get_option(self::SETTINGS_OPTION, array()));
159 159
 
160
-			if ( 'yes' === $options['testmode'] ) {
160
+			if ('yes' === $options['testmode']) {
161 161
 				$options['test_publishable_key'] = '';
162 162
 				$options['test_secret_key']      = '';
163 163
 			} else {
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
 
168 168
 			// While we are at it, let's also clear the account_id and
169 169
 			// test_account_id if present.
170
-			unset( $options['account_id'] );
171
-			unset( $options['test_account_id'] );
170
+			unset($options['account_id']);
171
+			unset($options['test_account_id']);
172 172
 
173
-			update_option( self::SETTINGS_OPTION, $options );
173
+			update_option(self::SETTINGS_OPTION, $options);
174 174
 
175 175
 		}
176 176
 
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 		 */
180 180
 		public function wc_ajax_oauth_init() {
181 181
 
182
-			if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], '_wc_stripe_oauth_nonce' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.ValidatedSanitizedInput.MissingUnslash
183
-				wp_die( __( 'You are not authorized to automatically copy Stripe keys.', 'woocommerce-gateway-stripe' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
182
+			if (empty($_POST['nonce']) || ! wp_verify_nonce($_POST['nonce'], '_wc_stripe_oauth_nonce')) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.ValidatedSanitizedInput.MissingUnslash
183
+				wp_die(__('You are not authorized to automatically copy Stripe keys.', 'woocommerce-gateway-stripe')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
184 184
 			}
185 185
 
186 186
 			$oauth_url = $this->get_oauth_url();
187 187
 
188
-			if ( is_wp_error( $oauth_url ) ) {
189
-				wp_send_json_error( $oauth_url->get_error_message() );
188
+			if (is_wp_error($oauth_url)) {
189
+				wp_send_json_error($oauth_url->get_error_message());
190 190
 			}
191 191
 
192
-			wp_send_json_success( $oauth_url );
192
+			wp_send_json_success($oauth_url);
193 193
 		}
194 194
 	}
195 195
 }
Please login to merge, or discard this patch.