mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
make environment listen to the correct sandbox option key
This commit is contained in:
parent
e6638aa6a4
commit
aa2e7e7427
2 changed files with 13 additions and 2 deletions
|
@ -87,7 +87,8 @@ return [
|
|||
return new State($environment, $settings);
|
||||
},
|
||||
'onboarding.environment' => function(ContainerInterface $container) : Environment {
|
||||
return new Environment();
|
||||
$settings = $container->get('wcgateway.settings');
|
||||
return new Environment($settings);
|
||||
},
|
||||
|
||||
'onboarding.assets' => function(ContainerInterface $container) : OnboardingAssets {
|
||||
|
|
|
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||
namespace Inpsyde\PayPalCommerce\Onboarding;
|
||||
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class Environment
|
||||
{
|
||||
|
||||
|
@ -16,9 +18,17 @@ class Environment
|
|||
|
||||
public const OPTION_KEY = 'ppcp-env';
|
||||
|
||||
private $settings;
|
||||
public function __construct(ContainerInterface $settings)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
public function currentEnvironment() : string
|
||||
{
|
||||
return (string) get_option(self::OPTION_KEY, self::PRODUCTION);
|
||||
return (
|
||||
$this->settings->has('sandbox_on') && wc_string_to_bool($this->settings->get('sandbox_on'))
|
||||
) ? self::SANDBOX : self::PRODUCTION;
|
||||
}
|
||||
|
||||
public function currentEnvironmentIs(string $environment) : bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue