Validate length for expiry - 4 chars for year and 2 for month.

This commit is contained in:
Justin Shreve 2016-02-08 08:36:27 -08:00
parent 214f077a91
commit 7b57b4c4cc
2 changed files with 10 additions and 2 deletions

View File

@ -77,10 +77,10 @@ if ( ! defined( 'ABSPATH' ) ) {
}
/**
* Returns the type of this payment token (cc, echeck, or something else)
* Returns the type of this payment token (CC, eCheck, or something else)
*
* @since 2.6.0
* @return string Payment token type
* @return string Payment Token Type (CC, eCheck)
*/
public function get_type() {
return isset( $this->data['type'] ) ? $this->data['type'] : '';

View File

@ -54,6 +54,14 @@ class WC_Payment_Token_CC extends WC_Payment_Token {
return false;
}
if ( 4 !== strlen( $this->meta['expiry_year'] ) ) {
return false;
}
if ( 2 !== strlen( $this->meta['expiry_month'] ) ) {
return false;
}
return true;
}