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-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   +111 added lines, -111 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,15 +197,15 @@  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' ) );
208
-				add_action( 'admin_enqueue_scripts', array( $this->connect, 'maybe_connect_oauth' ) );
207
+				add_action('rest_api_init', array($this, 'register_connect_routes'));
208
+				add_action('admin_enqueue_scripts', array($this->connect, 'maybe_connect_oauth'));
209 209
 			}
210 210
 
211 211
 			/**
@@ -215,55 +215,55 @@  discard block
 block discarded – undo
215 215
 			 * @version 4.0.0
216 216
 			 */
217 217
 			public function init() {
218
-				if ( is_admin() ) {
219
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php';
218
+				if (is_admin()) {
219
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php';
220 220
 				}
221 221
 
222
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php';
223
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php';
224
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php';
225
-				include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php';
226
-				require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
227
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php';
228
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php';
229
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php';
230
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
231
-				require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php';
232
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
233
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
234
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
235
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
236
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
237
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
238
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
239
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
240
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
241
-				require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
242
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php';
243
-				require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
244
-				require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect.php';
245
-				require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect-api.php';
246
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php';
247
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php';
248
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php';
249
-				require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-intent-controller.php';
250
-
251
-				if ( is_admin() ) {
252
-					require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php';
222
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-exception.php';
223
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-logger.php';
224
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-helper.php';
225
+				include_once dirname(__FILE__) . '/includes/class-wc-stripe-api.php';
226
+				require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
227
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php';
228
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php';
229
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php';
230
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php';
231
+				require_once dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php';
232
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php';
233
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php';
234
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php';
235
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php';
236
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php';
237
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php';
238
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php';
239
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php';
240
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php';
241
+				require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php';
242
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php';
243
+				require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php';
244
+				require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect.php';
245
+				require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect-api.php';
246
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php';
247
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php';
248
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-customer.php';
249
+				require_once dirname(__FILE__) . '/includes/class-wc-stripe-intent-controller.php';
250
+
251
+				if (is_admin()) {
252
+					require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php';
253 253
 				}
254 254
 
255 255
 				// REMOVE IN THE FUTURE.
256
-				require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
256
+				require_once dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php';
257 257
 
258
-				add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) );
259
-				add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
260
-				add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
258
+				add_filter('woocommerce_payment_gateways', array($this, 'add_gateways'));
259
+				add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
260
+				add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2);
261 261
 
262 262
 				// Modify emails emails.
263
-				add_filter( 'woocommerce_email_classes', array( $this, 'add_emails' ), 20 );
263
+				add_filter('woocommerce_email_classes', array($this, 'add_emails'), 20);
264 264
 
265
-				if ( version_compare( WC_VERSION, '3.4', '<' ) ) {
266
-					add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) );
265
+				if (version_compare(WC_VERSION, '3.4', '<')) {
266
+					add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin'));
267 267
 				}
268 268
 			}
269 269
 
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 			 * @version 4.0.0
275 275
 			 */
276 276
 			public function update_plugin_version() {
277
-				delete_option( 'wc_stripe_version' );
278
-				update_option( 'wc_stripe_version', WC_STRIPE_VERSION );
277
+				delete_option('wc_stripe_version');
278
+				update_option('wc_stripe_version', WC_STRIPE_VERSION);
279 279
 			}
280 280
 
281 281
 			/**
@@ -285,15 +285,15 @@  discard block
 block discarded – undo
285 285
 			 * @version 3.1.0
286 286
 			 */
