Try following function:
function is_wc_endpoint() {
if ( empty( $_SERVER['REQUEST_URI'] ) ) return false;
$url = parse_url( $_SERVER['REQUEST_URI'] );
if ( empty( $url['query'] ) ) return false;
global $wpdb;
$all_woocommerce_endpoints = array();
$results = $wpdb->get_results( "SELECT option_name, option_value FROM {$wpdb->prefix}options WHERE option_name LIKE 'woocommerce_%_endpoint'", 'ARRAY_A' );
foreach ( $results as $result ) {
$all_woocommerce_endpoints[$result['option_name']] = $result['option_value'];
}
foreach ( $all_woocommerce_endpoints as $woocommerce_endpoint ) {
if ( strpos( $url['query'], $woocommerce_endpoint ) !== false ) {
return true;
}
}
return false;
}
Hope it'll give you result you are expecting.