WC_Payment_Token_CC::validate()
Validate credit card payment tokens.
These fields are required by all credit card payment tokens: expiry_month - string Expiration date (MM) for the card expiry_year - string Expiration date (YYYY) for the card last4 - string Last 4 digits of the card card_type - string Card type (visa, mastercard, etc)
Метод класса: WC_Payment_Token_CC{}
Хуков нет.
Возвращает
true|false
. True if the passed data is valid
Использование
$WC_Payment_Token_CC = new WC_Payment_Token_CC(); $WC_Payment_Token_CC->validate();
Список изменений
С версии 2.6.0 | Введена. |
Код WC_Payment_Token_CC::validate() WC Payment Token CC::validate WC 9.7.1
public function validate() { if ( false === parent::validate() ) { return false; } if ( ! $this->get_last4( 'edit' ) ) { return false; } if ( ! $this->get_expiry_year( 'edit' ) ) { return false; } if ( ! $this->get_expiry_month( 'edit' ) ) { return false; } if ( ! $this->get_card_type( 'edit' ) ) { return false; } if ( 4 !== strlen( $this->get_expiry_year( 'edit' ) ) ) { return false; } if ( 2 !== strlen( $this->get_expiry_month( 'edit' ) ) ) { return false; } return true; }