woocommerce/includes/payment-tokens/class-wc-payment-token-eche...

84 lines
1.6 KiB
PHP
Raw Normal View History

2016-02-02 17:08:32 +00:00
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* WooCommerce eCheck Payment Token.
2016-02-02 17:08:32 +00:00
*
* Representation of a payment token for eChecks.
2016-02-02 17:08:32 +00:00
*
* @class WC_Payment_Token_eCheck
2016-11-14 14:20:41 +00:00
* @version 2.7.0
2016-02-02 17:08:32 +00:00
* @since 2.6.0
* @category PaymentTokens
* @package WooCommerce/PaymentTokens
* @author WooThemes
*/
class WC_Payment_Token_eCheck extends WC_Payment_Token {
/** @protected string Token Type String */
protected $type = 'eCheck';
2016-11-14 14:20:41 +00:00
/**
* Hook prefix
*
* @since 2.7.0
*/
protected function get_hook_prefix() {
return 'woocommerce_payment_token_echeck_get_';
}
2016-06-06 19:04:45 +00:00
/**
2016-02-02 17:08:32 +00:00
* Validate eCheck payment tokens.
*
* These fields are required by all eCheck payment tokens:
* last4 - string Last 4 digits of the check
2016-02-02 17:08:32 +00:00
*
* @since 2.6.0
* @return boolean True if the passed data is valid
2016-02-02 17:08:32 +00:00
*/
public function validate() {
if ( false === parent::validate() ) {
return false;
}
2016-11-14 14:20:41 +00:00
if ( ! $this->get_last4( 'edit' ) ) {
2016-02-02 17:08:32 +00:00
return false;
}
return true;
}
2016-05-26 10:55:11 +00:00
/**
* Get type to display to user.
2016-11-14 14:20:41 +00:00
*
* @since 2.6.0
* @param string $context
2016-05-26 10:55:11 +00:00
* @return string
*/
2016-11-14 14:20:41 +00:00
public function get_display_name( $context = 'view' ) {
2016-05-26 10:55:11 +00:00
return __( 'eCheck', 'woocommerce' );
}
2016-02-02 17:08:32 +00:00
/**
* Returns the last four digits.
2016-11-14 14:20:41 +00:00
*
* @since 2.6.0
* @param string $context
2016-02-02 17:08:32 +00:00
* @return string Last 4 digits
*/
2016-11-14 14:20:41 +00:00
public function get_last4( $context = 'view' ) {
return $this->get_meta( 'last4', true, $context );
2016-02-02 17:08:32 +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->add_meta_data( 'last4', $last4, true );
2016-02-02 17:08:32 +00:00
}
}