From 1c25075ea45fee4efc946aeb2ed6f1f76cf2370e Mon Sep 17 00:00:00 2001 From: Philipp Stracker Date: Fri, 14 Feb 2025 12:52:35 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Draft=20a=20paylater=20messaging=20?= =?UTF-8?q?data=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/ppcp-settings/services.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/ppcp-settings/services.php b/modules/ppcp-settings/services.php index da64c0968..56ca01917 100644 --- a/modules/ppcp-settings/services.php +++ b/modules/ppcp-settings/services.php @@ -40,6 +40,9 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; use WooCommerce\PayPalCommerce\Settings\Service\DataSanitizer; use WooCommerce\PayPalCommerce\Settings\Service\SettingsDataManager; use WooCommerce\PayPalCommerce\Settings\Data\Definition\PaymentMethodsDefinition; +use WooCommerce\PayPalCommerce\PayLaterConfigurator\Factory\ConfigFactory; +use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; +use WooCommerce\PayPalCommerce\PayLaterConfigurator\Endpoint\SaveConfig; return array( 'settings.url' => static function ( ContainerInterface $container ) : string { @@ -93,6 +96,25 @@ return array( $container->get( 'settings.service.sanitizer' ) ); }, + 'settings.data.paylater-messaging' => static function ( ContainerInterface $container ) : array { + // TODO: Create an AbstractDataModel wrapper for this configuration! + + $config_factors = $container->get( 'paylater-configurator.factory.config' ); + assert( $config_factors instanceof ConfigFactory ); + + $save_config = $container->get( 'paylater-configurator.endpoint.save-config' ); + assert( $save_config instanceof SaveConfig ); + + $settings = $container->get( 'wcgateway.settings' ); + assert( $settings instanceof Settings ); + + $pay_later_config = $config_factors->from_settings( $settings ); + + return array( + 'read' => $pay_later_config, + 'save' => $save_config, + ); + }, /** * Checks if valid merchant connection details are stored in the DB. */