Solution:
This sample code may work:
if ( is_checkout() && !empty( is_wc_endpoint_url('order-received') ) ) { ... }