diff --git a/modules/ppcp-wc-gateway/resources/js/gateway-settings.js b/modules/ppcp-wc-gateway/resources/js/gateway-settings.js index 6548412f8..01ac034c8 100644 --- a/modules/ppcp-wc-gateway/resources/js/gateway-settings.js +++ b/modules/ppcp-wc-gateway/resources/js/gateway-settings.js @@ -114,10 +114,13 @@ import {setVisibleByClass, isVisible} from "../../../ppcp-button/resources/js/mo 'integration-date': PayPalCommerceGatewaySettings.integration_date, 'components': ['buttons', 'funding-eligibility', 'messages'], 'enable-funding': ['venmo', 'paylater'], - 'buyer-country': PayPalCommerceGatewaySettings.country, }; - if(payLaterButtonPreview?.length) { + if (PayPalCommerceGatewaySettings.environment === 'sandbox') { + settings['buyer-country'] = PayPalCommerceGatewaySettings.country; + } + + if (payLaterButtonPreview?.length) { disabledSources = Object.keys(PayPalCommerceGatewaySettings.all_funding_sources); } diff --git a/modules/ppcp-wc-gateway/src/Assets/SettingsPageAssets.php b/modules/ppcp-wc-gateway/src/Assets/SettingsPageAssets.php index e772d9028..aa069a7e7 100644 --- a/modules/ppcp-wc-gateway/src/Assets/SettingsPageAssets.php +++ b/modules/ppcp-wc-gateway/src/Assets/SettingsPageAssets.php @@ -9,6 +9,7 @@ declare(strict_types=1); namespace WooCommerce\PayPalCommerce\WcGateway\Assets; +use WooCommerce\PayPalCommerce\Onboarding\Environment; use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper; /** @@ -58,6 +59,13 @@ class SettingsPageAssets { */ private $country; + /** + * The environment object. + * + * @var Environment + */ + private $environment; + /** * Whether Pay Later button is enabled either for checkout, cart or product page. * @@ -88,6 +96,7 @@ class SettingsPageAssets { * @param string $client_id The PayPal SDK client ID. * @param string $currency 3-letter currency code of the shop. * @param string $country 2-letter country code of the shop. + * @param Environment $environment The environment object. * @param bool $is_pay_later_button_enabled Whether Pay Later button is enabled either for checkout, cart or product page. * @param array $disabled_sources The list of disabled funding sources. * @param array $all_funding_sources The list of all existing funding sources. @@ -99,6 +108,7 @@ class SettingsPageAssets { string $client_id, string $currency, string $country, + Environment $environment, bool $is_pay_later_button_enabled, array $disabled_sources, array $all_funding_sources @@ -109,6 +119,7 @@ class SettingsPageAssets { $this->client_id = $client_id; $this->currency = $currency; $this->country = $country; + $this->environment = $environment; $this->is_pay_later_button_enabled = $is_pay_later_button_enabled; $this->disabled_sources = $disabled_sources; $this->all_funding_sources = $all_funding_sources; @@ -191,6 +202,7 @@ class SettingsPageAssets { 'client_id' => $this->client_id, 'currency' => $this->currency, 'country' => $this->country, + 'environment' => $this->environment->current_environment(), 'integration_date' => PAYPAL_INTEGRATION_DATE, 'is_pay_later_button_enabled' => $this->is_pay_later_button_enabled, 'disabled_sources' => $this->disabled_sources, diff --git a/modules/ppcp-wc-gateway/src/WCGatewayModule.php b/modules/ppcp-wc-gateway/src/WCGatewayModule.php index b5d2939d0..436664078 100644 --- a/modules/ppcp-wc-gateway/src/WCGatewayModule.php +++ b/modules/ppcp-wc-gateway/src/WCGatewayModule.php @@ -174,6 +174,7 @@ class WCGatewayModule implements ModuleInterface { $c->get( 'button.client_id_for_admin' ), $c->get( 'api.shop.currency' ), $c->get( 'api.shop.country' ), + $c->get( 'onboarding.environment' ), $settings_status->is_pay_later_button_enabled(), $settings->has( 'disable_funding' ) ? $settings->get( 'disable_funding' ) : array(), $c->get( 'wcgateway.all-funding-sources' ) diff --git a/tests/PHPUnit/WcGateway/Assets/SettingsPagesAssetsTest.php b/tests/PHPUnit/WcGateway/Assets/SettingsPagesAssetsTest.php index 259a25ebb..6bd2ca14f 100644 --- a/tests/PHPUnit/WcGateway/Assets/SettingsPagesAssetsTest.php +++ b/tests/PHPUnit/WcGateway/Assets/SettingsPagesAssetsTest.php @@ -3,6 +3,7 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Assets; use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer; +use WooCommerce\PayPalCommerce\Onboarding\Environment; use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper; use WooCommerce\PayPalCommerce\TestCase; use function Brain\Monkey\Functions\when; @@ -23,6 +24,7 @@ class SettingsPagesAssetsTest extends TestCase '123', 'EUR', 'DE', + Mockery::mock(Environment::class), true, array(), array()