File "class-wc-payment-token-cc.php"

Full path: /home/kosmetik/public_html/wp-content/plugins/woocommerce/includes/payment-tokens/class-wc-payment-token-cc.php
File size: 2.19 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php

if (!defined('ABSPATH')) {
    exit;
}
class WC_Payment_Token_CC extends WC_Payment_Token
{
    protected $type = 'CC';
    protected $extra_data = array('last4' => '', 'expiry_year' => '', 'expiry_month' => '', 'card_type' => '');
    public function get_display_name($deprecated = '')
    {
        $display = sprintf(__('%1$s ending in %2$s (expires %3$s/%4$s)', 'woocommerce'), wc_get_credit_card_type_label($this->get_card_type()), $this->get_last4(), $this->get_expiry_month(), substr($this->get_expiry_year(), 2));
        return $display;
    }
    protected function get_hook_prefix()
    {
        return 'woocommerce_payment_token_cc_get_';
    }
    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;
    }
    public function get_card_type($context = 'view')
    {
        return $this->get_prop('card_type', $context);
    }
    public function set_card_type($type)
    {
        $this->set_prop('card_type', $type);
    }
    public function get_expiry_year($context = 'view')
    {
        return $this->get_prop('expiry_year', $context);
    }
    public function set_expiry_year($year)
    {
        $this->set_prop('expiry_year', $year);
    }
    public function get_expiry_month($context = 'view')
    {
        return $this->get_prop('expiry_month', $context);
    }
    public function set_expiry_month($month)
    {
        $this->set_prop('expiry_month', str_pad($month, 2, '0', STR_PAD_LEFT));
    }
    public function get_last4($context = 'view')
    {
        return $this->get_prop('last4', $context);
    }
    public function set_last4($last4)
    {
        $this->set_prop('last4', $last4);
    }
}