@@ -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,14 +22,14 @@ 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 | 30 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
| 31 | 31 | |
| 32 | - return WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, self::META_NAME_STRIPE_CURRENCY, true ) : $order->get_meta( self::META_NAME_STRIPE_CURRENCY, true ); |
|
| 32 | + return WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, self::META_NAME_STRIPE_CURRENCY, true) : $order->get_meta(self::META_NAME_STRIPE_CURRENCY, true); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -39,14 +39,14 @@ discard block |
||
| 39 | 39 | * @param object $order |
| 40 | 40 | * @param string $currency |
| 41 | 41 | */ |
| 42 | - public static function update_stripe_currency( $order = null, $currency ) { |
|
| 43 | - if ( is_null( $order ) ) { |
|
| 42 | + public static function update_stripe_currency($order = null, $currency) { |
|
| 43 | + if (is_null($order)) { |
|
| 44 | 44 | return false; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
| 48 | 48 | |
| 49 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, self::META_NAME_STRIPE_CURRENCY, $currency ) : $order->update_meta_data( self::META_NAME_STRIPE_CURRENCY, $currency ); |
|
| 49 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_STRIPE_CURRENCY, $currency) : $order->update_meta_data(self::META_NAME_STRIPE_CURRENCY, $currency); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -56,22 +56,22 @@ discard block |
||
| 56 | 56 | * @param object $order |
| 57 | 57 | * @return string $amount |
| 58 | 58 | */ |
| 59 | - public static function get_stripe_fee( $order = null ) { |
|
| 60 | - if ( is_null( $order ) ) { |
|
| 59 | + public static function get_stripe_fee($order = null) { |
|
| 60 | + if (is_null($order)) { |
|
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
| 65 | 65 | |
| 66 | - $amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, self::META_NAME_FEE, true ) : $order->get_meta( self::META_NAME_FEE, true ); |
|
| 66 | + $amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, self::META_NAME_FEE, true) : $order->get_meta(self::META_NAME_FEE, true); |
|
| 67 | 67 | |
| 68 | 68 | // If not found let's check for legacy name. |
| 69 | - if ( empty( $amount ) ) { |
|
| 70 | - $amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, self::LEGACY_META_NAME_FEE, true ) : $order->get_meta( self::LEGACY_META_NAME_FEE, true ); |
|
| 69 | + if (empty($amount)) { |
|
| 70 | + $amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, self::LEGACY_META_NAME_FEE, true) : $order->get_meta(self::LEGACY_META_NAME_FEE, true); |
|
| 71 | 71 | |
| 72 | 72 | // If found update to new name. |
| 73 | - if ( $amount ) { |
|
| 74 | - self::update_stripe_fee( $order, $amount ); |
|
| 73 | + if ($amount) { |
|
| 74 | + self::update_stripe_fee($order, $amount); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | * @param object $order |
| 86 | 86 | * @param float $amount |
| 87 | 87 | */ |
| 88 | - public static function update_stripe_fee( $order = null, $amount = 0.0 ) { |
|
| 89 | - if ( is_null( $order ) ) { |
|
| 88 | + public static function update_stripe_fee($order = null, $amount = 0.0) { |
|
| 89 | + if (is_null($order)) { |
|
| 90 | 90 | return false; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
| 94 | 94 | |
| 95 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, self::META_NAME_FEE, $amount ) : $order->update_meta_data( self::META_NAME_FEE, $amount ); |
|
| 95 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_FEE, $amount) : $order->update_meta_data(self::META_NAME_FEE, $amount); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -101,15 +101,15 @@ discard block |
||
| 101 | 101 | * @since 4.1.0 |
| 102 | 102 | * @param object $order |
| 103 | 103 | */ |
| 104 | - public static function delete_stripe_fee( $order = null ) { |
|
| 105 | - if ( is_null( $order ) ) { |
|
| 104 | + public static function delete_stripe_fee($order = null) { |
|
| 105 | + if (is_null($order)) { |
|
| 106 | 106 | return false; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
| 110 | 110 | |
| 111 | - delete_post_meta( $order_id, self::META_NAME_FEE ); |
|
| 112 | - delete_post_meta( $order_id, self::LEGACY_META_NAME_FEE ); |
|
| 111 | + delete_post_meta($order_id, self::META_NAME_FEE); |
|
| 112 | + delete_post_meta($order_id, self::LEGACY_META_NAME_FEE); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -119,22 +119,22 @@ discard block |
||
| 119 | 119 | * @param object $order |
| 120 | 120 | * @return string $amount |
| 121 | 121 | */ |
| 122 | - public static function get_stripe_net( $order = null ) { |
|
| 123 | - if ( is_null( $order ) ) { |
|
| 122 | + public static function get_stripe_net($order = null) { |
|
| 123 | + if (is_null($order)) { |
|
| 124 | 124 | return false; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
| 128 | 128 | |
| 129 | - $amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, self::META_NAME_NET, true ) : $order->get_meta( self::META_NAME_NET, true ); |
|
| 129 | + $amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, self::META_NAME_NET, true) : $order->get_meta(self::META_NAME_NET, true); |
|
| 130 | 130 | |
| 131 | 131 | // If not found let's check for legacy name. |
| 132 | - if ( empty( $amount ) ) { |
|
| 133 | - $amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, self::LEGACY_META_NAME_NET, true ) : $order->get_meta( self::LEGACY_META_NAME_NET, true ); |
|
| 132 | + if (empty($amount)) { |
|
| 133 | + $amount = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, self::LEGACY_META_NAME_NET, true) : $order->get_meta(self::LEGACY_META_NAME_NET, true); |
|
| 134 | 134 | |
| 135 | 135 | // If found update to new name. |
| 136 | - if ( $amount ) { |
|
| 137 | - self::update_stripe_net( $order, $amount ); |
|
| 136 | + if ($amount) { |
|
| 137 | + self::update_stripe_net($order, $amount); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
@@ -148,14 +148,14 @@ discard block |
||
| 148 | 148 | * @param object $order |
| 149 | 149 | * @param float $amount |
| 150 | 150 | */ |
| 151 | - public static function update_stripe_net( $order = null, $amount = 0.0 ) { |
|
| 152 | - if ( is_null( $order ) ) { |
|
| 151 | + public static function update_stripe_net($order = null, $amount = 0.0) { |
|
| 152 | + if (is_null($order)) { |
|
| 153 | 153 | return false; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
| 157 | 157 | |
| 158 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, self::META_NAME_NET, $amount ) : $order->update_meta_data( self::META_NAME_NET, $amount ); |
|
| 158 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_NET, $amount) : $order->update_meta_data(self::META_NAME_NET, $amount); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -164,15 +164,15 @@ discard block |
||
| 164 | 164 | * @since 4.1.0 |
| 165 | 165 | * @param object $order |
| 166 | 166 | */ |
| 167 | - public static function delete_stripe_net( $order = null ) { |
|
| 168 | - if ( is_null( $order ) ) { |
|
| 167 | + public static function delete_stripe_net($order = null) { |
|
| 168 | + if (is_null($order)) { |
|
| 169 | 169 | return false; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
| 173 | 173 | |
| 174 | - delete_post_meta( $order_id, self::META_NAME_NET ); |
|
| 175 | - delete_post_meta( $order_id, self::LEGACY_META_NAME_NET ); |
|
| 174 | + delete_post_meta($order_id, self::META_NAME_NET); |
|
| 175 | + delete_post_meta($order_id, self::LEGACY_META_NAME_NET); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -183,15 +183,15 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @return float|int |
| 185 | 185 | */ |
| 186 | - public static function get_stripe_amount( $total, $currency = '' ) { |
|
| 187 | - if ( ! $currency ) { |
|
| 186 | + public static function get_stripe_amount($total, $currency = '') { |
|
| 187 | + if ( ! $currency) { |
|
| 188 | 188 | $currency = get_woocommerce_currency(); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if ( in_array( strtolower( $currency ), self::no_decimal_currencies() ) ) { |
|
| 192 | - return absint( $total ); |
|
| 191 | + if (in_array(strtolower($currency), self::no_decimal_currencies())) { |
|
| 192 | + return absint($total); |
|
| 193 | 193 | } else { |
| 194 | - return absint( wc_format_decimal( ( (float) $total * 100 ), wc_get_price_decimals() ) ); // In cents. |
|
| 194 | + return absint(wc_format_decimal(((float) $total * 100), wc_get_price_decimals())); // In cents. |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
@@ -203,25 +203,25 @@ discard block |
||
| 203 | 203 | * @return array |
| 204 | 204 | */ |
| 205 | 205 | public static function get_localized_messages() { |
| 206 | - return apply_filters( 'wc_stripe_localized_messages', array( |
|
| 207 | - 'invalid_number' => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ), |
|
| 208 | - 'invalid_expiry_month' => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ), |
|
| 209 | - 'invalid_expiry_year' => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ), |
|
| 210 | - 'invalid_cvc' => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ), |
|
| 211 | - 'incorrect_number' => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ), |
|
| 212 | - 'incomplete_number' => __( 'The card number is incomplete.', 'woocommerce-gateway-stripe' ), |
|
| 213 | - 'incomplete_cvc' => __( 'The card\'s security code is incomplete.', 'woocommerce-gateway-stripe' ), |
|
| 214 | - 'incomplete_expiry' => __( 'The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe' ), |
|
| 215 | - 'expired_card' => __( 'The card has expired.', 'woocommerce-gateway-stripe' ), |
|
| 216 | - 'incorrect_cvc' => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ), |
|
| 217 | - 'incorrect_zip' => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ), |
|
| 218 | - 'invalid_expiry_year_past' => __( 'The card\'s expiration year is in the past', 'woocommerce-gateway-stripe' ), |
|
| 219 | - 'card_declined' => __( 'The card was declined.', 'woocommerce-gateway-stripe' ), |
|
| 220 | - 'missing' => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ), |
|
| 221 | - 'processing_error' => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ), |
|
| 222 | - 'invalid_request_error' => __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ), |
|
| 223 | - 'invalid_sofort_country' => __( 'The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe' ), |
|
| 224 | - ) ); |
|
| 206 | + return apply_filters('wc_stripe_localized_messages', array( |
|
| 207 | + 'invalid_number' => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'), |
|
| 208 | + 'invalid_expiry_month' => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'), |
|
| 209 | + 'invalid_expiry_year' => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'), |
|
| 210 | + 'invalid_cvc' => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'), |
|
| 211 | + 'incorrect_number' => __('The card number is incorrect.', 'woocommerce-gateway-stripe'), |
|
| 212 | + 'incomplete_number' => __('The card number is incomplete.', 'woocommerce-gateway-stripe'), |
|
| 213 | + 'incomplete_cvc' => __('The card\'s security code is incomplete.', 'woocommerce-gateway-stripe'), |
|
| 214 | + 'incomplete_expiry' => __('The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe'), |
|
| 215 | + 'expired_card' => __('The card has expired.', 'woocommerce-gateway-stripe'), |
|
| 216 | + 'incorrect_cvc' => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'), |
|
| 217 | + 'incorrect_zip' => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'), |
|
| 218 | + 'invalid_expiry_year_past' => __('The card\'s expiration year is in the past', 'woocommerce-gateway-stripe'), |
|
| 219 | + 'card_declined' => __('The card was declined.', 'woocommerce-gateway-stripe'), |
|
| 220 | + 'missing' => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'), |
|
| 221 | + 'processing_error' => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'), |
|
| 222 | + 'invalid_request_error' => __('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe'), |
|
| 223 | + 'invalid_sofort_country' => __('The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe'), |
|
| 224 | + )); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -258,24 +258,24 @@ discard block |
||
| 258 | 258 | * @param string $type Type of number to format |
| 259 | 259 | * @return string |
| 260 | 260 | */ |
| 261 | - public static function format_balance_fee( $balance_transaction, $type = 'fee' ) { |
|
| 262 | - if ( ! is_object( $balance_transaction ) ) { |
|
| 261 | + public static function format_balance_fee($balance_transaction, $type = 'fee') { |
|
| 262 | + if ( ! is_object($balance_transaction)) { |
|
| 263 | 263 | return; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - if ( in_array( strtolower( $balance_transaction->currency ), self::no_decimal_currencies() ) ) { |
|
| 267 | - if ( 'fee' === $type ) { |
|
| 266 | + if (in_array(strtolower($balance_transaction->currency), self::no_decimal_currencies())) { |
|
| 267 | + if ('fee' === $type) { |
|
| 268 | 268 | return $balance_transaction->fee; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | return $balance_transaction->net; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if ( 'fee' === $type ) { |
|
| 275 | - return number_format( $balance_transaction->fee / 100, 2, '.', '' ); |
|
| 274 | + if ('fee' === $type) { |
|
| 275 | + return number_format($balance_transaction->fee / 100, 2, '.', ''); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - return number_format( $balance_transaction->net / 100, 2, '.', '' ); |
|
| 278 | + return number_format($balance_transaction->net / 100, 2, '.', ''); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | public static function get_minimum_amount() { |
| 285 | 285 | // Check order amount |
| 286 | - switch ( get_woocommerce_currency() ) { |
|
| 286 | + switch (get_woocommerce_currency()) { |
|
| 287 | 287 | case 'USD': |
| 288 | 288 | case 'CAD': |
| 289 | 289 | case 'EUR': |
@@ -328,14 +328,14 @@ discard block |
||
| 328 | 328 | * @param string $method The payment method to get the settings from. |
| 329 | 329 | * @param string $setting The name of the setting to get. |
| 330 | 330 | */ |
| 331 | - public static function get_settings( $method = null, $setting = null ) { |
|
| 332 | - $all_settings = null === $method ? get_option( 'woocommerce_stripe_settings', array() ) : get_option( 'woocommerce_stripe_' . $method . '_settings', array() ); |
|
| 331 | + public static function get_settings($method = null, $setting = null) { |
|
| 332 | + $all_settings = null === $method ? get_option('woocommerce_stripe_settings', array()) : get_option('woocommerce_stripe_' . $method . '_settings', array()); |
|
| 333 | 333 | |
| 334 | - if ( null === $setting ) { |
|
| 334 | + if (null === $setting) { |
|
| 335 | 335 | return $all_settings; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - return isset( $all_settings[ $setting ] ) ? $all_settings[ $setting ] : ''; |
|
| 338 | + return isset($all_settings[$setting]) ? $all_settings[$setting] : ''; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | * @return bool |
| 346 | 346 | */ |
| 347 | 347 | public static function is_pre_orders_exists() { |
| 348 | - return class_exists( 'WC_Pre_Orders_Order' ); |
|
| 348 | + return class_exists('WC_Pre_Orders_Order'); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | * @return bool |
| 357 | 357 | */ |
| 358 | 358 | public static function is_pre_30() { |
| 359 | - return version_compare( WC_VERSION, '3.0.0', '<' ); |
|
| 359 | + return version_compare(WC_VERSION, '3.0.0', '<'); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | * @return string |
| 370 | 370 | */ |
| 371 | 371 | public static function get_webhook_url() { |
| 372 | - return add_query_arg( 'wc-api', 'wc_stripe', trailingslashit( get_home_url() ) ); |
|
| 372 | + return add_query_arg('wc-api', 'wc_stripe', trailingslashit(get_home_url())); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -379,13 +379,13 @@ discard block |
||
| 379 | 379 | * @version 4.0.0 |
| 380 | 380 | * @param string $source_id |
| 381 | 381 | */ |
| 382 | - public static function get_order_by_source_id( $source_id ) { |
|
| 382 | + public static function get_order_by_source_id($source_id) { |
|
| 383 | 383 | global $wpdb; |
| 384 | 384 | |
| 385 | - $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' ) ); |
|
| 385 | + $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')); |
|
| 386 | 386 | |
| 387 | - if ( ! empty( $order_id ) ) { |
|
| 388 | - return wc_get_order( $order_id ); |
|
| 387 | + if ( ! empty($order_id)) { |
|
| 388 | + return wc_get_order($order_id); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | return false; |
@@ -398,13 +398,13 @@ discard block |
||
| 398 | 398 | * @version 4.0.0 |
| 399 | 399 | * @param string $charge_id |
| 400 | 400 | */ |
| 401 | - public static function get_order_by_charge_id( $charge_id ) { |
|
| 401 | + public static function get_order_by_charge_id($charge_id) { |
|
| 402 | 402 | global $wpdb; |
| 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; |
@@ -420,13 +420,13 @@ discard block |
||
| 420 | 420 | * @param string $statement_descriptor |
| 421 | 421 | * @return string $statement_descriptor Sanitized statement descriptor |
| 422 | 422 | */ |
| 423 | - public static function clean_statement_descriptor( $statement_descriptor = '' ) { |
|
| 424 | - $disallowed_characters = array( '<', '>', '"', "'" ); |
|
| 423 | + public static function clean_statement_descriptor($statement_descriptor = '') { |
|
| 424 | + $disallowed_characters = array('<', '>', '"', "'"); |
|
| 425 | 425 | |
| 426 | 426 | // Remove special characters. |
| 427 | - $statement_descriptor = str_replace( $disallowed_characters, '', $statement_descriptor ); |
|
| 427 | + $statement_descriptor = str_replace($disallowed_characters, '', $statement_descriptor); |
|
| 428 | 428 | |
| 429 | - $statement_descriptor = substr( trim( $statement_descriptor ), 0, 22 ); |
|
| 429 | + $statement_descriptor = substr(trim($statement_descriptor), 0, 22); |
|
| 430 | 430 | |
| 431 | 431 | return $statement_descriptor; |
| 432 | 432 | } |