WC_Payment_Token_CC::validate()
Validate credit card payment tokens.
Description Description
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)
Return Return
(boolean) True if the passed data is valid
Source Source
File: includes/payment-tokens/class-wc-payment-token-cc.php
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;
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |