8 – How do I get a single payment processor id with a hook?

I am trying to use hook_form_alter() on Drupal 8/9 to change the details of the CiviCRM Payment Processor for specific users (to change from live mode to test mode).

If the payment processor is set by ‘User Select’, then the payment processor element and its details are in $form('elements')('contribution_pagebreak'), but if a specific payment processor is set on the CiviCRM configuration screen then there is no payment processor there.

Are the details somewhere else, or do I have to use a different mechanism?