WC_Payment_Tokens
in package
Payment tokens class.
Table of Contents
- delete() : mixed
- Remove a payment token from the database by ID.
- get() : null|WC_Payment_Token
- Get a token object by ID.
- get_customer_default_token() : WC_Payment_Token|null
- Returns a customers default token or NULL if there is no default token.
- get_customer_tokens() : array<string|int, WC_Payment_Token>
- Returns an array of payment token objects associated with the passed customer ID.
- get_order_tokens() : array<string|int, WC_Payment_Token>
- Returns an array of payment token objects associated with the passed order ID.
- get_token_type_by_id() : string
- Returns what type (credit card, echeck, etc) of token a token is by ID.
- get_tokens() : array<string|int, WC_Payment_Token>
- Gets valid tokens from the database based on user defined criteria.
- set_users_default() : mixed
- Loops through all of a users payment tokens and sets is_default to false for all but a specific token.
- get_token_classname() : string
- Get classname based on token type.
Methods
delete()
Remove a payment token from the database by ID.
public
static delete(int $token_id) : mixed
Parameters
- $token_id : int
-
Token ID.
Tags
Return values
mixed —get()
Get a token object by ID.
public
static get(int $token_id[, object $token_result = null ]) : null|WC_Payment_Token
Parameters
- $token_id : int
-
Token ID.
- $token_result : object = null
-
Token result.
Tags
Return values
null|WC_Payment_Token — Returns a valid payment token or null if no token can be found.get_customer_default_token()
Returns a customers default token or NULL if there is no default token.
public
static get_customer_default_token(int $customer_id) : WC_Payment_Token|null
Parameters
- $customer_id : int
-
Customer ID.
Tags
Return values
WC_Payment_Token|null —get_customer_tokens()
Returns an array of payment token objects associated with the passed customer ID.
public
static get_customer_tokens(int $customer_id[, string $gateway_id = '' ]) : array<string|int, WC_Payment_Token>
Parameters
- $customer_id : int
-
Customer ID.
- $gateway_id : string = ''
-
Optional Gateway ID for getting tokens for a specific gateway.
Tags
Return values
array<string|int, WC_Payment_Token> — Array of token objects.get_order_tokens()
Returns an array of payment token objects associated with the passed order ID.
public
static get_order_tokens(int $order_id) : array<string|int, WC_Payment_Token>
Parameters
- $order_id : int
-
Order ID.
Tags
Return values
array<string|int, WC_Payment_Token> — Array of token objects.get_token_type_by_id()
Returns what type (credit card, echeck, etc) of token a token is by ID.
public
static get_token_type_by_id(int $token_id) : string
Parameters
- $token_id : int
-
Token ID.
Tags
Return values
string — Type.get_tokens()
Gets valid tokens from the database based on user defined criteria.
public
static get_tokens(array<string|int, mixed> $args) : array<string|int, WC_Payment_Token>
Parameters
- $args : array<string|int, mixed>
-
Query arguments { Array of query parameters.
@type string $token_id Token ID. @type string $user_id User ID. @type string $gateway_id Gateway ID. @type string $type Token type.
}
Tags
Return values
array<string|int, WC_Payment_Token> —set_users_default()
Loops through all of a users payment tokens and sets is_default to false for all but a specific token.
public
static set_users_default(int $user_id, int $token_id) : mixed
Parameters
- $user_id : int
-
User to set a default for.
- $token_id : int
-
The ID of the token that should be default.
Tags
Return values
mixed —get_token_classname()
Get classname based on token type.
protected
static get_token_classname(string $type) : string
Parameters
- $type : string
-
Token type.