PHP Class WC_Payment_Token

Representation of a general payment token to be extended by individuals types of tokens examples: Credit Card, eCheck.
Since: 2.6.0
Author: WooThemes
Inheritance: extends WC_Legacy_Payment_Token
ファイルを表示 Open project: woocommerce/woocommerce Class Usage Examples

Protected Properties

Property Type Description
$data array Token Data (stored in the payment_tokens table).

Public Methods

Method Description
__construct ( mixed $token = '' ) Initialize a payment token.
get_display_name ( string $context = 'view' ) : string Get type to display to user.
get_gateway_id ( string $context = 'view' ) : string Returns the ID of the gateway associated with this payment token.
get_is_default ( string $context = 'view' ) : string Returns the ID of the gateway associated with this payment token.
get_token ( string $context = 'view' ) : string Returns the raw payment token.
get_type ( string $context = 'view' ) : string Returns the type of this payment token (CC, eCheck, or something else).
get_user_id ( string $context = 'view' ) : integer Returns the user ID associated with the token or false if this token is not associated.
is_default ( ) : boolean Returns if the token is marked as default.
set_default ( boolean $is_default ) Marks the payment as default or non-default.
set_gateway_id ( string $gateway_id ) Set the gateway ID.
set_token ( string $token ) Set the raw payment token.
set_type ( $type ) Sets the type of this payment token (CC, eCheck, or something else).
set_user_id ( integer $user_id ) Set the user ID for the user associated with this order.
validate ( ) : boolean Validate basic token info (token and type are required).

Method Details

__construct() public method

These fields are accepted by all payment tokens: is_default - boolean Optional - Indicates this is the default payment token for a user token - string Required - The actual token to store gateway_id - string Required - Identifier for the gateway this token is associated with user_id - int Optional - ID for the user this token is associated with. 0 if this token is not associated with a user
Since: 2.6.0
public __construct ( mixed $token = '' )
$token mixed

get_display_name() public method

Get's overwritten by child classes.
Since: 2.6.0
public get_display_name ( string $context = 'view' ) : string
$context string
return string

get_gateway_id() public method

Returns the ID of the gateway associated with this payment token.
Since: 2.6.0
public get_gateway_id ( string $context = 'view' ) : string
$context string
return string Gateway ID

get_is_default() public method

Returns the ID of the gateway associated with this payment token.
Since: 2.6.0
public get_is_default ( string $context = 'view' ) : string
$context string
return string Gateway ID

get_token() public method

Returns the raw payment token.
Since: 2.6.0
public get_token ( string $context = 'view' ) : string
$context string
return string Raw token

get_type() public method

Returns the type of this payment token (CC, eCheck, or something else).
Since: 2.6.0
public get_type ( string $context = 'view' ) : string
$context string
return string Payment Token Type (CC, eCheck)

get_user_id() public method

Returns the user ID associated with the token or false if this token is not associated.
Since: 2.6.0
public get_user_id ( string $context = 'view' ) : integer
$context string
return integer User ID if this token is associated with a user or 0 if no user is associated

is_default() public method

Returns if the token is marked as default.
Since: 2.6.0
public is_default ( ) : boolean
return boolean True if the token is default

set_default() public method

Marks the payment as default or non-default.
Since: 2.6.0
public set_default ( boolean $is_default )
$is_default boolean True or false

set_gateway_id() public method

Set the gateway ID.
Since: 2.6.0
public set_gateway_id ( string $gateway_id )
$gateway_id string

set_token() public method

Set the raw payment token.
Since: 2.6.0
public set_token ( string $token )
$token string

set_type() public method

Sets the type of this payment token (CC, eCheck, or something else).
Since: 2.7.0
public set_type ( $type )

set_user_id() public method

Set the user ID for the user associated with this order.
Since: 2.6.0
public set_user_id ( integer $user_id )
$user_id integer

validate() public method

Validate basic token info (token and type are required).
Since: 2.6.0
public validate ( ) : boolean
return boolean True if the passed data is valid

Property Details

$data protected_oe property

Token Data (stored in the payment_tokens table).
protected array $data
return array