x Sorry, these patches are not available anymore due to data migration. Please run a fresh inspection.
Completed
Push — master ( e1ae54...c6044c )
by Roy
02:21
created
includes/class-wc-stripe-customer.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -213,7 +213,6 @@
 block discarded – undo
213 213
 	/**
214 214
 	 * Get a customers saved sources using their Stripe ID.
215 215
 	 *
216
-	 * @param  string $customer_id
217 216
 	 * @return array
218 217
 	 */
219 218
 	public function get_sources() {
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 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
 
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 	 * Constructor
33 33
 	 * @param int $user_id The WP user ID
34 34
 	 */
35
-	public function __construct( $user_id = 0 ) {
36
-		if ( $user_id ) {
37
-			$this->set_user_id( $user_id );
38
-			$this->set_id( get_user_meta( $user_id, '_stripe_customer_id', true ) );
35
+	public function __construct($user_id = 0) {
36
+		if ($user_id) {
37
+			$this->set_user_id($user_id);
38
+			$this->set_id(get_user_meta($user_id, '_stripe_customer_id', true));
39 39
 		}
40 40
 	}
41 41
 
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 * Set Stripe customer ID.
52 52
 	 * @param [type] $id [description]
53 53
 	 */
54
-	public function set_id( $id ) {
55
-		$this->id = wc_clean( $id );
54
+	public function set_id($id) {
55
+		$this->id = wc_clean($id);
56 56
 	}
57 57
 
58 58
 	/**
@@ -60,15 +60,15 @@  discard block
 block discarded – undo
60 60
 	 * @return int
61 61
 	 */
62 62
 	public function get_user_id() {
63
-		return absint( $this->user_id );
63
+		return absint($this->user_id);
64 64
 	}
65 65
 
66 66
 	/**
67 67
 	 * Set User ID used by WordPress.
68 68
 	 * @param int $user_id
69 69
 	 */
70
-	public function set_user_id( $user_id ) {
71
-		$this->user_id = absint( $user_id );
70
+	public function set_user_id($user_id) {
71
+		$this->user_id = absint($user_id);
72 72
 	}
73 73
 
74 74
 	/**
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
 	 * @return WP_User
77 77
 	 */
78 78
 	protected function get_user() {
79
-		return $this->get_user_id() ? get_user_by( 'id', $this->get_user_id() ) : false;
79
+		return $this->get_user_id() ? get_user_by('id', $this->get_user_id()) : false;
80 80
 	}
81 81
 
82 82
 	/**
83 83
 	 * Store data from the Stripe API about this customer
84 84
 	 */
85
-	public function set_customer_data( $data ) {
85
+	public function set_customer_data($data) {
86 86
 		$this->customer_data = $data;
87 87
 	}
88 88
 
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 	 * @param array $args
92 92
 	 * @return WP_Error|int
93 93
 	 */
94
-	public function create_customer( $args = array() ) {
95
-		$billing_email = isset( $_POST['billing_email'] ) ? filter_var( $_POST['billing_email'], FILTER_SANITIZE_EMAIL ) : '';
94
+	public function create_customer($args = array()) {
95
+		$billing_email = isset($_POST['billing_email']) ? filter_var($_POST['billing_email'], FILTER_SANITIZE_EMAIL) : '';
96 96
 		$user = $this->get_user();
97 97
 
98
-		if ( $user ) {
99
-			$billing_first_name = get_user_meta( $user->ID, 'billing_first_name', true );
100
-			$billing_last_name  = get_user_meta( $user->ID, 'billing_last_name', true );
98
+		if ($user) {
99
+			$billing_first_name = get_user_meta($user->ID, 'billing_first_name', true);
100
+			$billing_last_name  = get_user_meta($user->ID, 'billing_last_name', true);
101 101
 
102 102
 			$defaults = array(
103 103
 				'email'       => $user->user_email,
@@ -112,24 +112,24 @@  discard block
 block discarded – undo
112 112
 
113 113
 		$metadata = array();
114 114
 
115
-		$defaults['metadata'] = apply_filters( 'wc_stripe_customer_metadata', $metadata, $user );
115
+		$defaults['metadata'] = apply_filters('wc_stripe_customer_metadata', $metadata, $user);
116 116
 
117
-		$args     = wp_parse_args( $args, $defaults );
118
-		$response = WC_Stripe_API::request( apply_filters( 'wc_stripe_create_customer_args', $args ), 'customers' );
117
+		$args     = wp_parse_args($args, $defaults);
118
+		$response = WC_Stripe_API::request(apply_filters('wc_stripe_create_customer_args', $args), 'customers');
119 119
 
120
-		if ( ! empty( $response->error ) ) {
121
-			throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
120
+		if ( ! empty($response->error)) {
121
+			throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
122 122
 		}
123 123
 
124
-		$this->set_id( $response->id );
124
+		$this->set_id($response->id);
125 125
 		$this->clear_cache();
126
-		$this->set_customer_data( $response );
126
+		$this->set_customer_data($response);
127 127
 
128
-		if ( $this->get_user_id() ) {
129
-			update_user_meta( $this->get_user_id(), '_stripe_customer_id', $response->id );
128
+		if ($this->get_user_id()) {
129
+			update_user_meta($this->get_user_id(), '_stripe_customer_id', $response->id);
130 130
 		}
131 131
 
132
-		do_action( 'woocommerce_stripe_add_customer', $args, $response );
132
+		do_action('woocommerce_stripe_add_customer', $args, $response);
133 133
 
134 134
 		return $response->id;
135 135
 	}
@@ -140,72 +140,72 @@  discard block
 block discarded – undo
140 140
 	 * @param bool $retry
141 141
 	 * @return WP_Error|int
142 142
 	 */
143
-	public function add_source( $source_id, $retry = true ) {
144
-		if ( ! $this->get_id() ) {
145
-			$this->set_id( $this->create_customer() );
143
+	public function add_source($source_id, $retry = true) {
144
+		if ( ! $this->get_id()) {
145
+			$this->set_id($this->create_customer());
146 146
 		}
147 147
 
148
-		$response = WC_Stripe_API::request( array(
148
+		$response = WC_Stripe_API::request(array(
149 149
 			'source' => $source_id,
150
-		), 'customers/' . $this->get_id() . '/sources' );
150
+		), 'customers/' . $this->get_id() . '/sources');
151 151
 
152
-		if ( ! empty( $response->error ) ) {
152
+		if ( ! empty($response->error)) {
153 153
 			// It is possible the WC user once was linked to a customer on Stripe
154 154
 			// but no longer exists. Instead of failing, lets try to create a
155 155
 			// new customer.
156
-			if ( preg_match( '/No such customer/i', $response->error->message ) ) {
157
-				delete_user_meta( $this->get_user_id(), '_stripe_customer_id' );
156
+			if (preg_match('/No such customer/i', $response->error->message)) {
157
+				delete_user_meta($this->get_user_id(), '_stripe_customer_id');
158 158
 				$this->create_customer();
159
-				return $this->add_source( $source_id, false );
159
+				return $this->add_source($source_id, false);
160 160
 			} else {
161 161
 				return $response;
162 162
 			}
163
-		} elseif ( empty( $response->id ) ) {
164
-			return new WP_Error( 'error', __( 'Unable to add payment source.', 'woocommerce-gateway-stripe' ) );
163
+		} elseif (empty($response->id)) {
164
+			return new WP_Error('error', __('Unable to add payment source.', 'woocommerce-gateway-stripe'));
165 165
 		}
166 166
 
167 167
 		// Add token to WooCommerce.
168
-		if ( $this->get_user_id() && class_exists( 'WC_Payment_Token_CC' ) ) {
169
-			if ( ! empty( $response->type ) ) {
170
-				switch ( $response->type ) {
168
+		if ($this->get_user_id() && class_exists('WC_Payment_Token_CC')) {
169
+			if ( ! empty($response->type)) {
170
+				switch ($response->type) {
171 171
 					case 'alipay':
172 172
 						break;
173 173
 					case 'sepa_debit':
174 174
 						$wc_token = new WC_Payment_Token_SEPA();
175
-						$wc_token->set_token( $response->id );
176
-						$wc_token->set_gateway_id( 'stripe_sepa' );
177
-						$wc_token->set_last4( $response->sepa_debit->last4 );
175
+						$wc_token->set_token($response->id);
176
+						$wc_token->set_gateway_id('stripe_sepa');
177
+						$wc_token->set_last4($response->sepa_debit->last4);
178 178
 						break;
179 179
 					default:
180
-						if ( 'source' === $response->object && 'card' === $response->type ) {
180
+						if ('source' === $response->object && 'card' === $response->type) {
181 181
 							$wc_token = new WC_Payment_Token_CC();
182
-							$wc_token->set_token( $response->id );
183
-							$wc_token->set_gateway_id( 'stripe' );
184
-							$wc_token->set_card_type( strtolower( $response->card->brand ) );
185
-							$wc_token->set_last4( $response->card->last4 );
186
-							$wc_token->set_expiry_month( $response->card->exp_month );
187
-							$wc_token->set_expiry_year( $response->card->exp_year );
182
+							$wc_token->set_token($response->id);
183
+							$wc_token->set_gateway_id('stripe');
184
+							$wc_token->set_card_type(strtolower($response->card->brand));
185
+							$wc_token->set_last4($response->card->last4);
186
+							$wc_token->set_expiry_month($response->card->exp_month);
187
+							$wc_token->set_expiry_year($response->card->exp_year);
188 188
 						}
189 189
 						break;
190 190
 				}
191 191
 			} else {
192 192
 				// Legacy.
193 193
 				$wc_token = new WC_Payment_Token_CC();
194
-				$wc_token->set_token( $response->id );
195
-				$wc_token->set_gateway_id( 'stripe' );
196
-				$wc_token->set_card_type( strtolower( $response->brand ) );
197
-				$wc_token->set_last4( $response->last4 );
198
-				$wc_token->set_expiry_month( $response->exp_month );
199
-				$wc_token->set_expiry_year( $response->exp_year );
194
+				$wc_token->set_token($response->id);
195
+				$wc_token->set_gateway_id('stripe');
196
+				$wc_token->set_card_type(strtolower($response->brand));
197
+				$wc_token->set_last4($response->last4);
198
+				$wc_token->set_expiry_month($response->exp_month);
199
+				$wc_token->set_expiry_year($response->exp_year);
200 200
 			}
201 201
 
202
-			$wc_token->set_user_id( $this->get_user_id() );
202
+			$wc_token->set_user_id($this->get_user_id());
203 203
 			$wc_token->save();
204 204
 		}
205 205
 
206 206
 		$this->clear_cache();
207 207
 
208
-		do_action( 'woocommerce_stripe_add_source', $this->get_id(), $wc_token, $response, $source_id );
208
+		do_action('woocommerce_stripe_add_source', $this->get_id(), $wc_token, $response, $source_id);
209 209
 
210 210
 		return $response->id;
211 211
 	}
@@ -217,42 +217,42 @@  discard block
 block discarded – undo
217 217
 	 * @return array
218 218
 	 */
219 219
 	public function get_sources() {
220
-		if ( ! $this->get_id() ) {
220
+		if ( ! $this->get_id()) {
221 221
 			return array();
222 222
 		}
223 223
 
224
-		$sources = get_transient( 'stripe_sources_' . $this->get_id() );
224
+		$sources = get_transient('stripe_sources_' . $this->get_id());
225 225
 
226
-		$response = WC_Stripe_API::request( array(
226
+		$response = WC_Stripe_API::request(array(
227 227
 			'limit'       => 100,
228
-		), 'customers/' . $this->get_id() . '/sources', 'GET' );
228
+		), 'customers/' . $this->get_id() . '/sources', 'GET');
229 229
 
230
-		if ( ! empty( $response->error ) ) {
230
+		if ( ! empty($response->error)) {
231 231
 			return array();
232 232
 		}
233 233
 
234
-		if ( is_array( $response->data ) ) {
234
+		if (is_array($response->data)) {
235 235
 			$sources = $response->data;
236 236
 		}
237 237
 
238
-		return empty( $sources ) ? array() : $sources;
238
+		return empty($sources) ? array() : $sources;
239 239
 	}
240 240
 
241 241
 	/**
242 242
 	 * Delete a source from stripe.
243 243
 	 * @param string $source_id
244 244
 	 */
245
-	public function delete_source( $source_id ) {
246
-		if ( ! $this->get_id() ) {
245
+	public function delete_source($source_id) {
246
+		if ( ! $this->get_id()) {
247 247
 			return false;
248 248
 		}
249 249
 
250
-		$response = WC_Stripe_API::request( array(), 'customers/' . $this->get_id() . '/sources/' . sanitize_text_field( $source_id ), 'DELETE' );
250
+		$response = WC_Stripe_API::request(array(), 'customers/' . $this->get_id() . '/sources/' . sanitize_text_field($source_id), 'DELETE');
251 251
 
252 252
 		$this->clear_cache();
253 253
 
254
-		if ( empty( $response->error ) ) {
255
-			do_action( 'wc_stripe_delete_source', $this->get_id(), $response );
254
+		if (empty($response->error)) {
255
+			do_action('wc_stripe_delete_source', $this->get_id(), $response);
256 256
 
257 257
 			return true;
258 258
 		}
@@ -264,15 +264,15 @@  discard block
 block discarded – undo
264 264
 	 * Set default source in Stripe
265 265
 	 * @param string $source_id
266 266
 	 */
267
-	public function set_default_source( $source_id ) {
268
-		$response = WC_Stripe_API::request( array(
269
-			'default_source' => sanitize_text_field( $source_id ),
270
-		), 'customers/' . $this->get_id(), 'POST' );
267
+	public function set_default_source($source_id) {
268
+		$response = WC_Stripe_API::request(array(
269
+			'default_source' => sanitize_text_field($source_id),
270
+		), 'customers/' . $this->get_id(), 'POST');
271 271
 
272 272
 		$this->clear_cache();
273 273
 
274
-		if ( empty( $response->error ) ) {
275
-			do_action( 'wc_stripe_set_default_source', $this->get_id(), $response );
274
+		if (empty($response->error)) {
275
+			do_action('wc_stripe_set_default_source', $this->get_id(), $response);
276 276
 
277 277
 			return true;
278 278
 		}
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 	 * Deletes caches for this users cards.
285 285
 	 */
286 286
 	public function clear_cache() {
287
-		delete_transient( 'stripe_sources_' . $this->get_id() );
288
-		delete_transient( 'stripe_customer_' . $this->get_id() );
287
+		delete_transient('stripe_sources_' . $this->get_id());
288
+		delete_transient('stripe_customer_' . $this->get_id());
289 289
 		$this->customer_data = array();
290 290
 	}
291 291
 }
Please login to merge, or discard this patch.
includes/admin/stripe-settings.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,184 +1,184 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6 6
 $webhook_url = WC_Stripe_Helper::get_webhook_url();
7 7
 
8
-return apply_filters( 'wc_stripe_settings',
8
+return apply_filters('wc_stripe_settings',
9 9
 	array(
10 10
 		'enabled' => array(
11
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
12
-			'label'       => __( 'Enable Stripe', 'woocommerce-gateway-stripe' ),
11
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
12
+			'label'       => __('Enable Stripe', 'woocommerce-gateway-stripe'),
13 13
 			'type'        => 'checkbox',
14 14
 			'description' => '',
15 15
 			'default'     => 'no',
16 16
 		),
17 17
 		'title' => array(
18
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
18
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
19 19
 			'type'        => 'text',
20
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
21
-			'default'     => __( 'Credit Card (Stripe)', 'woocommerce-gateway-stripe' ),
20
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
21
+			'default'     => __('Credit Card (Stripe)', 'woocommerce-gateway-stripe'),
22 22
 			'desc_tip'    => true,
23 23
 		),
24 24
 		'description' => array(
25
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
25
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
26 26
 			'type'        => 'text',
27
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
28
-			'default'     => __( 'Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe' ),
27
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
28
+			'default'     => __('Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe'),
29 29
 			'desc_tip'    => true,
30 30
 		),
31 31
 		'webhook' => array(
32
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
32
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
33 33
 			'type'        => 'title',
34 34
 			/* translators: webhook URL */
35
-			'description' => sprintf( __( 'You must add the webhook endpoint <strong style="background-color:#ddd;">&nbsp;&nbsp;%s&nbsp;&nbsp;</strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe' ), $webhook_url ),
35
+			'description' => sprintf(__('You must add the webhook endpoint <strong style="background-color:#ddd;">&nbsp;&nbsp;%s&nbsp;&nbsp;</strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe'), $webhook_url),
36 36
 		),
37 37
 		'testmode' => array(
38
-			'title'       => __( 'Test mode', 'woocommerce-gateway-stripe' ),
39
-			'label'       => __( 'Enable Test Mode', 'woocommerce-gateway-stripe' ),
38
+			'title'       => __('Test mode', 'woocommerce-gateway-stripe'),
39
+			'label'       => __('Enable Test Mode', 'woocommerce-gateway-stripe'),
40 40
 			'type'        => 'checkbox',
41
-			'description' => __( 'Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe' ),
41
+			'description' => __('Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe'),
42 42
 			'default'     => 'yes',
43 43
 			'desc_tip'    => true,
44 44
 		),
45 45
 		'test_publishable_key' => array(
46
-			'title'       => __( 'Test Publishable Key', 'woocommerce-gateway-stripe' ),
46
+			'title'       => __('Test Publishable Key', 'woocommerce-gateway-stripe'),
47 47
 			'type'        => 'password',
48
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
48
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
49 49
 			'default'     => '',
50 50
 			'desc_tip'    => true,
51 51
 		),
52 52
 		'test_secret_key' => array(
53
-			'title'       => __( 'Test Secret Key', 'woocommerce-gateway-stripe' ),
53
+			'title'       => __('Test Secret Key', 'woocommerce-gateway-stripe'),
54 54
 			'type'        => 'password',
55
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
55
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
56 56
 			'default'     => '',
57 57
 			'desc_tip'    => true,
58 58
 		),
59 59
 		'publishable_key' => array(
60
-			'title'       => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ),
60
+			'title'       => __('Live Publishable Key', 'woocommerce-gateway-stripe'),
61 61
 			'type'        => 'password',
62
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
62
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
63 63
 			'default'     => '',
64 64
 			'desc_tip'    => true,
65 65
 		),
66 66
 		'secret_key' => array(
67
-			'title'       => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ),
67
+			'title'       => __('Live Secret Key', 'woocommerce-gateway-stripe'),
68 68
 			'type'        => 'password',
69
-			'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ),
69
+			'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'),
70 70
 			'default'     => '',
71 71
 			'desc_tip'    => true,
72 72
 		),
73 73
 		'inline_cc_form' => array(
74
-			'title'       => __( 'Inline Credit Card Form', 'woocommerce-gateway-stripe' ),
74
+			'title'       => __('Inline Credit Card Form', 'woocommerce-gateway-stripe'),
75 75
 			'type'        => 'checkbox',
76
-			'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' ),
76
+			'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'),
77 77
 			'default'     => 'no',
78 78
 			'desc_tip'    => true,
79 79
 		),
80 80
 		'statement_descriptor' => array(
81
-			'title'       => __( 'Statement Descriptor', 'woocommerce-gateway-stripe' ),
81
+			'title'       => __('Statement Descriptor', 'woocommerce-gateway-stripe'),
82 82
 			'type'        => 'text',
83
-			'description' => __( 'This may be up to 22 characters. The statement description must contain at least one letter, may not include ><"\' characters, and will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe' ),
83
+			'description' => __('This may be up to 22 characters. The statement description must contain at least one letter, may not include ><"\' characters, and will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe'),
84 84
 			'default'     => '',
85 85
 			'desc_tip'    => true,
86 86
 		),
87 87
 		'capture' => array(
88
-			'title'       => __( 'Capture', 'woocommerce-gateway-stripe' ),
89
-			'label'       => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ),
88
+			'title'       => __('Capture', 'woocommerce-gateway-stripe'),
89
+			'label'       => __('Capture charge immediately', 'woocommerce-gateway-stripe'),
90 90
 			'type'        => 'checkbox',
91
-			'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' ),
91
+			'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'),
92 92
 			'default'     => 'yes',
93 93
 			'desc_tip'    => true,
94 94
 		),
95 95
 		'three_d_secure' => array(
96
-			'title'       => __( '3D Secure', 'woocommerce-gateway-stripe' ),
97
-			'label'       => __( 'Require 3D Secure when applicable', 'woocommerce-gateway-stripe' ),
96
+			'title'       => __('3D Secure', 'woocommerce-gateway-stripe'),
97
+			'label'       => __('Require 3D Secure when applicable', 'woocommerce-gateway-stripe'),
98 98
 			'type'        => 'checkbox',
99
-			'description' => __( 'Some payment methods have 3D Secure feature. This is an extra security layer for your store. Choose how to handle payments when 3D Secure is optional. Enabling would require customers to use 3D Secure when optional.', 'woocommerce-gateway-stripe' ),
99
+			'description' => __('Some payment methods have 3D Secure feature. This is an extra security layer for your store. Choose how to handle payments when 3D Secure is optional. Enabling would require customers to use 3D Secure when optional.', 'woocommerce-gateway-stripe'),
100 100
 			'default'     => 'no',
101 101
 			'desc_tip'    => true,
102 102
 		),
103 103
 		'stripe_checkout' => array(
104
-			'title'       => __( 'Stripe Checkout', 'woocommerce-gateway-stripe' ),
105
-			'label'       => __( 'Enable Stripe Checkout', 'woocommerce-gateway-stripe' ),
104
+			'title'       => __('Stripe Checkout', 'woocommerce-gateway-stripe'),
105
+			'label'       => __('Enable Stripe Checkout', 'woocommerce-gateway-stripe'),
106 106
 			'type'        => 'checkbox',
107
-			'description' => __( 'If enabled, this option shows a "pay" button and modal credit card form on the checkout, instead of credit card fields directly on the page.', 'woocommerce-gateway-stripe' ),
107
+			'description' => __('If enabled, this option shows a "pay" button and modal credit card form on the checkout, instead of credit card fields directly on the page.', 'woocommerce-gateway-stripe'),
108 108
 			'default'     => 'no',
109 109
 			'desc_tip'    => true,
110 110
 		),
111 111
 		'stripe_bitcoin' => array(
112
-			'title'       => __( 'Bitcoin Currency', 'woocommerce-gateway-stripe' ),
113
-			'label'       => __( 'Enable Bitcoin Currency', 'woocommerce-gateway-stripe' ),
112
+			'title'       => __('Bitcoin Currency', 'woocommerce-gateway-stripe'),
113
+			'label'       => __('Enable Bitcoin Currency', 'woocommerce-gateway-stripe'),
114 114
 			'type'        => 'checkbox',
115
-			'description' => __( 'If enabled, an option to accept bitcoin will show on the checkout modal. Note: Stripe Checkout needs to be enabled and store currency must be set to USD.', 'woocommerce-gateway-stripe' ),
115
+			'description' => __('If enabled, an option to accept bitcoin will show on the checkout modal. Note: Stripe Checkout needs to be enabled and store currency must be set to USD.', 'woocommerce-gateway-stripe'),
116 116
 			'default'     => 'no',
117 117
 			'desc_tip'    => true,
118 118
 		),
119 119
 		'stripe_checkout_image' => array(
120
-			'title'       => __( 'Stripe Checkout Image', 'woocommerce-gateway-stripe' ),
121
-			'description' => __( 'Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe' ),
120
+			'title'       => __('Stripe Checkout Image', 'woocommerce-gateway-stripe'),
121
+			'description' => __('Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe'),
122 122
 			'type'        => 'text',
123 123
 			'default'     => '',
124 124
 			'desc_tip'    => true,
125 125
 		),
126 126
 		'payment_request' => array(
127
-			'title'       => __( 'Payment Request Buttons', 'woocommerce-gateway-stripe' ),
127
+			'title'       => __('Payment Request Buttons', 'woocommerce-gateway-stripe'),
128 128
 			/* translators: 1) br tag 2) opening anchor tag 3) closing anchor tag */
129
-			'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>' ),
129
+			'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>'),
130 130
 			'type'        => 'checkbox',
131
-			'description' => __( 'If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe' ),
131
+			'description' => __('If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe'),
132 132
 			'default'     => 'yes',
133 133
 			'desc_tip'    => true,
134 134
 		),
135 135
 		'payment_request_button_type' => array(
136
-			'title'       => __( 'Payment Request Button Type', 'woocommerce-gateway-stripe' ),
137
-			'label'       => __( 'Button Type', 'woocommerce-gateway-stripe' ),
136
+			'title'       => __('Payment Request Button Type', 'woocommerce-gateway-stripe'),
137
+			'label'       => __('Button Type', 'woocommerce-gateway-stripe'),
138 138
 			'type'        => 'select',
139
-			'description' => __( 'Select the button type you would like to show.', 'woocommerce-gateway-stripe' ),
139
+			'description' => __('Select the button type you would like to show.', 'woocommerce-gateway-stripe'),
140 140
 			'default'     => 'buy',
141 141
 			'desc_tip'    => true,
142 142
 			'options'     => array(
143
-				'default' => __( 'Default', 'woocommerce-gateway-stripe' ),
144
-				'buy'     => __( 'Buy', 'woocommerce-gateway-stripe' ),
145
-				'donate'  => __( 'Donate', 'woocommerce-gateway-stripe' ),
143
+				'default' => __('Default', 'woocommerce-gateway-stripe'),
144
+				'buy'     => __('Buy', 'woocommerce-gateway-stripe'),
145
+				'donate'  => __('Donate', 'woocommerce-gateway-stripe'),
146 146
 			),
147 147
 		),
148 148
 		'payment_request_button_theme' => array(
149
-			'title'       => __( 'Payment Request Button Theme', 'woocommerce-gateway-stripe' ),
150
-			'label'       => __( 'Button Theme', 'woocommerce-gateway-stripe' ),
149
+			'title'       => __('Payment Request Button Theme', 'woocommerce-gateway-stripe'),
150
+			'label'       => __('Button Theme', 'woocommerce-gateway-stripe'),
151 151
 			'type'        => 'select',
152
-			'description' => __( 'Select the button theme you would like to show.', 'woocommerce-gateway-stripe' ),
152
+			'description' => __('Select the button theme you would like to show.', 'woocommerce-gateway-stripe'),
153 153
 			'default'     => 'dark',
154 154
 			'desc_tip'    => true,
155 155
 			'options'     => array(
156
-				'dark'          => __( 'Dark', 'woocommerce-gateway-stripe' ),
157
-				'light'         => __( 'Light', 'woocommerce-gateway-stripe' ),
158
-				'light-outline' => __( 'Light-Outline', 'woocommerce-gateway-stripe' ),
156
+				'dark'          => __('Dark', 'woocommerce-gateway-stripe'),
157
+				'light'         => __('Light', 'woocommerce-gateway-stripe'),
158
+				'light-outline' => __('Light-Outline', 'woocommerce-gateway-stripe'),
159 159
 			),
160 160
 		),
161 161
 		'payment_request_button_height' => array(
162
-			'title'       => __( 'Payment Request Button Height', 'woocommerce-gateway-stripe' ),
163
-			'label'       => __( 'Button Height', 'woocommerce-gateway-stripe' ),
162
+			'title'       => __('Payment Request Button Height', 'woocommerce-gateway-stripe'),
163
+			'label'       => __('Button Height', 'woocommerce-gateway-stripe'),
164 164
 			'type'        => 'text',
165
-			'description' => __( 'Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe' ),
165
+			'description' => __('Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe'),
166 166
 			'default'     => '44',
167 167
 			'desc_tip'    => true,
168 168
 		),
169 169
 		'saved_cards' => array(
170
-			'title'       => __( 'Saved Cards', 'woocommerce-gateway-stripe' ),
171
-			'label'       => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ),
170
+			'title'       => __('Saved Cards', 'woocommerce-gateway-stripe'),
171
+			'label'       => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'),
172 172
 			'type'        => 'checkbox',
173
-			'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' ),
173
+			'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'),
174 174
 			'default'     => 'no',
175 175
 			'desc_tip'    => true,
176 176
 		),
177 177
 		'logging' => array(
178
-			'title'       => __( 'Logging', 'woocommerce-gateway-stripe' ),
179
-			'label'       => __( 'Log debug messages', 'woocommerce-gateway-stripe' ),
178
+			'title'       => __('Logging', 'woocommerce-gateway-stripe'),
179
+			'label'       => __('Log debug messages', 'woocommerce-gateway-stripe'),
180 180
 			'type'        => 'checkbox',
181
-			'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ),
181
+			'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'),
182 182
 			'default'     => 'no',
183 183
 			'desc_tip'    => true,
184 184
 		),
Please login to merge, or discard this patch.
includes/class-wc-gateway-stripe.php 1 patch
Spacing   +207 added lines, -207 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
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	public function __construct() {
114 114
 		$this->id                   = 'stripe';
115
-		$this->method_title         = __( 'Stripe', 'woocommerce-gateway-stripe' );
115
+		$this->method_title         = __('Stripe', 'woocommerce-gateway-stripe');
116 116
 		/* translators: 1) link to Stripe register page 2) link to Stripe api keys page */
117
-		$this->method_description   = sprintf( __( 'Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification. <a href="%1$s" target="_blank">Sign up</a> for a Stripe account, and <a href="%2$s" target="_blank">get your Stripe account keys</a>.', 'woocommerce-gateway-stripe' ), 'https://dashboard.stripe.com/register', 'https://dashboard.stripe.com/account/apikeys' );
117
+		$this->method_description   = sprintf(__('Stripe works by adding payment fields on the checkout and then sending the details to Stripe for verification. <a href="%1$s" target="_blank">Sign up</a> for a Stripe account, and <a href="%2$s" target="_blank">get your Stripe account keys</a>.', 'woocommerce-gateway-stripe'), 'https://dashboard.stripe.com/register', 'https://dashboard.stripe.com/account/apikeys');
118 118
 		$this->has_fields           = true;
119 119
 		$this->supports             = array(
120 120
 			'products',
@@ -141,37 +141,37 @@  discard block
 block discarded – undo
141 141
 		$this->init_settings();
142 142
 
143 143
 		// Get setting values.
144
-		$this->title                   = $this->get_option( 'title' );
145
-		$this->description             = $this->get_option( 'description' );
146
-		$this->enabled                 = $this->get_option( 'enabled' );
147
-		$this->testmode                = 'yes' === $this->get_option( 'testmode' );
148
-		$this->inline_cc_form          = 'yes' === $this->get_option( 'inline_cc_form' );
149
-		$this->capture                 = 'yes' === $this->get_option( 'capture', 'yes' );
150
-		$this->statement_descriptor    = WC_Stripe_Helper::clean_statement_descriptor( $this->get_option( 'statement_descriptor' ) );
151
-		$this->three_d_secure          = 'yes' === $this->get_option( 'three_d_secure' );
152
-		$this->stripe_checkout         = 'yes' === $this->get_option( 'stripe_checkout' );
153
-		$this->stripe_checkout_image   = $this->get_option( 'stripe_checkout_image', '' );
154
-		$this->saved_cards             = 'yes' === $this->get_option( 'saved_cards' );
155
-		$this->secret_key              = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' );
156
-		$this->publishable_key         = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' );
157
-		$this->bitcoin                 = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' );
158
-		$this->payment_request         = 'yes' === $this->get_option( 'payment_request', 'yes' );
159
-		$this->apple_pay_domain_set    = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' );
144
+		$this->title                   = $this->get_option('title');
145
+		$this->description             = $this->get_option('description');
146
+		$this->enabled                 = $this->get_option('enabled');
147
+		$this->testmode                = 'yes' === $this->get_option('testmode');
148
+		$this->inline_cc_form          = 'yes' === $this->get_option('inline_cc_form');
149
+		$this->capture                 = 'yes' === $this->get_option('capture', 'yes');
150
+		$this->statement_descriptor    = WC_Stripe_Helper::clean_statement_descriptor($this->get_option('statement_descriptor'));
151
+		$this->three_d_secure          = 'yes' === $this->get_option('three_d_secure');
152
+		$this->stripe_checkout         = 'yes' === $this->get_option('stripe_checkout');
153
+		$this->stripe_checkout_image   = $this->get_option('stripe_checkout_image', '');
154
+		$this->saved_cards             = 'yes' === $this->get_option('saved_cards');
155
+		$this->secret_key              = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key');
156
+		$this->publishable_key         = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key');
157
+		$this->bitcoin                 = 'USD' === strtoupper(get_woocommerce_currency()) && 'yes' === $this->get_option('stripe_bitcoin');
158
+		$this->payment_request         = 'yes' === $this->get_option('payment_request', 'yes');
159
+		$this->apple_pay_domain_set    = 'yes' === $this->get_option('apple_pay_domain_set', 'no');
160 160
 		$this->apple_pay_verify_notice = '';
161 161
 
162
-		if ( $this->stripe_checkout ) {
163
-			$this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' );
162
+		if ($this->stripe_checkout) {
163
+			$this->order_button_text = __('Continue to payment', 'woocommerce-gateway-stripe');
164 164
 		}
165 165
 
166
-		WC_Stripe_API::set_secret_key( $this->secret_key );
166
+		WC_Stripe_API::set_secret_key($this->secret_key);
167 167
 
168 168
 		$this->init_apple_pay();
169 169
 
170 170
 		// Hooks.
171
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
172
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
173
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
174
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
171
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
172
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'));
173
+		add_action('admin_notices', array($this, 'admin_notices'));
174
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
175 175
 	}
176 176
 
177 177
 	/**
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 * @since 4.0.2
181 181
 	 */
182 182
 	public function is_available() {
183
-		if ( is_add_payment_method_page() && ! $this->saved_cards ) {
183
+		if (is_add_payment_method_page() && ! $this->saved_cards) {
184 184
 			return false;
185 185
 		}
186 186
 
@@ -203,17 +203,17 @@  discard block
 block discarded – undo
203 203
 		$icons_str .= $icons['amex'];
204 204
 		$icons_str .= $icons['mastercard'];
205 205
 
206
-		if ( 'USD' === get_woocommerce_currency() ) {
206
+		if ('USD' === get_woocommerce_currency()) {
207 207
 			$icons_str .= $icons['discover'];
208 208
 			$icons_str .= $icons['jcb'];
209 209
 			$icons_str .= $icons['diners'];
210 210
 		}
211 211
 
212
-		if ( $this->bitcoin && $this->stripe_checkout ) {
212
+		if ($this->bitcoin && $this->stripe_checkout) {
213 213
 			$icons_str .= $icons['bitcoin'];
214 214
 		}
215 215
 
216
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
216
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
217 217
 	}
218 218
 
219 219
 	/**
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
 	public function init_apple_pay() {
226 226
 		if (
227 227
 			is_admin() &&
228
-			isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] &&
229
-			isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'] &&
230
-			isset( $_GET['section'] ) && 'stripe' === $_GET['section'] &&
228
+			isset($_GET['page']) && 'wc-settings' === $_GET['page'] &&
229
+			isset($_GET['tab']) && 'checkout' === $_GET['tab'] &&
230
+			isset($_GET['section']) && 'stripe' === $_GET['section'] &&
231 231
 			$this->payment_request
232 232
 		) {
233 233
 			$this->process_apple_pay_verification();
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
 	 * @version 3.1.0
242 242
 	 * @param string $secret_key
243 243
 	 */
244
-	private function register_apple_pay_domain( $secret_key = '' ) {
245
-		if ( empty( $secret_key ) ) {
246
-			throw new Exception( __( 'Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe' ) );
244
+	private function register_apple_pay_domain($secret_key = '') {
245
+		if (empty($secret_key)) {
246
+			throw new Exception(__('Unable to verify domain - missing secret key.', 'woocommerce-gateway-stripe'));
247 247
 		}
248 248
 
249 249
 		$endpoint = 'https://api.stripe.com/v1/apple_pay/domains';
@@ -257,23 +257,23 @@  discard block
 block discarded – undo
257 257
 			'Authorization' => 'Bearer ' . $secret_key,
258 258
 		);
259 259
 
260
-		$response = wp_remote_post( $endpoint, array(
260
+		$response = wp_remote_post($endpoint, array(
261 261
 			'headers' => $headers,
262
-			'body'    => http_build_query( $data ),
263
-		) );
262
+			'body'    => http_build_query($data),
263
+		));
264 264
 
265
-		if ( is_wp_error( $response ) ) {
265
+		if (is_wp_error($response)) {
266 266
 			/* translators: error message */
267
-			throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) );
267
+			throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $response->get_error_message()));
268 268
 		}
269 269
 
270
-		if ( 200 !== $response['response']['code'] ) {
271
-			$parsed_response = json_decode( $response['body'] );
270
+		if (200 !== $response['response']['code']) {
271
+			$parsed_response = json_decode($response['body']);
272 272
 
273 273
 			$this->apple_pay_verify_notice = $parsed_response->error->message;
274 274
 
275 275
 			/* translators: error message */
276
-			throw new Exception( sprintf( __( 'Unable to verify domain - %s', 'woocommerce-gateway-stripe' ), $parsed_response->error->message ) );
276
+			throw new Exception(sprintf(__('Unable to verify domain - %s', 'woocommerce-gateway-stripe'), $parsed_response->error->message));
277 277
 		}
278 278
 	}
279 279
 
@@ -284,48 +284,48 @@  discard block
 block discarded – undo
284 284
 	 * @version 3.1.0
285 285
 	 */
286 286
 	public function process_apple_pay_verification() {
287
-		$gateway_settings = get_option( 'woocommerce_stripe_settings', array() );
287
+		$gateway_settings = get_option('woocommerce_stripe_settings', array());
288 288
 
289 289
 		try {
290
-			$path     = untrailingslashit( $_SERVER['DOCUMENT_ROOT'] );
290
+			$path     = untrailingslashit($_SERVER['DOCUMENT_ROOT']);
291 291
 			$dir      = '.well-known';
292 292
 			$file     = 'apple-developer-merchantid-domain-association';
293 293
 			$fullpath = $path . '/' . $dir . '/' . $file;
294 294
 
295
-			if ( ! empty( $gateway_settings['apple_pay_domain_set'] ) && 'yes' === $gateway_settings['apple_pay_domain_set'] && file_exists( $fullpath ) ) {
295
+			if ( ! empty($gateway_settings['apple_pay_domain_set']) && 'yes' === $gateway_settings['apple_pay_domain_set'] && file_exists($fullpath)) {
296 296
 				return;
297 297
 			}
298 298
 
299
-			if ( ! file_exists( $path . '/' . $dir ) ) {
300
-				if ( ! @mkdir( $path . '/' . $dir, 0755 ) ) {
301
-					throw new Exception( __( 'Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe' ) );
299
+			if ( ! file_exists($path . '/' . $dir)) {
300
+				if ( ! @mkdir($path . '/' . $dir, 0755)) {
301
+					throw new Exception(__('Unable to create domain association folder to domain root.', 'woocommerce-gateway-stripe'));
302 302
 				}
303 303
 			}
304 304
 
305
-			if ( ! file_exists( $fullpath ) ) {
306
-				if ( ! @copy( WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath ) ) {
307
-					throw new Exception( __( 'Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe' ) );
305
+			if ( ! file_exists($fullpath)) {
306
+				if ( ! @copy(WC_STRIPE_PLUGIN_PATH . '/' . $file, $fullpath)) {
307
+					throw new Exception(__('Unable to copy domain association file to domain root.', 'woocommerce-gateway-stripe'));
308 308
 				}
309 309
 			}
310 310
 
311 311
 			// At this point then the domain association folder and file should be available.
312 312
 			// Proceed to verify/and or verify again.
313
-			$this->register_apple_pay_domain( $this->secret_key );
313
+			$this->register_apple_pay_domain($this->secret_key);
314 314
 
315 315
 			// No errors to this point, verification success!
316 316
 			$gateway_settings['apple_pay_domain_set'] = 'yes';
317 317
 			$this->apple_pay_domain_set = true;
318 318
 
319
-			update_option( 'woocommerce_stripe_settings', $gateway_settings );
319
+			update_option('woocommerce_stripe_settings', $gateway_settings);
320 320
 
321
-			WC_Stripe_Logger::log( 'Your domain has been verified with Apple Pay!' );
321
+			WC_Stripe_Logger::log('Your domain has been verified with Apple Pay!');
322 322
 
323
-		} catch ( Exception $e ) {
323
+		} catch (Exception $e) {
324 324
 			$gateway_settings['apple_pay_domain_set'] = 'no';
325 325
 
326
-			update_option( 'woocommerce_stripe_settings', $gateway_settings );
326
+			update_option('woocommerce_stripe_settings', $gateway_settings);
327 327
 
328
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
328
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
329 329
 		}
330 330
 	}
331 331
 
@@ -333,11 +333,11 @@  discard block
 block discarded – undo
333 333
 	 * Check if SSL is enabled and notify the user
334 334
 	 */
335 335
 	public function admin_notices() {
336
-		if ( 'no' === $this->enabled ) {
336
+		if ('no' === $this->enabled) {
337 337
 			return;
338 338
 		}
339 339
 
340
-		if ( $this->payment_request && ! empty( $this->apple_pay_verify_notice ) ) {
340
+		if ($this->payment_request && ! empty($this->apple_pay_verify_notice)) {
341 341
 			$allowed_html = array(
342 342
 				'a' => array(
343 343
 					'href' => array(),
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 				),
346 346
 			);
347 347
 
348
-			echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses( make_clickable( $this->apple_pay_verify_notice ), $allowed_html ) . '</p></div>';
348
+			echo '<div class="error stripe-apple-pay-message"><p>' . wp_kses(make_clickable($this->apple_pay_verify_notice), $allowed_html) . '</p></div>';
349 349
 		}
350 350
 
351 351
 		/**
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
 		 * when setting screen is displayed. So if domain verification is not set,
354 354
 		 * something went wrong so lets notify user.
355 355
 		 */
356
-		if ( ! empty( $this->secret_key ) && $this->payment_request && ! $this->apple_pay_domain_set ) {
356
+		if ( ! empty($this->secret_key) && $this->payment_request && ! $this->apple_pay_domain_set) {
357 357
 			/* translators: 1) HTML anchor open tag 2) HTML anchor closing tag */
358
-			echo '<div class="error stripe-apple-pay-message"><p>' . sprintf( __( 'Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe' ), '<a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">', '</a>' ) . '</p></div>';
358
+			echo '<div class="error stripe-apple-pay-message"><p>' . sprintf(__('Apple Pay domain verification failed. Please check the %1$slog%2$s to see the issue. (Logging must be enabled to see recorded logs)', 'woocommerce-gateway-stripe'), '<a href="' . admin_url('admin.php?page=wc-status&tab=logs') . '">', '</a>') . '</p></div>';
359 359
 		}
360 360
 	}
361 361
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 * Initialise Gateway Settings Form Fields
364 364
 	 */
365 365
 	public function init_form_fields() {
366
-		$this->form_fields = require( dirname( __FILE__ ) . '/admin/stripe-settings.php' );
366
+		$this->form_fields = require(dirname(__FILE__) . '/admin/stripe-settings.php');
367 367
 	}
368 368
 
369 369
 	/**
@@ -371,59 +371,59 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	public function payment_fields() {
373 373
 		$user                 = wp_get_current_user();
374
-		$display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards;
374
+		$display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards;
375 375
 		$total                = WC()->cart->total;
376 376
 		$user_email           = '';
377 377
 
378 378
 		// If paying from order, we need to get total from order not cart.
379
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
380
-			$order      = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) );
379
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
380
+			$order      = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key'])));
381 381
 			$total      = $order->get_total();
382 382
 			$user_email = WC_Stripe_Helper::is_pre_30() ? $order->billing_email : $order->get_billing_email();
383 383
 		} else {
384
-			if ( $user->ID ) {
385
-				$user_email = get_user_meta( $user->ID, 'billing_email', true );
384
+			if ($user->ID) {
385
+				$user_email = get_user_meta($user->ID, 'billing_email', true);
386 386
 				$user_email = $user_email ? $user_email : $user->user_email;
387 387
 			}
388 388
 		}
389 389
 
390
-		if ( is_add_payment_method_page() ) {
391
-			$pay_button_text = __( 'Add Card', 'woocommerce-gateway-stripe' );
392
-			$total        = '';
390
+		if (is_add_payment_method_page()) {
391
+			$pay_button_text = __('Add Card', 'woocommerce-gateway-stripe');
392
+			$total = '';
393 393
 		} else {
394 394
 			$pay_button_text = '';
395 395
 		}
396 396
 
397 397
 		echo '<div
398 398
 			id="stripe-payment-data"
399
-			data-panel-label="' . esc_attr( $pay_button_text ) . '"
399
+			data-panel-label="' . esc_attr($pay_button_text) . '"
400 400
 			data-description=""
401
-			data-email="' . esc_attr( $user_email ) . '"
402
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
403
-			data-name="' . esc_attr( $this->statement_descriptor ) . '"
404
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '"
405
-			data-image="' . esc_attr( $this->stripe_checkout_image ) . '"
406
-			data-bitcoin="' . esc_attr( ( $this->bitcoin && $this->capture ) ? 'true' : 'false' ) . '"
407
-			data-locale="' . esc_attr( apply_filters( 'wc_stripe_checkout_locale', substr( get_locale(), 0, 2 ) ) ) . '"
408
-			data-three-d-secure="' . esc_attr( $this->three_d_secure ? 'true' : 'false' ) . '"
409
-			data-allow-remember-me="' . esc_attr( $this->saved_cards ? 'true' : 'false' ) . '">';
410
-
411
-		if ( $this->description ) {
412
-			if ( $this->testmode ) {
401
+			data-email="' . esc_attr($user_email) . '"
402
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
403
+			data-name="' . esc_attr($this->statement_descriptor) . '"
404
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '"
405
+			data-image="' . esc_attr($this->stripe_checkout_image) . '"
406
+			data-bitcoin="' . esc_attr(($this->bitcoin && $this->capture) ? 'true' : 'false') . '"
407
+			data-locale="' . esc_attr(apply_filters('wc_stripe_checkout_locale', substr(get_locale(), 0, 2))) . '"
408
+			data-three-d-secure="' . esc_attr($this->three_d_secure ? 'true' : 'false') . '"
409
+			data-allow-remember-me="' . esc_attr($this->saved_cards ? 'true' : 'false') . '">';
410
+
411
+		if ($this->description) {
412
+			if ($this->testmode) {
413 413
 				/* translators: link to Stripe testing page */
414
-				$this->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 documentation "<a href="%s" target="_blank">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' );
415
-				$this->description  = trim( $this->description );
414
+				$this->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 documentation "<a href="%s" target="_blank">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe'), 'https://stripe.com/docs/testing');
415
+				$this->description  = trim($this->description);
416 416
 			}
417
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) );
417
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description)));
418 418
 		}
419 419
 
420
-		if ( $display_tokenization ) {
420
+		if ($display_tokenization) {
421 421
 			$this->tokenization_script();
422 422
 			$this->saved_payment_methods();
423 423
 		}
424 424
 
425
-		if ( ! $this->stripe_checkout ) {
426
-			if ( apply_filters( 'wc_stripe_use_elements_checkout_form', true ) ) {
425
+		if ( ! $this->stripe_checkout) {
426
+			if (apply_filters('wc_stripe_use_elements_checkout_form', true)) {
427 427
 				$this->elements_form();
428 428
 			} else {
429 429
 				$this->form();
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 			}
432 432
 		}
433 433
 
434
-		if ( apply_filters( 'wc_stripe_display_save_payment_method_checkbox', $display_tokenization ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) {
434
+		if (apply_filters('wc_stripe_display_save_payment_method_checkbox', $display_tokenization) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) {
435 435
 			$this->save_payment_method_checkbox();
436 436
 		}
437 437
 
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
 	 */
447 447
 	public function elements_form() {
448 448
 		?>
449
-		<fieldset id="wc-<?php echo esc_attr( $this->id ); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
450
-			<?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?>
449
+		<fieldset id="wc-<?php echo esc_attr($this->id); ?>-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">
450
+			<?php do_action('woocommerce_credit_card_form_start', $this->id); ?>
451 451
 
452
-			<?php if ( $this->inline_cc_form ) { ?>
452
+			<?php if ($this->inline_cc_form) { ?>
453 453
 				<label for="card-element">
454
-					<?php esc_html_e( 'Credit or debit card', 'woocommerce-gateway-stripe' ); ?>
454
+					<?php esc_html_e('Credit or debit card', 'woocommerce-gateway-stripe'); ?>
455 455
 				</label>
456 456
 
457 457
 				<div id="stripe-card-element" style="background:#fff;padding:0 1em;border:1px solid #ddd;margin:5px 0;padding:10px 5px;">
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 				</div>
460 460
 			<?php } else { ?>
461 461
 				<div class="form-row form-row-wide">
462
-					<label><?php _e( 'Card Number', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
462
+					<label><?php _e('Card Number', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
463 463
 
464 464
 					<div id="stripe-card-element" style="background:#fff;padding:0 1em;border:1px solid #ddd;margin:5px 0;padding:10px 5px;">
465 465
 					<!-- a Stripe Element will be inserted here. -->
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 				</div>
468 468
 
469 469
 				<div class="form-row form-row-first">
470
-					<label><?php _e( 'Expiry Date', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
470
+					<label><?php _e('Expiry Date', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
471 471
 
472 472
 					<div id="stripe-exp-element" style="background:#fff;padding:0 1em;border:1px solid #ddd;margin:5px 0;padding:10px 5px;">
473 473
 					<!-- a Stripe Element will be inserted here. -->
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 				</div>
476 476
 
477 477
 				<div class="form-row form-row-last">
478
-					<label><?php _e( 'Card Code (CVC)', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span></label>
478
+					<label><?php _e('Card Code (CVC)', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span></label>
479 479
 				<div id="stripe-cvc-element" style="background:#fff;padding:0 1em;border:1px solid #ddd;margin:5px 0;padding:10px 5px;">
480 480
 				<!-- a Stripe Element will be inserted here. -->
481 481
 				</div>
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 
486 486
 			<!-- Used to display form errors -->
487 487
 			<div class="stripe-source-errors" role="alert"></div>
488
-			<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
488
+			<?php do_action('woocommerce_credit_card_form_end', $this->id); ?>
489 489
 			<div class="clear"></div>
490 490
 		</fieldset>
491 491
 		<?php
@@ -498,13 +498,13 @@  discard block
 block discarded – undo
498 498
 	 * @version 3.1.0
499 499
 	 */
500 500
 	public function admin_scripts() {
501
-		if ( 'woocommerce_page_wc-settings' !== get_current_screen()->id ) {
501
+		if ('woocommerce_page_wc-settings' !== get_current_screen()->id) {
502 502
 			return;
503 503
 		}
504 504
 
505
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
505
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
506 506
 
507
-		wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true );
507
+		wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true);
508 508
 	}
509 509
 
510 510
 	/**
@@ -516,29 +516,29 @@  discard block
 block discarded – undo
516 516
 	 * @version 4.0.0
517 517
 	 */
518 518
 	public function payment_scripts() {
519
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) {
519
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) {
520 520
 			return;
521 521
 		}
522 522
 
523
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
523
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
524 524
 
525
-		wp_register_style( 'stripe_paymentfonts', plugins_url( 'assets/css/stripe-paymentfonts.css', WC_STRIPE_MAIN_FILE ), array(), '1.2.5' );
526
-		wp_enqueue_style( 'stripe_paymentfonts' );
527
-		wp_register_script( 'stripe_checkout', 'https://checkout.stripe.com/checkout.js', '', WC_STRIPE_VERSION, true );
528
-		wp_register_script( 'stripev2', 'https://js.stripe.com/v2/', '', '2.0', true );
529
-		wp_register_script( 'stripe', 'https://js.stripe.com/v3/', '', '3.0', true );
530
-		wp_register_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripev2', 'stripe' ), WC_STRIPE_VERSION, true );
525
+		wp_register_style('stripe_paymentfonts', plugins_url('assets/css/stripe-paymentfonts.css', WC_STRIPE_MAIN_FILE), array(), '1.2.5');
526
+		wp_enqueue_style('stripe_paymentfonts');
527
+		wp_register_script('stripe_checkout', 'https://checkout.stripe.com/checkout.js', '', WC_STRIPE_VERSION, true);
528
+		wp_register_script('stripev2', 'https://js.stripe.com/v2/', '', '2.0', true);
529
+		wp_register_script('stripe', 'https://js.stripe.com/v3/', '', '3.0', true);
530
+		wp_register_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripev2', 'stripe'), WC_STRIPE_VERSION, true);
531 531
 
532 532
 		$stripe_params = array(
533 533
 			'key'                  => $this->publishable_key,
534
-			'i18n_terms'           => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ),
535
-			'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ),
534
+			'i18n_terms'           => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'),
535
+			'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'),
536 536
 		);
537 537
 
538 538
 		// If we're on the pay page we need to pass stripe.js the address of the order.
539
-		if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) {
540
-			$order_id = wc_get_order_id_by_order_key( urldecode( $_GET['key'] ) );
541
-			$order    = wc_get_order( $order_id );
539
+		if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) {
540
+			$order_id = wc_get_order_id_by_order_key(urldecode($_GET['key']));
541
+			$order    = wc_get_order($order_id);
542 542
 
543 543
 			$stripe_params['billing_first_name'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_first_name : $order->get_billing_first_name();
544 544
 			$stripe_params['billing_last_name']  = WC_Stripe_Helper::is_pre_30() ? $order->billing_last_name : $order->get_billing_last_name();
@@ -550,38 +550,38 @@  discard block
 block discarded – undo
550 550
 			$stripe_params['billing_country']    = WC_Stripe_Helper::is_pre_30() ? $order->billing_country : $order->get_billing_country();
551 551
 		}
552 552
 
553
-		$stripe_params['no_prepaid_card_msg']                     = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
554
-		$stripe_params['no_sepa_owner_msg']                       = __( 'Please enter your IBAN account name.', 'woocommerce-gateway-stripe' );
555
-		$stripe_params['no_sepa_iban_msg']                        = __( 'Please enter your IBAN account number.', 'woocommerce-gateway-stripe' );
556
-		$stripe_params['sepa_mandate_notification']               = apply_filters( 'wc_stripe_sepa_mandate_notification', 'email' );
557
-		$stripe_params['allow_prepaid_card']                      = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no';
553
+		$stripe_params['no_prepaid_card_msg']                     = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
554
+		$stripe_params['no_sepa_owner_msg']                       = __('Please enter your IBAN account name.', 'woocommerce-gateway-stripe');
555
+		$stripe_params['no_sepa_iban_msg']                        = __('Please enter your IBAN account number.', 'woocommerce-gateway-stripe');
556
+		$stripe_params['sepa_mandate_notification']               = apply_filters('wc_stripe_sepa_mandate_notification', 'email');
557
+		$stripe_params['allow_prepaid_card']                      = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no';
558 558
 		$stripe_params['inline_cc_form']                          = $this->inline_cc_form ? 'yes' : 'no';
559
-		$stripe_params['stripe_checkout_require_billing_address'] = apply_filters( 'wc_stripe_checkout_require_billing_address', false ) ? 'yes' : 'no';
560
-		$stripe_params['is_checkout']                             = ( is_checkout() && empty( $_GET['pay_for_order'] ) );
559
+		$stripe_params['stripe_checkout_require_billing_address'] = apply_filters('wc_stripe_checkout_require_billing_address', false) ? 'yes' : 'no';
560
+		$stripe_params['is_checkout']                             = (is_checkout() && empty($_GET['pay_for_order']));
561 561
 		$stripe_params['return_url']                              = $this->get_stripe_return_url();
562
-		$stripe_params['ajaxurl']                                 = WC_AJAX::get_endpoint( '%%endpoint%%' );
563
-		$stripe_params['stripe_nonce']                            = wp_create_nonce( '_wc_stripe_nonce' );
562
+		$stripe_params['ajaxurl']                                 = WC_AJAX::get_endpoint('%%endpoint%%');
563
+		$stripe_params['stripe_nonce']                            = wp_create_nonce('_wc_stripe_nonce');
564 564
 		$stripe_params['statement_descriptor']                    = $this->statement_descriptor;
565
-		$stripe_params['use_elements']                            = apply_filters( 'wc_stripe_use_elements_checkout_form', true ) ? 'yes' : 'no';
566
-		$stripe_params['elements_options']                        = apply_filters( 'wc_stripe_elements_options', array() );
565
+		$stripe_params['use_elements']                            = apply_filters('wc_stripe_use_elements_checkout_form', true) ? 'yes' : 'no';
566
+		$stripe_params['elements_options']                        = apply_filters('wc_stripe_elements_options', array());
567 567
 		$stripe_params['is_stripe_checkout']                      = $this->stripe_checkout ? 'yes' : 'no';
568
-		$stripe_params['is_change_payment_page']                  = ( isset( $_GET['pay_for_order'] ) || isset( $_GET['change_payment_method'] ) ) ? 'yes' : 'no';
568
+		$stripe_params['is_change_payment_page']                  = (isset($_GET['pay_for_order']) || isset($_GET['change_payment_method'])) ? 'yes' : 'no';
569 569
 		$stripe_params['is_add_payment_method_page']              = is_add_payment_method_page() ? 'yes' : 'no';
570
-		$stripe_params['elements_styling']                        = apply_filters( 'wc_stripe_elements_styling', false );
571
-		$stripe_params['elements_classes']                        = apply_filters( 'wc_stripe_elements_classes', false );
570
+		$stripe_params['elements_styling']                        = apply_filters('wc_stripe_elements_styling', false);
571
+		$stripe_params['elements_classes']                        = apply_filters('wc_stripe_elements_classes', false);
572 572
 
573 573
 		// merge localized messages to be use in JS
574
-		$stripe_params = array_merge( $stripe_params, WC_Stripe_Helper::get_localized_messages() );
574
+		$stripe_params = array_merge($stripe_params, WC_Stripe_Helper::get_localized_messages());
575 575
 
576
-		wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
577
-		wp_localize_script( 'woocommerce_stripe_checkout', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) );
576
+		wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
577
+		wp_localize_script('woocommerce_stripe_checkout', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params));
578 578
 
579
-		if ( $this->stripe_checkout ) {
580
-			wp_enqueue_script( 'stripe_checkout' );
579
+		if ($this->stripe_checkout) {
580
+			wp_enqueue_script('stripe_checkout');
581 581
 		}
582 582
 
583 583
 		$this->tokenization_script();
584
-		wp_enqueue_script( 'woocommerce_stripe' );
584
+		wp_enqueue_script('woocommerce_stripe');
585 585
 	}
586 586
 
587 587
 	/**
@@ -597,43 +597,43 @@  discard block
 block discarded – undo
597 597
 	 *
598 598
 	 * @return array|void
599 599
 	 */
600
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
600
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
601 601
 		try {
602
-			$order = wc_get_order( $order_id );
602
+			$order = wc_get_order($order_id);
603 603
 
604 604
 			// This comes from the create account checkbox in the checkout page.
605
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
605
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
606 606
 
607
-			if ( $create_account ) {
607
+			if ($create_account) {
608 608
 				$new_customer_id     = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id();
609
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
609
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
610 610
 				$new_stripe_customer->create_customer();
611 611
 			}
612 612
 
613 613
 			$source_object   = $this->get_source_object();
614
-			$prepared_source = $this->prepare_source( $source_object, get_current_user_id(), $force_save_source );
614
+			$prepared_source = $this->prepare_source($source_object, get_current_user_id(), $force_save_source);
615 615
 
616 616
 			// Check if we don't allow prepaid credit cards.
617
-			if ( ! apply_filters( 'wc_stripe_allow_prepaid_card', true ) ) {
618
-				if ( $source_object && 'token' === $source_object->object && 'prepaid' === $source_object->card->funding ) {
619
-					$localized_message = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
620
-					throw new WC_Stripe_Exception( print_r( $source_object, true ), $localized_message );
617
+			if ( ! apply_filters('wc_stripe_allow_prepaid_card', true)) {
618
+				if ($source_object && 'token' === $source_object->object && 'prepaid' === $source_object->card->funding) {
619
+					$localized_message = __('Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe');
620
+					throw new WC_Stripe_Exception(print_r($source_object, true), $localized_message);
621 621
 				}
622 622
 			}
623 623
 
624
-			if ( empty( $prepared_source->source ) ) {
625
-				$localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' );
626
-				throw new WC_Stripe_Exception( print_r( $prepared_source, true ), $localized_message );
624
+			if (empty($prepared_source->source)) {
625
+				$localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe');
626
+				throw new WC_Stripe_Exception(print_r($prepared_source, true), $localized_message);
627 627
 			}
628 628
 
629
-			$this->save_source_to_order( $order, $prepared_source );
629
+			$this->save_source_to_order($order, $prepared_source);
630 630
 
631 631
 			// Result from Stripe API request.
632 632
 			$response = null;
633 633
 
634
-			if ( $order->get_total() > 0 ) {
634
+			if ($order->get_total() > 0) {
635 635
 				// This will throw exception if not valid.
636
-				$this->validate_minimum_order_amount( $order );
636
+				$this->validate_minimum_order_amount($order);
637 637
 
638 638
 				/*
639 639
 				 * Check if card 3DS is required or optional with 3DS setting.
@@ -642,109 +642,109 @@  discard block
 block discarded – undo
642 642
 				 * Note that if we need to save source, the original source must be first
643 643
 				 * attached to a customer in Stripe before it can be charged.
644 644
 				 */
645
-				if ( $this->is_3ds_required( $source_object ) ) {
646
-					$response = $this->create_3ds_source( $order, $source_object );
645
+				if ($this->is_3ds_required($source_object)) {
646
+					$response = $this->create_3ds_source($order, $source_object);
647 647
 
648
-					if ( ! empty( $response->error ) ) {
648
+					if ( ! empty($response->error)) {
649 649
 						$localized_message = $response->error->message;
650 650
 
651
-						$order->add_order_note( $localized_message );
651
+						$order->add_order_note($localized_message);
652 652
 
653
-						throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
653
+						throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
654 654
 					}
655 655
 
656 656
 					// Update order meta with 3DS source.
657
-					if ( WC_Stripe_Helper::is_pre_30() ) {
658
-						update_post_meta( $order_id, '_stripe_source_id', $response->id );
657
+					if (WC_Stripe_Helper::is_pre_30()) {
658
+						update_post_meta($order_id, '_stripe_source_id', $response->id);
659 659
 					} else {
660
-						$order->update_meta_data( '_stripe_source_id', $response->id );
660
+						$order->update_meta_data('_stripe_source_id', $response->id);
661 661
 						$order->save();
662 662
 					}
663 663
 
664
-					WC_Stripe_Logger::log( 'Info: Redirecting to 3DS...' );
664
+					WC_Stripe_Logger::log('Info: Redirecting to 3DS...');
665 665
 
666 666
 					return array(
667 667
 						'result'   => 'success',
668
-						'redirect' => esc_url_raw( $response->redirect->url ),
668
+						'redirect' => esc_url_raw($response->redirect->url),
669 669
 					);
670 670
 				}
671 671
 
672
-				WC_Stripe_Logger::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
672
+				WC_Stripe_Logger::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}");
673 673
 
674 674
 				// Make the request.
675
-				$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $prepared_source ) );
675
+				$response = WC_Stripe_API::request($this->generate_payment_request($order, $prepared_source));
676 676
 
677
-				if ( ! empty( $response->error ) ) {
677
+				if ( ! empty($response->error)) {
678 678
 					// If it is an API error such connection or server, let's retry.
679
-					if ( 'api_connection_error' === $response->error->type || 'api_error' === $response->error->type ) {
680
-						if ( $retry ) {
681
-							sleep( 5 );
682
-							return $this->process_payment( $order_id, false, $force_save_source );
679
+					if ('api_connection_error' === $response->error->type || 'api_error' === $response->error->type) {
680
+						if ($retry) {
681
+							sleep(5);
682
+							return $this->process_payment($order_id, false, $force_save_source);
683 683
 						} else {
684 684
 							$localized_message = 'API connection error and retries exhausted.';
685
-							$order->add_order_note( $localized_message );
686
-							throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
685
+							$order->add_order_note($localized_message);
686
+							throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
687 687
 						}
688 688
 					}
689 689
 
690 690
 					// We want to retry.
691
-					if ( $this->is_retryable_error( $response->error ) ) {
692
-						if ( $retry ) {
691
+					if ($this->is_retryable_error($response->error)) {
692
+						if ($retry) {
693 693
 							// Don't do anymore retries after this.
694
-							if ( 5 <= $this->retry_interval ) {
694
+							if (5 <= $this->retry_interval) {
695 695
 
696
-								return $this->process_payment( $notification, false );
696
+								return $this->process_payment($notification, false);
697 697
 							}
698 698
 
699
-							sleep( $this->retry_interval );
699
+							sleep($this->retry_interval);
700 700
 
701 701
 							$this->retry_interval++;
702
-							return $this->process_payment( $notification, true );
702
+							return $this->process_payment($notification, true);
703 703
 						} else {
704
-							$localized_message = __( 'On going requests error and retries exhausted.', 'woocommerce-gateway-stripe' );
705
-							$order->add_order_note( $localized_message );
706
-							throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
704
+							$localized_message = __('On going requests error and retries exhausted.', 'woocommerce-gateway-stripe');
705
+							$order->add_order_note($localized_message);
706
+							throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
707 707
 						}
708 708
 					}
709 709
 
710 710
 					// Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without.
711
-					if ( preg_match( '/No such customer/i', $response->error->message ) && $retry ) {
712
-						if ( WC_Stripe_Helper::is_pre_30() ) {
713
-							delete_user_meta( $order->customer_user, '_stripe_customer_id' );
714
-							delete_post_meta( $order_id, '_stripe_customer_id' );
711
+					if (preg_match('/No such customer/i', $response->error->message) && $retry) {
712
+						if (WC_Stripe_Helper::is_pre_30()) {
713
+							delete_user_meta($order->customer_user, '_stripe_customer_id');
714
+							delete_post_meta($order_id, '_stripe_customer_id');
715 715
 						} else {
716
-							delete_user_meta( $order->get_customer_id(), '_stripe_customer_id' );
717
-							$order->delete_meta_data( '_stripe_customer_id' );
716
+							delete_user_meta($order->get_customer_id(), '_stripe_customer_id');
717
+							$order->delete_meta_data('_stripe_customer_id');
718 718
 							$order->save();
719 719
 						}
720 720
 
721
-						return $this->process_payment( $order_id, false, $force_save_source );
722
-					} elseif ( preg_match( '/No such token/i', $response->error->message ) && $prepared_source->token_id ) {
721
+						return $this->process_payment($order_id, false, $force_save_source);
722
+					} elseif (preg_match('/No such token/i', $response->error->message) && $prepared_source->token_id) {
723 723
 						// Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message.
724
-						$wc_token = WC_Payment_Tokens::get( $prepared_source->token_id );
724
+						$wc_token = WC_Payment_Tokens::get($prepared_source->token_id);
725 725
 						$wc_token->delete();
726
-						$localized_message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' );
727
-						$order->add_order_note( $localized_message );
728
-						throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
726
+						$localized_message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe');
727
+						$order->add_order_note($localized_message);
728
+						throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
729 729
 					}
730 730
 
731 731
 					$localized_messages = WC_Stripe_Helper::get_localized_messages();
732 732
 
733
-					if ( 'card_error' === $response->error->type ) {
734
-						$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
733
+					if ('card_error' === $response->error->type) {
734
+						$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
735 735
 					} else {
736
-						$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
736
+						$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
737 737
 					}
738 738
 
739
-					$order->add_order_note( $localized_message );
739
+					$order->add_order_note($localized_message);
740 740
 
741
-					throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
741
+					throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
742 742
 				}
743 743
 
744
-				do_action( 'wc_gateway_stripe_process_payment', $response, $order );
744
+				do_action('wc_gateway_stripe_process_payment', $response, $order);
745 745
 
746 746
 				// Process valid response.
747
-				$this->process_response( $response, $order );
747
+				$this->process_response($response, $order);
748 748
 			} else {
749 749
 				$order->payment_complete();
750 750
 			}
@@ -755,17 +755,17 @@  discard block
 block discarded – undo
755 755
 			// Return thank you page redirect.
756 756
 			return array(
757 757
 				'result'   => 'success',
758
-				'redirect' => $this->get_return_url( $order ),
758
+				'redirect' => $this->get_return_url($order),
759 759
 			);
760 760
 
761
-		} catch ( WC_Stripe_Exception $e ) {
762
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
763
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
761
+		} catch (WC_Stripe_Exception $e) {
762
+			wc_add_notice($e->getLocalizedMessage(), 'error');
763
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
764 764
 
765
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
765
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
766 766
 
767
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
768
-				$this->send_failed_order_email( $order_id );
767
+			if ($order->has_status(array('pending', 'failed'))) {
768
+				$this->send_failed_order_email($order_id);
769 769
 			}
770 770
 
771 771
 			return array(
Please login to merge, or discard this patch.