🚚 Extract services from onboarding module

This commit is contained in:
Philipp Stracker 2025-02-03 14:34:25 +01:00
parent abb80f9957
commit 1286d0866e
No known key found for this signature in database
2 changed files with 31 additions and 29 deletions

View file

@ -80,6 +80,8 @@ use WooCommerce\PayPalCommerce\ApiClient\Repository\PayeeRepository;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
use WooCommerce\PayPalCommerce\ApiClient\Authentication\ConnectBearer; use WooCommerce\PayPalCommerce\ApiClient\Authentication\ConnectBearer;
use WooCommerce\PayPalCommerce\WcGateway\Helper\EnvironmentConfig; use WooCommerce\PayPalCommerce\WcGateway\Helper\EnvironmentConfig;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\WcGateway\Helper\Environment;
return array( return array(
'api.host' => function( ContainerInterface $container ) : string { 'api.host' => function( ContainerInterface $container ) : string {
@ -933,4 +935,33 @@ return array(
$container->get( 'api.endpoint.partner-referrals-sandbox' ) $container->get( 'api.endpoint.partner-referrals-sandbox' )
); );
}, },
'api.sandbox-host' => static function ( ContainerInterface $container ): string {
$state = $container->get( 'onboarding.state' );
/**
* The State object.
*
* @var State $state
*/
if ( $state->current_state() >= State::STATE_ONBOARDED ) {
return PAYPAL_SANDBOX_API_URL;
}
return CONNECT_WOO_SANDBOX_URL;
},
'api.production-host' => static function ( ContainerInterface $container ): string {
$state = $container->get( 'onboarding.state' );
/**
* The Environment and State variables.
*
* @var Environment $environment
* @var State $state
*/
if ( $state->current_state() >= State::STATE_ONBOARDED ) {
return PAYPAL_API_URL;
}
return CONNECT_WOO_URL;
},
); );

View file

@ -20,35 +20,6 @@ use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingRenderer;
use WooCommerce\PayPalCommerce\WcGateway\Helper\Environment; use WooCommerce\PayPalCommerce\WcGateway\Helper\Environment;
return array( return array(
'api.sandbox-host' => static function ( ContainerInterface $container ): string {
$state = $container->get( 'onboarding.state' );
/**
* The State object.
*
* @var State $state
*/
if ( $state->current_state() >= State::STATE_ONBOARDED ) {
return PAYPAL_SANDBOX_API_URL;
}
return CONNECT_WOO_SANDBOX_URL;
},
'api.production-host' => static function ( ContainerInterface $container ): string {
$state = $container->get( 'onboarding.state' );
/**
* The Environment and State variables.
*
* @var Environment $environment
* @var State $state
*/
if ( $state->current_state() >= State::STATE_ONBOARDED ) {
return PAYPAL_API_URL;
}
return CONNECT_WOO_URL;
},
'api.host' => static function ( ContainerInterface $container ): string { 'api.host' => static function ( ContainerInterface $container ): string {
$environment = $container->get( 'onboarding.environment' ); $environment = $container->get( 'onboarding.environment' );