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
 /**
  * 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);
 }
 /**
  * Process the delete payment method form.
  */
 public static function delete_payment_method_action()
 {
     global $wp;
     if (isset($wp->query_vars['delete-payment-method'])) {
         $token_id = absint($wp->query_vars['delete-payment-method']);
         $token = WC_Payment_Tokens::get($token_id);
         $delete = true;
         if (is_null($token)) {
             wc_add_notice(__('Invalid payment method.', 'woocommerce'), 'error');
             $delete = false;
         }
         if (get_current_user_id() !== $token->get_user_id()) {
             wc_add_notice(__('Invalid payment method.', 'woocommerce'), 'error');
             $delete = false;
         }
         if (false === wp_verify_nonce($_REQUEST['_wpnonce'], 'delete-payment-method-' . $token_id)) {
             wc_add_notice(__('Invalid payment method.', 'woocommerce'), 'error');
             $delete = false;
         }
         if ($delete) {
             WC_Payment_Tokens::delete($token_id);
             wc_add_notice(__('Payment method deleted.', 'woocommerce'));
         }
         wp_redirect(wc_get_account_endpoint_url('payment-methods'));
         exit;
     }
 }
 /**
  * Deletes a payment method from a users list and displays a message to the user
  *
  * @since  2.6
  * @param  int $id  Payment Token ID
  */
 public static function delete_payment_method($id)
 {
     $token = WC_Payment_Tokens::get($id);
     if (is_null($token)) {
         wc_add_notice(__('Invalid payment method', 'woocommerce'), 'error');
         woocommerce_account_payment_methods();
         return false;
     }
     if (get_current_user_id() !== $token->get_user_id()) {
         wc_add_notice(__('Invalid payment method', 'woocommerce'), 'error');
         woocommerce_account_payment_methods();
         return false;
     }
     if (false === wp_verify_nonce($_REQUEST['_wpnonce'], 'delete-payment-method-' . $id)) {
         wc_add_notice(__('Invalid payment method', 'woocommerce'), 'error');
         woocommerce_account_payment_methods();
         return false;
     }
     WC_Payment_Tokens::delete($id);
     wc_add_notice(__('Payment method deleted.', 'woocommerce'));
     woocommerce_account_payment_methods();
 }