2016-02-02 17:08:32 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit; // Exit if accessed directly
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-01 19:37:06 +00:00
|
|
|
* WooCommerce eCheck Payment Token.
|
2016-02-02 17:08:32 +00:00
|
|
|
*
|
2016-03-01 19:37:06 +00:00
|
|
|
* Representation of a payment token for eChecks.
|
2016-02-02 17:08:32 +00:00
|
|
|
*
|
|
|
|
* @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 18:33:53 +00:00
|
|
|
public function validate() {
|
2016-02-08 16:26:57 +00:00
|
|
|
if ( false === parent::validate() ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-03-23 10:13:51 +00:00
|
|
|
if ( ! $this->get_last4() ) {
|
2016-02-02 17:08:32 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-01 19:37:06 +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() {
|
2016-03-18 18:24:06 +00:00
|
|
|
return $this->get_meta( 'last4' );
|
2016-02-02 17:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-01 19:37:06 +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 ) {
|
2016-03-18 18:24:06 +00:00
|
|
|
$this->add_meta_data( 'last4', $last4, true );
|
2016-02-02 17:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|