PHP側で
function MODULE_page_attachments(&$attachments) { if ($payment_gateway_storage = \Drupal::service('entity_type.manager')->getStorage('commerce_payment_gateway')) { if ($payment_gateways = $payment_gateway_storage->loadMultiple()) { foreach ($payment_gateways as $name => $payment_gateway) { if (strpos($name, 'MODULE') !== FALSE) { if ($configuration = $payment_gateway->get('configuration')) { $attachments['#attached']['drupalSettings']['MODULE']['configuration'] = $configuration; } } } } } }
JavaScript側で
var configuration = drupalSettings.MODULE.configuration;