@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -17,15 +17,15 @@ discard block |
||
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,21 +37,21 @@ discard block |
||
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 | - 'expired_card' => __( 'The card has expired.', 'woocommerce-gateway-stripe' ), |
|
47 | - 'incorrect_cvc' => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ), |
|
48 | - 'incorrect_zip' => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ), |
|
49 | - 'card_declined' => __( 'The card was declined.', 'woocommerce-gateway-stripe' ), |
|
50 | - 'missing' => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ), |
|
51 | - 'processing_error' => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ), |
|
52 | - 'invalid_request_error' => __( 'Could not find payment information. Please try with another payment method.', 'woocommerce-gateway-stripe' ), |
|
53 | - 'invalid_expiry_year_past' => __( 'Your card\'s expiration year is in the past', 'woocommerce-gateway-stripe' ), |
|
54 | - ) ); |
|
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 | + 'expired_card' => __('The card has expired.', 'woocommerce-gateway-stripe'), |
|
47 | + 'incorrect_cvc' => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'), |
|
48 | + 'incorrect_zip' => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'), |
|
49 | + 'card_declined' => __('The card was declined.', 'woocommerce-gateway-stripe'), |
|
50 | + 'missing' => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'), |
|
51 | + 'processing_error' => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'), |
|
52 | + 'invalid_request_error' => __('Could not find payment information. Please try with another payment method.', 'woocommerce-gateway-stripe'), |
|
53 | + 'invalid_expiry_year_past' => __('Your card\'s expiration year is in the past', 'woocommerce-gateway-stripe'), |
|
54 | + )); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -88,24 +88,24 @@ discard block |
||
88 | 88 | * @param string $type Type of number to format |
89 | 89 | * @return string |
90 | 90 | */ |
91 | - public static function format_balance_fee( $balance_transaction, $type = 'fee' ) { |
|
92 | - if ( ! is_object( $balance_transaction ) ) { |
|
91 | + public static function format_balance_fee($balance_transaction, $type = 'fee') { |
|
92 | + if ( ! is_object($balance_transaction)) { |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
96 | - if ( in_array( strtolower( $balance_transaction->currency ), self::no_decimal_currencies() ) ) { |
|
97 | - if ( 'fee' === $type ) { |
|
96 | + if (in_array(strtolower($balance_transaction->currency), self::no_decimal_currencies())) { |
|
97 | + if ('fee' === $type) { |
|
98 | 98 | return $balance_transaction->fee; |
99 | 99 | } |
100 | 100 | |
101 | 101 | return $balance_transaction->net; |
102 | 102 | } |
103 | 103 | |
104 | - if ( 'fee' === $type ) { |
|
105 | - return number_format( $balance_transaction->fee / 100, 2, '.', '' ); |
|
104 | + if ('fee' === $type) { |
|
105 | + return number_format($balance_transaction->fee / 100, 2, '.', ''); |
|
106 | 106 | } |
107 | 107 | |
108 | - return number_format( $balance_transaction->net / 100, 2, '.', '' ); |
|
108 | + return number_format($balance_transaction->net / 100, 2, '.', ''); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public static function get_minimum_amount() { |
115 | 115 | // Check order amount |
116 | - switch ( get_woocommerce_currency() ) { |
|
116 | + switch (get_woocommerce_currency()) { |
|
117 | 117 | case 'USD': |
118 | 118 | case 'CAD': |
119 | 119 | case 'EUR': |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | * @param string $method The payment method to get the settings from. |
159 | 159 | * @param string $setting The name of the setting to get. |
160 | 160 | */ |
161 | - public static function get_settings( $method = null, $setting = null ) { |
|
162 | - $all_settings = null === $method ? get_option( 'woocommerce_stripe_settings', array() ) : get_option( 'woocommerce_stripe_' . $method . '_settings', array() ); |
|
161 | + public static function get_settings($method = null, $setting = null) { |
|
162 | + $all_settings = null === $method ? get_option('woocommerce_stripe_settings', array()) : get_option('woocommerce_stripe_' . $method . '_settings', array()); |
|
163 | 163 | |
164 | - if ( null === $setting ) { |
|
164 | + if (null === $setting) { |
|
165 | 165 | return $all_settings; |
166 | 166 | } |
167 | 167 | |
168 | - return isset( $all_settings[ $setting ] ) ? $all_settings[ $setting ] : ''; |
|
168 | + return isset($all_settings[$setting]) ? $all_settings[$setting] : ''; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @return bool |
177 | 177 | */ |
178 | 178 | public static function is_pre_30() { |
179 | - return version_compare( WC_VERSION, '3.0.0', '<' ); |
|
179 | + return version_compare(WC_VERSION, '3.0.0', '<'); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * @return string |
190 | 190 | */ |
191 | 191 | public static function get_webhook_url() { |
192 | - return add_query_arg( 'wc-api', 'wc_stripe', trailingslashit( get_home_url() ) ); |
|
192 | + return add_query_arg('wc-api', 'wc_stripe', trailingslashit(get_home_url())); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | * @version 4.0.0 |
200 | 200 | * @param string $source_id |
201 | 201 | */ |
202 | - public static function get_order_by_source_id( $source_id ) { |
|
202 | + public static function get_order_by_source_id($source_id) { |
|
203 | 203 | global $wpdb; |
204 | 204 | |
205 | - $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 ) ); |
|
205 | + $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)); |
|
206 | 206 | |
207 | - if ( ! empty( $order_id ) ) { |
|
208 | - return wc_get_order( $order_id ); |
|
207 | + if ( ! empty($order_id)) { |
|
208 | + return wc_get_order($order_id); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | return false; |
@@ -218,13 +218,13 @@ discard block |
||
218 | 218 | * @version 4.0.0 |
219 | 219 | * @param string $charge_id |
220 | 220 | */ |
221 | - public static function get_order_by_charge_id( $charge_id ) { |
|
221 | + public static function get_order_by_charge_id($charge_id) { |
|
222 | 222 | global $wpdb; |
223 | 223 | |
224 | - $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 ) ); |
|
224 | + $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)); |
|
225 | 225 | |
226 | - if ( ! empty( $order_id ) ) { |
|
227 | - return wc_get_order( $order_id ); |
|
226 | + if ( ! empty($order_id)) { |
|
227 | + return wc_get_order($order_id); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | return false; |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | * @param string $statement_descriptor |
241 | 241 | * @return string $statement_descriptor Sanitized statement descriptor |
242 | 242 | */ |
243 | - public static function clean_statement_descriptor( $statement_descriptor = '' ) { |
|
244 | - $disallowed_characters = array( '<', '>', '"', "'" ); |
|
243 | + public static function clean_statement_descriptor($statement_descriptor = '') { |
|
244 | + $disallowed_characters = array('<', '>', '"', "'"); |
|
245 | 245 | |
246 | 246 | // Remove special characters. |
247 | - $statement_descriptor = str_replace( $disallowed_characters, '', $statement_descriptor ); |
|
247 | + $statement_descriptor = str_replace($disallowed_characters, '', $statement_descriptor); |
|
248 | 248 | |
249 | - $statement_descriptor = substr( trim( $statement_descriptor ), 0, 22 ); |
|
249 | + $statement_descriptor = substr(trim($statement_descriptor), 0, 22); |
|
250 | 250 | |
251 | 251 | return $statement_descriptor; |
252 | 252 | } |