The CheckoutConfigProvider class provides the configuration required by the React checkout application. It currently focuses on payment configuration and essential store metadata.
Developers can intercept and modify the configuration data before it is serialized and sent to the frontend by listening to the hyva_react_checkout_config event. This is the primary extension point for adding custom configuration keys to the React app.
When the event is dispatched, it carries a transport object (an instance of ext{Magento extbackslash Framework extbackslash DataObject}) containing:
checkoutConfig: The full Magento checkout configuration.output: The specific subset of data that will be serialized and sent to the frontend. This includes:storeCode: The current store code.payment: The payment configuration (including a calculated restUrlPrefix in the format /rest/{storeCode}/V1/).language: The current locale string.currency: The currency configuration provided by CurrencyProvider.defaultCountryId: The default country ID from the checkout configuration.
<?php
// Example observer implementation
public function execute(\Magento\Framework\Event\Observer `$observer`)
{
$transport = $observer->get('transport');
$output = $transport->getData('output');
// Add custom data to the output array
$output['my_custom_key'] = 'my_value';
// Update the transport with the modified output
$transport->setData('output', $output);
}