2016-02-02 17:08:32 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit; // Exit if accessed directly
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WooCommerce eCheck Payment Token
|
|
|
|
*
|
|
|
|
* Representation of a payment token for eChecks
|
|
|
|
*
|
|
|
|
* @class WC_Payment_Token_eCheck
|
|
|
|
* @since 2.6.0
|
|
|
|
* @category PaymentTokens
|
|
|
|
* @package WooCommerce/PaymentTokens
|
|
|
|
* @author WooThemes
|
|
|
|
*/
|
|
|
|
class WC_Payment_Token_eCheck extends WC_Payment_Token {
|
|
|
|
|
2016-02-08 16:26:57 +00:00
|
|
|
/** @protected string Token Type String */
|
|
|
|
protected $type = 'eCheck';
|
|
|
|
|
2016-02-02 17:08:32 +00:00
|
|
|
/**
|
|
|
|
* Validate eCheck payment tokens.
|
|
|
|
*
|
2016-02-08 16:26:57 +00:00
|
|
|
* These fields are required by all eCheck payment tokens:
|
2016-02-04 16:23:41 +00:00
|
|
|
* last4 - string Last 4 digits of the check
|
2016-02-02 17:08:32 +00:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
2016-02-08 16:26:57 +00:00
|
|
|
* @return boolean True if the passed data is valid
|
2016-02-02 17:08:32 +00:00
|
|
|
*/
|
2016-02-08 16:26:57 +00:00
|
|
|
public static function validate() {
|
|
|
|
if ( false === parent::validate() ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( empty( $this->meta['last4'] ) ) {
|
2016-02-02 17:08:32 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-02-04 16:23:41 +00:00
|
|
|
* Returns the last four digits
|
2016-02-02 17:08:32 +00:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
* @return string Last 4 digits
|
|
|
|
*/
|
|
|
|
public function get_last4() {
|
|
|
|
return isset( $this->meta['last4'] ) ? $this->meta['last4'] : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-02-04 16:23:41 +00:00
|
|
|
* Set the last four digits
|
2016-02-02 17:08:32 +00:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
* @param string $last4
|
|
|
|
*/
|
|
|
|
public function set_last4( $last4 ) {
|
|
|
|
$this->meta['last4'] = $last4;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|