diff --git a/modules/ppcp-button/services.php b/modules/ppcp-button/services.php index 673108e57..ed9930ac9 100644 --- a/modules/ppcp-button/services.php +++ b/modules/ppcp-button/services.php @@ -40,11 +40,8 @@ return array( * @var Environment $env */ - /** - * ToDo: Add production platform client Id. - */ return $env->current_environment_is( Environment::SANDBOX ) ? - 'AQB97CzMsd58-It1vxbcDAGvMuXNCXRD9le_XUaMlHB_U7XsU9IiItBwGQOtZv9sEeD6xs2vlIrL4NiD' : ''; + CONNECT_WOO_SANDBOX_CLIENT_ID : CONNECT_WOO_CLIENT_ID; }, 'button.smart-button' => static function ( $container ): SmartButtonInterface { diff --git a/modules/ppcp-onboarding/assets/js/onboarding.js b/modules/ppcp-onboarding/assets/js/onboarding.js index ca2ecd0b2..3b67c10d6 100644 --- a/modules/ppcp-onboarding/assets/js/onboarding.js +++ b/modules/ppcp-onboarding/assets/js/onboarding.js @@ -155,7 +155,6 @@ const disconnect = (event) => { element.value = ''; } ); - document.querySelector('.woocommerce-save-button').click(); }; diff --git a/modules/ppcp-onboarding/services.php b/modules/ppcp-onboarding/services.php index 1435faa21..ac87010b4 100644 --- a/modules/ppcp-onboarding/services.php +++ b/modules/ppcp-onboarding/services.php @@ -32,7 +32,6 @@ return array( if ( $state->current_state() >= State::STATE_ONBOARDED ) { return PAYPAL_SANDBOX_API_URL; } - // ToDo: Real connect.woocommerce.com sandbox link. return CONNECT_WOO_SANDBOX_URL; }, 'api.production-host' => static function ( $container ): string { @@ -68,6 +67,12 @@ return array( 'api.paypal-host-sandbox' => static function( $container ) : string { return PAYPAL_SANDBOX_API_URL; }, + 'api.partner_merchant_id-production' => static function( $container ) : string { + return CONNECT_WOO_MERCHANT_ID; + }, + 'api.partner_merchant_id-sandbox' => static function( $container ) : string { + return CONNECT_WOO_SANDBOX_MERCHANT_ID; + }, 'api.paypal-host' => function( $container ) : string { $environment = $container->get( 'onboarding.environment' ); /** @@ -140,7 +145,7 @@ return array( $logger = $container->get( 'woocommerce.logger.woocommerce' ); return new LoginSeller( $container->get( 'api.paypal-host-production' ), - $container->get( 'api.partner_merchant_id' ), + $container->get( 'api.partner_merchant_id-production' ), $logger ); }, @@ -150,7 +155,7 @@ return array( $logger = $container->get( 'woocommerce.logger.woocommerce' ); return new LoginSeller( $container->get( 'api.paypal-host-sandbox' ), - $container->get( 'api.partner_merchant_id' ), + $container->get( 'api.partner_merchant_id-sandbox' ), $logger ); }, @@ -185,7 +190,7 @@ return array( 'api.endpoint.partner-referrals-production' => static function ( $container ) : PartnerReferrals { return new PartnerReferrals( - CONNECT_WOO_SANDBOX_URL, + CONNECT_WOO_URL, new ConnectBearer(), $container->get( 'api.repository.partner-referrals-data' ), $container->get( 'woocommerce.logger.woocommerce' ) diff --git a/modules/ppcp-wc-gateway/extensions.php b/modules/ppcp-wc-gateway/extensions.php index 59f179b9a..d8fcae8b9 100644 --- a/modules/ppcp-wc-gateway/extensions.php +++ b/modules/ppcp-wc-gateway/extensions.php @@ -10,6 +10,7 @@ declare(strict_types=1); namespace WooCommerce\PayPalCommerce\WcGateway; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint; +use WooCommerce\PayPalCommerce\Onboarding\Environment; use WooCommerce\PayPalCommerce\Session\SessionHandler; use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; use WooCommerce\WooCommerce\Logging\Logger\NullLogger; @@ -27,9 +28,16 @@ return array( $settings = $container->get( 'wcgateway.settings' ); return $settings->has( 'merchant_id' ) ? (string) $settings->get( 'merchant_id' ) : ''; }, - 'api.partner_merchant_id' => static function (): string { - // @ToDo: Replace with the real merchant id of platform - return 'KQ8FCM66JFGDL'; + 'api.partner_merchant_id' => static function ( $container ): string { + $environment = $container->get( 'onboarding.environment' ); + + /** + * The environment. + * + * @var Environment $environment + */ + return $environment->current_environment_is( Environment::SANDBOX ) ? + (string) $container->get( 'api.partner_merchant_id-sandbox' ) : (string) $container->get( 'api.partner_merchant_id-production' ); }, 'api.key' => static function ( $container ): string { $settings = $container->get( 'wcgateway.settings' ); diff --git a/modules/ppcp-wc-gateway/src/Settings/class-settingslistener.php b/modules/ppcp-wc-gateway/src/Settings/class-settingslistener.php index 1f7500d7d..6f314c3f5 100644 --- a/modules/ppcp-wc-gateway/src/Settings/class-settingslistener.php +++ b/modules/ppcp-wc-gateway/src/Settings/class-settingslistener.php @@ -208,6 +208,7 @@ class SettingsListener { private function maybe_register_webhooks( array $settings ) { if ( ! $this->settings->has( 'client_id' ) && $settings['client_id'] ) { + $this->settings->set( 'products_dcc_enabled', null ); $this->webhook_registrar->register(); } if ( $this->settings->has( 'client_id' ) && $this->settings->get( 'client_id' ) ) { @@ -217,6 +218,7 @@ class SettingsListener { $settings['client_id'] !== $this->settings->get( 'client_id' ) || $settings['client_secret'] !== $current_secret ) { + $this->settings->set( 'products_dcc_enabled', null ); $this->webhook_registrar->unregister(); $this->webhook_registrar->register(); } diff --git a/woocommerce-paypal-payments.php b/woocommerce-paypal-payments.php index 20a75f3d1..5da6710a9 100644 --- a/woocommerce-paypal-payments.php +++ b/woocommerce-paypal-payments.php @@ -1,11 +1,11 @@