/**
  * Validate the payment fields when processing the checkout
  *
  * NOTE: if we want to bring billing field validation (ie length) into the
  * fold, see the Elavon VM Payment Gateway for a sample implementation
  *
  * @since 1.0.0
  * @see WC_Payment_Gateway::validate_fields()
  * @return bool true if fields are valid, false otherwise
  */
 public function validate_fields()
 {
     $is_valid = parent::validate_fields();
     if ($this->supports_tokenization()) {
         // tokenized transaction?
         if (SV_WC_Helper::get_post('wc-' . $this->get_id_dasherized() . '-payment-token')) {
             // unknown token?
             if (!$this->has_payment_token(get_current_user_id(), SV_WC_Helper::get_post('wc-' . $this->get_id_dasherized() . '-payment-token'))) {
                 SV_WC_Helper::wc_add_notice(_x('Payment error, please try another payment method or contact us to complete your transaction.', 'Supports tokenization', $this->text_domain), 'error');
                 $is_valid = false;
             }
             // no more validation to perform
             return $is_valid;
         }
     }
     // validate remaining payment fields
     if ($this->is_credit_card_gateway()) {
         return $this->validate_credit_card_fields($is_valid);
     } elseif ($this->is_echeck_gateway()) {
         return $this->validate_check_fields($is_valid);
     } else {
         $method_name = 'validate_' . str_replace('-', '_', strtolower($this->get_payment_type())) . '_fields';
         if (is_callable(array($this, $method_name))) {
             return $this->{$method_name}($is_valid);
         }
     }
 }
 /**
  * Validate the payment fields when processing the checkout
  *
  * NOTE: if we want to bring billing field validation (ie length) into the
  * fold, see the Elavon VM Payment Gateway for a sample implementation
  *
  * @since 1.0.0
  * @see WC_Payment_Gateway::validate_fields()
  * @return bool true if fields are valid, false otherwise
  */
 public function validate_fields()
 {
     $is_valid = parent::validate_fields();
     if ($this->supports_tokenization()) {
         // tokenized transaction?
         if (SV_WC_Helper::get_post('wc-' . $this->get_id_dasherized() . '-payment-token')) {
             // unknown token?
             if (!$this->get_payment_tokens_handler()->user_has_token(get_current_user_id(), SV_WC_Helper::get_post('wc-' . $this->get_id_dasherized() . '-payment-token'))) {
                 SV_WC_Helper::wc_add_notice(esc_html__('Payment error, please try another payment method or contact us to complete your transaction.', 'woocommerce-plugin-framework'), 'error');
                 $is_valid = false;
             }
             // Check the CSC if enabled
             if ($this->csc_enabled() && $this->is_credit_card_gateway()) {
                 $is_valid = $this->validate_csc(SV_WC_Helper::get_post('wc-' . $this->get_id_dasherized() . '-csc')) && $is_valid;
             }
             // no more validation to perform
             return $is_valid;
         }
     }
     // validate remaining payment fields
     if ($this->is_credit_card_gateway()) {
         return $this->validate_credit_card_fields($is_valid);
     } elseif ($this->is_echeck_gateway()) {
         return $this->validate_check_fields($is_valid);
     } else {
         $method_name = 'validate_' . str_replace('-', '_', strtolower($this->get_payment_type())) . '_fields';
         if (is_callable(array($this, $method_name))) {
             return $this->{$method_name}($is_valid);
         }
     }
     // no more validation to perform. Return the parent method's outcome.
     return $is_valid;
 }