Merge branch 'pcp-370-onboarding' of github.com:woocommerce/woocommerce-paypal-payments into pcp-370-onboarding

This commit is contained in:
dinamiko 2022-02-10 09:34:57 +01:00
commit bf303ee38d
5 changed files with 21 additions and 15 deletions

View file

@ -257,6 +257,11 @@ function ppcp_onboarding_productionCallback(...args) {
}
);
const isSandboxInBackend = PayPalCommerceGatewayOnboarding.current_env === 'sandbox';
if (sandboxSwitchElement.checked !== isSandboxInBackend) {
sandboxSwitchElement.checked = isSandboxInBackend;
}
updateOptionsState();
const settingsContainer = document.querySelector('#mainform .form-table');

View file

@ -118,9 +118,8 @@ return array(
);
},
'onboarding.state' => function( ContainerInterface $container ) : State {
$environment = $container->get( 'onboarding.environment' );
$settings = $container->get( 'wcgateway.settings' );
return new State( $environment, $settings );
return new State( $settings );
},
'onboarding.environment' => function( ContainerInterface $container ) : Environment {
$settings = $container->get( 'wcgateway.settings' );
@ -133,6 +132,7 @@ return array(
return new OnboardingAssets(
$container->get( 'onboarding.url' ),
$state,
$container->get( 'onboarding.environment' ),
$login_seller_endpoint
);
},

View file

@ -10,6 +10,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Onboarding\Assets;
use WooCommerce\PayPalCommerce\Onboarding\Endpoint\LoginSellerEndpoint;
use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\Onboarding\State;
/**
@ -31,6 +32,13 @@ class OnboardingAssets {
*/
private $state;
/**
* The Environment.
*
* @var Environment
*/
private $environment;
/**
* The LoginSeller Endpoint.
*
@ -43,16 +51,19 @@ class OnboardingAssets {
*
* @param string $module_url The URL to the module.
* @param State $state The State object.
* @param Environment $environment The Environment.
* @param LoginSellerEndpoint $login_seller_endpoint The LoginSeller endpoint.
*/
public function __construct(
string $module_url,
State $state,
Environment $environment,
LoginSellerEndpoint $login_seller_endpoint
) {
$this->module_url = untrailingslashit( $module_url );
$this->state = $state;
$this->environment = $environment;
$this->login_seller_endpoint = $login_seller_endpoint;
}
@ -109,6 +120,7 @@ class OnboardingAssets {
'sandbox_state' => State::get_state_name( $this->state->sandbox_state() ),
'production_state' => State::get_state_name( $this->state->production_state() ),
'current_state' => State::get_state_name( $this->state->current_state() ),
'current_env' => $this->environment->current_environment(),
'error_messages' => array(
'no_credentials' => __( 'Enter the credentials.', 'woocommerce-paypal-payments' ),
),

View file

@ -19,13 +19,6 @@ class State {
const STATE_START = 0;
const STATE_ONBOARDED = 8;
/**
* The Environment.
*
* @var Environment
*/
private $environment;
/**
* The Settings.
*
@ -36,16 +29,13 @@ class State {
/**
* State constructor.
*
* @param Environment $environment The Environment.
* @param ContainerInterface $settings The Settings.
*/
public function __construct(
Environment $environment,
ContainerInterface $settings
) {
$this->environment = $environment;
$this->settings = $settings;
$this->settings = $settings;
}
/**
@ -133,7 +123,7 @@ class State {
}
/**
* Returns the state based on progressive and onboarded values being looked up in the settings.
* Returns the state based on onboarding settings values.
*
* @param array $onboarded_keys The keys which need to be present to be in onboarded state.
*

View file

@ -12,7 +12,6 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
use WooCommerce\PayPalCommerce\AdminNotices\Entity\Message;
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
use WooCommerce\PayPalCommerce\Button\Helper\MessagesApply;
use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
use Psr\Container\ContainerInterface;