Completed
Pull Request — master (#535)
by Roy
02:20
created
includes/admin/stripe-p24-settings.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,46 +1,46 @@
 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_p24_settings',
8
+return apply_filters('wc_stripe_p24_settings',
9 9
 	array(
10 10
 		'geo_target' => array(
11
-			'description' => __( 'Relevant Payer Geography: Poland', 'woocommerce-gateway-stripe' ),
11
+			'description' => __('Relevant Payer Geography: Poland', 'woocommerce-gateway-stripe'),
12 12
 			'type'        => 'title',
13 13
 		),
14 14
 		'activation' => array(
15
-			'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ),
15
+			'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'),
16 16
 			'type'   => 'title',
17 17
 		),
18 18
 		'enabled' => array(
19
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
20
-			'label'       => __( 'Enable Stripe P24', 'woocommerce-gateway-stripe' ),
19
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
20
+			'label'       => __('Enable Stripe P24', 'woocommerce-gateway-stripe'),
21 21
 			'type'        => 'checkbox',
22 22
 			'description' => '',
23 23
 			'default'     => 'no',
24 24
 		),
25 25
 		'title' => array(
26
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
26
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
27 27
 			'type'        => 'text',
28
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
29
-			'default'     => __( 'Przelewy24 (P24)', 'woocommerce-gateway-stripe' ),
28
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
29
+			'default'     => __('Przelewy24 (P24)', 'woocommerce-gateway-stripe'),
30 30
 			'desc_tip'    => true,
31 31
 		),
32 32
 		'description' => array(
33
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
33
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
34 34
 			'type'        => 'text',
35
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
36
-			'default'     => __( 'You will be redirected to P24.', 'woocommerce-gateway-stripe' ),
35
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
36
+			'default'     => __('You will be redirected to P24.', 'woocommerce-gateway-stripe'),
37 37
 			'desc_tip'    => true,
38 38
 		),
39 39
 		'webhook' => array(
40
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
40
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
41 41
 			'type'        => 'title',
42 42
 			/* translators: webhook URL */
43
-			'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 ),
43
+			'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),
44 44
 		),
45 45
 	)
46 46
 );
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit; // Exit if accessed directly
4 4
 }
5 5
 
6 6
 // if uninstall not called from WordPress exit
7
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
7
+if ( ! defined('WP_UNINSTALL_PLUGIN')) {
8 8
 	exit;
9 9
 }
10 10
 
@@ -13,20 +13,20 @@  discard block
 block discarded – undo
13 13
  * wp-config.php. This is to prevent data loss when deleting the plugin from the backend
14 14
  * and to ensure only the site owner can perform this action.
15 15
  */
16
-if ( defined( 'WC_REMOVE_ALL_DATA' ) && true === WC_REMOVE_ALL_DATA ) {
16
+if (defined('WC_REMOVE_ALL_DATA') && true === WC_REMOVE_ALL_DATA) {
17 17
 	// Delete options.
18
-	delete_option( 'woocommerce_stripe_settings' );
19
-	delete_option( 'wc_stripe_show_request_api_notice' );
20
-	delete_option( 'wc_stripe_show_apple_pay_notice' );
21
-	delete_option( 'wc_stripe_show_ssl_notice' );
22
-	delete_option( 'wc_stripe_show_keys_notice' );
23
-	delete_option( 'wc_stripe_version' );
24
-	delete_option( 'woocommerce_stripe_bancontact_settings' );
25
-	delete_option( 'woocommerce_stripe_alipay_settings' );
26
-	delete_option( 'woocommerce_stripe_bitcoin_settings' );
27
-	delete_option( 'woocommerce_stripe_ideal_settings' );
28
-	delete_option( 'woocommerce_stripe_p24_settings' );
29
-	delete_option( 'woocommerce_stripe_giropay_settings' );
30
-	delete_option( 'woocommerce_stripe_sepa_settings' );
31
-	delete_option( 'woocommerce_stripe_sofort_settings' );
18
+	delete_option('woocommerce_stripe_settings');
19
+	delete_option('wc_stripe_show_request_api_notice');
20
+	delete_option('wc_stripe_show_apple_pay_notice');
21
+	delete_option('wc_stripe_show_ssl_notice');
22
+	delete_option('wc_stripe_show_keys_notice');
23
+	delete_option('wc_stripe_version');
24
+	delete_option('woocommerce_stripe_bancontact_settings');
25
+	delete_option('woocommerce_stripe_alipay_settings');
26
+	delete_option('woocommerce_stripe_bitcoin_settings');
27
+	delete_option('woocommerce_stripe_ideal_settings');
28
+	delete_option('woocommerce_stripe_p24_settings');
29
+	delete_option('woocommerce_stripe_giropay_settings');
30
+	delete_option('woocommerce_stripe_sepa_settings');
31
+	delete_option('woocommerce_stripe_sofort_settings');
32 32
 }
Please login to merge, or discard this patch.
includes/class-wc-stripe-exception.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @since 4.0.2
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 	 * @param string $error_message Full response
24 24
 	 * @param string $localized_message user-friendly translated error message
25 25
 	 */
26
-	public function __construct( $error_message = '', $localized_message = '' ) {
26
+	public function __construct($error_message = '', $localized_message = '') {
27 27
 		$this->localized_message = $localized_message;
28
-		parent::__construct( $error_message );
28
+		parent::__construct($error_message);
29 29
 	}
30 30
 
31 31
 	/**
Please login to merge, or discard this patch.
includes/class-wc-stripe-helper.php 1 patch
Spacing   +51 added lines, -51 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
 
@@ -17,15 +17,15 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @return float|int
19 19
 	 */
20
-	public static function get_stripe_amount( $total, $currency = '' ) {
21
-		if ( ! $currency ) {
20
+	public static function get_stripe_amount($total, $currency = '') {
21
+		if ( ! $currency) {
22 22
 			$currency = get_woocommerce_currency();
23 23
 		}
24 24
 
25
-		if ( in_array( strtolower( $currency ), self::no_decimal_currencies() ) ) {
26
-			return absint( $total );
25
+		if (in_array(strtolower($currency), self::no_decimal_currencies())) {
26
+			return absint($total);
27 27
 		} else {
28
-			return absint( wc_format_decimal( ( (float) $total * 100 ), wc_get_price_decimals() ) ); // In cents.
28
+			return absint(wc_format_decimal(((float) $total * 100), wc_get_price_decimals())); // In cents.
29 29
 		}
30 30
 	}
31 31
 
@@ -37,25 +37,25 @@  discard block
 block discarded – undo
37 37
 	 * @return array
38 38
 	 */
39 39
 	public static function get_localized_messages() {
40
-		return apply_filters( 'wc_stripe_localized_messages', array(
41
-			'invalid_number'           => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ),
42
-			'invalid_expiry_month'     => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ),
43
-			'invalid_expiry_year'      => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ),
44
-			'invalid_cvc'              => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ),
45
-			'incorrect_number'         => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ),
46
-			'incomplete_number'        => __( 'The card number is incomplete.', 'woocommerce-gateway-stripe' ),
47
-			'incomplete_cvc'           => __( 'The card\'s security code is incomplete.', 'woocommerce-gateway-stripe' ),
48
-			'incomplete_expiry'        => __( 'The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe' ),
49
-			'expired_card'             => __( 'The card has expired.', 'woocommerce-gateway-stripe' ),
50
-			'incorrect_cvc'            => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ),
51
-			'incorrect_zip'            => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ),
52
-			'invalid_expiry_year_past' => __( 'The card\'s expiration year is in the past', 'woocommerce-gateway-stripe' ),
53
-			'card_declined'            => __( 'The card was declined.', 'woocommerce-gateway-stripe' ),
54
-			'missing'                  => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ),
55
-			'processing_error'         => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ),
56
-			'invalid_request_error'    => __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ),
57
-			'invalid_sofort_country'   => __( 'The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe' ),
58
-		) );
40
+		return apply_filters('wc_stripe_localized_messages', array(
41
+			'invalid_number'           => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'),
42
+			'invalid_expiry_month'     => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'),
43
+			'invalid_expiry_year'      => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'),
44
+			'invalid_cvc'              => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'),
45
+			'incorrect_number'         => __('The card number is incorrect.', 'woocommerce-gateway-stripe'),
46
+			'incomplete_number'        => __('The card number is incomplete.', 'woocommerce-gateway-stripe'),
47
+			'incomplete_cvc'           => __('The card\'s security code is incomplete.', 'woocommerce-gateway-stripe'),
48
+			'incomplete_expiry'        => __('The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe'),
49
+			'expired_card'             => __('The card has expired.', 'woocommerce-gateway-stripe'),
50
+			'incorrect_cvc'            => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'),
51
+			'incorrect_zip'            => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'),
52
+			'invalid_expiry_year_past' => __('The card\'s expiration year is in the past', 'woocommerce-gateway-stripe'),
53
+			'card_declined'            => __('The card was declined.', 'woocommerce-gateway-stripe'),
54
+			'missing'                  => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'),
55
+			'processing_error'         => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'),
56
+			'invalid_request_error'    => __('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe'),
57
+			'invalid_sofort_country'   => __('The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe'),
58
+		));
59 59
 	}
60 60
 
61 61
 	/**
@@ -92,24 +92,24 @@  discard block
 block discarded – undo
92 92
 	 * @param string $type Type of number to format
93 93
 	 * @return string
94 94
 	 */
