From 40edcdfc3d57db84a72dcb62420746456d91dbac Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Wed, 29 Jan 2025 16:51:12 +0100 Subject: [PATCH] Add get response details --- modules/ppcp-settings/services.php | 4 ++- .../Endpoint/PayLaterMessagingEndpoint.php | 27 +++++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/modules/ppcp-settings/services.php b/modules/ppcp-settings/services.php index 97f561a9e..0016a0096 100644 --- a/modules/ppcp-settings/services.php +++ b/modules/ppcp-settings/services.php @@ -127,7 +127,9 @@ return array( ); }, 'settings.rest.pay_later_messaging' => static function ( ContainerInterface $container ) : PayLaterMessagingEndpoint { - return new PayLaterMessagingEndpoint(); + return new PayLaterMessagingEndpoint( + $container->get( 'wcgateway.settings' ) + ); }, 'settings.rest.settings' => static function ( ContainerInterface $container ) : SettingsRestEndpoint { return new SettingsRestEndpoint( diff --git a/modules/ppcp-settings/src/Endpoint/PayLaterMessagingEndpoint.php b/modules/ppcp-settings/src/Endpoint/PayLaterMessagingEndpoint.php index 5e5643261..5dfbe7613 100644 --- a/modules/ppcp-settings/src/Endpoint/PayLaterMessagingEndpoint.php +++ b/modules/ppcp-settings/src/Endpoint/PayLaterMessagingEndpoint.php @@ -9,6 +9,8 @@ declare( strict_types = 1 ); namespace WooCommerce\PayPalCommerce\Settings\Endpoint; +use WooCommerce\PayPalCommerce\PayLaterConfigurator\Factory\ConfigFactory; +use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; use WP_REST_Request; use WP_REST_Response; use WP_REST_Server; @@ -27,6 +29,22 @@ class PayLaterMessagingEndpoint extends RestEndpoint { */ protected $rest_base = 'pay_later_messaging'; + /** + * The settings. + * + * @var Settings + */ + protected $settings; + + /** + * PayLaterMessagingEndpoint constructor. + * + * @param Settings $settings The settings. + */ + public function __construct( Settings $settings ) { + $this->settings = $settings; + } + /** * Configure REST API routes. */ @@ -46,13 +64,6 @@ class PayLaterMessagingEndpoint extends RestEndpoint { /** * POST wc/v3/wc_paypal/pay_later_messaging - * { - * [gateway_id]: { - * enabled - * title - * description - * } - * } */ register_rest_route( $this->namespace, @@ -71,7 +82,7 @@ class PayLaterMessagingEndpoint extends RestEndpoint { * @return WP_REST_Response The current payment methods details. */ public function get_details() : WP_REST_Response { - return $this->return_success( array() ); + return $this->return_success( ( new ConfigFactory() )->from_settings( $this->settings ) ); } /**