@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if ( ! defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | * @param object $order |
| 23 | 23 | * @return string $currency |
| 24 | 24 | */ |
| 25 | - public static function get_stripe_currency( $order = null ) { |
|
| 26 | - if ( is_null( $order ) ) { |
|
| 25 | + public static function get_stripe_currency($order = null) { |
|
| 26 | + if (is_null($order)) { |
|
| 27 | 27 | return false; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - return $order->get_meta( self::META_NAME_STRIPE_CURRENCY, true ); |
|
| 30 | + return $order->get_meta(self::META_NAME_STRIPE_CURRENCY, true); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -37,12 +37,12 @@ discard block |
||
| 37 | 37 | * @param object $order |
| 38 | 38 | * @param string $currency |
| 39 | 39 | */ |
| 40 | - public static function update_stripe_currency( $order = null, $currency ) { |
|
| 41 | - if ( is_null( $order ) ) { |
|
| 40 | + public static function update_stripe_currency($order = null, $currency) { |
|
| 41 | + if (is_null($order)) { |
|
| 42 | 42 | return false; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - $order->update_meta_data( self::META_NAME_STRIPE_CURRENCY, $currency ); |
|
| 45 | + $order->update_meta_data(self::META_NAME_STRIPE_CURRENCY, $currency); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -52,20 +52,20 @@ discard block |
||
| 52 | 52 | * @param object $order |
| 53 | 53 | * @return string $amount |
| 54 | 54 | */ |
| 55 | - public static function get_stripe_fee( $order = null ) { |
|
| 56 | - if ( is_null( $order ) ) { |
|
| 55 | + public static function get_stripe_fee($order = null) { |
|
| 56 | + if (is_null($order)) { |
|
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $amount = $order->get_meta( self::META_NAME_FEE, true ); |
|
| 60 | + $amount = $order->get_meta(self::META_NAME_FEE, true); |
|
| 61 | 61 | |
| 62 | 62 | // If not found let's check for legacy name. |
| 63 | - if ( empty( $amount ) ) { |
|
| 64 | - $amount = $order->get_meta( self::LEGACY_META_NAME_FEE, true ); |
|
| 63 | + if (empty($amount)) { |
|
| 64 | + $amount = $order->get_meta(self::LEGACY_META_NAME_FEE, true); |
|
| 65 | 65 | |
| 66 | 66 | // If found update to new name. |
| 67 | - if ( $amount ) { |
|
| 68 | - self::update_stripe_fee( $order, $amount ); |
|
| 67 | + if ($amount) { |
|
| 68 | + self::update_stripe_fee($order, $amount); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | * @param object $order |
| 80 | 80 | * @param float $amount |
| 81 | 81 | */ |
| 82 | - public static function update_stripe_fee( $order = null, $amount = 0.0 ) { |
|
| 83 | - if ( is_null( $order ) ) { |
|
| 82 | + public static function update_stripe_fee($order = null, $amount = 0.0) { |
|
| 83 | + if (is_null($order)) { |
|
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $order->update_meta_data( self::META_NAME_FEE, $amount ); |
|
| 87 | + $order->update_meta_data(self::META_NAME_FEE, $amount); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -93,15 +93,15 @@ discard block |
||
| 93 | 93 | * @since 4.1.0 |
| 94 | 94 | * @param object $order |
| 95 | 95 | */ |
| 96 | - public static function delete_stripe_fee( $order = null ) { |
|
| 97 | - if ( is_null( $order ) ) { |
|
| 96 | + public static function delete_stripe_fee($order = null) { |
|
| 97 | + if (is_null($order)) { |
|
| 98 | 98 | return false; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $order_id = $order->get_id(); |
| 102 | 102 | |
| 103 | - delete_post_meta( $order_id, self::META_NAME_FEE ); |
|
| 104 | - delete_post_meta( $order_id, self::LEGACY_META_NAME_FEE ); |
|
| 103 | + delete_post_meta($order_id, self::META_NAME_FEE); |
|
| 104 | + delete_post_meta($order_id, self::LEGACY_META_NAME_FEE); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -111,20 +111,20 @@ discard block |
||
| 111 | 111 | * @param object $order |
| 112 | 112 | * @return string $amount |
| 113 | 113 | */ |
| 114 | - public static function get_stripe_net( $order = null ) { |
|
| 115 | - if ( is_null( $order ) ) { |
|
| 114 | + public static function get_stripe_net($order = null) { |
|
| 115 | + if (is_null($order)) { |
|
| 116 | 116 | return false; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - $amount = $order->get_meta( self::META_NAME_NET, true ); |
|
| 119 | + $amount = $order->get_meta(self::META_NAME_NET, true); |
|
| 120 | 120 | |
| 121 | 121 | // If not found let's check for legacy name. |
| 122 | - if ( empty( $amount ) ) { |
|
| 123 | - $amount = $order->get_meta( self::LEGACY_META_NAME_NET, true ); |
|
| 122 | + if (empty($amount)) { |
|
| 123 | + $amount = $order->get_meta(self::LEGACY_META_NAME_NET, true); |
|
| 124 | 124 | |
| 125 | 125 | // If found update to new name. |
| 126 | - if ( $amount ) { |
|
| 127 | - self::update_stripe_net( $order, $amount ); |
|
| 126 | + if ($amount) { |
|
| 127 | + self::update_stripe_net($order, $amount); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
@@ -138,12 +138,12 @@ discard block |
||
| 138 | 138 | * @param object $order |
| 139 | 139 | * @param float $amount |
| 140 | 140 | */ |
| 141 | - public static function update_stripe_net( $order = null, $amount = 0.0 ) { |
|
| 142 | - if ( is_null( $order ) ) { |
|
| 141 | + public static function update_stripe_net($order = null, $amount = 0.0) { |
|
| 142 | + if (is_null($order)) { |
|
| 143 | 143 | return false; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $order->update_meta_data( self::META_NAME_NET, $amount ); |
|
| 146 | + $order->update_meta_data(self::META_NAME_NET, $amount); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -152,15 +152,15 @@ discard block |
||
| 152 | 152 | * @since 4.1.0 |
| 153 | 153 | * @param object $order |
| 154 | 154 | */ |
| 155 | - public static function delete_stripe_net( $order = null ) { |
|
| 156 | - if ( is_null( $order ) ) { |
|
| 155 | + public static function delete_stripe_net($order = null) { |
|
| 156 | + if (is_null($order)) { |
|
| 157 | 157 | return false; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | $order_id = $order->get_id(); |
| 161 | 161 | |
| 162 | - delete_post_meta( $order_id, self::META_NAME_NET ); |
|
| 163 | - delete_post_meta( $order_id, self::LEGACY_META_NAME_NET ); |
|
| 162 | + delete_post_meta($order_id, self::META_NAME_NET); |
|
| 163 | + delete_post_meta($order_id, self::LEGACY_META_NAME_NET); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -171,15 +171,15 @@ discard block |
||
| 171 | 171 | * |
| 172 | 172 | * @return float|int |
| 173 | 173 | */ |
| 174 | - public static function get_stripe_amount( $total, $currency = '' ) { |
|
| 175 | - if ( ! $currency ) { |
|
| 174 | + public static function get_stripe_amount($total, $currency = '') { |
|
| 175 | + if ( ! $currency) { |
|
| 176 | 176 | $currency = get_woocommerce_currency(); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( in_array( strtolower( $currency ), self::no_decimal_currencies() ) ) { |
|
| 180 | - return absint( $total ); |
|
| 179 | + if (in_array(strtolower($currency), self::no_decimal_currencies())) { |
|
| 180 | + return absint($total); |
|
| 181 | 181 | } else { |
| 182 | - return absint( wc_format_decimal( ( (float) $total * 100 ), wc_get_price_decimals() ) ); // In cents. |
|
| 182 | + return absint(wc_format_decimal(((float) $total * 100), wc_get_price_decimals())); // In cents. |
|
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
@@ -194,26 +194,26 @@ discard block |
||
| 194 | 194 | return apply_filters( |
| 195 | 195 | 'wc_stripe_localized_messages', |
| 196 | 196 | array( |
| 197 | - 'invalid_number' => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ), |
|
| 198 | - 'invalid_expiry_month' => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ), |
|
| 199 | - 'invalid_expiry_year' => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ), |
|
| 200 | - 'invalid_cvc' => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ), |
|
| 201 | - 'incorrect_number' => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ), |
|
| 202 | - 'incomplete_number' => __( 'The card number is incomplete.', 'woocommerce-gateway-stripe' ), |
|
| 203 | - 'incomplete_cvc' => __( 'The card\'s security code is incomplete.', 'woocommerce-gateway-stripe' ), |
|
| 204 | - 'incomplete_expiry' => __( 'The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe' ), |
|
| 205 | - 'expired_card' => __( 'The card has expired.', 'woocommerce-gateway-stripe' ), |
|
| 206 | - 'incorrect_cvc' => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ), |
|
| 207 | - 'incorrect_zip' => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ), |
|
| 208 | - 'invalid_expiry_year_past' => __( 'The card\'s expiration year is in the past', 'woocommerce-gateway-stripe' ), |
|
| 209 | - 'card_declined' => __( 'The card was declined.', 'woocommerce-gateway-stripe' ), |
|
| 210 | - 'missing' => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ), |
|
| 211 | - 'processing_error' => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ), |
|
| 212 | - 'invalid_sofort_country' => __( 'The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe' ), |
|
| 213 | - 'email_invalid' => __( 'Invalid email address, please correct and try again.', 'woocommerce-gateway-stripe' ), |
|
| 197 | + 'invalid_number' => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'), |
|
| 198 | + 'invalid_expiry_month' => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'), |
|
| 199 | + 'invalid_expiry_year' => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'), |
|
| 200 | + 'invalid_cvc' => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'), |
|
| 201 | + 'incorrect_number' => __('The card number is incorrect.', 'woocommerce-gateway-stripe'), |
|
| 202 | + 'incomplete_number' => __('The card number is incomplete.', 'woocommerce-gateway-stripe'), |
|
| 203 | + 'incomplete_cvc' => __('The card\'s security code is incomplete.', 'woocommerce-gateway-stripe'), |
|
| 204 | + 'incomplete_expiry' => __('The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe'), |
|
| 205 | + 'expired_card' => __('The card has expired.', 'woocommerce-gateway-stripe'), |
|
| 206 | + 'incorrect_cvc' => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'), |
|
| 207 | + 'incorrect_zip' => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'), |
|
| 208 | + 'invalid_expiry_year_past' => __('The card\'s expiration year is in the past', 'woocommerce-gateway-stripe'), |
|
| 209 | + 'card_declined' => __('The card was declined.', 'woocommerce-gateway-stripe'), |
|
| 210 | + 'missing' => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'), |
|
| 211 | + 'processing_error' => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'), |
|
| 212 | + 'invalid_sofort_country' => __('The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe'), |
|
| 213 | + 'email_invalid' => __('Invalid email address, please correct and try again.', 'woocommerce-gateway-stripe'), |
|
| 214 | 214 | 'invalid_request_error' => is_add_payment_method_page() |
| 215 | - ? __( 'Unable to save this payment method, please try again or use alternative method.', 'woocommerce-gateway-stripe' ) |
|
| 216 | - : __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ), |
|
| 215 | + ? __('Unable to save this payment method, please try again or use alternative method.', 'woocommerce-gateway-stripe') |
|
| 216 | + : __('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe'), |
|
| 217 | 217 | ) |
| 218 | 218 | ); |
| 219 | 219 | } |
@@ -254,24 +254,24 @@ discard block |
||
| 254 | 254 | * @param string $type Type of number to format |
| 255 | 255 | * @return string |
| 256 | 256 | */ |
| 257 | - public static function format_balance_fee( $balance_transaction, $type = 'fee' ) { |
|
| 258 | - if ( ! is_object( $balance_transaction ) ) { |
|
| 257 | + public static function format_balance_fee($balance_transaction, $type = 'fee') { |
|
| 258 | + if ( ! is_object($balance_transaction)) { |
|
| 259 | 259 | return; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if ( in_array( strtolower( $balance_transaction->currency ), self::no_decimal_currencies() ) ) { |
|
| 263 | - if ( 'fee' === $type ) { |
|
| 262 | + if (in_array(strtolower($balance_transaction->currency), self::no_decimal_currencies())) { |
|
| 263 | + if ('fee' === $type) { |
|
| 264 | 264 | return $balance_transaction->fee; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | return $balance_transaction->net; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if ( 'fee' === $type ) { |
|
| 271 | - return number_format( $balance_transaction->fee / 100, 2, '.', '' ); |
|
| 270 | + if ('fee' === $type) { |
|
| 271 | + return number_format($balance_transaction->fee / 100, 2, '.', ''); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - return number_format( $balance_transaction->net / 100, 2, '.', '' ); |
|
| 274 | + return number_format($balance_transaction->net / 100, 2, '.', ''); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | public static function get_minimum_amount() { |
| 281 | 281 | // Check order amount |
| 282 | - switch ( get_woocommerce_currency() ) { |
|
| 282 | + switch (get_woocommerce_currency()) { |
|
| 283 | 283 | case 'USD': |
| 284 | 284 | case 'CAD': |
| 285 | 285 | case 'EUR': |
@@ -324,14 +324,14 @@ discard block |
||
| 324 | 324 | * @param string $method The payment method to get the settings from. |
| 325 | 325 | * @param string $setting The name of the setting to get. |
| 326 | 326 | */ |
| 327 | - public static function get_settings( $method = null, $setting = null ) { |
|
| 328 | - $all_settings = null === $method ? get_option( 'woocommerce_stripe_settings', array() ) : get_option( 'woocommerce_stripe_' . $method . '_settings', array() ); |
|
| 327 | + public static function get_settings($method = null, $setting = null) { |
|
| 328 | + $all_settings = null === $method ? get_option('woocommerce_stripe_settings', array()) : get_option('woocommerce_stripe_' . $method . '_settings', array()); |
|
| 329 | 329 | |
| 330 | - if ( null === $setting ) { |
|
| 330 | + if (null === $setting) { |
|
| 331 | 331 | return $all_settings; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - return isset( $all_settings[ $setting ] ) ? $all_settings[ $setting ] : ''; |
|
| 334 | + return isset($all_settings[$setting]) ? $all_settings[$setting] : ''; |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | * @return bool |
| 342 | 342 | */ |
| 343 | 343 | public static function is_pre_orders_exists() { |
| 344 | - return class_exists( 'WC_Pre_Orders_Order' ); |
|
| 344 | + return class_exists('WC_Pre_Orders_Order'); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -351,8 +351,8 @@ discard block |
||
| 351 | 351 | * @param string $version Version to check against. |
| 352 | 352 | * @return bool |
| 353 | 353 | */ |
| 354 | - public static function is_wc_lt( $version ) { |
|
| 355 | - return version_compare( WC_VERSION, $version, '<' ); |
|
| 354 | + public static function is_wc_lt($version) { |
|
| 355 | + return version_compare(WC_VERSION, $version, '<'); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @return string |
| 366 | 366 | */ |
| 367 | 367 | public static function get_webhook_url() { |
| 368 | - return add_query_arg( 'wc-api', 'wc_stripe', trailingslashit( get_home_url() ) ); |
|
| 368 | + return add_query_arg('wc-api', 'wc_stripe', trailingslashit(get_home_url())); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -375,13 +375,13 @@ discard block |
||
| 375 | 375 | * @version 4.0.0 |
| 376 | 376 | * @param string $source_id |
| 377 | 377 | */ |
| 378 | - public static function get_order_by_source_id( $source_id ) { |
|
| 378 | + public static function get_order_by_source_id($source_id) { |
|
| 379 | 379 | global $wpdb; |
| 380 | 380 | |
| 381 | - $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 AND meta.meta_key = %s", $source_id, '_stripe_source_id' ) ); |
|
| 381 | + $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 AND meta.meta_key = %s", $source_id, '_stripe_source_id')); |
|
| 382 | 382 | |
| 383 | - if ( ! empty( $order_id ) ) { |
|
| 384 | - return wc_get_order( $order_id ); |
|
| 383 | + if ( ! empty($order_id)) { |
|
| 384 | + return wc_get_order($order_id); |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | return false; |
@@ -394,17 +394,17 @@ discard block |
||
| 394 | 394 | * @since 4.1.16 Return false if charge_id is empty. |
| 395 | 395 | * @param string $charge_id |
| 396 | 396 | */ |
| 397 | - public static function get_order_by_charge_id( $charge_id ) { |
|
| 397 | + public static function get_order_by_charge_id($charge_id) { |
|
| 398 | 398 | global $wpdb; |
| 399 | 399 | |
| 400 | - if ( empty( $charge_id ) ) { |
|
| 400 | + if (empty($charge_id)) { |
|
| 401 | 401 | return false; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - $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 AND meta.meta_key = %s", $charge_id, '_transaction_id' ) ); |
|
| 404 | + $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 AND meta.meta_key = %s", $charge_id, '_transaction_id')); |
|
| 405 | 405 | |
| 406 | - if ( ! empty( $order_id ) ) { |
|
| 407 | - return wc_get_order( $order_id ); |
|
| 406 | + if ( ! empty($order_id)) { |
|
| 407 | + return wc_get_order($order_id); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | return false; |
@@ -417,13 +417,13 @@ discard block |
||
| 417 | 417 | * @param string $intent_id The ID of the intent. |
| 418 | 418 | * @return WC_Order|bool Either an order or false when not found. |
| 419 | 419 | */ |
| 420 | - public static function get_order_by_intent_id( $intent_id ) { |
|
| 420 | + public static function get_order_by_intent_id($intent_id) { |
|
| 421 | 421 | global $wpdb; |
| 422 | 422 | |
| 423 | - $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 AND meta.meta_key = %s", $intent_id, '_stripe_intent_id' ) ); |
|
| 423 | + $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 AND meta.meta_key = %s", $intent_id, '_stripe_intent_id')); |
|
| 424 | 424 | |
| 425 | - if ( ! empty( $order_id ) ) { |
|
| 426 | - return wc_get_order( $order_id ); |
|
| 425 | + if ( ! empty($order_id)) { |
|
| 426 | + return wc_get_order($order_id); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | return false; |
@@ -436,13 +436,13 @@ discard block |
||
| 436 | 436 | * @param string $intent_id The ID of the intent. |
| 437 | 437 | * @return WC_Order|bool Either an order or false when not found. |
| 438 | 438 | */ |
| 439 | - public static function get_order_by_setup_intent_id( $intent_id ) { |
|
| 439 | + public static function get_order_by_setup_intent_id($intent_id) { |
|
| 440 | 440 | global $wpdb; |
| 441 | 441 | |
| 442 | - $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 AND meta.meta_key = %s", $intent_id, '_stripe_setup_intent' ) ); |
|
| 442 | + $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 AND meta.meta_key = %s", $intent_id, '_stripe_setup_intent')); |
|
| 443 | 443 | |
| 444 | - if ( ! empty( $order_id ) ) { |
|
| 445 | - return wc_get_order( $order_id ); |
|
| 444 | + if ( ! empty($order_id)) { |
|
| 445 | + return wc_get_order($order_id); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | return false; |
@@ -457,21 +457,21 @@ discard block |
||
| 457 | 457 | * @param string $statement_descriptor |
| 458 | 458 | * @return string $statement_descriptor Sanitized statement descriptor |
| 459 | 459 | */ |
| 460 | - public static function clean_statement_descriptor( $statement_descriptor = '' ) { |
|
| 461 | - $disallowed_characters = array( '<', '>', '\\', '*', '"', "'", '/', '(', ')', '{', '}' ); |
|
| 460 | + public static function clean_statement_descriptor($statement_descriptor = '') { |
|
| 461 | + $disallowed_characters = array('<', '>', '\\', '*', '"', "'", '/', '(', ')', '{', '}'); |
|
| 462 | 462 | |
| 463 | 463 | // Strip any tags. |
| 464 | - $statement_descriptor = strip_tags( $statement_descriptor ); |
|
| 464 | + $statement_descriptor = strip_tags($statement_descriptor); |
|
| 465 | 465 | |
| 466 | 466 | // Strip any HTML entities. |
| 467 | 467 | // Props https://stackoverflow.com/questions/657643/how-to-remove-html-special-chars . |
| 468 | - $statement_descriptor = preg_replace( "/&#?[a-z0-9]{2,8};/i", "", $statement_descriptor ); |
|
| 468 | + $statement_descriptor = preg_replace("/&#?[a-z0-9]{2,8};/i", "", $statement_descriptor); |
|
| 469 | 469 | |
| 470 | 470 | // Next, remove any remaining disallowed characters. |
| 471 | - $statement_descriptor = str_replace( $disallowed_characters, '', $statement_descriptor ); |
|
| 471 | + $statement_descriptor = str_replace($disallowed_characters, '', $statement_descriptor); |
|
| 472 | 472 | |
| 473 | 473 | // Trim any whitespace at the ends and limit to 22 characters. |
| 474 | - $statement_descriptor = substr( trim( $statement_descriptor ), 0, 22 ); |
|
| 474 | + $statement_descriptor = substr(trim($statement_descriptor), 0, 22); |
|
| 475 | 475 | |
| 476 | 476 | return $statement_descriptor; |
| 477 | 477 | } |