mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Fix sandbox checkbox
Sometimes the state of UI may get restored after page reload and will not match the server settings
This commit is contained in:
parent
cb2adfd044
commit
44cb17107c
3 changed files with 18 additions and 0 deletions
|
@ -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');
|
||||
|
|
|
@ -132,6 +132,7 @@ return array(
|
|||
return new OnboardingAssets(
|
||||
$container->get( 'onboarding.url' ),
|
||||
$state,
|
||||
$container->get( 'onboarding.environment' ),
|
||||
$login_seller_endpoint
|
||||
);
|
||||
},
|
||||
|
|
|
@ -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' ),
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue