How can I accurately determine when a customer is on the "Review" step in Commerce?
A good place to look for example code related to the checkout form is CheckoutController.php. Its formPage() function ensures the form for the correct checkout page is built by comparing the checkout step requested in the URL to the checkout step the order last advanced to, ensuring the customer isn't trying to directly navigate to a later step than it's entitled to.

You can see that it uses the a route matcher to get the named 'step' parameter from the URL, and you can do the same thing in your own code. Typically you'd inject the route matcher into the checkout pane class, but a quick and dirty solution to fetch the current route matcher from the container is:

$container = \Drupal::getContainer();
$route_matcher = $container-&gt;get('current_route_match');
$step_id = $route_matcher-&gt;getParameter('step');


This will functionally do what you've done by looking at the URL directly, to be honest, but it's a bit more structured way of doing so.