@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if ( ! defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | $this->retry_interval = 1; |
| 25 | 25 | |
| 26 | - add_action( 'wp', array( $this, 'maybe_process_redirect_order' ) ); |
|
| 27 | - add_action( 'woocommerce_order_status_on-hold_to_processing', array( $this, 'capture_payment' ) ); |
|
| 28 | - add_action( 'woocommerce_order_status_on-hold_to_completed', array( $this, 'capture_payment' ) ); |
|
| 29 | - add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'cancel_payment' ) ); |
|
| 30 | - add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'cancel_payment' ) ); |
|
| 26 | + add_action('wp', array($this, 'maybe_process_redirect_order')); |
|
| 27 | + add_action('woocommerce_order_status_on-hold_to_processing', array($this, 'capture_payment')); |
|
| 28 | + add_action('woocommerce_order_status_on-hold_to_completed', array($this, 'capture_payment')); |
|
| 29 | + add_action('woocommerce_order_status_on-hold_to_cancelled', array($this, 'cancel_payment')); |
|
| 30 | + add_action('woocommerce_order_status_on-hold_to_refunded', array($this, 'cancel_payment')); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -51,25 +51,25 @@ discard block |
||
| 51 | 51 | * @param bool $retry |
| 52 | 52 | * @param mix $previous_error Any error message from previous request. |
| 53 | 53 | */ |
| 54 | - public function process_redirect_payment( $order_id, $retry = true, $previous_error = false ) { |
|
| 54 | + public function process_redirect_payment($order_id, $retry = true, $previous_error = false) { |
|
| 55 | 55 | try { |
| 56 | - $source = wc_clean( $_GET['source'] ); |
|
| 56 | + $source = wc_clean($_GET['source']); |
|
| 57 | 57 | |
| 58 | - if ( empty( $source ) ) { |
|
| 58 | + if (empty($source)) { |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if ( empty( $order_id ) ) { |
|
| 62 | + if (empty($order_id)) { |
|
| 63 | 63 | return; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - $order = wc_get_order( $order_id ); |
|
| 66 | + $order = wc_get_order($order_id); |
|
| 67 | 67 | |
| 68 | - if ( ! is_object( $order ) ) { |
|
| 68 | + if ( ! is_object($order)) { |
|
| 69 | 69 | return; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if ( 'processing' === $order->get_status() || 'completed' === $order->get_status() || 'on-hold' === $order->get_status() ) { |
|
| 72 | + if ('processing' === $order->get_status() || 'completed' === $order->get_status() || 'on-hold' === $order->get_status()) { |
|
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -77,124 +77,124 @@ discard block |
||
| 77 | 77 | $response = null; |
| 78 | 78 | |
| 79 | 79 | // This will throw exception if not valid. |
| 80 | - $this->validate_minimum_order_amount( $order ); |
|
| 80 | + $this->validate_minimum_order_amount($order); |
|
| 81 | 81 | |
| 82 | - WC_Stripe_Logger::log( "Info: (Redirect) Begin processing payment for order $order_id for the amount of {$order->get_total()}" ); |
|
| 82 | + WC_Stripe_Logger::log("Info: (Redirect) Begin processing payment for order $order_id for the amount of {$order->get_total()}"); |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * First check if the source is chargeable at this time. If not, |
| 86 | 86 | * webhook will take care of it later. |
| 87 | 87 | */ |
| 88 | - $source_info = WC_Stripe_API::retrieve( 'sources/' . $source ); |
|
| 88 | + $source_info = WC_Stripe_API::retrieve('sources/' . $source); |
|
| 89 | 89 | |
| 90 | - if ( ! empty( $source_info->error ) ) { |
|
| 91 | - throw new WC_Stripe_Exception( print_r( $source_info, true ), $source_info->error->message ); |
|
| 90 | + if ( ! empty($source_info->error)) { |
|
| 91 | + throw new WC_Stripe_Exception(print_r($source_info, true), $source_info->error->message); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ( 'failed' === $source_info->status || 'canceled' === $source_info->status ) { |
|
| 95 | - throw new WC_Stripe_Exception( print_r( $source_info, true ), __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ) ); |
|
| 94 | + if ('failed' === $source_info->status || 'canceled' === $source_info->status) { |
|
| 95 | + throw new WC_Stripe_Exception(print_r($source_info, true), __('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe')); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // If already consumed, then ignore request. |
| 99 | - if ( 'consumed' === $source_info->status ) { |
|
| 99 | + if ('consumed' === $source_info->status) { |
|
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // If not chargeable, then ignore request. |
| 104 | - if ( 'chargeable' !== $source_info->status ) { |
|
| 104 | + if ('chargeable' !== $source_info->status) { |
|
| 105 | 105 | return; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // Prep source object. |
| 109 | 109 | $source_object = new stdClass(); |
| 110 | 110 | $source_object->token_id = ''; |
| 111 | - $source_object->customer = $this->get_stripe_customer_id( $order ); |
|
| 111 | + $source_object->customer = $this->get_stripe_customer_id($order); |
|
| 112 | 112 | $source_object->source = $source_info->id; |
| 113 | 113 | $source_object->status = 'chargeable'; |
| 114 | 114 | |
| 115 | 115 | /* If we're doing a retry and source is chargeable, we need to pass |
| 116 | 116 | * a different idempotency key and retry for success. |
| 117 | 117 | */ |
| 118 | - if ( $this->need_update_idempotency_key( $source_object, $previous_error ) ) { |
|
| 119 | - add_filter( 'wc_stripe_idempotency_key', array( $this, 'change_idempotency_key' ), 10, 2 ); |
|
| 118 | + if ($this->need_update_idempotency_key($source_object, $previous_error)) { |
|
| 119 | + add_filter('wc_stripe_idempotency_key', array($this, 'change_idempotency_key'), 10, 2); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | // Make the request. |
| 123 | - $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source_object ), 'charges', 'POST', true ); |
|
| 123 | + $response = WC_Stripe_API::request($this->generate_payment_request($order, $source_object), 'charges', 'POST', true); |
|
| 124 | 124 | $headers = $response['headers']; |
| 125 | 125 | $response = $response['body']; |
| 126 | 126 | |
| 127 | - if ( ! empty( $response->error ) ) { |
|
| 127 | + if ( ! empty($response->error)) { |
|
| 128 | 128 | // Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without. |
| 129 | - if ( $this->is_no_such_customer_error( $response->error ) ) { |
|
| 130 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
| 131 | - delete_user_meta( $order->customer_user, '_stripe_customer_id' ); |
|
| 132 | - delete_post_meta( $order_id, '_stripe_customer_id' ); |
|
| 129 | + if ($this->is_no_such_customer_error($response->error)) { |
|
| 130 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
| 131 | + delete_user_meta($order->customer_user, '_stripe_customer_id'); |
|
| 132 | + delete_post_meta($order_id, '_stripe_customer_id'); |
|
| 133 | 133 | } else { |
| 134 | - delete_user_meta( $order->get_customer_id(), '_stripe_customer_id' ); |
|
| 135 | - $order->delete_meta_data( '_stripe_customer_id' ); |
|
| 134 | + delete_user_meta($order->get_customer_id(), '_stripe_customer_id'); |
|
| 135 | + $order->delete_meta_data('_stripe_customer_id'); |
|
| 136 | 136 | $order->save(); |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if ( $this->is_no_such_token_error( $response->error ) && $prepared_source->token_id ) { |
|
| 140 | + if ($this->is_no_such_token_error($response->error) && $prepared_source->token_id) { |
|
| 141 | 141 | // Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message. |
| 142 | - $wc_token = WC_Payment_Tokens::get( $prepared_source->token_id ); |
|
| 142 | + $wc_token = WC_Payment_Tokens::get($prepared_source->token_id); |
|
| 143 | 143 | $wc_token->delete(); |
| 144 | - $localized_message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' ); |
|
| 145 | - $order->add_order_note( $localized_message ); |
|
| 146 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
| 144 | + $localized_message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe'); |
|
| 145 | + $order->add_order_note($localized_message); |
|
| 146 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | // We want to retry. |
| 150 | - if ( $this->is_retryable_error( $response->error ) ) { |
|
| 151 | - if ( $retry ) { |
|
| 150 | + if ($this->is_retryable_error($response->error)) { |
|
| 151 | + if ($retry) { |
|
| 152 | 152 | // Don't do anymore retries after this. |
| 153 | - if ( 5 <= $this->retry_interval ) { |
|
| 154 | - return $this->process_redirect_payment( $order_id, false, $response->error ); |
|
| 153 | + if (5 <= $this->retry_interval) { |
|
| 154 | + return $this->process_redirect_payment($order_id, false, $response->error); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - sleep( $this->retry_interval ); |
|
| 157 | + sleep($this->retry_interval); |
|
| 158 | 158 | |
| 159 | 159 | $this->retry_interval++; |
| 160 | - return $this->process_redirect_payment( $order_id, true, $response->error ); |
|
| 160 | + return $this->process_redirect_payment($order_id, true, $response->error); |
|
| 161 | 161 | } else { |
| 162 | - $localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' ); |
|
| 163 | - $order->add_order_note( $localized_message ); |
|
| 164 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
| 162 | + $localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe'); |
|
| 163 | + $order->add_order_note($localized_message); |
|
| 164 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $localized_messages = WC_Stripe_Helper::get_localized_messages(); |
| 169 | 169 | |
| 170 | - if ( 'card_error' === $response->error->type ) { |
|
| 171 | - $message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message; |
|
| 170 | + if ('card_error' === $response->error->type) { |
|
| 171 | + $message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message; |
|
| 172 | 172 | } else { |
| 173 | - $message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message; |
|
| 173 | + $message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - throw new WC_Stripe_Exception( print_r( $response, true ), $message ); |
|
| 176 | + throw new WC_Stripe_Exception(print_r($response, true), $message); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | // To prevent double processing the order on WC side. |
| 180 | - if ( ! $this->is_original_request( $headers ) ) { |
|
| 180 | + if ( ! $this->is_original_request($headers)) { |
|
| 181 | 181 | return; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - do_action( 'wc_gateway_stripe_process_redirect_payment', $response, $order ); |
|
| 184 | + do_action('wc_gateway_stripe_process_redirect_payment', $response, $order); |
|
| 185 | 185 | |
| 186 | - $this->process_response( $response, $order ); |
|
| 186 | + $this->process_response($response, $order); |
|
| 187 | 187 | |
| 188 | - } catch ( WC_Stripe_Exception $e ) { |
|
| 189 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
| 188 | + } catch (WC_Stripe_Exception $e) { |
|
| 189 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
| 190 | 190 | |
| 191 | - do_action( 'wc_gateway_stripe_process_redirect_payment_error', $e, $order ); |
|
| 191 | + do_action('wc_gateway_stripe_process_redirect_payment_error', $e, $order); |
|
| 192 | 192 | |
| 193 | 193 | /* translators: error message */ |
| 194 | - $order->update_status( 'failed', sprintf( __( 'Stripe payment failed: %s', 'woocommerce-gateway-stripe' ), $e->getLocalizedMessage() ) ); |
|
| 194 | + $order->update_status('failed', sprintf(__('Stripe payment failed: %s', 'woocommerce-gateway-stripe'), $e->getLocalizedMessage())); |
|
| 195 | 195 | |
| 196 | - wc_add_notice( $e->getLocalizedMessage(), 'error' ); |
|
| 197 | - wp_safe_redirect( wc_get_checkout_url() ); |
|
| 196 | + wc_add_notice($e->getLocalizedMessage(), 'error'); |
|
| 197 | + wp_safe_redirect(wc_get_checkout_url()); |
|
| 198 | 198 | exit; |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | * @version 4.0.0 |
| 207 | 207 | */ |
| 208 | 208 | public function maybe_process_redirect_order() { |
| 209 | - if ( ! is_order_received_page() || empty( $_GET['client_secret'] ) || empty( $_GET['source'] ) ) { |
|
| 209 | + if ( ! is_order_received_page() || empty($_GET['client_secret']) || empty($_GET['source'])) { |
|
| 210 | 210 | return; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - $order_id = wc_clean( $_GET['order_id'] ); |
|
| 213 | + $order_id = wc_clean($_GET['order_id']); |
|
| 214 | 214 | |
| 215 | - $this->process_redirect_payment( $order_id ); |
|
| 215 | + $this->process_redirect_payment($order_id); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -222,52 +222,52 @@ discard block |
||
| 222 | 222 | * @version 4.0.0 |
| 223 | 223 | * @param int $order_id |
| 224 | 224 | */ |
| 225 | - public function capture_payment( $order_id ) { |
|
| 226 | - $order = wc_get_order( $order_id ); |
|
| 225 | + public function capture_payment($order_id) { |
|
| 226 | + $order = wc_get_order($order_id); |
|
| 227 | 227 | |
| 228 | - if ( 'stripe' === ( WC_Stripe_Helper::is_pre_30() ? $order->payment_method : $order->get_payment_method() ) ) { |
|
| 229 | - $charge = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, '_transaction_id', true ) : $order->get_transaction_id(); |
|
| 230 | - $captured = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, '_stripe_charge_captured', true ) : $order->get_meta( '_stripe_charge_captured', true ); |
|
| 228 | + if ('stripe' === (WC_Stripe_Helper::is_pre_30() ? $order->payment_method : $order->get_payment_method())) { |
|
| 229 | + $charge = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, '_transaction_id', true) : $order->get_transaction_id(); |
|
| 230 | + $captured = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, '_stripe_charge_captured', true) : $order->get_meta('_stripe_charge_captured', true); |
|
| 231 | 231 | |
| 232 | - if ( $charge && 'no' === $captured ) { |
|
| 232 | + if ($charge && 'no' === $captured) { |
|
| 233 | 233 | $order_total = $order->get_total(); |
| 234 | 234 | |
| 235 | - if ( 0 < $order->get_total_refunded() ) { |
|
| 235 | + if (0 < $order->get_total_refunded()) { |
|
| 236 | 236 | $order_total = $order_total - $order->get_total_refunded(); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - $result = WC_Stripe_API::request( array( |
|
| 240 | - 'amount' => WC_Stripe_Helper::get_stripe_amount( $order_total ), |
|
| 239 | + $result = WC_Stripe_API::request(array( |
|
| 240 | + 'amount' => WC_Stripe_Helper::get_stripe_amount($order_total), |
|
| 241 | 241 | 'expand[]' => 'balance_transaction', |
| 242 | - ), 'charges/' . $charge . '/capture' ); |
|
| 242 | + ), 'charges/' . $charge . '/capture'); |
|
| 243 | 243 | |
| 244 | - if ( ! empty( $result->error ) ) { |
|
| 244 | + if ( ! empty($result->error)) { |
|
| 245 | 245 | /* translators: error message */ |
| 246 | - $order->update_status( 'failed', sprintf( __( 'Unable to capture charge! %s', 'woocommerce-gateway-stripe' ), $result->error->message ) ); |
|
| 246 | + $order->update_status('failed', sprintf(__('Unable to capture charge! %s', 'woocommerce-gateway-stripe'), $result->error->message)); |
|
| 247 | 247 | } else { |
| 248 | 248 | /* translators: transaction id */ |
| 249 | - $order->add_order_note( sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $result->id ) ); |
|
| 250 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, '_stripe_charge_captured', 'yes' ) : $order->update_meta_data( '_stripe_charge_captured', 'yes' ); |
|
| 249 | + $order->add_order_note(sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $result->id)); |
|
| 250 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, '_stripe_charge_captured', 'yes') : $order->update_meta_data('_stripe_charge_captured', 'yes'); |
|
| 251 | 251 | |
| 252 | 252 | // Store other data such as fees |
| 253 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, '_transaction_id', $result->id ) : $order->set_transaction_id( $result->id ); |
|
| 253 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, '_transaction_id', $result->id) : $order->set_transaction_id($result->id); |
|
| 254 | 254 | |
| 255 | - if ( isset( $result->balance_transaction ) && isset( $result->balance_transaction->fee ) ) { |
|
| 255 | + if (isset($result->balance_transaction) && isset($result->balance_transaction->fee)) { |
|
| 256 | 256 | // Fees and Net needs to both come from Stripe to be accurate as the returned |
| 257 | 257 | // values are in the local currency of the Stripe account, not from WC. |
| 258 | - $fee = ! empty( $result->balance_transaction->fee ) ? WC_Stripe_Helper::format_balance_fee( $result->balance_transaction, 'fee' ) : 0; |
|
| 259 | - $net = ! empty( $result->balance_transaction->net ) ? WC_Stripe_Helper::format_balance_fee( $result->balance_transaction, 'net' ) : 0; |
|
| 260 | - WC_Stripe_Helper::update_stripe_fee( $order, $fee ); |
|
| 261 | - WC_Stripe_Helper::update_stripe_net( $order, $net ); |
|
| 258 | + $fee = ! empty($result->balance_transaction->fee) ? WC_Stripe_Helper::format_balance_fee($result->balance_transaction, 'fee') : 0; |
|
| 259 | + $net = ! empty($result->balance_transaction->net) ? WC_Stripe_Helper::format_balance_fee($result->balance_transaction, 'net') : 0; |
|
| 260 | + WC_Stripe_Helper::update_stripe_fee($order, $fee); |
|
| 261 | + WC_Stripe_Helper::update_stripe_net($order, $net); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if ( is_callable( array( $order, 'save' ) ) ) { |
|
| 264 | + if (is_callable(array($order, 'save'))) { |
|
| 265 | 265 | $order->save(); |
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // This hook fires when admin manually changes order status to processing or completed. |
| 270 | - do_action( 'woocommerce_stripe_process_manual_capture', $order, $result ); |
|
| 270 | + do_action('woocommerce_stripe_process_manual_capture', $order, $result); |
|
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | } |
@@ -279,14 +279,14 @@ discard block |
||
| 279 | 279 | * @version 4.0.0 |
| 280 | 280 | * @param int $order_id |
| 281 | 281 | */ |
| 282 | - public function cancel_payment( $order_id ) { |
|
| 283 | - $order = wc_get_order( $order_id ); |
|
| 282 | + public function cancel_payment($order_id) { |
|
| 283 | + $order = wc_get_order($order_id); |
|
| 284 | 284 | |
| 285 | - if ( 'stripe' === ( WC_Stripe_Helper::is_pre_30() ? $order->payment_method : $order->get_payment_method() ) ) { |
|
| 286 | - $this->process_refund( $order_id ); |
|
| 285 | + if ('stripe' === (WC_Stripe_Helper::is_pre_30() ? $order->payment_method : $order->get_payment_method())) { |
|
| 286 | + $this->process_refund($order_id); |
|
| 287 | 287 | |
| 288 | 288 | // This hook fires when admin manually changes order status to cancel. |
| 289 | - do_action( 'woocommerce_stripe_process_manual_cancel', $order ); |
|
| 289 | + do_action('woocommerce_stripe_process_manual_cancel', $order); |
|
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if ( ! defined('ABSPATH')) { |
|
| 4 | 4 | exit; // Exit if accessed directly |
| 5 | 5 | } |
| 6 | 6 | |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | * @param string $deprecated Deprecated since WooCommerce 3.0 |
| 36 | 36 | * @return string |
| 37 | 37 | */ |
| 38 | - public function get_display_name( $deprecated = '' ) { |
|
| 38 | + public function get_display_name($deprecated = '') { |
|
| 39 | 39 | $display = sprintf( |
| 40 | 40 | /* translators: last 4 digits of IBAN account */ |
| 41 | - __( 'SEPA IBAN ending in %s', 'woocommerce-gateway-stripe' ), |
|
| 41 | + __('SEPA IBAN ending in %s', 'woocommerce-gateway-stripe'), |
|
| 42 | 42 | $this->get_last4() |
| 43 | 43 | ); |
| 44 | 44 | |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | * @return boolean True if the passed data is valid |
| 67 | 67 | */ |
| 68 | 68 | public function validate() { |
| 69 | - if ( false === parent::validate() ) { |
|
| 69 | + if (false === parent::validate()) { |
|
| 70 | 70 | return false; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if ( ! $this->get_last4( 'edit' ) ) { |
|
| 73 | + if ( ! $this->get_last4('edit')) { |
|
| 74 | 74 | return false; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | * @param string $context |
| 86 | 86 | * @return string Last 4 digits |
| 87 | 87 | */ |
| 88 | - public function get_last4( $context = 'view' ) { |
|
| 89 | - return WC_Stripe_Helper::is_pre_30() ? $this->get_meta( 'last4' ) : $this->get_prop( 'last4', $context ); |
|
| 88 | + public function get_last4($context = 'view') { |
|
| 89 | + return WC_Stripe_Helper::is_pre_30() ? $this->get_meta('last4') : $this->get_prop('last4', $context); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @version 4.0.0 |
| 96 | 96 | * @param string $last4 |
| 97 | 97 | */ |
| 98 | - public function set_last4( $last4 ) { |
|
| 99 | - WC_Stripe_Helper::is_pre_30() ? $this->add_meta_data( 'last4', $last4, true ) : $this->set_prop( 'last4', $last4 ); |
|
| 98 | + public function set_last4($last4) { |
|
| 99 | + WC_Stripe_Helper::is_pre_30() ? $this->add_meta_data('last4', $last4, true) : $this->set_prop('last4', $last4); |
|
| 100 | 100 | } |
| 101 | 101 | } |