WC_Payment_Tokens::delete PHP Method

delete() public static method

Remove a payment token from the database by ID.
Since: 2.6.0
public static delete ( WC_Payment_Token $token_id )
$token_id WC_Payment_Token Token ID
    public static function delete($token_id)
    {
        $type = self::get_token_type_by_id($token_id);
        if (!empty($type)) {
            $class = 'WC_Payment_Token_' . $type;
            $token = new $class($token_id);
            $token->delete();
        }
    }

Usage Example

Esempio n. 1
0
 /**
  * Test deleting a token by ID.
  * @since 2.6.0
  */
 function test_wc_payment_tokens_delete()
 {
     $token = WC_Helper_Payment_Token::create_cc_token();
     $token_id = $token->get_id();
     WC_Payment_Tokens::delete($token_id);
     $get_token = WC_Payment_Tokens::get($token_id);
     $this->assertNull($get_token);
 }
All Usage Examples Of WC_Payment_Tokens::delete