95
-	public static function format_balance_fee( $balance_transaction, $type = 'fee' ) {
96
-		if ( ! is_object( $balance_transaction ) ) {
95
+	public static function format_balance_fee($balance_transaction, $type = 'fee') {
96
+		if ( ! is_object($balance_transaction)) {
97 97
 			return;
98 98
 		}
99 99
 
100
-		if ( in_array( strtolower( $balance_transaction->currency ), self::no_decimal_currencies() ) ) {
101
-			if ( 'fee' === $type ) {
100
+		if (in_array(strtolower($balance_transaction->currency), self::no_decimal_currencies())) {
101
+			if ('fee' === $type) {
102 102
 				return $balance_transaction->fee;
103 103
 			}
104 104
 
105 105
 			return $balance_transaction->net;
106 106
 		}
107 107
 
108
-		if ( 'fee' === $type ) {
109
-			return number_format( $balance_transaction->fee / 100, 2, '.', '' );
108
+		if ('fee' === $type) {
109
+			return number_format($balance_transaction->fee / 100, 2, '.', '');
110 110
 		}
111 111
 
112
-		return number_format( $balance_transaction->net / 100, 2, '.', '' );
112
+		return number_format($balance_transaction->net / 100, 2, '.', '');
113 113
 	}
114 114
 
115 115
 	/**
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public static function get_minimum_amount() {
119 119
 		// Check order amount
120
-		switch ( get_woocommerce_currency() ) {
120
+		switch (get_woocommerce_currency()) {
121 121
 			case 'USD':
122 122
 			case 'CAD':
123 123
 			case 'EUR':
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
 	 * @param string $method The payment method to get the settings from.
163 163
 	 * @param string $setting The name of the setting to get.
164 164
 	 */
165
-	public static function get_settings( $method = null, $setting = null ) {
166
-		$all_settings = null === $method ? get_option( 'woocommerce_stripe_settings', array() ) : get_option( 'woocommerce_stripe_' . $method . '_settings', array() );
165
+	public static function get_settings($method = null, $setting = null) {
166
+		$all_settings = null === $method ? get_option('woocommerce_stripe_settings', array()) : get_option('woocommerce_stripe_' . $method . '_settings', array());
167 167
 
168
-		if ( null === $setting ) {
168
+		if (null === $setting) {
169 169
 			return $all_settings;
170 170
 		}
171 171
 
172
-		return isset( $all_settings[ $setting ] ) ? $all_settings[ $setting ] : '';
172
+		return isset($all_settings[$setting]) ? $all_settings[$setting] : '';
173 173
 	}
174 174
 
175 175
 	/**
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 * @return bool
181 181
 	 */
182 182
 	public static function is_pre_30() {
183
-		return version_compare( WC_VERSION, '3.0.0', '<' );
183
+		return version_compare(WC_VERSION, '3.0.0', '<');
184 184
 	}
185 185
 
186 186
 	/**
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @return string
194 194
 	 */
195 195
 	public static function get_webhook_url() {
196
-		return add_query_arg( 'wc-api', 'wc_stripe', trailingslashit( get_home_url() ) );
196
+		return add_query_arg('wc-api', 'wc_stripe', trailingslashit(get_home_url()));
197 197
 	}
198 198
 
199 199
 	/**
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
 	 * @version 4.0.0
204 204
 	 * @param string $source_id
205 205
 	 */
206
-	public static function get_order_by_source_id( $source_id ) {
206
+	public static function get_order_by_source_id($source_id) {
207 207
 		global $wpdb;
208 208
 
209
-		$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s", $source_id ) );
209
+		$order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s", $source_id));
210 210
 
211
-		if ( ! empty( $order_id ) ) {
212
-			return wc_get_order( $order_id );
211
+		if ( ! empty($order_id)) {
212
+			return wc_get_order($order_id);
213 213
 		}
214 214
 
215 215
 		return false;
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
 	 * @version 4.0.0
223 223
 	 * @param string $charge_id
224 224
 	 */
225
-	public static function get_order_by_charge_id( $charge_id ) {
225
+	public static function get_order_by_charge_id($charge_id) {
226 226
 		global $wpdb;
227 227
 
228
-		$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s", $charge_id ) );
228
+		$order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s", $charge_id));
229 229
 
230
-		if ( ! empty( $order_id ) ) {
231
-			return wc_get_order( $order_id );
230
+		if ( ! empty($order_id)) {
231
+			return wc_get_order($order_id);
232 232
 		}
233 233
 
234 234
 		return false;
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 	 * @param string $statement_descriptor
245 245
 	 * @return string $statement_descriptor Sanitized statement descriptor
246 246
 	 */
247
-	public static function clean_statement_descriptor( $statement_descriptor = '' ) {
248
-		$disallowed_characters = array( '<', '>', '"', "'" );
247
+	public static function clean_statement_descriptor($statement_descriptor = '') {
248
+		$disallowed_characters = array('<', '>', '"', "'");
249 249
 
250 250
 		// Remove special characters.
251
-		$statement_descriptor = str_replace( $disallowed_characters, '', $statement_descriptor );
251
+		$statement_descriptor = str_replace($disallowed_characters, '', $statement_descriptor);
252 252
 
253
-		$statement_descriptor = substr( trim( $statement_descriptor ), 0, 22 );
253
+		$statement_descriptor = substr(trim($statement_descriptor), 0, 22);
254 254
 
255 255
 		return $statement_descriptor;
256 256
 	}
Please login to merge, or discard this patch.
includes/payment-methods/class-wc-gateway-stripe-p24.php 1 patch
Spacing   +74 added lines, -74 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
 
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function __construct() {
59 59
 		$this->id                   = 'stripe_p24';
60
-		$this->method_title         = __( 'Stripe P24', 'woocommerce-gateway-stripe' );
60
+		$this->method_title         = __('Stripe P24', 'woocommerce-gateway-stripe');
61 61
 		/* translators: link */
62
-		$this->method_description   = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
62
+		$this->method_description   = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe'));
63 63
 		$this->supports             = array(
64 64
 			'products',
65 65
 			'refunds',
@@ -71,25 +71,25 @@  discard block
 block discarded – undo
71 71
 		// Load the settings.
72 72
 		$this->init_settings();
73 73
 
74
-		$main_settings              = get_option( 'woocommerce_stripe_settings' );
75
-		$this->title                = $this->get_option( 'title' );
76
-		$this->description          = $this->get_option( 'description' );
77
-		$this->enabled              = $this->get_option( 'enabled' );
78
-		$this->testmode             = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false;
79
-		$this->saved_cards          = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false;
80
-		$this->publishable_key      = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : '';
81
-		$this->secret_key           = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : '';
82
-		$this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : '';
83
-
84
-		if ( $this->testmode ) {
85
-			$this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : '';
86
-			$this->secret_key      = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : '';
74
+		$main_settings              = get_option('woocommerce_stripe_settings');
75
+		$this->title                = $this->get_option('title');
76
+		$this->description          = $this->get_option('description');
77
+		$this->enabled              = $this->get_option('enabled');
78
+		$this->testmode             = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false;
79
+		$this->saved_cards          = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false;
80
+		$this->publishable_key      = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : '';
81
+		$this->secret_key           = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : '';
82
+		$this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : '';
83
+
84
+		if ($this->testmode) {
85
+			$this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : '';
86
+			$this->secret_key      = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : '';
87 87
 		}
88 88
 
89
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
90
-		add_action( 'admin_notices', array( $this, 'check_environment' ) );
91
-		add_action( 'admin_head', array( $this, 'remove_admin_notice' ) );
92
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
89
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
90
+		add_action('admin_notices', array($this, 'check_environment'));
91
+		add_action('admin_head', array($this, 'remove_admin_notice'));
92
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
93 93
 	}
94 94
 
95 95
 	/**
@@ -99,19 +99,19 @@  discard block
 block discarded – undo
99 99
 	 * @version 4.0.0
100 100
 	 */
101 101
 	public function check_environment() {
102
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
102
+		if ( ! current_user_can('manage_woocommerce')) {
103 103
 			return;
104 104
 		}
105 105
 
106 106
 		$environment_warning = $this->get_environment_warning();
107 107
 
108
-		if ( $environment_warning ) {
109
-			$this->add_admin_notice( 'bad_environment', 'error', $environment_warning );
108
+		if ($environment_warning) {
109
+			$this->add_admin_notice('bad_environment', 'error', $environment_warning);
110 110
 		}
111 111
 
112
-		foreach ( (array) $this->notices as $notice_key => $notice ) {
113
-			echo "<div class='" . esc_attr( $notice['class'] ) . "'><p>";
114
-			echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) );
112
+		foreach ((array) $this->notices as $notice_key => $notice) {
113
+			echo "<div class='" . esc_attr($notice['class']) . "'><p>";
114
+			echo wp_kses($notice['message'], array('a' => array('href' => array())));
115 115
 			echo '</p></div>';
116 116
 		}
117 117
 	}
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 	 * @version 4.0.0
125 125
 	 */
126 126
 	public function get_environment_warning() {
127
-		if ( 'yes' === $this->enabled && ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
128
-			$message = __( 'P24 is enabled - it requires store currency to be set to Euros or Polish Zloty.', 'woocommerce-gateway-stripe' );
127
+		if ('yes' === $this->enabled && ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
128
+			$message = __('P24 is enabled - it requires store currency to be set to Euros or Polish Zloty.', 'woocommerce-gateway-stripe');
129 129
 
130 130
 			return $message;
131 131
 		}
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
 	 * @return array
142 142
 	 */
143 143
 	public function get_supported_currency() {
144
-		return apply_filters( 'wc_stripe_p24_supported_currencies', array(
144
+		return apply_filters('wc_stripe_p24_supported_currencies', array(
145 145
 			'EUR',
146 146
 			'PLN',
147
-		) );
147
+		));
148 148
 	}
149 149
 
150 150
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @return bool
156 156
 	 */
157 157
 	public function is_available() {
158
-		if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
158
+		if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
159 159
 			return false;
160 160
 		}
161 161
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 		$icons_str .= $icons['p24'];
178 178
 
179
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
179
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
180 180
 	}
181 181
 
182 182
 	/**
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
 	 * @access public
188 188
 	 */
189 189
 	public function payment_scripts() {
190
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) {
190
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) {
191 191
 			return;
192 192
 		}
193 193
 
194
-		wp_enqueue_style( 'stripe_paymentfonts' );
195
-		wp_enqueue_script( 'woocommerce_stripe' );
194
+		wp_enqueue_style('stripe_paymentfonts');
195
+		wp_enqueue_script('woocommerce_stripe');
196 196
 	}
197 197
 
198 198
 	/**
199 199
 	 * Initialize Gateway Settings Form Fields.
200 200
 	 */
201 201
 	public function init_form_fields() {
202
-		$this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-p24-settings.php' );
202
+		$this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-p24-settings.php');
203 203
 	}
204 204
 
205 205
 	/**
@@ -210,25 +210,25 @@  discard block
 block discarded – undo
210 210
 		$total                = WC()->cart->total;
211 211
 
212 212
 		// If paying from order, we need to get total from order not cart.
213
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
214
-			$order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) );
213
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
214
+			$order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key'])));
215 215
 			$total = $order->get_total();
216 216
 		}
217 217
 
218
-		if ( is_add_payment_method_page() ) {
219
-			$pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' );
220
-			$total        = '';
218
+		if (is_add_payment_method_page()) {
219
+			$pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe');
220
+			$total = '';
221 221
 		} else {
222 222
 			$pay_button_text = '';
223 223
 		}
224 224
 
225 225
 		echo '<div
226 226
 			id="stripe-p24-payment-data"
227
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
228
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">';
227
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
228
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">';
229 229
 
230
-		if ( $this->description ) {
231
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) );
230
+		if ($this->description) {
231
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description)));
232 232
 		}
233 233
 
234 234
 		echo '</div>';
@@ -242,20 +242,20 @@  discard block
 block discarded – undo
242 242
 	 * @param object $order
243 243
 	 * @return mixed
244 244
 	 */
245
-	public function create_source( $order ) {
245
+	public function create_source($order) {
246 246
 		$currency              = WC_Stripe_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency();
247 247
 		$order_id              = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
248
-		$return_url            = $this->get_stripe_return_url( $order );
248
+		$return_url            = $this->get_stripe_return_url($order);
249 249
 		$post_data             = array();
250
-		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency );
251
-		$post_data['currency'] = strtolower( $currency );
250
+		$post_data['amount']   = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency);
251
+		$post_data['currency'] = strtolower($currency);
252 252
 		$post_data['type']     = 'p24';
253
-		$post_data['owner']    = $this->get_owner_details( $order );
254
-		$post_data['redirect'] = array( 'return_url' => $return_url );
253
+		$post_data['owner']    = $this->get_owner_details($order);
254
+		$post_data['redirect'] = array('return_url' => $return_url);
255 255
 
256
-		WC_Stripe_Logger::log( 'Info: Begin creating P24 source' );
256
+		WC_Stripe_Logger::log('Info: Begin creating P24 source');
257 257
 
258
-		return WC_Stripe_API::request( apply_filters( 'wc_stripe_p24_source', $post_data, $order ), 'sources' );
258
+		return WC_Stripe_API::request(apply_filters('wc_stripe_p24_source', $post_data, $order), 'sources');
259 259
 	}
260 260
 
261 261
 	/**
@@ -269,51 +269,51 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 * @return array|void
271 271
 	 */
272
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
272
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
273 273
 		try {
274
-			$order = wc_get_order( $order_id );
274
+			$order = wc_get_order($order_id);
275 275
 
276 276
 			// This will throw exception if not valid.
277
-			$this->validate_minimum_order_amount( $order );
277
+			$this->validate_minimum_order_amount($order);
278 278
 
279 279
 			// This comes from the create account checkbox in the checkout page.
280
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
280
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
281 281
 
282
-			if ( $create_account ) {
282
+			if ($create_account) {
283 283
 				$new_customer_id     = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id();
284
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
284
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
285 285
 				$new_stripe_customer->create_customer();
286 286
 			}
287 287
 
288
-			$response = $this->create_source( $order );
288
+			$response = $this->create_source($order);
289 289
 
290
-			if ( ! empty( $response->error ) ) {
291
-				$order->add_order_note( $response->error->message );
290
+			if ( ! empty($response->error)) {
291
+				$order->add_order_note($response->error->message);
292 292
 
293
-				throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
293
+				throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
294 294
 			}
295 295
 
296
-			if ( WC_Stripe_Helper::is_pre_30() ) {
297
-				update_post_meta( $order_id, '_stripe_source_id', $response->id );
296
+			if (WC_Stripe_Helper::is_pre_30()) {
297
+				update_post_meta($order_id, '_stripe_source_id', $response->id);
298 298
 			} else {
299
-				$order->update_meta_data( '_stripe_source_id', $response->id );
299
+				$order->update_meta_data('_stripe_source_id', $response->id);
300 300
 				$order->save();
301 301
 			}
302 302
 
303
-			WC_Stripe_Logger::log( 'Info: Redirecting to P24...' );
303
+			WC_Stripe_Logger::log('Info: Redirecting to P24...');
304 304
 
305 305
 			return array(
306 306
 				'result'   => 'success',
307
-				'redirect' => esc_url_raw( $response->redirect->url ),
307
+				'redirect' => esc_url_raw($response->redirect->url),
308 308
 			);
309
-		} catch ( WC_Stripe_Exception $e ) {
310
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
311
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
309
+		} catch (WC_Stripe_Exception $e) {
310
+			wc_add_notice($e->getLocalizedMessage(), 'error');
311
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
312 312
 
313
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
313
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
314 314
 
315
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
316
-				$this->send_failed_order_email( $order_id );
315
+			if ($order->has_status(array('pending', 'failed'))) {
316
+				$this->send_failed_order_email($order_id);
317 317
 			}
318 318
 
319 319
 			return array(
Please login to merge, or discard this patch.
includes/payment-methods/class-wc-gateway-stripe-alipay.php 1 patch
Spacing   +77 added lines, -77 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
 
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function __construct() {
59 59
 		$this->id                   = 'stripe_alipay';
60
-		$this->method_title         = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' );
60
+		$this->method_title         = __('Stripe Alipay', 'woocommerce-gateway-stripe');
61 61
 		/* translators: link */
62
-		$this->method_description   = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
62
+		$this->method_description   = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe'));
63 63
 		$this->supports             = array(
64 64
 			'products',
65 65
 			'refunds',
@@ -71,25 +71,25 @@  discard block
 block discarded – undo
71 71
 		// Load the settings.
72 72
 		$this->init_settings();
73 73
 
74
-		$main_settings              = get_option( 'woocommerce_stripe_settings' );
75
-		$this->title                = $this->get_option( 'title' );
76
-		$this->description          = $this->get_option( 'description' );
77
-		$this->enabled              = $this->get_option( 'enabled' );
78
-		$this->testmode             = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false;
79
-		$this->saved_cards          = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false;
80
-		$this->publishable_key      = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : '';
81
-		$this->secret_key           = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : '';
82
-		$this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : '';
83
-
84
-		if ( $this->testmode ) {
85
-			$this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : '';
86
-			$this->secret_key      = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : '';
74
+		$main_settings              = get_option('woocommerce_stripe_settings');
75
+		$this->title                = $this->get_option('title');
76
+		$this->description          = $this->get_option('description');
77
+		$this->enabled              = $this->get_option('enabled');
78
+		$this->testmode             = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false;
79
+		$this->saved_cards          = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false;
80
+		$this->publishable_key      = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : '';
81
+		$this->secret_key           = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : '';
82
+		$this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : '';
83
+
84
+		if ($this->testmode) {
85
+			$this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : '';
86
+			$this->secret_key      = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : '';
87 87
 		}
88 88
 
89
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
90
-		add_action( 'admin_notices', array( $this, 'check_environment' ) );
91
-		add_action( 'admin_head', array( $this, 'remove_admin_notice' ) );
92
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
89
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
90
+		add_action('admin_notices', array($this, 'check_environment'));
91
+		add_action('admin_head', array($this, 'remove_admin_notice'));
92
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
93 93
 	}
94 94
 
95 95
 	/**
@@ -99,19 +99,19 @@  discard block
 block discarded – undo
99 99
 	 * @version 4.0.0
100 100
 	 */
101 101
 	public function check_environment() {
102
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
102
+		if ( ! current_user_can('manage_woocommerce')) {
103 103
 			return;
104 104
 		}
105 105
 
106 106
 		$environment_warning = $this->get_environment_warning();
107 107
 
108
-		if ( $environment_warning ) {
109
-			$this->add_admin_notice( 'bad_environment', 'error', $environment_warning );
108
+		if ($environment_warning) {
109
+			$this->add_admin_notice('bad_environment', 'error', $environment_warning);
110 110
 		}
111 111
 
112
-		foreach ( (array) $this->notices as $notice_key => $notice ) {
113
-			echo "<div class='" . esc_attr( $notice['class'] ) . "'><p>";
114
-			echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) );
112
+		foreach ((array) $this->notices as $notice_key => $notice) {
113
+			echo "<div class='" . esc_attr($notice['class']) . "'><p>";
114
+			echo wp_kses($notice['message'], array('a' => array('href' => array())));
115 115
 			echo '</p></div>';
116 116
 		}
117 117
 	}
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function get_environment_warning() {
127 127
 		if (
128
-			'yes' === $this->enabled && ! in_array( get_woocommerce_currency(), $this->get_supported_currency() )
128
+			'yes' === $this->enabled && ! in_array(get_woocommerce_currency(), $this->get_supported_currency())
129 129
 		) {
130 130
 			/* translators: supported currency list */
131
-			$message = sprintf( __( 'Alipay is enabled - it requires store currency to be set to %s', 'woocommerce-gateway-stripe' ), implode( ', ', $this->get_supported_currency() ) );
131
+			$message = sprintf(__('Alipay is enabled - it requires store currency to be set to %s', 'woocommerce-gateway-stripe'), implode(', ', $this->get_supported_currency()));
132 132
 
133 133
 			return $message;
134 134
 		}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @return array
145 145
 	 */
146 146
 	public function get_supported_currency() {
147
-		return apply_filters( 'wc_stripe_alipay_supported_currencies', array(
147
+		return apply_filters('wc_stripe_alipay_supported_currencies', array(
148 148
 			'EUR',
149 149
 			'AUD',
150 150
 			'CAD',
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 			'NZD',
155 155
 			'SGD',
156 156
 			'USD',
157
-		) );
157
+		));
158 158
 	}
159 159
 
160 160
 	/**
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @return bool
166 166
 	 */
167 167
 	public function is_available() {
168
-		if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
168
+		if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
169 169
 			return false;
170 170
 		}
171 171
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
 		$icons_str .= $icons['alipay'];
188 188
 
189
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
189
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
190 190
 	}
191 191
 
192 192
 	/**
@@ -196,19 +196,19 @@  discard block
 block discarded – undo
196 196
 	 * @version 4.0.0
197 197
 	 */
198 198
 	public function payment_scripts() {
199
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) {
199
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) {
200 200
 			return;
201 201
 		}
202 202
 
203
-		wp_enqueue_style( 'stripe_paymentfonts' );
204
-		wp_enqueue_script( 'woocommerce_stripe' );
203
+		wp_enqueue_style('stripe_paymentfonts');
204
+		wp_enqueue_script('woocommerce_stripe');
205 205
 	}
206 206
 
207 207
 	/**
208 208
 	 * Initialize Gateway Settings Form Fields.
209 209
 	 */
210 210
 	public function init_form_fields() {
211
-		$this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-alipay-settings.php' );
211
+		$this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-alipay-settings.php');
212 212
 	}
213 213
 
214 214
 	/**
@@ -219,25 +219,25 @@  discard block
 block discarded – undo
219 219
 		$total                = WC()->cart->total;
220 220
 
221 221
 		// If paying from order, we need to get total from order not cart.
222
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
223
-			$order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) );
222
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
223
+			$order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key'])));
224 224
 			$total = $order->get_total();
225 225
 		}
226 226
 
227
-		if ( is_add_payment_method_page() ) {
228
-			$pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' );
229
-			$total        = '';
227
+		if (is_add_payment_method_page()) {
228
+			$pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe');
229
+			$total = '';
230 230
 		} else {
231 231
 			$pay_button_text = '';
232 232
 		}
233 233
 
234 234
 		echo '<div
235 235
 			id="stripe-alipay-payment-data"
236
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
237
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">';
236
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
237
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">';
238 238
 
239
-		if ( $this->description ) {
240
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) );
239
+		if ($this->description) {
240
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description)));
241 241
 		}
242 242
 
243 243
 		echo '</div>';
@@ -251,24 +251,24 @@  discard block
 block discarded – undo
251 251
 	 * @param object $order
252 252
 	 * @return mixed
253 253
 	 */
254
-	public function create_source( $order ) {
254
+	public function create_source($order) {
255 255
 		$currency                          = WC_Stripe_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency();
256 256
 		$order_id                          = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
257
-		$return_url                        = $this->get_stripe_return_url( $order );
257
+		$return_url                        = $this->get_stripe_return_url($order);
258 258
 		$post_data                         = array();
259
-		$post_data['amount']               = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency );
260
-		$post_data['currency']             = strtolower( $currency );
259
+		$post_data['amount']               = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency);
260
+		$post_data['currency']             = strtolower($currency);
261 261
 		$post_data['type']                 = 'alipay';
262
-		$post_data['owner']                = $this->get_owner_details( $order );
263
-		$post_data['redirect']             = array( 'return_url' => $return_url );
262
+		$post_data['owner']                = $this->get_owner_details($order);
263
+		$post_data['redirect']             = array('return_url' => $return_url);
264 264
 
265
-		if ( ! empty( $this->statement_descriptor ) ) {
266
-			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor );
265
+		if ( ! empty($this->statement_descriptor)) {
266
+			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor);
267 267
 		}
268 268
 
269
-		WC_Stripe_Logger::log( 'Info: Begin creating Alipay source' );
269
+		WC_Stripe_Logger::log('Info: Begin creating Alipay source');
270 270
 
271
-		return WC_Stripe_API::request( apply_filters( 'wc_stripe_alipay_source', $post_data, $order ), 'sources' );
271
+		return WC_Stripe_API::request(apply_filters('wc_stripe_alipay_source', $post_data, $order), 'sources');
272 272
 	}
273 273
 
274 274
 	/**
@@ -282,53 +282,53 @@  discard block
 block discarded – undo
282 282
 	 *
283 283
 	 * @return array|void
284 284
 	 */
285
-	public function process_payment( $order_id, $retry = true, $force_save_save = false ) {
285
+	public function process_payment($order_id, $retry = true, $force_save_save = false) {
286 286
 		try {
287
-			$order = wc_get_order( $order_id );
287
+			$order = wc_get_order($order_id);
288 288
 
289 289
 			// This will throw exception if not valid.
290
-			$this->validate_minimum_order_amount( $order );
290
+			$this->validate_minimum_order_amount($order);
291 291
 
292 292
 			// This comes from the create account checkbox in the checkout page.
293
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
293
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
294 294
 
295
-			if ( $create_account ) {
295
+			if ($create_account) {
296 296
 				$new_customer_id     = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id();
297
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
297
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
298 298
 				$new_stripe_customer->create_customer();
299 299
 			}
300 300
 
301
-			$response = $this->create_source( $order );
301
+			$response = $this->create_source($order);
302 302
 
303
-			if ( ! empty( $response->error ) ) {
304
-				$order->add_order_note( $response->error->message );
303
+			if ( ! empty($response->error)) {
304
+				$order->add_order_note($response->error->message);
305 305
 
306
-				throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
306
+				throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
307 307
 			}
308 308
 
309
-			if ( WC_Stripe_Helper::is_pre_30() ) {
310
-				update_post_meta( $order_id, '_stripe_source_id', $response->id );
309
+			if (WC_Stripe_Helper::is_pre_30()) {
310
+				update_post_meta($order_id, '_stripe_source_id', $response->id);
311 311
 			} else {
312
-				$order->update_meta_data( '_stripe_source_id', $response->id );
312
+				$order->update_meta_data('_stripe_source_id', $response->id);
313 313
 				$order->save();
314 314
 			}
315 315
 
316
-			WC_Stripe_Logger::log( 'Info: Redirecting to Alipay...' );
316
+			WC_Stripe_Logger::log('Info: Redirecting to Alipay...');
317 317
 
318 318
 			return array(
319 319
 				'result'   => 'success',
320
-				'redirect' => esc_url_raw( $response->redirect->url ),
320
+				'redirect' => esc_url_raw($response->redirect->url),
321 321
 			);
322
-		} catch ( WC_Stripe_Exception $e ) {
323
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
324
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
322
+		} catch (WC_Stripe_Exception $e) {
323
+			wc_add_notice($e->getLocalizedMessage(), 'error');
324
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
325 325
 
326
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
326
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
327 327
 
328
-			$statuses = array( 'pending', 'failed' );
328
+			$statuses = array('pending', 'failed');
329 329
 
330
-			if ( $order->has_status( $statuses ) ) {
331
-				$this->send_failed_order_email( $order_id );
330
+			if ($order->has_status($statuses)) {
331
+				$this->send_failed_order_email($order_id);
332 332
 			}
333 333
 
334 334
 			return array(
Please login to merge, or discard this patch.
includes/payment-methods/class-wc-gateway-stripe-giropay.php 1 patch
Spacing   +76 added lines, -76 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
 
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function __construct() {
59 59
 		$this->id                   = 'stripe_giropay';
60
-		$this->method_title         = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' );
60
+		$this->method_title         = __('Stripe Giropay', 'woocommerce-gateway-stripe');
61 61
 		/* translators: link */
62
-		$this->method_description   = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
62
+		$this->method_description   = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe'));
63 63
 		$this->supports             = array(
64 64
 			'products',
65 65
 			'refunds',
@@ -71,25 +71,25 @@  discard block
 block discarded – undo
71 71
 		// Load the settings.
72 72
 		$this->init_settings();
73 73
 
74
-		$main_settings              = get_option( 'woocommerce_stripe_settings' );
75
-		$this->title                = $this->get_option( 'title' );
76
-		$this->description          = $this->get_option( 'description' );
77
-		$this->enabled              = $this->get_option( 'enabled' );
78
-		$this->testmode             = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false;
79
-		$this->saved_cards          = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false;
80
-		$this->publishable_key      = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : '';
81
-		$this->secret_key           = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : '';
82
-		$this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : '';
83
-
84
-		if ( $this->testmode ) {
85
-			$this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : '';
86
-			$this->secret_key      = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : '';
74
+		$main_settings              = get_option('woocommerce_stripe_settings');
75
+		$this->title                = $this->get_option('title');
76
+		$this->description          = $this->get_option('description');
77
+		$this->enabled              = $this->get_option('enabled');
78
+		$this->testmode             = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false;
79
+		$this->saved_cards          = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false;
80
+		$this->publishable_key      = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : '';
81
+		$this->secret_key           = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : '';
82
+		$this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : '';
83
+
84
+		if ($this->testmode) {
85
+			$this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : '';
86
+			$this->secret_key      = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : '';
87 87
 		}
88 88
 
89
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
90
-		add_action( 'admin_notices', array( $this, 'check_environment' ) );
91
-		add_action( 'admin_head', array( $this, 'remove_admin_notice' ) );
92
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
89
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
90
+		add_action('admin_notices', array($this, 'check_environment'));
91
+		add_action('admin_head', array($this, 'remove_admin_notice'));
92
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
93 93
 	}
94 94
 
95 95
 	/**
@@ -99,19 +99,19 @@  discard block
 block discarded – undo
99 99
 	 * @version 4.0.0
100 100
 	 */
101 101
 	public function check_environment() {
102
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
102
+		if ( ! current_user_can('manage_woocommerce')) {
103 103
 			return;
104 104
 		}
105 105
 
106 106
 		$environment_warning = $this->get_environment_warning();
107 107
 
108
-		if ( $environment_warning ) {
109
-			$this->add_admin_notice( 'bad_environment', 'error', $environment_warning );
108
+		if ($environment_warning) {
109
+			$this->add_admin_notice('bad_environment', 'error', $environment_warning);
110 110
 		}
111 111
 
112
-		foreach ( (array) $this->notices as $notice_key => $notice ) {
113
-			echo "<div class='" . esc_attr( $notice['class'] ) . "'><p>";
114
-			echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) );
112
+		foreach ((array) $this->notices as $notice_key => $notice) {
113
+			echo "<div class='" . esc_attr($notice['class']) . "'><p>";
114
+			echo wp_kses($notice['message'], array('a' => array('href' => array())));
115 115
 			echo '</p></div>';
116 116
 		}
117 117
 	}
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 	 * @version 4.0.0
125 125
 	 */
126 126
 	public function get_environment_warning() {
127
-		if ( 'yes' === $this->enabled && ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
128
-			$message = __( 'Giropay is enabled - it requires store currency to be set to Euros.', 'woocommerce-gateway-stripe' );
127
+		if ('yes' === $this->enabled && ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
128
+			$message = __('Giropay is enabled - it requires store currency to be set to Euros.', 'woocommerce-gateway-stripe');
129 129
 
130 130
 			return $message;
131 131
 		}
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 	 * @return array
142 142
 	 */
143 143
 	public function get_supported_currency() {
144
-		return apply_filters( 'wc_stripe_giropay_supported_currencies', array(
144
+		return apply_filters('wc_stripe_giropay_supported_currencies', array(
145 145
 			'EUR',
146
-		) );
146
+		));
147 147
 	}
148 148
 
149 149
 	/**
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 * @return bool
155 155
 	 */
156 156
 	public function is_available() {
157
-		if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
157
+		if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
158 158
 			return false;
159 159
 		}
160 160
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 
176 176
 		$icons_str .= $icons['giropay'];
177 177
 
178
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
178
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
179 179
 	}
180 180
 
181 181
 	/**
@@ -186,19 +186,19 @@  discard block
 block discarded – undo
186 186
 	 * @access public
187 187
 	 */
188 188
 	public function payment_scripts() {
189
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) {
189
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) {
190 190
 			return;
191 191
 		}
192 192
 
193
-		wp_enqueue_style( 'stripe_paymentfonts' );
194
-		wp_enqueue_script( 'woocommerce_stripe' );
193
+		wp_enqueue_style('stripe_paymentfonts');
194
+		wp_enqueue_script('woocommerce_stripe');
195 195
 	}
196 196
 
197 197
 	/**
198 198
 	 * Initialize Gateway Settings Form Fields.
199 199
 	 */
200 200
 	public function init_form_fields() {
201
-		$this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-giropay-settings.php' );
201
+		$this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-giropay-settings.php');
202 202
 	}
203 203
 
204 204
 	/**
@@ -209,25 +209,25 @@  discard block
 block discarded – undo
209 209
 		$total                = WC()->cart->total;
210 210
 
211 211
 		// If paying from order, we need to get total from order not cart.
212
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
213
-			$order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) );
212
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
213
+			$order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key'])));
214 214
 			$total = $order->get_total();
215 215
 		}
216 216
 
217
-		if ( is_add_payment_method_page() ) {
218
-			$pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' );
219
-			$total        = '';
217
+		if (is_add_payment_method_page()) {
218
+			$pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe');
219
+			$total = '';
220 220
 		} else {
221 221
 			$pay_button_text = '';
222 222
 		}
223 223
 
224 224
 		echo '<div
225 225
 			id="stripe-giropay-payment-data"
226
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
227
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">';
226
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
227
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">';
228 228
 
229
-		if ( $this->description ) {
230
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) );
229
+		if ($this->description) {
230
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description)));
231 231
 		}
232 232
 
233 233
 		echo '</div>';
@@ -241,24 +241,24 @@  discard block
 block discarded – undo
241 241
 	 * @param object $order
242 242
 	 * @return mixed
243 243
 	 */
244
-	public function create_source( $order ) {
244
+	public function create_source($order) {
245 245
 		$currency                          = WC_Stripe_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency();
246 246
 		$order_id                          = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
247
-		$return_url                        = $this->get_stripe_return_url( $order );
247
+		$return_url                        = $this->get_stripe_return_url($order);
248 248
 		$post_data                         = array();
249
-		$post_data['amount']               = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency );
250
-		$post_data['currency']             = strtolower( $currency );
249
+		$post_data['amount']               = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency);
250
+		$post_data['currency']             = strtolower($currency);
251 251
 		$post_data['type']                 = 'giropay';
252
-		$post_data['owner']                = $this->get_owner_details( $order );
253
-		$post_data['redirect']             = array( 'return_url' => $return_url );
252
+		$post_data['owner']                = $this->get_owner_details($order);
253
+		$post_data['redirect']             = array('return_url' => $return_url);
254 254
 
255
-		if ( ! empty( $this->statement_descriptor ) ) {
256
-			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor );
255
+		if ( ! empty($this->statement_descriptor)) {
256
+			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor);
257 257
 		}
258 258
 
259
-		WC_Stripe_Logger::log( 'Info: Begin creating Giropay source' );
259
+		WC_Stripe_Logger::log('Info: Begin creating Giropay source');
260 260
 
261
-		return WC_Stripe_API::request( apply_filters( 'wc_stripe_giropay_source', $post_data, $order ), 'sources' );
261
+		return WC_Stripe_API::request(apply_filters('wc_stripe_giropay_source', $post_data, $order), 'sources');
262 262
 	}
263 263
 
264 264
 	/**
@@ -272,51 +272,51 @@  discard block
 block discarded – undo
272 272
 	 *
273 273
 	 * @return array|void
274 274
 	 */
275
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
275
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
276 276
 		try {
277
-			$order = wc_get_order( $order_id );
277
+			$order = wc_get_order($order_id);
278 278
 
279 279
 			// This will throw exception if not valid.
280
-			$this->validate_minimum_order_amount( $order );
280
+			$this->validate_minimum_order_amount($order);
281 281
 
282 282
 			// This comes from the create account checkbox in the checkout page.
283
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
283
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
284 284
 
285
-			if ( $create_account ) {
285
+			if ($create_account) {
286 286
 				$new_customer_id     = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id();
287
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
287
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
288 288
 				$new_stripe_customer->create_customer();
289 289
 			}
290 290
 
291
-			$response = $this->create_source( $order );
291
+			$response = $this->create_source($order);
292 292
 
293
-			if ( ! empty( $response->error ) ) {
294
-				$order->add_order_note( $response->error->message );
293
+			if ( ! empty($response->error)) {
294
+				$order->add_order_note($response->error->message);
295 295
 
296
-				throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
296
+				throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
297 297
 			}
298 298
 
299
-			if ( WC_Stripe_Helper::is_pre_30() ) {
300
-				update_post_meta( $order_id, '_stripe_source_id', $response->id );
299
+			if (WC_Stripe_Helper::is_pre_30()) {
300
+				update_post_meta($order_id, '_stripe_source_id', $response->id);
301 301
 			} else {
302
-				$order->update_meta_data( '_stripe_source_id', $response->id );
302
+				$order->update_meta_data('_stripe_source_id', $response->id);
303 303
 				$order->save();
304 304
 			}
305 305
 
306
-			WC_Stripe_Logger::log( 'Info: Redirecting to Giropay...' );
306
+			WC_Stripe_Logger::log('Info: Redirecting to Giropay...');
307 307
 
308 308
 			return array(
309 309
 				'result'   => 'success',
310
-				'redirect' => esc_url_raw( $response->redirect->url ),
310
+				'redirect' => esc_url_raw($response->redirect->url),
311 311
 			);
312
-		} catch ( WC_Stripe_Exception $e ) {
313
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
314
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
312
+		} catch (WC_Stripe_Exception $e) {
313
+			wc_add_notice($e->getLocalizedMessage(), 'error');
314
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
315 315
 
316
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
316
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
317 317
 
318
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
319
-				$this->send_failed_order_email( $order_id );
318
+			if ($order->has_status(array('pending', 'failed'))) {
319
+				$this->send_failed_order_email($order_id);
320 320
 			}
321 321
 
322 322
 			return array(
Please login to merge, or discard this patch.
includes/payment-methods/class-wc-gateway-stripe-ideal.php 1 patch
Spacing   +76 added lines, -76 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
 
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function __construct() {
59 59
 		$this->id                   = 'stripe_ideal';
60
-		$this->method_title         = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' );
60
+		$this->method_title         = __('Stripe iDeal', 'woocommerce-gateway-stripe');
61 61
 		/* translators: link */
62
-		$this->method_description   = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
62
+		$this->method_description   = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe'));
63 63
 		$this->supports             = array(
64 64
 			'products',
65 65
 			'refunds',
@@ -71,25 +71,25 @@  discard block
 block discarded – undo
71 71
 		// Load the settings.
72 72
 		$this->init_settings();
73 73
 
74
-		$main_settings              = get_option( 'woocommerce_stripe_settings' );
75
-		$this->title                = $this->get_option( 'title' );
76
-		$this->description          = $this->get_option( 'description' );
77
-		$this->enabled              = $this->get_option( 'enabled' );
78
-		$this->testmode             = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false;
79
-		$this->saved_cards          = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false;
80
-		$this->publishable_key      = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : '';
81
-		$this->secret_key           = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : '';
82
-		$this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : '';
83
-
84
-		if ( $this->testmode ) {
85
-			$this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : '';
86
-			$this->secret_key      = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : '';
74
+		$main_settings              = get_option('woocommerce_stripe_settings');
75
+		$this->title                = $this->get_option('title');
76
+		$this->description          = $this->get_option('description');
77
+		$this->enabled              = $this->get_option('enabled');
78
+		$this->testmode             = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false;
79
+		$this->saved_cards          = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false;
80
+		$this->publishable_key      = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : '';
81
+		$this->secret_key           = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : '';
82
+		$this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : '';
83
+
84
+		if ($this->testmode) {
85
+			$this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : '';
86
+			$this->secret_key      = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : '';
87 87
 		}
88 88
 
89
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
90
-		add_action( 'admin_notices', array( $this, 'check_environment' ) );
91
-		add_action( 'admin_head', array( $this, 'remove_admin_notice' ) );
92
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
89
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
90
+		add_action('admin_notices', array($this, 'check_environment'));
91
+		add_action('admin_head', array($this, 'remove_admin_notice'));
92
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
93 93
 	}
94 94
 
95 95
 	/**
@@ -99,19 +99,19 @@  discard block
 block discarded – undo
99 99
 	 * @version 4.0.0
100 100
 	 */
101 101
 	public function check_environment() {
102
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
102
+		if ( ! current_user_can('manage_woocommerce')) {
103 103
 			return;
104 104
 		}
105 105
 
106 106
 		$environment_warning = $this->get_environment_warning();
107 107
 
108
-		if ( $environment_warning ) {
109
-			$this->add_admin_notice( 'bad_environment', 'error', $environment_warning );
108
+		if ($environment_warning) {
109
+			$this->add_admin_notice('bad_environment', 'error', $environment_warning);
110 110
 		}
111 111
 
112
-		foreach ( (array) $this->notices as $notice_key => $notice ) {
113
-			echo "<div class='" . esc_attr( $notice['class'] ) . "'><p>";
114
-			echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) );
112
+		foreach ((array) $this->notices as $notice_key => $notice) {
113
+			echo "<div class='" . esc_attr($notice['class']) . "'><p>";
114
+			echo wp_kses($notice['message'], array('a' => array('href' => array())));
115 115
 			echo '</p></div>';
116 116
 		}
117 117
 	}
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 	 * @version 4.0.0
125 125
 	 */
126 126
 	public function get_environment_warning() {
127
-		if ( 'yes' === $this->enabled && ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
128
-			$message = __( 'iDeal is enabled - it requires store currency to be set to Euros.', 'woocommerce-gateway-stripe' );
127
+		if ('yes' === $this->enabled && ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
128
+			$message = __('iDeal is enabled - it requires store currency to be set to Euros.', 'woocommerce-gateway-stripe');
129 129
 
130 130
 			return $message;
131 131
 		}
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 	 * @return array
142 142
 	 */
143 143
 	public function get_supported_currency() {
144
-		return apply_filters( 'wc_stripe_ideal_supported_currencies', array(
144
+		return apply_filters('wc_stripe_ideal_supported_currencies', array(
145 145
 			'EUR',
146
-		) );
146
+		));
147 147
 	}
148 148
 
149 149
 	/**
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 * @return bool
155 155
 	 */
156 156
 	public function is_available() {
157
-		if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
157
+		if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
158 158
 			return false;
159 159
 		}
160 160
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 
176 176
 		$icons_str .= $icons['ideal'];
177 177
 
178
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
178
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
179 179
 	}
180 180
 
181 181
 	/**
@@ -186,19 +186,19 @@  discard block
 block discarded – undo
186 186
 	 * @access public
187 187
 	 */
188 188
 	public function payment_scripts() {
189
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) {
189
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) {
190 190
 			return;
191 191
 		}
192 192
 
193
-		wp_enqueue_style( 'stripe_paymentfonts' );
194
-		wp_enqueue_script( 'woocommerce_stripe' );
193
+		wp_enqueue_style('stripe_paymentfonts');
194
+		wp_enqueue_script('woocommerce_stripe');
195 195
 	}
196 196
 
197 197
 	/**
198 198
 	 * Initialize Gateway Settings Form Fields.
199 199
 	 */
200 200
 	public function init_form_fields() {
201
-		$this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-ideal-settings.php' );
201
+		$this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-ideal-settings.php');
202 202
 	}
203 203
 
204 204
 	/**
@@ -209,25 +209,25 @@  discard block
 block discarded – undo
209 209
 		$total                = WC()->cart->total;
210 210
 
211 211
 		// If paying from order, we need to get total from order not cart.
212
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
213
-			$order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) );
212
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
213
+			$order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key'])));
214 214
 			$total = $order->get_total();
215 215
 		}
216 216
 
217
-		if ( is_add_payment_method_page() ) {
218
-			$pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' );
219
-			$total        = '';
217
+		if (is_add_payment_method_page()) {
218
+			$pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe');
219
+			$total = '';
220 220
 		} else {
221 221
 			$pay_button_text = '';
222 222
 		}
223 223
 
224 224
 		echo '<div
225 225
 			id="stripe-ideal-payment-data"
226
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
227
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">';
226
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
227
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">';
228 228
 
229
-		if ( $this->description ) {
230
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) );
229
+		if ($this->description) {
230
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description)));
231 231
 		}
232 232
 
233 233
 		echo '</div>';
@@ -241,24 +241,24 @@  discard block
 block discarded – undo
241 241
 	 * @param object $order
242 242
 	 * @return mixed
243 243
 	 */
244
-	public function create_source( $order ) {
244
+	public function create_source($order) {
245 245
 		$currency                          = WC_Stripe_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency();
246 246
 		$order_id                          = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id();
247
-		$return_url                        = $this->get_stripe_return_url( $order );
247
+		$return_url                        = $this->get_stripe_return_url($order);
248 248
 		$post_data                         = array();
249
-		$post_data['amount']               = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency );
250
-		$post_data['currency']             = strtolower( $currency );
249
+		$post_data['amount']               = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency);
250
+		$post_data['currency']             = strtolower($currency);
251 251
 		$post_data['type']                 = 'ideal';
252
-		$post_data['owner']                = $this->get_owner_details( $order );
253
-		$post_data['redirect']             = array( 'return_url' => $return_url );
252
+		$post_data['owner']                = $this->get_owner_details($order);
253
+		$post_data['redirect']             = array('return_url' => $return_url);
254 254
 
255
-		if ( ! empty( $this->statement_descriptor ) ) {
256
-			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor );
255
+		if ( ! empty($this->statement_descriptor)) {
256
+			$post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor);
257 257
 		}
258 258
 
259
-		WC_Stripe_Logger::log( 'Info: Begin creating iDeal source' );
259
+		WC_Stripe_Logger::log('Info: Begin creating iDeal source');
260 260
 
261
-		return WC_Stripe_API::request( apply_filters( 'wc_stripe_ideal_source', $post_data, $order ), 'sources' );
261
+		return WC_Stripe_API::request(apply_filters('wc_stripe_ideal_source', $post_data, $order), 'sources');
262 262
 	}
263 263
 
264 264
 	/**
@@ -272,51 +272,51 @@  discard block
 block discarded – undo
272 272
 	 *
273 273
 	 * @return array|void
274 274
 	 */
275
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
275
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
276 276
 		try {
277
-			$order = wc_get_order( $order_id );
277
+			$order = wc_get_order($order_id);
278 278
 
279 279
 			// This will throw exception if not valid.
280
-			$this->validate_minimum_order_amount( $order );
280
+			$this->validate_minimum_order_amount($order);
281 281
 
282 282
 			// This comes from the create account checkbox in the checkout page.
283
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
283
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
284 284
 
285
-			if ( $create_account ) {
285
+			if ($create_account) {
286 286
 				$new_customer_id     = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id();
287
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
287
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
288 288
 				$new_stripe_customer->create_customer();
289 289
 			}
290 290
 
291
-			$response = $this->create_source( $order );
291
+			$response = $this->create_source($order);
292 292
 
293
-			if ( ! empty( $response->error ) ) {
294
-				$order->add_order_note( $response->error->message );
293
+			if ( ! empty($response->error)) {
294
+				$order->add_order_note($response->error->message);
295 295
 
296
-				throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message );
296
+				throw new WC_Stripe_Exception(print_r($response, true), $response->error->message);
297 297
 			}
298 298
 
299
-			if ( WC_Stripe_Helper::is_pre_30() ) {
300
-				update_post_meta( $order_id, '_stripe_source_id', $response->id );
299
+			if (WC_Stripe_Helper::is_pre_30()) {
300
+				update_post_meta($order_id, '_stripe_source_id', $response->id);
301 301
 			} else {
302
-				$order->update_meta_data( '_stripe_source_id', $response->id );
302
+				$order->update_meta_data('_stripe_source_id', $response->id);
303 303
 				$order->save();
304 304
 			}
305 305
 
306
-			WC_Stripe_Logger::log( 'Info: Redirecting to iDeal...' );
306
+			WC_Stripe_Logger::log('Info: Redirecting to iDeal...');
307 307
 
308 308
 			return array(
309 309
 				'result'   => 'success',
310
-				'redirect' => esc_url_raw( $response->redirect->url ),
310
+				'redirect' => esc_url_raw($response->redirect->url),
311 311
 			);
312
-		} catch ( WC_Stripe_Exception $e ) {
313
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
314
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
312
+		} catch (WC_Stripe_Exception $e) {
313
+			wc_add_notice($e->getLocalizedMessage(), 'error');
314
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
315 315
 
316
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
316
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
317 317
 
318
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
319
-				$this->send_failed_order_email( $order_id );
318
+			if ($order->has_status(array('pending', 'failed'))) {
319
+				$this->send_failed_order_email($order_id);
320 320
 			}
321 321
 
322 322
 			return array(
Please login to merge, or discard this patch.
includes/payment-methods/class-wc-gateway-stripe-sepa.php 1 patch
Spacing   +102 added lines, -102 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
 
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function __construct() {
59 59
 		$this->id                   = 'stripe_sepa';
60
-		$this->method_title         = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' );
60
+		$this->method_title         = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe');
61 61
 		/* translators: link */
62
-		$this->method_description   = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) );
62
+		$this->method_description   = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout&section=stripe'));
63 63
 		$this->supports             = array(
64 64
 			'products',
65 65
 			'refunds',
@@ -84,25 +84,25 @@  discard block
 block discarded – undo
84 84
 		// Load the settings.
85 85
 		$this->init_settings();
86 86
 
87
-		$main_settings              = get_option( 'woocommerce_stripe_settings' );
88
-		$this->title                = $this->get_option( 'title' );
89
-		$this->description          = $this->get_option( 'description' );
90
-		$this->enabled              = $this->get_option( 'enabled' );
91
-		$this->testmode             = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false;
92
-		$this->saved_cards          = ( ! empty( $main_settings['saved_cards'] ) && 'yes' === $main_settings['saved_cards'] ) ? true : false;
93
-		$this->publishable_key      = ! empty( $main_settings['publishable_key'] ) ? $main_settings['publishable_key'] : '';
94
-		$this->secret_key           = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : '';
95
-		$this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : '';
96
-
97
-		if ( $this->testmode ) {
98
-			$this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : '';
99
-			$this->secret_key      = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : '';
87
+		$main_settings              = get_option('woocommerce_stripe_settings');
88
+		$this->title                = $this->get_option('title');
89
+		$this->description          = $this->get_option('description');
90
+		$this->enabled              = $this->get_option('enabled');
91
+		$this->testmode             = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false;
92
+		$this->saved_cards          = ( ! empty($main_settings['saved_cards']) && 'yes' === $main_settings['saved_cards']) ? true : false;
93
+		$this->publishable_key      = ! empty($main_settings['publishable_key']) ? $main_settings['publishable_key'] : '';
94
+		$this->secret_key           = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : '';
95
+		$this->statement_descriptor = ! empty($main_settings['statement_descriptor']) ? $main_settings['statement_descriptor'] : '';
96
+
97
+		if ($this->testmode) {
98
+			$this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : '';
99
+			$this->secret_key      = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : '';
100 100
 		}
101 101
 
102
-		add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
103
-		add_action( 'admin_notices', array( $this, 'check_environment' ) );
104
-		add_action( 'admin_head', array( $this, 'remove_admin_notice' ) );
105
-		add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
102
+		add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
103
+		add_action('admin_notices', array($this, 'check_environment'));
104
+		add_action('admin_head', array($this, 'remove_admin_notice'));
105
+		add_action('wp_enqueue_scripts', array($this, 'payment_scripts'));
106 106
 	}
107 107
 
108 108
 	/**
@@ -112,19 +112,19 @@  discard block
 block discarded – undo
112 112
 	 * @version 4.0.0
113 113
 	 */
114 114
 	public function check_environment() {
115
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
115
+		if ( ! current_user_can('manage_woocommerce')) {
116 116
 			return;
117 117
 		}
118 118
 
119 119
 		$environment_warning = $this->get_environment_warning();
120 120
 
121
-		if ( $environment_warning ) {
122
-			$this->add_admin_notice( 'bad_environment', 'error', $environment_warning );
121
+		if ($environment_warning) {
122
+			$this->add_admin_notice('bad_environment', 'error', $environment_warning);
123 123
 		}
124 124
 
125
-		foreach ( (array) $this->notices as $notice_key => $notice ) {
126
-			echo "<div class='" . esc_attr( $notice['class'] ) . "'><p>";
127
-			echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) );
125
+		foreach ((array) $this->notices as $notice_key => $notice) {
126
+			echo "<div class='" . esc_attr($notice['class']) . "'><p>";
127
+			echo wp_kses($notice['message'], array('a' => array('href' => array())));
128 128
 			echo '</p></div>';
129 129
 		}
130 130
 	}
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 	 * @version 4.0.0
138 138
 	 */
139 139
 	public function get_environment_warning() {
140
-		if ( 'yes' === $this->enabled && ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
141
-			$message = __( 'SEPA is enabled - it requires store currency to be set to Euros.', 'woocommerce-gateway-stripe' );
140
+		if ('yes' === $this->enabled && ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
141
+			$message = __('SEPA is enabled - it requires store currency to be set to Euros.', 'woocommerce-gateway-stripe');
142 142
 
143 143
 			return $message;
144 144
 		}
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
 	 * @return array
155 155
 	 */
156 156
 	public function get_supported_currency() {
157
-		return apply_filters( 'wc_stripe_sepa_supported_currencies', array(
157
+		return apply_filters('wc_stripe_sepa_supported_currencies', array(
158 158
 			'EUR',
159
-		) );
159
+		));
160 160
 	}
161 161
 
162 162
 	/**
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 	 * @return bool
168 168
 	 */
169 169
 	public function is_available() {
170
-		if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) {
170
+		if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) {
171 171
 			return false;
172 172
 		}
173 173
 
174
-		if ( is_add_payment_method_page() && ! $this->saved_cards ) {
174
+		if (is_add_payment_method_page() && ! $this->saved_cards) {
175 175
 			return false;
176 176
 		}
177 177
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$icons_str .= $icons['sepa'];
194 194
 
195
-		return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id );
195
+		return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id);
196 196
 	}
197 197
 
198 198
 	/**
@@ -203,19 +203,19 @@  discard block
 block discarded – undo
203 203
 	 * @access public
204 204
 	 */
205 205
 	public function payment_scripts() {
206
-		if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) {
206
+		if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) {
207 207
 			return;
208 208
 		}
209 209
 
210
-		wp_enqueue_style( 'stripe_paymentfonts' );
211
-		wp_enqueue_script( 'woocommerce_stripe' );
210
+		wp_enqueue_style('stripe_paymentfonts');
211
+		wp_enqueue_script('woocommerce_stripe');
212 212
 	}
213 213
 
214 214
 	/**
215 215
 	 * Initialize Gateway Settings Form Fields.
216 216
 	 */
217 217
 	public function init_form_fields() {
218
-		$this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-sepa-settings.php' );
218
+		$this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-sepa-settings.php');
219 219
 	}
220 220
 
221 221
 	/**
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	public function mandate_display() {
229 229
 		/* translators: statement descriptor */
230
-		printf( __( 'By providing your IBAN and confirming this payment, you are authorizing %s and Stripe, our payment service provider, to send instructions to your bank to debit your account and your bank to debit your account in accordance with those instructions. You are entitled to a refund from your bank under the terms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited.', 'woocommerce-gateway-stripe' ), WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor ) );
230
+		printf(__('By providing your IBAN and confirming this payment, you are authorizing %s and Stripe, our payment service provider, to send instructions to your bank to debit your account and your bank to debit your account in accordance with those instructions. You are entitled to a refund from your bank under the terms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited.', 'woocommerce-gateway-stripe'), WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor));
231 231
 	}
232 232
 
233 233
 	/**
@@ -238,24 +238,24 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	public function form() {
240 240
 		?>
241
-		<fieldset id="wc-<?php echo esc_attr( $this->id ); ?>-form" class="wc-payment-form">
242
-			<?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?>
241
+		<fieldset id="wc-<?php echo esc_attr($this->id); ?>-form" class="wc-payment-form">
242
+			<?php do_action('woocommerce_credit_card_form_start', $this->id); ?>
243 243
 			<p class="wc-stripe-sepa-mandate" style="margin-bottom:40px;"><?php $this->mandate_display(); ?></p>
244 244
 			<p class="form-row form-row-wide">
245 245
 				<label for="stripe-sepa-owner">
246
-					<?php esc_html_e( 'IBAN Account Name.', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span>
246
+					<?php esc_html_e('IBAN Account Name.', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span>
247 247
 				</label>
248 248
 				<input id="stripe-sepa-owner" name="stripe_sepa_owner" value="" style="border:1px solid #ddd;margin:5px 0;padding:10px 5px;background-color:#fff;outline:0;" />
249 249
 			</p>
250 250
 			<p class="form-row form-row-wide">
251 251
 				<label for="stripe-sepa-iban">
252
-					<?php esc_html_e( 'IBAN Account Number.', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span>
252
+					<?php esc_html_e('IBAN Account Number.', 'woocommerce-gateway-stripe'); ?> <span class="required">*</span>
253 253
 				</label>
254 254
 				<input id="stripe-sepa-iban" name="stripe_sepa_iban" value="" style="border:1px solid #ddd;margin:5px 0;padding:10px 5px;background-color:#fff;outline:0;" />
255 255
 			</p>
256 256
 			<!-- Used to display form errors -->
257 257
 			<div class="stripe-source-errors" role="alert"></div>
258
-			<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
258
+			<?php do_action('woocommerce_credit_card_form_end', $this->id); ?>
259 259
 			<div class="clear"></div>
260 260
 		</fieldset>
261 261
 		<?php
@@ -267,42 +267,42 @@  discard block
 block discarded – undo
267 267
 	public function payment_fields() {
268 268
 		$user                 = wp_get_current_user();
269 269
 		$total                = WC()->cart->total;
270
-		$display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards;
270
+		$display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards;
271 271
 
272 272
 		// If paying from order, we need to get total from order not cart.
273
-		if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) {
274
-			$order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) );
273
+		if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) {
274
+			$order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key'])));
275 275
 			$total = $order->get_total();
276 276
 		}
277 277
 
278
-		if ( is_add_payment_method_page() ) {
279
-			$pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' );
280
-			$total        = '';
278
+		if (is_add_payment_method_page()) {
279
+			$pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe');
280
+			$total = '';
281 281
 		} else {
282 282
 			$pay_button_text = '';
283 283
 		}
284 284
 
285 285
 		echo '<div
286 286
 			id="stripe-sepa_debit-payment-data"
287
-			data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '"
288
-			data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">';
287
+			data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '"
288
+			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">';
289 289
 
290
-		if ( $this->description ) {
291
-			if ( $this->testmode ) {
292
-				$this->description .= ' ' . __( 'TEST MODE ENABLED. In test mode, you can use IBAN number DE89370400440532013000.', 'woocommerce-gateway-stripe' );
293
-				$this->description  = trim( $this->description );
290
+		if ($this->description) {
291
+			if ($this->testmode) {
292
+				$this->description .= ' ' . __('TEST MODE ENABLED. In test mode, you can use IBAN number DE89370400440532013000.', 'woocommerce-gateway-stripe');
293
+				$this->description  = trim($this->description);
294 294
 			}
295
-			echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) );
295
+			echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description)));
296 296
 		}
297 297
 
298
-		if ( $display_tokenization ) {
298
+		if ($display_tokenization) {
299 299
 			$this->tokenization_script();
300 300
 			$this->saved_payment_methods();
301 301
 		}
302 302
 
303 303
 		$this->form();
304 304
 
305
-		if ( apply_filters( 'wc_stripe_display_save_payment_method_checkbox', $display_tokenization ) && ! is_add_payment_method_page() && ! isset( $_GET['change_payment_method'] ) ) {
305
+		if (apply_filters('wc_stripe_display_save_payment_method_checkbox', $display_tokenization) && ! is_add_payment_method_page() && ! isset($_GET['change_payment_method'])) {
306 306
 			$this->save_payment_method_checkbox();
307 307
 		}
308 308
 
@@ -320,86 +320,86 @@  discard block
 block discarded – undo
320 320
 	 *
321 321
 	 * @return array|void
322 322
 	 */
323
-	public function process_payment( $order_id, $retry = true, $force_save_source = false ) {
323
+	public function process_payment($order_id, $retry = true, $force_save_source = false) {
324 324
 		try {
325
-			$order = wc_get_order( $order_id );
325
+			$order = wc_get_order($order_id);
326 326
 
327 327
 			// This comes from the create account checkbox in the checkout page.
328
-			$create_account = ! empty( $_POST['createaccount'] ) ? true : false;
328
+			$create_account = ! empty($_POST['createaccount']) ? true : false;
329 329
 
330
-			if ( $create_account ) {
330
+			if ($create_account) {
331 331
 				$new_customer_id     = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id();
332
-				$new_stripe_customer = new WC_Stripe_Customer( $new_customer_id );
332
+				$new_stripe_customer = new WC_Stripe_Customer($new_customer_id);
333 333
 				$new_stripe_customer->create_customer();
334 334
 			}
335 335
 
336
-			$prepared_source = $this->prepare_source( $this->get_source_object(), get_current_user_id(), $force_save_source );
336
+			$prepared_source = $this->prepare_source($this->get_source_object(), get_current_user_id(), $force_save_source);
337 337
 
338
-			$this->save_source_to_order( $order, $prepared_source );
338
+			$this->save_source_to_order($order, $prepared_source);
339 339
 
340 340
 			// Result from Stripe API request.
341 341
 			$response = null;
342 342
 
343
-			if ( $order->get_total() > 0 ) {
343
+			if ($order->get_total() > 0) {
344 344
 				// This will throw exception if not valid.
345
-				$this->validate_minimum_order_amount( $order );
345
+				$this->validate_minimum_order_amount($order);
346 346
 
347
-				WC_Stripe_Logger::log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
347
+				WC_Stripe_Logger::log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}");
348 348
 
349 349
 				// Make the request.
350
-				$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $prepared_source ) );
350
+				$response = WC_Stripe_API::request($this->generate_payment_request($order, $prepared_source));
351 351
 
352
-				if ( ! empty( $response->error ) ) {
352
+				if ( ! empty($response->error)) {
353 353
 					// If it is an API error such connection or server, let's retry.
354
-					if ( 'api_connection_error' === $response->error->type || 'api_error' === $response->error->type ) {
355
-						if ( $retry ) {
356
-							sleep( 5 );
357
-							return $this->process_payment( $order_id, false, $force_save_source );
354
+					if ('api_connection_error' === $response->error->type || 'api_error' === $response->error->type) {
355
+						if ($retry) {
356
+							sleep(5);
357
+							return $this->process_payment($order_id, false, $force_save_source);
358 358
 						} else {
359 359
 							$localized_message = 'API connection error and retries exhausted.';
360
-							$order->add_order_note( $localized_message );
361
-							throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
360
+							$order->add_order_note($localized_message);
361
+							throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
362 362
 						}
363 363
 					}
364 364
 
365 365
 					// Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without.
366
-					if ( preg_match( '/No such customer/i', $response->error->message ) && $retry ) {
367
-						if ( WC_Stripe_Helper::is_pre_30() ) {
368
-							delete_user_meta( $order->customer_user, '_stripe_customer_id' );
369
-							delete_post_meta( $order_id, '_stripe_customer_id' );
366
+					if (preg_match('/No such customer/i', $response->error->message) && $retry) {
367
+						if (WC_Stripe_Helper::is_pre_30()) {
368
+							delete_user_meta($order->customer_user, '_stripe_customer_id');
369
+							delete_post_meta($order_id, '_stripe_customer_id');
370 370
 						} else {
371
-							delete_user_meta( $order->get_customer_id(), '_stripe_customer_id' );
372
-							$order->delete_meta_data( '_stripe_customer_id' );
371
+							delete_user_meta($order->get_customer_id(), '_stripe_customer_id');
372
+							$order->delete_meta_data('_stripe_customer_id');
373 373
 							$order->save();
374 374
 						}
375 375
 
376
-						return $this->process_payment( $order_id, false, $force_save_source );
377
-					} elseif ( preg_match( '/No such token/i', $response->error->message ) && $prepared_source->token_id ) {
376
+						return $this->process_payment($order_id, false, $force_save_source);
377
+					} elseif (preg_match('/No such token/i', $response->error->message) && $prepared_source->token_id) {
378 378
 						// Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message.
379
-						$wc_token = WC_Payment_Tokens::get( $prepared_source->token_id );
379
+						$wc_token = WC_Payment_Tokens::get($prepared_source->token_id);
380 380
 						$wc_token->delete();
381
-						$localized_message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' );
382
-						$order->add_order_note( $localized_message );
383
-						throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
381
+						$localized_message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe');
382
+						$order->add_order_note($localized_message);
383
+						throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
384 384
 					}
385 385
 
386 386
 					$localized_messages = WC_Stripe_Helper::get_localized_messages();
387 387
 
388
-					if ( 'card_error' === $response->error->type ) {
389
-						$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
388
+					if ('card_error' === $response->error->type) {
389
+						$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
390 390
 					} else {
391
-						$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
391
+						$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
392 392
 					}
393 393
 
394
-					$order->add_order_note( $localized_message );
394
+					$order->add_order_note($localized_message);
395 395
 
396
-					throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
396
+					throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
397 397
 				}
398 398
 
399
-				do_action( 'wc_gateway_stripe_process_payment', $response, $order );
399
+				do_action('wc_gateway_stripe_process_payment', $response, $order);
400 400
 
401 401
 				// Process valid response.
402
-				$this->process_response( $response, $order );
402
+				$this->process_response($response, $order);
403 403
 			} else {
404 404
 				$order->payment_complete();
405 405
 			}
@@ -410,17 +410,17 @@  discard block
 block discarded – undo
410 410
 			// Return thank you page redirect.
411 411
 			return array(
412 412
 				'result'   => 'success',
413
-				'redirect' => $this->get_return_url( $order ),
413
+				'redirect' => $this->get_return_url($order),
414 414
 			);
415 415
 
416
-		} catch ( WC_Stripe_Exception $e ) {
417
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
418
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
416
+		} catch (WC_Stripe_Exception $e) {
417
+			wc_add_notice($e->getLocalizedMessage(), 'error');
418
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
419 419
 
420
-			do_action( 'wc_gateway_stripe_process_payment_error', $e, $order );
420
+			do_action('wc_gateway_stripe_process_payment_error', $e, $order);
421 421
 
422
-			if ( $order->has_status( array( 'pending', 'failed' ) ) ) {
423
-				$this->send_failed_order_email( $order_id );
422
+			if ($order->has_status(array('pending', 'failed'))) {
423
+				$this->send_failed_order_email($order_id);
424 424
 			}
425 425
 
426 426
 			return array(
Please login to merge, or discard this patch.