287 287
 			public function install() {
288
-				if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) {
288
+				if ( ! is_plugin_active(plugin_basename(__FILE__))) {
289 289
 					return;
290 290
 				}
291 291
 
292
-				if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) {
293
-					do_action( 'woocommerce_stripe_updated' );
292
+				if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) {
293
+					do_action('woocommerce_stripe_updated');
294 294
 
295
-					if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) {
296
-						define( 'WC_STRIPE_INSTALLING', true );
295
+					if ( ! defined('WC_STRIPE_INSTALLING')) {
296
+						define('WC_STRIPE_INSTALLING', true);
297 297
 					}
298 298
 
299 299
 					$this->update_plugin_version();
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 			 * @since 1.0.0
307 307
 			 * @version 4.0.0
308 308
 			 */
309
-			public function plugin_action_links( $links ) {
309
+			public function plugin_action_links($links) {
310 310
 				$plugin_links = array(
311
-					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>',
311
+					'<a href="admin.php?page=wc-settings&tab=checkout&section=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>',
312 312
 				);
313
-				return array_merge( $plugin_links, $links );
313
+				return array_merge($plugin_links, $links);
314 314
 			}
315 315
 
316 316
 			/**
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
 			 * @param  string $file  Name of current file.
322 322
 			 * @return array  $links Update list of plugin links.
323 323
 			 */
324
-			public function plugin_row_meta( $links, $file ) {
325
-				if ( plugin_basename( __FILE__ ) === $file ) {
324
+			public function plugin_row_meta($links, $file) {
325
+				if (plugin_basename(__FILE__) === $file) {
326 326
 					$row_meta = array(
327
-						'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>',
328
-						'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>',
327
+						'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>',
328
+						'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>',
329 329
 					);
330
-					return array_merge( $links, $row_meta );
330
+					return array_merge($links, $row_meta);
331 331
 				}
332 332
 				return (array) $links;
333 333
 			}
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 			 * @since 1.0.0
339 339
 			 * @version 4.0.0
340 340
 			 */
341
-			public function add_gateways( $methods ) {
342
-				if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) {
341
+			public function add_gateways($methods) {
342
+				if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) {
343 343
 					$methods[] = 'WC_Stripe_Subs_Compat';
344 344
 					$methods[] = 'WC_Stripe_Sepa_Subs_Compat';
345 345
 				} else {
@@ -365,28 +365,28 @@  discard block
 block discarded – undo
365 365
 			 * @since 4.0.0
366 366
 			 * @version 4.0.0
367 367
 			 */
368
-			public function filter_gateway_order_admin( $sections ) {
369
-				unset( $sections['stripe'] );
370
-				unset( $sections['stripe_bancontact'] );
371
-				unset( $sections['stripe_sofort'] );
372
-				unset( $sections['stripe_giropay'] );
373
-				unset( $sections['stripe_eps'] );
374
-				unset( $sections['stripe_ideal'] );
375
-				unset( $sections['stripe_p24'] );
376
-				unset( $sections['stripe_alipay'] );
377
-				unset( $sections['stripe_sepa'] );
378
-				unset( $sections['stripe_multibanco'] );
368
+			public function filter_gateway_order_admin($sections) {
369
+				unset($sections['stripe']);
370
+				unset($sections['stripe_bancontact']);
371
+				unset($sections['stripe_sofort']);
372
+				unset($sections['stripe_giropay']);
373
+				unset($sections['stripe_eps']);
374
+				unset($sections['stripe_ideal']);
375
+				unset($sections['stripe_p24']);
376
+				unset($sections['stripe_alipay']);
377
+				unset($sections['stripe_sepa']);
378
+				unset($sections['stripe_multibanco']);
379 379
 
380 380
 				$sections['stripe']            = 'Stripe';
381
-				$sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' );
382
-				$sections['stripe_sofort']     = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' );
383
-				$sections['stripe_giropay']    = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' );
384
-				$sections['stripe_eps']        = __( 'Stripe EPS', 'woocommerce-gateway-stripe' );
385
-				$sections['stripe_ideal']      = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' );
386
-				$sections['stripe_p24']        = __( 'Stripe P24', 'woocommerce-gateway-stripe' );
387
-				$sections['stripe_alipay']     = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' );
388
-				$sections['stripe_sepa']       = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' );
389
-				$sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' );
381
+				$sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe');
382
+				$sections['stripe_sofort']     = __('Stripe SOFORT', 'woocommerce-gateway-stripe');
383
+				$sections['stripe_giropay']    = __('Stripe Giropay', 'woocommerce-gateway-stripe');
384
+				$sections['stripe_eps']        = __('Stripe EPS', 'woocommerce-gateway-stripe');
385
+				$sections['stripe_ideal']      = __('Stripe iDeal', 'woocommerce-gateway-stripe');
386
+				$sections['stripe_p24']        = __('Stripe P24', 'woocommerce-gateway-stripe');
387
+				$sections['stripe_alipay']     = __('Stripe Alipay', 'woocommerce-gateway-stripe');
388
+				$sections['stripe_sepa']       = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe');
389
+				$sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe');
390 390
 
391 391
 				return $sections;
392 392
 			}
@@ -397,16 +397,16 @@  discard block
 block discarded – undo
397 397
 			 * @param WC_Email[] $email_classes All existing emails.
398 398
 			 * @return WC_Email[]
399 399
 			 */
400
-			public function add_emails( $email_classes ) {
400
+			public function add_emails($email_classes) {
401 401
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication.php';
402 402
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-renewal-authentication.php';
403 403
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-preorder-authentication.php';
404 404
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication-retry.php';
405 405
 
406 406
 				// Add all emails, generated by the gateway.
407
-				$email_classes['WC_Stripe_Email_Failed_Renewal_Authentication']  = new WC_Stripe_Email_Failed_Renewal_Authentication( $email_classes );
408
-				$email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication( $email_classes );
409
-				$email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry( $email_classes );
407
+				$email_classes['WC_Stripe_Email_Failed_Renewal_Authentication']  = new WC_Stripe_Email_Failed_Renewal_Authentication($email_classes);
408
+				$email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication($email_classes);
409
+				$email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry($email_classes);
410 410
 
411 411
 				return $email_classes;
412 412
 			}
@@ -421,9 +421,9 @@  discard block
 block discarded – undo
421 421
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/connect/class-wc-stripe-connect-rest-oauth-connect-controller.php';
422 422
 				require_once WC_STRIPE_PLUGIN_PATH . '/includes/connect/class-wc-stripe-connect-rest-deauthorize-controller.php';
423 423
 
424
-				$oauth_init    = new WC_Stripe_Connect_REST_Oauth_Init_Controller( $this->connect, $this->api );
425
-				$oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller( $this->connect, $this->api );
426
-				$deauthorize   = new WC_Stripe_Connect_REST_Deauthorize_Controller( $this->connect, $this->api );
424
+				$oauth_init    = new WC_Stripe_Connect_REST_Oauth_Init_Controller($this->connect, $this->api);
425
+				$oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller($this->connect, $this->api);
426
+				$deauthorize   = new WC_Stripe_Connect_REST_Deauthorize_Controller($this->connect, $this->api);
427 427
 
428 428
 				$oauth_init->register_routes();
429 429
 				$oauth_connect->register_routes();
Please login to merge, or discard this patch.
includes/connect/class-wc-stripe-connect-api.php 1 patch
Spacing   +49 added lines, -49 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,40 +100,40 @@  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 ( ! is_array( $body ) ) {
105
+			if ( ! is_array($body)) {
106 106
 				return new WP_Error(
107 107
 					'request_body_should_be_array',
108
-					__( 'Unable to send request to WooCommerce Connect server. Body must be an array.', 'woocommerce-gateway-stripe' )
108
+					__('Unable to send request to WooCommerce Connect server. Body must be an array.', 'woocommerce-gateway-stripe')
109 109
 				);
110 110
 			}
111 111
 
112
-			$url = trailingslashit( WOOCOMMERCE_CONNECT_SERVER_URL );
113
-			$url = apply_filters( 'wc_connect_server_url', $url );
114
-			$url = trailingslashit( $url ) . ltrim( $path, '/' );
112
+			$url = trailingslashit(WOOCOMMERCE_CONNECT_SERVER_URL);
113
+			$url = apply_filters('wc_connect_server_url', $url);
114
+			$url = trailingslashit($url) . ltrim($path, '/');
115 115
 
116 116
 			// Add useful system information to requests that contain bodies.
117
-			if ( in_array( $method, array( 'POST', 'PUT' ), true ) ) {
118
-				$body = $this->request_body( $body );
119
-				$body = wp_json_encode( apply_filters( 'wc_connect_api_client_body', $body ) );
117
+			if (in_array($method, array('POST', 'PUT'), true)) {
118
+				$body = $this->request_body($body);
119
+				$body = wp_json_encode(apply_filters('wc_connect_api_client_body', $body));
120 120
 
121
-				if ( ! $body ) {
121
+				if ( ! $body) {
122 122
 					return new WP_Error(
123 123
 						'unable_to_json_encode_body',
124
-						__( 'Unable to encode body for request to WooCommerce Connect server.', 'woocommerce-gateway-stripe' )
124
+						__('Unable to encode body for request to WooCommerce Connect server.', 'woocommerce-gateway-stripe')
125 125
 					);
126 126
 				}
127 127
 			}
128 128
 
129 129
 			$headers = $this->request_headers();
130
-			if ( is_wp_error( $headers ) ) {
130
+			if (is_wp_error($headers)) {
131 131
 				return $headers;
132 132
 			}
133 133
 
134 134
 			$http_timeout = 60; // 1 minute
135
-			if ( function_exists( 'wc_set_time_limit' ) ) {
136
-				wc_set_time_limit( $http_timeout + 10 );
135
+			if (function_exists('wc_set_time_limit')) {
136
+				wc_set_time_limit($http_timeout + 10);
137 137
 			}
138 138
 			$args = array(
139 139
 				'headers'     => $headers,
@@ -144,18 +144,18 @@  discard block
 block discarded – undo
144 144
 				'timeout'     => $http_timeout,
145 145
 			);
146 146
 
147
-			$args          = apply_filters( 'wc_connect_request_args', $args );
148
-			$response      = wp_remote_request( $url, $args );
149
-			$response_code = wp_remote_retrieve_response_code( $response );
150
-			$content_type  = wp_remote_retrieve_header( $response, 'content-type' );
147
+			$args          = apply_filters('wc_connect_request_args', $args);
148
+			$response      = wp_remote_request($url, $args);
149
+			$response_code = wp_remote_retrieve_response_code($response);
150
+			$content_type  = wp_remote_retrieve_header($response, 'content-type');
151 151
 
152
-			if ( false === strpos( $content_type, 'application/json' ) ) {
153
-				if ( 200 !== $response_code ) {
152
+			if (false === strpos($content_type, 'application/json')) {
153
+				if (200 !== $response_code) {
154 154
 					return new WP_Error(
155 155
 						'wcc_server_error',
156 156
 						sprintf(
157 157
 							// Translators: HTTP error code.
158
-							__( 'Error: The WooCommerce Connect server returned HTTP code: %d', 'woocommerce-gateway-stripe' ),
158
+							__('Error: The WooCommerce Connect server returned HTTP code: %d', 'woocommerce-gateway-stripe'),
159 159
 							$response_code
160 160
 						)
161 161
 					);
@@ -163,32 +163,32 @@  discard block
 block discarded – undo
163 163
 				return $response;
164 164
 			}
165 165
 
166
-			$response_body = wp_remote_retrieve_body( $response );
167
-			if ( ! empty( $response_body ) ) {
168
-				$response_body = json_decode( $response_body );
166
+			$response_body = wp_remote_retrieve_body($response);
167
+			if ( ! empty($response_body)) {
168
+				$response_body = json_decode($response_body);
169 169
 			}
170 170
 
171
-			if ( 200 !== $response_code ) {
172
-				if ( empty( $response_body ) ) {
171
+			if (200 !== $response_code) {
172
+				if (empty($response_body)) {
173 173
 					return new WP_Error(
174 174
 						'wcc_server_empty_response',
175 175
 						sprintf(
176 176
 							// Translators: HTTP error code.
177
-							__( 'Error: The WooCommerce Connect server returned ( %d ) and an empty response body.', 'woocommerce-gateway-stripe' ),
177
+							__('Error: The WooCommerce Connect server returned ( %d ) and an empty response body.', 'woocommerce-gateway-stripe'),
178 178
 							$response_code
179 179
 						)
180 180
 					);
181 181
 				}
182 182
 
183
-				$error   = property_exists( $response_body, 'error' ) ? $response_body->error : '';
184
-				$message = property_exists( $response_body, 'message' ) ? $response_body->message : '';
185
-				$data    = property_exists( $response_body, 'data' ) ? $response_body->data : '';
183
+				$error   = property_exists($response_body, 'error') ? $response_body->error : '';
184
+				$message = property_exists($response_body, 'message') ? $response_body->message : '';
185
+				$data    = property_exists($response_body, 'data') ? $response_body->data : '';
186 186
 
187 187
 				return new WP_Error(
188 188
 					'wcc_server_error_response',
189 189
 					sprintf(
190 190
 						/* translators: %1$s: error code, %2$s: error message, %3$d: HTTP response code */
191
-						__( 'Error: The WooCommerce Connect server returned: %1$s %2$s ( %3$d )', 'woocommerce-gateway-stripe' ),
191
+						__('Error: The WooCommerce Connect server returned: %1$s %2$s ( %3$d )', 'woocommerce-gateway-stripe'),
192 192
 						$error,
193 193
 						$message,
194 194
 						$response_code
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
 		 *
208 208
 		 * @return array
209 209
 		 */
210
-		protected function request_body( $initial_body = array() ) {
210
+		protected function request_body($initial_body = array()) {
211 211
 
212 212
 			$default_body = array(
213 213
 				'settings' => array(),
214 214
 			);
215 215
 
216
-			$body = array_merge( $default_body, $initial_body );
216
+			$body = array_merge($default_body, $initial_body);
217 217
 
218 218
 			// Add interesting fields to the body of each request.
219 219
 			$body['settings'] = wp_parse_args(
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 					'currency'       => get_woocommerce_currency(),
227 227
 					'stripe_version' => WC_STRIPE_VERSION,
228 228
 					'wc_version'     => WC()->version,
229
-					'wp_version'     => get_bloginfo( 'version' ),
229
+					'wp_version'     => get_bloginfo('version'),
230 230
 				)
231 231
 			);
232 232
 
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 		protected function request_headers() {
242 242
 
243 243
 			$headers                    = array();
244
-			$locale                     = strtolower( str_replace( '_', '-', get_locale() ) );
245
-			$locale_elements            = explode( '-', $locale );
244
+			$locale                     = strtolower(str_replace('_', '-', get_locale()));
245
+			$locale_elements            = explode('-', $locale);
246 246
 			$lang                       = $locale_elements[0];
247 247
 			$headers['Accept-Language'] = $locale . ',' . $lang;
248 248
 			$headers['Content-Type']    = 'application/json; charset=utf-8';
Please login to merge, or discard this patch.
includes/connect/class-wc-stripe-connect.php 1 patch
Spacing   +48 added lines, -48 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,12 +24,12 @@  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' ) );
32
-			add_action( 'wc_ajax_wc_stripe_clear_keys', array( $this, 'wc_ajax_clear_stripe_keys' ) );
31
+			add_action('wc_ajax_wc_stripe_oauth_init', array($this, 'wc_ajax_oauth_init'));
32
+			add_action('wc_ajax_wc_stripe_clear_keys', array($this, 'wc_ajax_clear_stripe_keys'));
33 33
 		}
34 34
 
35 35
 		/**
@@ -39,23 +39,23 @@  discard block
 block discarded – undo
39 39
 		 *
40 40
 		 * @return string|WP_Error
41 41
 		 */
42
-		public function get_oauth_url( $return_url = '' ) {
42
+		public function get_oauth_url($return_url = '') {
43 43
 
44
-			if ( empty( $return_url ) ) {
45
-				$return_url = admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' );
44
+			if (empty($return_url)) {
45
+				$return_url = admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe');
46 46
 			}
47 47
 
48
-			if ( substr( $return_url, 0, 8 ) !== 'https://' ) {
49
-				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' ) );
48
+			if (substr($return_url, 0, 8) !== 'https://') {
49
+				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'));
50 50
 			}
51 51
 
52
-			$result = $this->api->get_stripe_oauth_init( $return_url );
52
+			$result = $this->api->get_stripe_oauth_init($return_url);
53 53
 
54
-			if ( is_wp_error( $result ) ) {
54
+			if (is_wp_error($result)) {
55 55
 				return $result;
56 56
 			}
57 57
 
58
-			update_option( 'stripe_state', $result->state );
58
+			update_option('stripe_state', $result->state);
59 59
 
60 60
 			return $result->oauthUrl; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
61 61
 		}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 			$response = $this->api->deauthorize_stripe_account();
71 71
 
72
-			if ( is_wp_error( $response ) ) {
72
+			if (is_wp_error($response)) {
73 73
 				return $response;
74 74
 			}
75 75
 
@@ -86,21 +86,21 @@  discard block
 block discarded – undo
86 86
 		 *
87 87
 		 * @return string|WP_Error
88 88
 		 */
89
-		public function connect_oauth( $state, $code ) {
89
+		public function connect_oauth($state, $code) {
90 90
 
91
-			if ( get_option( 'stripe_state', false ) !== $state ) {
92
-				return new WP_Error( 'Invalid stripe state' );
91
+			if (get_option('stripe_state', false) !== $state) {
92
+				return new WP_Error('Invalid stripe state');
93 93
 			}
94 94
 
95
-			$response = $this->api->get_stripe_oauth_keys( $code );
95
+			$response = $this->api->get_stripe_oauth_keys($code);
96 96
 
97
-			if ( is_wp_error( $response ) ) {
97
+			if (is_wp_error($response)) {
98 98
 				return $response;
99 99
 			}
100 100
 
101
-			delete_option( 'stripe_state' );
101
+			delete_option('stripe_state');
102 102
 
103
-			return $this->save_stripe_keys( $response );
103
+			return $this->save_stripe_keys($response);
104 104
 		}
105 105
 
106 106
 		/**
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
 		 */
109 109
 		public function maybe_connect_oauth() {
110 110
 
111
-			if ( ! get_option( 'stripe_state', false ) ) {
111
+			if ( ! get_option('stripe_state', false)) {
112 112
 				return;
113 113
 			}
114 114
 
115
-			if ( isset( $_GET['wcs_stripe_code'], $_GET['wcs_stripe_state'] ) ) {
116
-				$response = $this->connect_oauth( $_GET['wcs_stripe_state'], $_GET['wcs_stripe_code'] );
115
+			if (isset($_GET['wcs_stripe_code'], $_GET['wcs_stripe_state'])) {
116
+				$response = $this->connect_oauth($_GET['wcs_stripe_state'], $_GET['wcs_stripe_code']);
117 117
 
118
-				wp_safe_redirect( remove_query_arg( array( 'wcs_stripe_state', 'wcs_stripe_code' ) ) );
118
+				wp_safe_redirect(remove_query_arg(array('wcs_stripe_state', 'wcs_stripe_code')));
119 119
 				exit;
120 120
 			}
121 121
 		}
@@ -127,28 +127,28 @@  discard block
 block discarded – undo
127 127
 		 *
128 128
 		 * @return array|WP_Error
129 129
 		 */
130
-		private function save_stripe_keys( $result ) {
130
+		private function save_stripe_keys($result) {
131 131
 
132
-			if ( ! isset( $result->publishableKey, $result->secretKey ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
133
-				return new WP_Error( 'Invalid credentials received from WooCommerce Connect server' );
132
+			if ( ! isset($result->publishableKey, $result->secretKey)) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
133
+				return new WP_Error('Invalid credentials received from WooCommerce Connect server');
134 134
 			}
135 135
 
136
-			$is_test         = false !== strpos( $result->publishableKey, '_test_' ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
136
+			$is_test         = false !== strpos($result->publishableKey, '_test_'); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
137 137
 			$prefix          = $is_test ? 'test_' : '';
138 138
 			$default_options = array();
139 139
 
140
-			$options                                = array_merge( $default_options, get_option( self::SETTINGS_OPTION, array() ) );
140
+			$options                                = array_merge($default_options, get_option(self::SETTINGS_OPTION, array()));
141 141
 			$options['enabled']                     = 'yes';
142 142
 			$options['testmode']                    = $is_test ? 'yes' : 'no';
143
-			$options[ $prefix . 'publishable_key' ] = $result->publishableKey; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
144
-			$options[ $prefix . 'secret_key' ]      = $result->secretKey; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
143
+			$options[$prefix . 'publishable_key'] = $result->publishableKey; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
144
+			$options[$prefix . 'secret_key']      = $result->secretKey; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
145 145
 
146 146
 			// While we are at it, let's also clear the account_id and
147 147
 			// test_account_id if present.
148
-			unset( $options['account_id'] );
149
-			unset( $options['test_account_id'] );
148
+			unset($options['account_id']);
149
+			unset($options['test_account_id']);
150 150
 
151
-			update_option( self::SETTINGS_OPTION, $options );
151
+			update_option(self::SETTINGS_OPTION, $options);
152 152
 
153 153
 			return $result;
154 154
 		}
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
 		 */
159 159
 		private function clear_stripe_keys() {
160 160
 
161
-			$options = get_option( self::SETTINGS_OPTION, array() );
161
+			$options = get_option(self::SETTINGS_OPTION, array());
162 162
 
163
-			if ( 'yes' === $options['testmode'] ) {
163
+			if ('yes' === $options['testmode']) {
164 164
 				$options['test_publishable_key'] = '';
165 165
 				$options['test_secret_key']      = '';
166 166
 			} else {
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
 
171 171
 			// While we are at it, let's also clear the account_id and
172 172
 			// test_account_id if present.
173
-			unset( $options['account_id'] );
174
-			unset( $options['test_account_id'] );
173
+			unset($options['account_id']);
174
+			unset($options['test_account_id']);
175 175
 
176
-			update_option( self::SETTINGS_OPTION, $options );
176
+			update_option(self::SETTINGS_OPTION, $options);
177 177
 
178 178
 		}
179 179
 
@@ -182,17 +182,17 @@  discard block
 block discarded – undo
182 182
 		 */
183 183
 		public function wc_ajax_oauth_init() {
184 184
 
185
-			if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], '_wc_stripe_admin_nonce' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.ValidatedSanitizedInput.MissingUnslash
186
-				wp_die( __( 'You are not authorized to automatically copy Stripe keys.', 'woocommerce-gateway-stripe' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
185
+			if (empty($_POST['nonce']) || ! wp_verify_nonce($_POST['nonce'], '_wc_stripe_admin_nonce')) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.ValidatedSanitizedInput.MissingUnslash
186
+				wp_die(__('You are not authorized to automatically copy Stripe keys.', 'woocommerce-gateway-stripe')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
187 187
 			}
188 188
 
189 189
 			$oauth_url = $this->get_oauth_url();
190 190
 
191
-			if ( is_wp_error( $oauth_url ) ) {
192
-				wp_send_json_error( $oauth_url->get_error_message() );
191
+			if (is_wp_error($oauth_url)) {
192
+				wp_send_json_error($oauth_url->get_error_message());
193 193
 			}
194 194
 
195
-			wp_send_json_success( $oauth_url );
195
+			wp_send_json_success($oauth_url);
196 196
 		}
197 197
 
198 198
 		/**
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
 		 */
201 201
 		public function wc_ajax_clear_stripe_keys() {
202 202
 
203
-			if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], '_wc_stripe_admin_nonce' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.ValidatedSanitizedInput.MissingUnslash
204
-				wp_die( __( 'You are not authorized to reset Stripe keys.', 'woocommerce-gateway-stripe' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
203
+			if (empty($_POST['nonce']) || ! wp_verify_nonce($_POST['nonce'], '_wc_stripe_admin_nonce')) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.ValidatedSanitizedInput.MissingUnslash
204
+				wp_die(__('You are not authorized to reset Stripe keys.', 'woocommerce-gateway-stripe')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
205 205
 			}
206 206
 
207 207
 			$this->clear_stripe_keys();
208 208
 
209
-			wp_send_json_success( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
209
+			wp_send_json_success(admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe'));
210 210
 		}
211 211
 	}
212 212
 }
Please login to merge, or discard this patch.
includes/admin/stripe-settings.php 1 patch
Spacing   +68 added lines, -68 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
 
@@ -7,186 +7,186 @@  discard block
 block discarded – undo
7 7
 	'wc_stripe_settings',
8 8
 	array(
9 9
 		'enabled'                       => array(
10
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
11
-			'label'       => __( 'Enable Stripe', 'woocommerce-gateway-stripe' ),
10
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
11
+			'label'       => __('Enable Stripe', 'woocommerce-gateway-stripe'),
12 12
 			'type'        => 'checkbox',
13 13
 			'description' => '',
14 14
 			'default'     => 'no',
15 15
 		),
16 16
 		'title'                         => array(
17
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
17
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
18 18
 			'type'        => 'text',
19
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
20
-			'default'     => __( 'Credit Card (Stripe)', 'woocommerce-gateway-stripe' ),
19
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
20
+			'default'     => __('Credit Card (Stripe)', 'woocommerce-gateway-stripe'),
21 21
 			'desc_tip'    => true,
22 22
 		),
23 23
 		'description'                   => array(
24
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
24
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
25 25
 			'type'        => 'text',
26
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
27
-			'default'     => __( 'Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe' ),
26
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
27
+			'default'     => __('Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe'),
28 28
 			'desc_tip'    => true,
29 29
 		),
30 30
 		'webhook'                       => array(
31
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
31
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
32 32
 			'type'        => 'title',
33 33
 			/* translators: webhook URL */
34 34
 			'description' => $this->display_admin_settings_webhook_description(),
35 35
 		),
36 36
 		'api_credentials'               => array(
37
-			'title' => __( 'API Credentials', 'woocommerce-gateway-stripe' ),
37
+			'title' => __('API Credentials', 'woocommerce-gateway-stripe'),
38 38
 			'type'  => 'title',
39 39
 		),
40 40
 		'testmode'                      => array(
41
-			'title'       => __( 'Test mode', 'woocommerce-gateway-stripe' ),
42
-			'label'       => __( 'Enable Test Mode', 'woocommerce-gateway-stripe' ),
41
+			'title'       => __('Test mode', 'woocommerce-gateway-stripe'),
42
+			'label'       => __('Enable Test Mode', 'woocommerce-gateway-stripe'),
43 43
 			'type'        => 'checkbox',
44
-			'description' => __( 'Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe' ),
44
+			'description' => __('Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe'),
45 45
 			'default'     => 'yes',
46 46
 			'desc_tip'    => true,
47 47
 		),
48 48
 		'test_publishable_key'          => array(
49
-			'title'       => __( 'Test Publishable Key', 'woocommerce-gateway-stripe' ),
49
+			'title'       => __('Test Publishable Key', 'woocommerce-gateway-stripe'),
50 50
 			'type'        => 'text',
51
-			'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_test_" will be saved.', 'woocommerce-gateway-stripe' ),
51
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_test_" will be saved.', 'woocommerce-gateway-stripe'),
52 52
 			'default'     => '',
53 53
 			'desc_tip'    => true,
54 54
 		),
55 55
 		'test_secret_key'               => array(
56
-			'title'       => __( 'Test Secret Key', 'woocommerce-gateway-stripe' ),
56
+			'title'       => __('Test Secret Key', 'woocommerce-gateway-stripe'),
57 57
 			'type'        => 'password',
58
-			'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_test_" or "rk_test_" will be saved.', 'woocommerce-gateway-stripe' ),
58
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_test_" or "rk_test_" will be saved.', 'woocommerce-gateway-stripe'),
59 59
 			'default'     => '',
60 60
 			'desc_tip'    => true,
61 61
 		),
62 62
 		'test_webhook_secret'           => array(
63
-			'title'       => __( 'Test Webhook Secret', 'woocommerce-gateway-stripe' ),
63
+			'title'       => __('Test Webhook Secret', 'woocommerce-gateway-stripe'),
64 64
 			'type'        => 'password',
65
-			'description' => __( 'Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe' ),
65
+			'description' => __('Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe'),
66 66
 			'default'     => '',
67 67
 			'desc_tip'    => true,
68 68
 		),
69 69
 		'publishable_key'               => array(
70
-			'title'       => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ),
70
+			'title'       => __('Live Publishable Key', 'woocommerce-gateway-stripe'),
71 71
 			'type'        => 'text',
72
-			'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_live_" will be saved.', 'woocommerce-gateway-stripe' ),
72
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_live_" will be saved.', 'woocommerce-gateway-stripe'),
73 73
 			'default'     => '',
74 74
 			'desc_tip'    => true,
75 75
 		),
76 76
 		'secret_key'                    => array(
77
-			'title'       => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ),
77
+			'title'       => __('Live Secret Key', 'woocommerce-gateway-stripe'),
78 78
 			'type'        => 'password',
79
-			'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_live_" or "rk_live_" will be saved.', 'woocommerce-gateway-stripe' ),
79
+			'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_live_" or "rk_live_" will be saved.', 'woocommerce-gateway-stripe'),
80 80
 			'default'     => '',
81 81
 			'desc_tip'    => true,
82 82
 		),
83 83
 		'webhook_secret'               => array(
84
-			'title'       => __( 'Webhook Secret', 'woocommerce-gateway-stripe' ),
84
+			'title'       => __('Webhook Secret', 'woocommerce-gateway-stripe'),
85 85
 			'type'        => 'password',
86
-			'description' => __( 'Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe' ),
86
+			'description' => __('Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe'),
87 87
 			'default'     => '',
88 88
 			'desc_tip'    => true,
89 89
 		),
90 90
 		'inline_cc_form'                => array(
91
-			'title'       => __( 'Inline Credit Card Form', 'woocommerce-gateway-stripe' ),
91
+			'title'       => __('Inline Credit Card Form', 'woocommerce-gateway-stripe'),
92 92
 			'type'        => 'checkbox',
93
-			'description' => __( 'Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe' ),
93
+			'description' => __('Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe'),
94 94
 			'default'     => 'no',
95 95
 			'desc_tip'    => true,
96 96
 		),
97 97
 		'statement_descriptor'          => array(
98
-			'title'       => __( 'Statement Descriptor', 'woocommerce-gateway-stripe' ),
98
+			'title'       => __('Statement Descriptor', 'woocommerce-gateway-stripe'),
99 99
 			'type'        => 'text',
100
-			'description' => __( 'Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe' ),
100
+			'description' => __('Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe'),
101 101
 			'default'     => '',
102 102
 			'desc_tip'    => true,
103 103
 		),
104 104
 		'capture'                       => array(
105
-			'title'       => __( 'Capture', 'woocommerce-gateway-stripe' ),
106
-			'label'       => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ),
105
+			'title'       => __('Capture', 'woocommerce-gateway-stripe'),
106
+			'label'       => __('Capture charge immediately', 'woocommerce-gateway-stripe'),
107 107
 			'type'        => 'checkbox',
108
-			'description' => __( 'Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe' ),
108
+			'description' => __('Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe'),
109 109
 			'default'     => 'yes',
110 110
 			'desc_tip'    => true,
111 111
 		),
112 112
 		'payment_request'               => array(
113
-			'title'       => __( 'Payment Request Buttons', 'woocommerce-gateway-stripe' ),
113
+			'title'       => __('Payment Request Buttons', 'woocommerce-gateway-stripe'),
114 114
 			/* translators: 1) br tag 2) opening anchor tag 3) closing anchor tag */
115
-			'label'       => sprintf( __( 'Enable Payment Request Buttons. (Apple Pay/Chrome Payment Request API) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe' ), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>' ),
115
+			'label'       => sprintf(__('Enable Payment Request Buttons. (Apple Pay/Chrome Payment Request API) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe'), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>'),
116 116
 			'type'        => 'checkbox',
117
-			'description' => __( 'If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe' ),
117
+			'description' => __('If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe'),
118 118
 			'default'     => 'yes',
119 119
 			'desc_tip'    => true,
120 120
 		),
121 121
 		'payment_request_button_type'   => array(
122
-			'title'       => __( 'Payment Request Button Type', 'woocommerce-gateway-stripe' ),
123
-			'label'       => __( 'Button Type', 'woocommerce-gateway-stripe' ),
122
+			'title'       => __('Payment Request Button Type', 'woocommerce-gateway-stripe'),
123
+			'label'       => __('Button Type', 'woocommerce-gateway-stripe'),
124 124
 			'type'        => 'select',
125
-			'description' => __( 'Select the button type you would like to show.', 'woocommerce-gateway-stripe' ),
125
+			'description' => __('Select the button type you would like to show.', 'woocommerce-gateway-stripe'),
126 126
 			'default'     => 'buy',
127 127
 			'desc_tip'    => true,
128 128
 			'options'     => array(
129
-				'default' => __( 'Default', 'woocommerce-gateway-stripe' ),
130
-				'buy'     => __( 'Buy', 'woocommerce-gateway-stripe' ),
131
-				'donate'  => __( 'Donate', 'woocommerce-gateway-stripe' ),
132
-				'branded' => __( 'Branded', 'woocommerce-gateway-stripe' ),
133
-				'custom'  => __( 'Custom', 'woocommerce-gateway-stripe' ),
129
+				'default' => __('Default', 'woocommerce-gateway-stripe'),
130
+				'buy'     => __('Buy', 'woocommerce-gateway-stripe'),
131
+				'donate'  => __('Donate', 'woocommerce-gateway-stripe'),
132
+				'branded' => __('Branded', 'woocommerce-gateway-stripe'),
133
+				'custom'  => __('Custom', 'woocommerce-gateway-stripe'),
134 134
 			),
135 135
 		),
136 136
 		'payment_request_button_theme'  => array(
137
-			'title'       => __( 'Payment Request Button Theme', 'woocommerce-gateway-stripe' ),
138
-			'label'       => __( 'Button Theme', 'woocommerce-gateway-stripe' ),
137
+			'title'       => __('Payment Request Button Theme', 'woocommerce-gateway-stripe'),
138
+			'label'       => __('Button Theme', 'woocommerce-gateway-stripe'),
139 139
 			'type'        => 'select',
140
-			'description' => __( 'Select the button theme you would like to show.', 'woocommerce-gateway-stripe' ),
140
+			'description' => __('Select the button theme you would like to show.', 'woocommerce-gateway-stripe'),
141 141
 			'default'     => 'dark',
142 142
 			'desc_tip'    => true,
143 143
 			'options'     => array(
144
-				'dark'          => __( 'Dark', 'woocommerce-gateway-stripe' ),
145
-				'light'         => __( 'Light', 'woocommerce-gateway-stripe' ),
146
-				'light-outline' => __( 'Light-Outline', 'woocommerce-gateway-stripe' ),
144
+				'dark'          => __('Dark', 'woocommerce-gateway-stripe'),
145
+				'light'         => __('Light', 'woocommerce-gateway-stripe'),
146
+				'light-outline' => __('Light-Outline', 'woocommerce-gateway-stripe'),
147 147
 			),
148 148
 		),
149 149
 		'payment_request_button_height' => array(
150
-			'title'       => __( 'Payment Request Button Height', 'woocommerce-gateway-stripe' ),
151
-			'label'       => __( 'Button Height', 'woocommerce-gateway-stripe' ),
150
+			'title'       => __('Payment Request Button Height', 'woocommerce-gateway-stripe'),
151
+			'label'       => __('Button Height', 'woocommerce-gateway-stripe'),
152 152
 			'type'        => 'text',
153
-			'description' => __( 'Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe' ),
153
+			'description' => __('Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe'),
154 154
 			'default'     => '44',
155 155
 			'desc_tip'    => true,
156 156
 		),
157 157
 		'payment_request_button_label' => array(
158
-			'title'       => __( 'Payment Request Button Label', 'woocommerce-gateway-stripe' ),
159
-			'label'       => __( 'Button Label', 'woocommerce-gateway-stripe' ),
158
+			'title'       => __('Payment Request Button Label', 'woocommerce-gateway-stripe'),
159
+			'label'       => __('Button Label', 'woocommerce-gateway-stripe'),
160 160
 			'type'        => 'text',
161
-			'description' => __( 'Enter the custom text you would like the button to have.', 'woocommerce-gateway-stripe' ),
162
-			'default'     => __( 'Buy now', 'woocommerce-gateway-stripe' ),
161
+			'description' => __('Enter the custom text you would like the button to have.', 'woocommerce-gateway-stripe'),
162
+			'default'     => __('Buy now', 'woocommerce-gateway-stripe'),
163 163
 			'desc_tip'    => true,
164 164
 		),
165 165
 		'payment_request_button_branded_type' => array(
166
-			'title'       => __( 'Payment Request Branded Button Label Format', 'woocommerce-gateway-stripe' ),
167
-			'label'       => __( 'Branded Button Label Format', 'woocommerce-gateway-stripe' ),
166
+			'title'       => __('Payment Request Branded Button Label Format', 'woocommerce-gateway-stripe'),
167
+			'label'       => __('Branded Button Label Format', 'woocommerce-gateway-stripe'),
168 168
 			'type'        => 'select',
169
-			'description' => __( 'Select the branded button label format.', 'woocommerce-gateway-stripe' ),
169
+			'description' => __('Select the branded button label format.', 'woocommerce-gateway-stripe'),
170 170
 			'default'     => 'long',
171 171
 			'desc_tip'    => true,
172 172
 			'options'     => array(
173
-				'short' => __( 'Logo only', 'woocommerce-gateway-stripe' ),
174
-				'long'  => __( 'Text and logo', 'woocommerce-gateway-stripe' ),
173
+				'short' => __('Logo only', 'woocommerce-gateway-stripe'),
174
+				'long'  => __('Text and logo', 'woocommerce-gateway-stripe'),
175 175
 			),
176 176
 		),
177 177
 		'saved_cards'                   => array(
178
-			'title'       => __( 'Saved Cards', 'woocommerce-gateway-stripe' ),
179
-			'label'       => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ),
178
+			'title'       => __('Saved Cards', 'woocommerce-gateway-stripe'),
179
+			'label'       => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'),
180 180
 			'type'        => 'checkbox',
181
-			'description' => __( 'If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe' ),
181
+			'description' => __('If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe'),
182 182
 			'default'     => 'yes',
183 183
 			'desc_tip'    => true,
184 184
 		),
185 185
 		'logging'                       => array(
186
-			'title'       => __( 'Logging', 'woocommerce-gateway-stripe' ),
187
-			'label'       => __( 'Log debug messages', 'woocommerce-gateway-stripe' ),
186
+			'title'       => __('Logging', 'woocommerce-gateway-stripe'),
187
+			'label'       => __('Log debug messages', 'woocommerce-gateway-stripe'),
188 188
 			'type'        => 'checkbox',
189
-			'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ),
189
+			'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'),
190 190
 			'default'     => 'no',
191 191
 			'desc_tip'    => true,
192 192
 		),
Please login to merge, or discard this patch.
includes/class-wc-gateway-stripe.php 1 patch
Spacing   +324 added lines, -324 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,35 +344,35 @@  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
 		$oauth_endpoint = $this->secret_key && $this->publishable_key ? 'wc_stripe_clear_keys' : 'wc_stripe_oauth_init';
353 353
 		$oauth_text     = array(
354 354
 			'wc_stripe_clear_keys' => sprintf(
355 355
 				/* translators: 1) opening anchor tag 2) closing anchor tag */
356
-				__( '%1$sReset Stripe account keys%2$s', 'woocommerce-gateway-stripe' ),
356
+				__('%1$sReset Stripe account keys%2$s', 'woocommerce-gateway-stripe'),
357 357
 				'<a href="#" class="button button-secondary">',
358 358
 				'</a>'
359 359
 			),
360 360
 			'wc_stripe_oauth_init' => sprintf(
361 361
 				/* translators: 1) opening anchor tag 2) closing anchor tag */
362
-				__( '%1$sSetup or link an existing Stripe Account%2$s or manually enter Stripe keys below.', 'woocommerce-gateway-stripe' ),
362
+				__('%1$sSetup or link an existing Stripe Account%2$s or manually enter Stripe keys below.', 'woocommerce-gateway-stripe'),
363 363
 				'<a href="#" class="button button-primary">',
364 364
 				'</a>'
365 365
 			),
366 366
 		);
367 367
 
368
-		wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true );
368
+		wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true);
369 369
 		wp_localize_script(
370 370
 			'woocommerce_stripe_admin',
371 371
 			'woocommerce_stripe_admin',
372 372
 			array(
373
-				'ajax_url'                  => WC_AJAX::get_endpoint( $oauth_endpoint ),
374
-				'wc_stripe_admin_nonce'     => wp_create_nonce( '_wc_stripe_admin_nonce' ),
375
-				'wc_stripe_api_button_text' => $oauth_text[ $oauth_endpoint ],
373
+				'ajax_url'                  => WC_AJAX::get_endpoint($oauth_endpoint),
374
+				'wc_stripe_admin_nonce'     => wp_create_nonce('_wc_stripe_admin_nonce'),
375
+				'wc_stripe_api_button_text' => $oauth_text[$oauth_endpoint],
376 376
 			)
377 377
 		);
378 378
 	}
@@ -391,54 +391,54 @@  discard block
 block discarded – undo
391 391
 			! is_product()
392 392
 			&& ! is_cart()
393 393
 			&& ! is_checkout()
394
-			&& ! isset( $_GET['pay_for_order'] ) // wpcs: csrf ok.
394
+			&& ! isset($_GET['pay_for_order']) // wpcs: csrf ok.
395 395
 			&& ! is_add_payment_method_page()
396
-			&& ! isset( $_GET['change_payment_method'] ) // wpcs: csrf ok.
397
-			&& ! ( ! 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() )
398
-			|| ( is_order_received_page() )
396
+			&& ! isset($_GET['change_payment_method']) // wpcs: csrf ok.
397
+			&& ! ( ! 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())
398
+			|| (is_order_received_page())
399 399
 		) {
400 400
 			return;
401 401
 		}
402 402
 
403 403
 		// If Stripe is not enabled bail.
404
-		if ( 'no' === $this->enabled ) {
404
+		if ('no' === $this->enabled) {
405 405
 			return;
406 406
 		}
407 407
 
408 408
 		// If keys are not set bail.
409
-		if ( ! $this->are_keys_set() ) {
410
-			WC_Stripe_Logger::log( 'Keys are not set correctly.' );
409
+		if ( ! $this->are_keys_set()) {
410
+			WC_Stripe_Logger::log('Keys are not set correctly.');
411 411
 			return;
412 412
 		}
413 413
 
414 414
 		// If no SSL bail.
415
-		if ( ! $this->testmode && ! is_ssl() ) {
416
-			WC_Stripe_Logger::log( 'Stripe live mode requires SSL.' );
415
+		if ( ! $this->testmode && ! is_ssl()) {
416
+			WC_Stripe_Logger::log('Stripe live mode requires SSL.');
417 417
 			return;
418 418
 		}
419 419
 
420 420
 		$current_theme = wp_get_theme();
421 421
 
422
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
422
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
423 423
 
424
-		wp_register_style( 'stripe_styles', plugins_url( 'assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION );
425
-		wp_enqueue_style( 'stripe_styles' );
424
+		wp_register_style('stripe_styles', plugins_url('assets/css/stripe-styles.css', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION);
425
+		wp_enqueue_style('stripe_styles');
426 426
 
427
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
428
-		wp_register_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripe' ), WC_STRIPE_VERSION, true );
427
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
428
+		wp_register_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripe'), WC_STRIPE_VERSION, true);
429 429
 
430 430
 		$stripe_params = array(
431 431
 			'key'                  => $this->publishable_key,
432
-			'i18n_terms'           => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ),
433
-			'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ),
432
+			'i18n_terms'           => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'),
433
+			'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'),
434 434
 		);
435 435
 
436 436
 		// If we're on the pay page we need to pass stripe.js the address of the order.
437
-		if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) { // wpcs: csrf ok.
438
-			$order_id = wc_clean( $wp->query_vars['order-pay'] ); // wpcs: csrf ok, sanitization ok, xss ok.
439
-			$order    = wc_get_order( $order_id );
437
+		if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) { // wpcs: csrf ok.
438
+			$order_id = wc_clean($wp->query_vars['order-pay']); // wpcs: csrf ok, sanitization ok, xss ok.
439
+			$order    = wc_get_order($order_id);
440 440
 
441
-			if ( is_a( $order, 'WC_Order' ) ) {
441
+			if (is_a($order, 'WC_Order')) {
442 442
 				$stripe_params['billing_first_name'] = $order->get_billing_first_name();
443 443
 				$stripe_params['billing_last_name']  = $order->get_billing_last_name();
444 444
 				$stripe_params['billing_address_1']  = $order->get_billing_address_1();
@@ -453,40 +453,40 @@  discard block
 block discarded – undo
453 453
 		$sepa_elements_options = apply_filters(
454 454
 			'wc_stripe_sepa_elements_options',
455 455
 			array(
456
-				'supportedCountries' => array( 'SEPA' ),
456
+				'supportedCountries' => array('SEPA'),
457 457
 				'placeholderCountry' => WC()->countries->get_base_country(),
458
-				'style'              => array( 'base' => array( 'fontSize' => '15px' ) ),
458
+				'style'              => array('base' => array('fontSize' => '15px')),
459 459
 			)
460 460
 		);
461 461
 
462
-		$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' );
463
-		$stripe_params['no_sepa_owner_msg']         = __( 'Please enter your IBAN account name.', 'woocommerce-gateway-stripe' );
464
-		$stripe_params['no_sepa_iban_msg']          = __( 'Please enter your IBAN account number.', 'woocommerce-gateway-stripe' );
465
-		$stripe_params['payment_intent_error']      = __( 'We couldn\'t initiate the payment. Please try again.', 'woocommerce-gateway-stripe' );
466
-		$stripe_params['sepa_mandate_notification'] = apply_filters( 'wc_stripe_sepa_mandate_notification', 'email' );
467
-		$stripe_params['allow_prepaid_card']        = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no';
462
+		$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');
463
+		$stripe_params['no_sepa_owner_msg']         = __('Please enter your IBAN account name.', 'woocommerce-gateway-stripe');
464
+		$stripe_params['no_sepa_iban_msg']          = __('Please enter your IBAN account number.', 'woocommerce-gateway-stripe');
465
+		$stripe_params['payment_intent_error']      = __('We couldn\'t initiate the payment. Please try again.', 'woocommerce-gateway-stripe');
466
+		$stripe_params['sepa_mandate_notification'] = apply_filters('wc_stripe_sepa_mandate_notification', 'email');
467
+		$stripe_params['allow_prepaid_card']        = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no';
468 468
 		$stripe_params['inline_cc_form']            = $this->inline_cc_form ? 'yes' : 'no';
469
-		$stripe_params['is_checkout']               = ( is_checkout() && empty( $_GET['pay_for_order'] ) ) ? 'yes' : 'no'; // wpcs: csrf ok.
469
+		$stripe_params['is_checkout']               = (is_checkout() && empty($_GET['pay_for_order'])) ? 'yes' : 'no'; // wpcs: csrf ok.
470 470
 		$stripe_params['return_url']                = $this->get_stripe_return_url();
471
-		$stripe_params['ajaxurl']                   = WC_AJAX::get_endpoint( '%%endpoint%%' );
472
-		$stripe_params['stripe_nonce']              = wp_create_nonce( '_wc_stripe_nonce' );
471
+		$stripe_params['ajaxurl']                   = WC_AJAX::get_endpoint('%%endpoint%%');
472
+		$stripe_params['stripe_nonce']              = wp_create_nonce('_wc_stripe_nonce');
473 473
 		$stripe_params['statement_descriptor']      = $this->statement_descriptor;
474
-		$stripe_params['elements_options']          = apply_filters( 'wc_stripe_elements_options', array() );
474
+		$stripe_params['elements_options']          = apply_filters('wc_stripe_elements_options', array());
475 475
 		$stripe_params['sepa_elements_options']     = $sepa_elements_options;
476
-		$stripe_params['invalid_owner_name']        = __( 'Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe' );
477
-		$stripe_params['is_change_payment_page']    = isset( $_GET['change_payment_method'] ) ? 'yes' : 'no'; // wpcs: csrf ok.
478
-		$stripe_params['is_add_payment_page']       = is_wc_endpoint_url( 'add-payment-method' ) ? 'yes' : 'no';
479
-		$stripe_params['is_pay_for_order_page']     = is_wc_endpoint_url( 'order-pay' ) ? 'yes' : 'no';
480
-		$stripe_params['elements_styling']          = apply_filters( 'wc_stripe_elements_styling', false );
481
-		$stripe_params['elements_classes']          = apply_filters( 'wc_stripe_elements_classes', false );
476
+		$stripe_params['invalid_owner_name']        = __('Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe');
477
+		$stripe_params['is_change_payment_page']    = isset($_GET['change_payment_method']) ? 'yes' : 'no'; // wpcs: csrf ok.
478
+		$stripe_params['is_add_payment_page']       = is_wc_endpoint_url('add-payment-method') ? 'yes' : 'no';
479
+		$stripe_params['is_pay_for_order_page']     = is_wc_endpoint_url('order-pay') ? 'yes' : 'no';
480
+		$stripe_params['elements_styling']          = apply_filters('wc_stripe_elements_styling', false);
481
+		$stripe_params['elements_classes']          = apply_filters('wc_stripe_elements_classes', false);
482 482
 
483 483
 		// Merge localized messages to be use in JS.
484
-		$stripe_params = array_merge( $stripe_params, WC_Stripe_Helper::get_localized_messages() );
484
+		$stripe_params = array_merge($stripe_params, WC_Stripe_Helper::get_localized_messages());
485 485
 
486
-		wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
486
+		wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
487 487
 
488 488
 		$this->tokenization_script();
489
-		wp_enqueue_script( 'woocommerce_stripe' );
489
+		wp_enqueue_script('woocommerce_stripe');
490 490
 	}
491 491
 
492 492
 	/**
@@ -497,14 +497,14 @@  discard block
 block discarded – undo
497 497
 	 * @param object $prepared_source The object with source details.
498 498
 	 * @throws WC_Stripe_Exception An exception if the card is prepaid, but prepaid cards are not allowed.
499 499
 	 */
500
-	public function maybe_disallow_prepaid_card( $prepared_source ) {
500
+	public function maybe_disallow_prepaid_card($prepared_source) {
501 501
 		// Check if we don't allow prepaid credit cards.
502
-		if ( apply_filters( 'wc_stripe_allow_prepaid_card', true ) || ! $this->is_prepaid_card( $prepared_source->source_object ) ) {
502
+		if (apply_filters('wc_stripe_allow_prepaid_card', true) || ! $this->is_prepaid_card($prepared_source->source_object)) {
503 503
 			return;
504 504
 		}
505 505
 
506
-		$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' );
507
-		throw new WC_Stripe_Exception( print_r( $prepared_source->source_object, true ), $localized_message );
506
+		$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');
507
+		throw new WC_Stripe_Exception(print_r($prepared_source->source_object, true), $localized_message);
508 508
 	}
509 509
 
510 510
 	/**
@@ -514,10 +514,10 @@  discard block
 block discarded – undo
514 514
 	 * @param  object $prepared_source The source that should be verified.
515 515
 	 * @throws WC_Stripe_Exception     An exception if the source ID is missing.
516 516
 	 */
517
-	public function check_source( $prepared_source ) {
518
-		if ( empty( $prepared_source->source ) ) {
519
-			$localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
520
-			throw new WC_Stripe_Exception( print_r( $prepared_source, true ), $localized_message );
517
+	public function check_source($prepared_source) {
518
+		if (empty($prepared_source->source)) {
519
+			$localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
520
+			throw new WC_Stripe_Exception(print_r($prepared_source, true), $localized_message);
521 521
 		}
522 522
 	}
523 523
 
@@ -529,13 +529,13 @@  discard block
 block discarded – undo
529 529
 	 * @param WC_Order $order The order those payment is being processed.
530 530
 	 * @return bool           A flag that indicates that the customer does not exist and should be removed.
531 531
 	 */
532
-	public function maybe_remove_non_existent_customer( $error, $order ) {
533
-		if ( ! $this->is_no_such_customer_error( $error ) ) {
532
+	public function maybe_remove_non_existent_customer($error, $order) {
533
+		if ( ! $this->is_no_such_customer_error($error)) {
534 534
 			return false;
535 535
 		}
536 536
 
537
-		delete_user_option( $order->get_customer_id(), '_stripe_customer_id' );
538
-		$order->delete_meta_data( '_stripe_customer_id' );
537
+		delete_user_option($order->get_customer_id(), '_stripe_customer_id');
538
+		$order->delete_meta_data('_stripe_customer_id');
539 539
 		$order->save();
540 540
 
541 541
 		return true;
@@ -550,15 +550,15 @@  discard block
 block discarded – undo
550 550
 	 * @param boolean  $force_save_source Whether the payment source must be saved, like when dealing with a Subscription setup.
551 551
 	 * @return array                      Redirection data for `process_payment`.
552 552
 	 */
553
-	public function complete_free_order( $order, $prepared_source, $force_save_source ) {
554
-		if ( $force_save_source ) {
555
-			$intent_secret = $this->setup_intent( $order, $prepared_source );
553
+	public function complete_free_order($order, $prepared_source, $force_save_source) {
554
+		if ($force_save_source) {
555
+			$intent_secret = $this->setup_intent($order, $prepared_source);
556 556
 
557
-			if ( ! empty( $intent_secret ) ) {
557
+			if ( ! empty($intent_secret)) {
558 558
 				// `get_return_url()` must be called immediately before returning a value.
559 559
 				return array(
560 560
 					'result'              => 'success',
561
-					'redirect'            => $this->get_return_url( $order ),
561
+					'redirect'            => $this->get_return_url($order),
562 562
 					'setup_intent_secret' => $intent_secret,
563 563
 				);
564 564
 			}
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 		// Return thank you page redirect.
573 573
 		return array(
574 574
 			'result'   => 'success',
575
-			'redirect' => $this->get_return_url( $order ),
575
+			'redirect' => $this->get_return_url($order),
576 576
 		);
577 577
 	}
578 578
 
@@ -590,81 +590,81 @@  discard block
 block discarded – undo
590 590
 	 * @throws Exception If payment will not be accepted.
591 591
 	 * @return array|void
592 592
 	 */
593
-	public function process_payment( $order_id, $retry = true, $force_save_source = false, $previous_error = false, $use_order_source = false ) {
593
+	public function process_payment($order_id, $retry = true, $force_save_source = false, $previous_error = false, $use_order_source = false) {
594 594
 		try {
595
-			$order = wc_get_order( $order_id );
595
+			$order = wc_get_order($order_id);
596 596
 
597 597
 			// ToDo: `process_pre_order` saves the source to the order for a later payment.
598 598
 			// This might not work well with PaymentIntents.
599
-			if ( $this->maybe_process_pre_orders( $order_id ) ) {
600
-				return $this->pre_orders->process_pre_order( $order_id );
599
+			if ($this->maybe_process_pre_orders($order_id)) {
600
+				return $this->pre_orders->process_pre_order($order_id);
601 601
 			}
602 602
 
603 603
 			// Check whether there is an existing intent.
604
-			$intent = $this->get_intent_from_order( $order );
605
-			if ( isset( $intent->object ) && 'setup_intent' === $intent->object ) {
604
+			$intent = $this->get_intent_from_order($order);
605
+			if (isset($intent->object) && 'setup_intent' === $intent->object) {
606 606
 				$intent = false; // This function can only deal with *payment* intents
607 607
 			}
608 608
 
609 609
 			$stripe_customer_id = null;
610
-			if ( $intent && ! empty( $intent->customer ) ) {
610
+			if ($intent && ! empty($intent->customer)) {
611 611
 				$stripe_customer_id = $intent->customer;
612 612
 			}
613 613
 
614 614
 			// For some payments the source should already be present in the order.
615
-			if ( $use_order_source ) {
616
-				$prepared_source = $this->prepare_order_source( $order );
615
+			if ($use_order_source) {
616
+				$prepared_source = $this->prepare_order_source($order);
617 617
 			} else {
618
-				$prepared_source = $this->prepare_source( get_current_user_id(), $force_save_source, $stripe_customer_id );
618
+				$prepared_source = $this->prepare_source(get_current_user_id(), $force_save_source, $stripe_customer_id);
619 619
 			}
620 620
 
621
-			$this->maybe_disallow_prepaid_card( $prepared_source );
622
-			$this->check_source( $prepared_source );
623
-			$this->save_source_to_order( $order, $prepared_source );
621
+			$this->maybe_disallow_prepaid_card($prepared_source);
622
+			$this->check_source($prepared_source);
623
+			$this->save_source_to_order($order, $prepared_source);
624 624
 
625
-			if ( 0 >= $order->get_total() ) {
626
-				return $this->complete_free_order( $order, $prepared_source, $force_save_source );
625
+			if (0 >= $order->get_total()) {
626
+				return $this->complete_free_order($order, $prepared_source, $force_save_source);
627 627
 			}
628 628
 
629 629
 			// This will throw exception if not valid.
630
-			$this->validate_minimum_order_amount( $order );
630
+			$this->validate_minimum_order_amount($order);
631 631
 
632
-			WC_Stripe_Logger::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
632
+			WC_Stripe_Logger::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}");
633 633
 
634
-			if ( $intent ) {
635
-				$intent = $this->update_existing_intent( $intent, $order, $prepared_source );
634
+			if ($intent) {
635
+				$intent = $this->update_existing_intent($intent, $order, $prepared_source);
636 636
 			} else {
637
-				$intent = $this->create_intent( $order, $prepared_source );
637
+				$intent = $this->create_intent($order, $prepared_source);
638 638
 			}
639 639
 
640 640
 			// Confirm the intent after locking the order to make sure webhooks will not interfere.
641
-			if ( empty( $intent->error ) ) {
642
-				$this->lock_order_payment( $order, $intent );
643
-				$intent = $this->confirm_intent( $intent, $order, $prepared_source );
641
+			if (empty($intent->error)) {
642
+				$this->lock_order_payment($order, $intent);
643
+				$intent = $this->confirm_intent($intent, $order, $prepared_source);
644 644
 			}
645 645
 
646
-			if ( ! empty( $intent->error ) ) {
647
-				$this->maybe_remove_non_existent_customer( $intent->error, $order );
646
+			if ( ! empty($intent->error)) {
647
+				$this->maybe_remove_non_existent_customer($intent->error, $order);
648 648
 
649 649
 				// We want to retry.
650
-				if ( $this->is_retryable_error( $intent->error ) ) {
651
-					return $this->retry_after_error( $intent, $order, $retry, $force_save_source, $previous_error, $use_order_source );
650
+				if ($this->is_retryable_error($intent->error)) {
651
+					return $this->retry_after_error($intent, $order, $retry, $force_save_source, $previous_error, $use_order_source);
652 652
 				}
653 653
 
654
-				$this->unlock_order_payment( $order );
655
-				$this->throw_localized_message( $intent, $order );
654
+				$this->unlock_order_payment($order);
655
+				$this->throw_localized_message($intent, $order);
656 656
 			}
657 657
 
658
-			if ( ! empty( $intent ) ) {
658
+			if ( ! empty($intent)) {
659 659
 				// Use the last charge within the intent to proceed.
660
-				$response = end( $intent->charges->data );
660
+				$response = end($intent->charges->data);
661 661
 
662 662
 				// If the intent requires a 3DS flow, redirect to it.
663
-				if ( 'requires_action' === $intent->status ) {
664
-					$this->unlock_order_payment( $order );
663
+				if ('requires_action' === $intent->status) {
664
+					$this->unlock_order_payment($order);
665 665
 
666
-					if ( is_wc_endpoint_url( 'order-pay' ) ) {
667
-						$redirect_url = add_query_arg( 'wc-stripe-confirmation', 1, $order->get_checkout_payment_url( false ) );
666
+					if (is_wc_endpoint_url('order-pay')) {
667
+						$redirect_url = add_query_arg('wc-stripe-confirmation', 1, $order->get_checkout_payment_url(false));
668 668
 
669 669
 						return array(
670 670
 							'result'   => 'success',
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 
680 680
 						return array(
681 681
 							'result'                => 'success',
682
-							'redirect'              => $this->get_return_url( $order ),
682
+							'redirect'              => $this->get_return_url($order),
683 683
 							'payment_intent_secret' => $intent->client_secret,
684 684
 						);
685 685
 					}
@@ -687,30 +687,30 @@  discard block
 block discarded – undo
687 687
 			}
688 688
 
689 689
 			// Process valid response.
690
-			$this->process_response( $response, $order );
690
+			$this->process_response($response, $order);
691 691
 
692 692
 			// Remove cart.
693
-			if ( isset( WC()->cart ) ) {
693
+			if (isset(WC()->cart)) {
694 694
 				WC()->cart->empty_cart();
695 695
 			}
696 696
 
697 697
 			// Unlock the order.
698
-			$this->unlock_order_payment( $order );
698
+			$this->unlock_order_payment($order);
699 699
 
700 700
 			// Return thank you page redirect.
701 701
 			return array(
702 702
 				'result'   => 'success',
703
-				'redirect' => $this->get_return_url( $order ),
703
+				'redirect' => $this->get_return_url($order),
704 704
 			);
705 705
 
706
-		} catch ( WC_Stripe_Exception $e ) {
707
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
708
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
706
+		} catch (WC_Stripe_Exception $e) {
707
+			wc_add_notice($e->getLocalizedMessage(), 'error');
708
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
709 709
 
710
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
710
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
711 711
 
712 712
 			/* translators: error message */
713
-			$order->update_status( 'failed' );
713
+			$order->update_status('failed');
714 714
 
715 715
 			return array(
716 716
 				'result'   => 'fail',
@@ -726,17 +726,17 @@  discard block
 block discarded – undo
726 726
 	 *
727 727
 	 * @param int $order_id The ID of the order.
728 728
 	 */
729
-	public function display_order_fee( $order_id ) {
730
-		if ( apply_filters( 'wc_stripe_hide_display_order_fee', false, $order_id ) ) {
729
+	public function display_order_fee($order_id) {
730
+		if (apply_filters('wc_stripe_hide_display_order_fee', false, $order_id)) {
731 731
 			return;
732 732
 		}
733 733
 
734
-		$order = wc_get_order( $order_id );
734
+		$order = wc_get_order($order_id);
735 735
 
736
-		$fee      = WC_Stripe_Helper::get_stripe_fee( $order );
737
-		$currency = WC_Stripe_Helper::get_stripe_currency( $order );
736
+		$fee      = WC_Stripe_Helper::get_stripe_fee($order);
737
+		$currency = WC_Stripe_Helper::get_stripe_currency($order);
738 738
 
739
-		if ( ! $fee || ! $currency ) {
739
+		if ( ! $fee || ! $currency) {
740 740
 			return;
741 741
 		}
742 742
 
@@ -744,12 +744,12 @@  discard block
 block discarded – undo
744 744
 
745 745
 		<tr>
746 746
 			<td class="label stripe-fee">
747
-				<?php echo wc_help_tip( __( 'This represents the fee Stripe collects for the transaction.', 'woocommerce-gateway-stripe' ) ); // wpcs: xss ok. ?>
748
-				<?php esc_html_e( 'Stripe Fee:', 'woocommerce-gateway-stripe' ); ?>
747
+				<?php echo wc_help_tip(__('This represents the fee Stripe collects for the transaction.', 'woocommerce-gateway-stripe')); // wpcs: xss ok. ?>
748
+				<?php esc_html_e('Stripe Fee:', 'woocommerce-gateway-stripe'); ?>
749 749
 			</td>
750 750
 			<td width="1%"></td>
751 751
 			<td class="total">
752
-				-&nbsp;<?php echo wc_price( $fee, array( 'currency' => $currency ) ); // wpcs: xss ok. ?>
752
+				-&nbsp;<?php echo wc_price($fee, array('currency' => $currency)); // wpcs: xss ok. ?>
753 753
 			</td>
754 754
 		</tr>
755 755
 
@@ -763,17 +763,17 @@  discard block
 block discarded – undo
763 763
 	 *
764 764
 	 * @param int $order_id The ID of the order.
765 765
 	 */
766
-	public function display_order_payout( $order_id ) {
767
-		if ( apply_filters( 'wc_stripe_hide_display_order_payout', false, $order_id ) ) {
766
+	public function display_order_payout($order_id) {
767
+		if (apply_filters('wc_stripe_hide_display_order_payout', false, $order_id)) {
768 768
 			return;
769 769
 		}
770 770
 
771
-		$order = wc_get_order( $order_id );
771
+		$order = wc_get_order($order_id);
772 772
 
773
-		$net      = WC_Stripe_Helper::get_stripe_net( $order );
774
-		$currency = WC_Stripe_Helper::get_stripe_currency( $order );
773
+		$net      = WC_Stripe_Helper::get_stripe_net($order);
774
+		$currency = WC_Stripe_Helper::get_stripe_currency($order);
775 775
 
776
-		if ( ! $net || ! $currency ) {
776
+		if ( ! $net || ! $currency) {
777 777
 			return;
778 778
 		}
779 779
 
@@ -781,12 +781,12 @@  discard block
 block discarded – undo
781 781
 
782 782
 		<tr>
783 783
 			<td class="label stripe-payout">
784
-				<?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. ?>
785
-				<?php esc_html_e( 'Stripe Payout:', 'woocommerce-gateway-stripe' ); ?>
784
+				<?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. ?>
785
+				<?php esc_html_e('Stripe Payout:', 'woocommerce-gateway-stripe'); ?>
786 786
 			</td>
787 787
 			<td width="1%"></td>
788 788
 			<td class="total">
789
-				<?php echo wc_price( $net, array( 'currency' => $currency ) ); // wpcs: xss ok. ?>
789
+				<?php echo wc_price($net, array('currency' => $currency)); // wpcs: xss ok. ?>
790 790
 			</td>
791 791
 		</tr>
792 792
 
@@ -802,13 +802,13 @@  discard block
 block discarded – undo
802 802
 	 *
803 803
 	 * @return string The localized error message.
804 804
 	 */
805
-	public function get_localized_error_message_from_response( $response ) {
805
+	public function get_localized_error_message_from_response($response) {
806 806
 		$localized_messages = WC_Stripe_Helper::get_localized_messages();
807 807
 
808
-		if ( 'card_error' === $response->error->type ) {
809
-			$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
808
+		if ('card_error' === $response->error->type) {
809
+			$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
810 810
 		} else {
811
-			$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
811
+			$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
812 812
 		}
813 813
 
814 814
 		return $localized_message;
@@ -822,12 +822,12 @@  discard block
 block discarded – undo
822 822
 	 * @param  WC_Order $order     The order to add a note to.
823 823
 	 * @throws WC_Stripe_Exception An exception with the right message.
824 824
 	 */
825
-	public function throw_localized_message( $response, $order ) {
826
-		$localized_message = $this->get_localized_error_message_from_response( $response );
825
+	public function throw_localized_message($response, $order) {
826
+		$localized_message = $this->get_localized_error_message_from_response($response);
827 827
 
828
-		$order->add_order_note( $localized_message );
828
+		$order->add_order_note($localized_message);
829 829
 
830
-		throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
830
+		throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
831 831
 	}
832 832
 
833 833
 	/**
@@ -843,22 +843,22 @@  discard block
 block discarded – undo
843 843
 	 * @throws WC_Stripe_Exception        If the payment is not accepted.
844 844
 	 * @return array|void
845 845
 	 */
846
-	public function retry_after_error( $response, $order, $retry, $force_save_source, $previous_error, $use_order_source ) {
847
-		if ( ! $retry ) {
848
-			$localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' );
849
-			$order->add_order_note( $localized_message );
850
-			throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.
846
+	public function retry_after_error($response, $order, $retry, $force_save_source, $previous_error, $use_order_source) {
847
+		if ( ! $retry) {
848
+			$localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe');
849
+			$order->add_order_note($localized_message);
850
+			throw new WC_Stripe_Exception(print_r($response, true), $localized_message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.
851 851
 		}
852 852
 
853 853
 		// Don't do anymore retries after this.
854
-		if ( 5 <= $this->retry_interval ) {
855
-			return $this->process_payment( $order->get_id(), false, $force_save_source, $response->error, $previous_error );
854
+		if (5 <= $this->retry_interval) {
855
+			return $this->process_payment($order->get_id(), false, $force_save_source, $response->error, $previous_error);
856 856
 		}
857 857
 
858
-		sleep( $this->retry_interval );
858
+		sleep($this->retry_interval);
859 859
 		$this->retry_interval++;
860 860
 
861
-		return $this->process_payment( $order->get_id(), true, $force_save_source, $response->error, $previous_error, $use_order_source );
861
+		return $this->process_payment($order->get_id(), true, $force_save_source, $response->error, $previous_error, $use_order_source);
862 862
 	}
863 863
 
864 864
 	/**
@@ -869,23 +869,23 @@  discard block
 block discarded – undo
869 869
 	 * @param WC_Payment_Gateway[] $gateways A list of all available gateways.
870 870
 	 * @return WC_Payment_Gateway[]          Either the same list or an empty one in the right conditions.
871 871
 	 */
872
-	public function prepare_order_pay_page( $gateways ) {
873
-		if ( ! is_wc_endpoint_url( 'order-pay' ) || ! isset( $_GET['wc-stripe-confirmation'] ) ) { // wpcs: csrf ok.
872
+	public function prepare_order_pay_page($gateways) {
873
+		if ( ! is_wc_endpoint_url('order-pay') || ! isset($_GET['wc-stripe-confirmation'])) { // wpcs: csrf ok.
874 874
 			return $gateways;
875 875
 		}
876 876
 
877 877
 		try {
878 878
 			$this->prepare_intent_for_order_pay_page();
879
-		} catch ( WC_Stripe_Exception $e ) {
879
+		} catch (WC_Stripe_Exception $e) {
880 880
 			// Just show the full order pay page if there was a problem preparing the Payment Intent
881 881
 			return $gateways;
882 882
 		}
883 883
 
884
-		add_filter( 'woocommerce_checkout_show_terms', '__return_false' );
885
-		add_filter( 'woocommerce_pay_order_button_html', '__return_false' );
886
-		add_filter( 'woocommerce_available_payment_gateways', '__return_empty_array' );
887
-		add_filter( 'woocommerce_no_available_payment_methods_message', array( $this, 'change_no_available_methods_message' ) );
888
-		add_action( 'woocommerce_pay_order_after_submit', array( $this, 'render_payment_intent_inputs' ) );
884
+		add_filter('woocommerce_checkout_show_terms', '__return_false');
885
+		add_filter('woocommerce_pay_order_button_html', '__return_false');
886
+		add_filter('woocommerce_available_payment_gateways', '__return_empty_array');
887
+		add_filter('woocommerce_no_available_payment_methods_message', array($this, 'change_no_available_methods_message'));
888
+		add_action('woocommerce_pay_order_after_submit', array($this, 'render_payment_intent_inputs'));
889 889
 
890 890
 		return array();
891 891
 	}
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 	 * @return string the new message.
899 899
 	 */
900 900
 	public function change_no_available_methods_message() {
901
-		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' ) );
901
+		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'));
902 902
 	}
903 903
 
904 904
 	/**
@@ -909,19 +909,19 @@  discard block
 block discarded – undo
909 909
 	 * @throws WC_Stripe_Exception
910 910
 	 * @since 4.3
911 911
 	 */
912
-	public function prepare_intent_for_order_pay_page( $order = null ) {
913
-		if ( ! isset( $order ) || empty( $order ) ) {
914
-			$order = wc_get_order( absint( get_query_var( 'order-pay' ) ) );
912
+	public function prepare_intent_for_order_pay_page($order = null) {
913
+		if ( ! isset($order) || empty($order)) {
914
+			$order = wc_get_order(absint(get_query_var('order-pay')));
915 915
 		}
916
-		$intent = $this->get_intent_from_order( $order );
916
+		$intent = $this->get_intent_from_order($order);
917 917
 
918
-		if ( ! $intent ) {
919
-			throw new WC_Stripe_Exception( 'Payment Intent not found', __( 'Payment Intent not found for order #' . $order->get_id(), 'woocommerce-gateway-stripe' ) );
918
+		if ( ! $intent) {
919
+			throw new WC_Stripe_Exception('Payment Intent not found', __('Payment Intent not found for order #' . $order->get_id(), 'woocommerce-gateway-stripe'));
920 920
 		}
921 921
 
922
-		if ( 'requires_payment_method' === $intent->status && isset( $intent->last_payment_error )
923
-		     && 'authentication_required' === $intent->last_payment_error->code ) {
924
-			$level3_data = $this->get_level3_data_from_order( $order );
922
+		if ('requires_payment_method' === $intent->status && isset($intent->last_payment_error)
923
+		     && 'authentication_required' === $intent->last_payment_error->code) {
924
+			$level3_data = $this->get_level3_data_from_order($order);
925 925
 			$intent      = WC_Stripe_API::request_with_level3_data(
926 926
 				array(
927 927
 					'payment_method' => $intent->last_payment_error->source->id,
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 				$order
932 932
 			);
933 933
 
934
-			if ( isset( $intent->error ) ) {
935
-				throw new WC_Stripe_Exception( print_r( $intent, true ), $intent->error->message );
934
+			if (isset($intent->error)) {
935
+				throw new WC_Stripe_Exception(print_r($intent, true), $intent->error->message);
936 936
 			}
937 937
 		}
938 938
 
@@ -947,26 +947,26 @@  discard block
 block discarded – undo
947 947
 	 * @throws WC_Stripe_Exception
948 948
 	 * @since 4.2
949 949
 	 */
950
-	public function render_payment_intent_inputs( $order = null ) {
951
-		if ( ! isset( $order ) || empty( $order ) ) {
952
-			$order = wc_get_order( absint( get_query_var( 'order-pay' ) ) );
950
+	public function render_payment_intent_inputs($order = null) {
951
+		if ( ! isset($order) || empty($order)) {
952
+			$order = wc_get_order(absint(get_query_var('order-pay')));
953 953
 		}
954
-		if ( ! isset( $this->order_pay_intent ) ) {
955
-			$this->prepare_intent_for_order_pay_page( $order );
954
+		if ( ! isset($this->order_pay_intent)) {
955
+			$this->prepare_intent_for_order_pay_page($order);
956 956
 		}
957 957
 
958 958
 		$verification_url = add_query_arg(
959 959
 			array(
960 960
 				'order'            => $order->get_id(),
961
-				'nonce'            => wp_create_nonce( 'wc_stripe_confirm_pi' ),
962
-				'redirect_to'      => rawurlencode( $this->get_return_url( $order ) ),
961
+				'nonce'            => wp_create_nonce('wc_stripe_confirm_pi'),
962
+				'redirect_to'      => rawurlencode($this->get_return_url($order)),
963 963
 				'is_pay_for_order' => true,
964 964
 			),
965
-			WC_AJAX::get_endpoint( 'wc_stripe_verify_intent' )
965
+			WC_AJAX::get_endpoint('wc_stripe_verify_intent')
966 966
 		);
967 967
 
968
-		echo '<input type="hidden" id="stripe-intent-id" value="' . esc_attr( $this->order_pay_intent->client_secret ) . '" />';
969
-		echo '<input type="hidden" id="stripe-intent-return" value="' . esc_attr( $verification_url ) . '" />';
968
+		echo '<input type="hidden" id="stripe-intent-id" value="' . esc_attr($this->order_pay_intent->client_secret) . '" />';
969
+		echo '<input type="hidden" id="stripe-intent-return" value="' . esc_attr($verification_url) . '" />';
970 970
 	}
971 971
 
972 972
 	/**
@@ -976,11 +976,11 @@  discard block
 block discarded – undo
976 976
 	 * @param WC_Payment_Token $token Payment Token.
977 977
 	 * @return string                 Generated payment method HTML
978 978
 	 */
979
-	public function get_saved_payment_method_option_html( $token ) {
980
-		$html          = parent::get_saved_payment_method_option_html( $token );
979
+	public function get_saved_payment_method_option_html($token) {
980
+		$html          = parent::get_saved_payment_method_option_html($token);
981 981
 		$error_wrapper = '<div class="stripe-source-errors" role="alert"></div>';
982 982
 
983
-		return preg_replace( '~</(\w+)>\s*$~', "$error_wrapper</$1>", $html );
983
+		return preg_replace('~</(\w+)>\s*$~', "$error_wrapper</$1>", $html);
984 984
 	}
985 985
 
986 986
 	/**
@@ -990,18 +990,18 @@  discard block
 block discarded – undo
990 990
 	 * @since 4.2.0
991 991
 	 * @param int $order_id The ID that will be used for the thank you page.
992 992
 	 */
993
-	public function check_intent_status_on_order_page( $order_id ) {
994
-		if ( empty( $order_id ) || absint( $order_id ) <= 0 ) {
993
+	public function check_intent_status_on_order_page($order_id) {
994
+		if (empty($order_id) || absint($order_id) <= 0) {
995 995
 			return;
996 996
 		}
997 997
 
998
-		$order = wc_get_order( absint( $order_id ) );
998
+		$order = wc_get_order(absint($order_id));
999 999
 
1000
-		if ( ! $order ) {
1000
+		if ( ! $order) {
1001 1001
 			return;
1002 1002
 		}
1003 1003
 
1004
-		$this->verify_intent_after_checkout( $order );
1004
+		$this->verify_intent_after_checkout($order);
1005 1005
 	}
1006 1006
 
1007 1007
 	/**
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
 	 * @param int   $order_id The ID of the order which is being paid for.
1016 1016
 	 * @return array
1017 1017
 	 */
1018
-	public function modify_successful_payment_result( $result, $order_id ) {
1019
-		if ( ! isset( $result['payment_intent_secret'] ) && ! isset( $result['setup_intent_secret'] ) ) {
1018
+	public function modify_successful_payment_result($result, $order_id) {
1019
+		if ( ! isset($result['payment_intent_secret']) && ! isset($result['setup_intent_secret'])) {
1020 1020
 			// Only redirects with intents need to be modified.
1021 1021
 			return $result;
1022 1022
 		}
@@ -1025,16 +1025,16 @@  discard block
 block discarded – undo
1025 1025
 		$verification_url = add_query_arg(
1026 1026
 			array(
1027 1027
 				'order'       => $order_id,
1028
-				'nonce'       => wp_create_nonce( 'wc_stripe_confirm_pi' ),
1029
-				'redirect_to' => rawurlencode( $result['redirect'] ),
1028
+				'nonce'       => wp_create_nonce('wc_stripe_confirm_pi'),
1029
+				'redirect_to' => rawurlencode($result['redirect']),
1030 1030
 			),
1031
-			WC_AJAX::get_endpoint( 'wc_stripe_verify_intent' )
1031
+			WC_AJAX::get_endpoint('wc_stripe_verify_intent')
1032 1032
 		);
1033 1033
 
1034
-		if ( isset( $result['payment_intent_secret'] ) ) {
1035
-			$redirect = sprintf( '#confirm-pi-%s:%s', $result['payment_intent_secret'], rawurlencode( $verification_url ) );
1036
-		} else if ( isset( $result['setup_intent_secret'] ) ) {
1037
-			$redirect = sprintf( '#confirm-si-%s:%s', $result['setup_intent_secret'], rawurlencode( $verification_url ) );
1034
+		if (isset($result['payment_intent_secret'])) {
1035
+			$redirect = sprintf('#confirm-pi-%s:%s', $result['payment_intent_secret'], rawurlencode($verification_url));
1036
+		} else if (isset($result['setup_intent_secret'])) {
1037
+			$redirect = sprintf('#confirm-si-%s:%s', $result['setup_intent_secret'], rawurlencode($verification_url));
1038 1038
 		}
1039 1039
 
1040 1040
 		return array(
@@ -1046,8 +1046,8 @@  discard block
 block discarded – undo
1046 1046
 	/**
1047 1047
 	 * Proceed with current request using new login session (to ensure consistent nonce).
1048 1048
 	 */
1049
-	public function set_cookie_on_current_request( $cookie ) {
1050
-		$_COOKIE[ LOGGED_IN_COOKIE ] = $cookie;
1049
+	public function set_cookie_on_current_request($cookie) {
1050
+		$_COOKIE[LOGGED_IN_COOKIE] = $cookie;
1051 1051
 	}
1052 1052
 
1053 1053
 	/**
@@ -1057,48 +1057,48 @@  discard block
 block discarded – undo
1057 1057
 	 * @since 4.2.0
1058 1058
 	 * @param WC_Order $order The order which is in a transitional state.
1059 1059
 	 */
1060
-	public function verify_intent_after_checkout( $order ) {
1060
+	public function verify_intent_after_checkout($order) {
1061 1061
 		$payment_method = $order->get_payment_method();
1062
-		if ( $payment_method !== $this->id ) {
1062
+		if ($payment_method !== $this->id) {
1063 1063
 			// If this is not the payment method, an intent would not be available.
1064 1064
 			return;
1065 1065
 		}
1066 1066
 
1067
-		$intent = $this->get_intent_from_order( $order );
1068
-		if ( ! $intent ) {
1067
+		$intent = $this->get_intent_from_order($order);
1068
+		if ( ! $intent) {
1069 1069
 			// No intent, redirect to the order received page for further actions.
1070 1070
 			return;
1071 1071
 		}
1072 1072
 
1073 1073
 		// A webhook might have modified or locked the order while the intent was retreived. This ensures we are reading the right status.
1074
-		clean_post_cache( $order->get_id() );
1075
-		$order = wc_get_order( $order->get_id() );
1074
+		clean_post_cache($order->get_id());
1075
+		$order = wc_get_order($order->get_id());
1076 1076
 
1077
-		if ( ! $order->has_status( array( 'pending', 'failed' ) ) ) {
1077
+		if ( ! $order->has_status(array('pending', 'failed'))) {
1078 1078
 			// If payment has already been completed, this function is redundant.
1079 1079
 			return;
1080 1080
 		}
1081 1081
 
1082
-		if ( $this->lock_order_payment( $order, $intent ) ) {
1082
+		if ($this->lock_order_payment($order, $intent)) {
1083 1083
 			return;
1084 1084
 		}
1085 1085
 
1086
-		if ( 'setup_intent' === $intent->object && 'succeeded' === $intent->status ) {
1086
+		if ('setup_intent' === $intent->object && 'succeeded' === $intent->status) {
1087 1087
 			WC()->cart->empty_cart();
1088
-			if ( WC_Stripe_Helper::is_pre_orders_exists() && WC_Pre_Orders_Order::order_contains_pre_order( $order ) ) {
1089
-				WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order );
1088
+			if (WC_Stripe_Helper::is_pre_orders_exists() && WC_Pre_Orders_Order::order_contains_pre_order($order)) {
1089
+				WC_Pre_Orders_Order::mark_order_as_pre_ordered($order);
1090 1090
 			} else {
1091 1091
 				$order->payment_complete();
1092 1092
 			}
1093
-		} else if ( 'succeeded' === $intent->status || 'requires_capture' === $intent->status ) {
1093
+		} else if ('succeeded' === $intent->status || 'requires_capture' === $intent->status) {
1094 1094
 			// Proceed with the payment completion.
1095
-			$this->handle_intent_verification_success( $order, $intent );
1096
-		} else if ( 'requires_payment_method' === $intent->status ) {
1095
+			$this->handle_intent_verification_success($order, $intent);
1096
+		} else if ('requires_payment_method' === $intent->status) {
1097 1097
 			// `requires_payment_method` means that SCA got denied for the current payment method.
1098
-			$this->handle_intent_verification_failure( $order, $intent );
1098
+			$this->handle_intent_verification_failure($order, $intent);
1099 1099
 		}
1100 1100
 
1101
-		$this->unlock_order_payment( $order );
1101
+		$this->unlock_order_payment($order);
1102 1102
 	}
1103 1103
 
1104 1104
 	/**
@@ -1108,8 +1108,8 @@  discard block
 block discarded – undo
1108 1108
 	 * @param WC_Order $order The order whose verification succeeded.
1109 1109
 	 * @param stdClass $intent The Payment Intent object.
1110 1110
 	 */
1111
-	protected function handle_intent_verification_success( $order, $intent ) {
1112
-		$this->process_response( end( $intent->charges->data ), $order );
1111
+	protected function handle_intent_verification_success($order, $intent) {
1112
+		$this->process_response(end($intent->charges->data), $order);
1113 1113
 	}
1114 1114
 
1115 1115
 	/**
@@ -1119,8 +1119,8 @@  discard block
 block discarded – undo
1119 1119
 	 * @param WC_Order $order The order whose verification failed.
1120 1120
 	 * @param stdClass $intent The Payment Intent object.
1121 1121
 	 */
1122
-	protected function handle_intent_verification_failure( $order, $intent ) {
1123
-		$this->failed_sca_auth( $order, $intent );
1122
+	protected function handle_intent_verification_failure($order, $intent) {
1123
+		$this->failed_sca_auth($order, $intent);
1124 1124
 	}
1125 1125
 
1126 1126
 	/**
@@ -1130,18 +1130,18 @@  discard block
 block discarded – undo
1130 1130
 	 * @param WC_Order $order  The order which should be checked.
1131 1131
 	 * @param object   $intent The intent, associated with the order.
1132 1132
 	 */
1133
-	public function failed_sca_auth( $order, $intent ) {
1133
+	public function failed_sca_auth($order, $intent) {
1134 1134
 		// If the order has already failed, do not repeat the same message.
1135
-		if ( $order->has_status( 'failed' ) ) {
1135
+		if ($order->has_status('failed')) {
1136 1136
 			return;
1137 1137
 		}
1138 1138
 
1139 1139
 		// Load the right message and update the status.
1140
-		$status_message = isset( $intent->last_payment_error )
1140
+		$status_message = isset($intent->last_payment_error)
1141 1141
 			/* translators: 1) The error message that was received from Stripe. */
1142
-			? sprintf( __( 'Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe' ), $intent->last_payment_error->message )
1143
-			: __( 'Stripe SCA authentication failed.', 'woocommerce-gateway-stripe' );
1144
-		$order->update_status( 'failed', $status_message );
1142
+			? sprintf(__('Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe'), $intent->last_payment_error->message)
1143
+			: __('Stripe SCA authentication failed.', 'woocommerce-gateway-stripe');
1144
+		$order->update_status('failed', $status_message);
1145 1145
 	}
1146 1146
 
1147 1147
 	/**
@@ -1152,10 +1152,10 @@  discard block
 block discarded – undo
1152 1152
 	 *
1153 1153
 	 * @return string Checkout URL for the given order.
1154 1154
 	 */
1155
-	public function get_checkout_payment_url( $pay_url, $order ) {
1155
+	public function get_checkout_payment_url($pay_url, $order) {
1156 1156
 		global $wp;
1157
-		if ( isset( $_GET['wc-stripe-confirmation'] ) && isset( $wp->query_vars['order-pay'] ) && $wp->query_vars['order-pay'] == $order->get_id() ) {
1158
-			$pay_url = add_query_arg( 'wc-stripe-confirmation', 1, $pay_url );
1157
+		if (isset($_GET['wc-stripe-confirmation']) && isset($wp->query_vars['order-pay']) && $wp->query_vars['order-pay'] == $order->get_id()) {
1158
+			$pay_url = add_query_arg('wc-stripe-confirmation', 1, $pay_url);
1159 1159
 		}
1160 1160
 		return $pay_url;
1161 1161
 	}
@@ -1165,63 +1165,63 @@  discard block
 block discarded – undo
1165 1165
 	 */
1166 1166
 	public function process_admin_options() {
1167 1167
 		// Load all old values before the new settings get saved.
1168
-		$old_publishable_key      = $this->get_option( 'publishable_key' );
1169
-		$old_secret_key           = $this->get_option( 'secret_key' );
1170
-		$old_test_publishable_key = $this->get_option( 'test_publishable_key' );
1171
-		$old_test_secret_key      = $this->get_option( 'test_secret_key' );
1168
+		$old_publishable_key      = $this->get_option('publishable_key');
1169
+		$old_secret_key           = $this->get_option('secret_key');
1170
+		$old_test_publishable_key = $this->get_option('test_publishable_key');
1171
+		$old_test_secret_key      = $this->get_option('test_secret_key');
1172 1172
 
1173 1173
 		parent::process_admin_options();
1174 1174
 
1175 1175
 		// Load all old values after the new settings have been saved.
1176
-		$new_publishable_key      = $this->get_option( 'publishable_key' );
1177
-		$new_secret_key           = $this->get_option( 'secret_key' );
1178
-		$new_test_publishable_key = $this->get_option( 'test_publishable_key' );
1179
-		$new_test_secret_key      = $this->get_option( 'test_secret_key' );
1176
+		$new_publishable_key      = $this->get_option('publishable_key');
1177
+		$new_secret_key           = $this->get_option('secret_key');
1178
+		$new_test_publishable_key = $this->get_option('test_publishable_key');
1179
+		$new_test_secret_key      = $this->get_option('test_secret_key');
1180 1180
 
1181 1181
 		// Checks whether a value has transitioned from a non-empty value to a new one.
1182
-		$has_changed = function( $old_value, $new_value ) {
1183
-			return ! empty( $old_value ) && ( $old_value !== $new_value );
1182
+		$has_changed = function($old_value, $new_value) {
1183
+			return ! empty($old_value) && ($old_value !== $new_value);
1184 1184
 		};
1185 1185
 
1186 1186
 		// Look for updates.
1187 1187
 		if (
1188
-			$has_changed( $old_publishable_key, $new_publishable_key )
1189
-			|| $has_changed( $old_secret_key, $new_secret_key )
1190
-			|| $has_changed( $old_test_publishable_key, $new_test_publishable_key )
1191
-			|| $has_changed( $old_test_secret_key, $new_test_secret_key )
1188
+			$has_changed($old_publishable_key, $new_publishable_key)
1189
+			|| $has_changed($old_secret_key, $new_secret_key)
1190
+			|| $has_changed($old_test_publishable_key, $new_test_publishable_key)
1191
+			|| $has_changed($old_test_secret_key, $new_test_secret_key)
1192 1192
 		) {
1193
-			update_option( 'wc_stripe_show_changed_keys_notice', 'yes' );
1193
+			update_option('wc_stripe_show_changed_keys_notice', 'yes');
1194 1194
 		}
1195 1195
 	}
1196 1196
 
1197
-	public function validate_publishable_key_field( $key, $value ) {
1198
-		$value = $this->validate_text_field( $key, $value );
1199
-		if ( ! empty( $value ) && ! preg_match( '/^pk_live_/', $value ) ) {
1200
-			throw new Exception( __( 'The "Live Publishable Key" should start with "pk_live", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1197
+	public function validate_publishable_key_field($key, $value) {
1198
+		$value = $this->validate_text_field($key, $value);
1199
+		if ( ! empty($value) && ! preg_match('/^pk_live_/', $value)) {
1200
+			throw new Exception(__('The "Live Publishable Key" should start with "pk_live", enter the correct key.', 'woocommerce-gateway-stripe'));
1201 1201
 		}
1202 1202
 		return $value;
1203 1203
 	}
1204 1204
 
1205
-	public function validate_secret_key_field( $key, $value ) {
1206
-		$value = $this->validate_text_field( $key, $value );
1207
-		if ( ! empty( $value ) && ! preg_match( '/^[rs]k_live_/', $value ) ) {
1208
-			throw new Exception( __( 'The "Live Secret Key" should start with "sk_live" or "rk_live", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1205
+	public function validate_secret_key_field($key, $value) {
1206
+		$value = $this->validate_text_field($key, $value);
1207
+		if ( ! empty($value) && ! preg_match('/^[rs]k_live_/', $value)) {
1208
+			throw new Exception(__('The "Live Secret Key" should start with "sk_live" or "rk_live", enter the correct key.', 'woocommerce-gateway-stripe'));
1209 1209
 		}
1210 1210
 		return $value;
1211 1211
 	}
1212 1212
 
1213
-	public function validate_test_publishable_key_field( $key, $value ) {
1214
-		$value = $this->validate_text_field( $key, $value );
1215
-		if ( ! empty( $value ) && ! preg_match( '/^pk_test_/', $value ) ) {
1216
-			throw new Exception( __( 'The "Test Publishable Key" should start with "pk_test", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1213
+	public function validate_test_publishable_key_field($key, $value) {
1214
+		$value = $this->validate_text_field($key, $value);
1215
+		if ( ! empty($value) && ! preg_match('/^pk_test_/', $value)) {
1216
+			throw new Exception(__('The "Test Publishable Key" should start with "pk_test", enter the correct key.', 'woocommerce-gateway-stripe'));
1217 1217
 		}
1218 1218
 		return $value;
1219 1219
 	}
1220 1220
 
1221
-	public function validate_test_secret_key_field( $key, $value ) {
1222
-		$value = $this->validate_text_field( $key, $value );
1223
-		if ( ! empty( $value ) && ! preg_match( '/^[rs]k_test_/', $value ) ) {
1224
-			throw new Exception( __( 'The "Test Secret Key" should start with "sk_test" or "rk_test", enter the correct key.', 'woocommerce-gateway-stripe' ) );
1221
+	public function validate_test_secret_key_field($key, $value) {
1222
+		$value = $this->validate_text_field($key, $value);
1223
+		if ( ! empty($value) && ! preg_match('/^[rs]k_test_/', $value)) {
1224
+			throw new Exception(__('The "Test Secret Key" should start with "sk_test" or "rk_test", enter the correct key.', 'woocommerce-gateway-stripe'));
1225 1225
 		}
1226 1226
 		return $value;
1227 1227
 	}
Please login to merge, or discard this patch.