WC_Form_Handler::delete_payment_method_action()
Process the delete payment method form.
Description Description
Source Source
File: includes/class-wc-form-handler.php
public static function delete_payment_method_action() {
global $wp;
if ( isset( $wp->query_vars['delete-payment-method'] ) ) {
wc_nocache_headers();
$token_id = absint( $wp->query_vars['delete-payment-method'] );
$token = WC_Payment_Tokens::get( $token_id );
if ( is_null( $token ) || get_current_user_id() !== $token->get_user_id() || ! isset( $_REQUEST['_wpnonce'] ) || false === wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), 'delete-payment-method-' . $token_id ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
wc_add_notice( __( 'Invalid payment method.', 'woocommerce' ), 'error' );
} else {
WC_Payment_Tokens::delete( $token_id );
wc_add_notice( __( 'Payment method deleted.', 'woocommerce' ) );
}
wp_safe_redirect( wc_get_account_endpoint_url( 'payment-methods' ) );
exit();
}
}