How to add inline Javascript code properly with drupal_add_js for a Drupal Commerce checkout pane? I have a custom checkout pane with a basic validation callback. That pane function commerce_checkout_xyz_pane_checkout_form adds some inline Javascript code with drupal_add_js().

The problem, that Javascript only appears on the initial form and is not added when the form is shown again after failed validation. 

I thought about moving the drupal_add_js() to a $form['#after_build'] callback but I don't know if that's the right thing to do and how to do it.
Presumably you're using hook_commerce_checkout_pane_info

Try using $form['#attached'] to add your js to the checkout pane form instead. That may work better there.

$form['#attached']['js'] = array(
  drupal_get_path('module', 'my_module') . '/checkout_pane.js',
);