From 32c34e7b89d38899829c7b1998c107143c49c73b Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Mon, 17 Feb 2025 17:52:11 +0100 Subject: [PATCH] Get country code from seller status --- modules/ppcp-api-client/src/Entity/SellerStatus.php | 6 +++++- modules/ppcp-settings/src/SettingsModule.php | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/ppcp-api-client/src/Entity/SellerStatus.php b/modules/ppcp-api-client/src/Entity/SellerStatus.php index 0fb18aa0a..23f05016d 100644 --- a/modules/ppcp-api-client/src/Entity/SellerStatus.php +++ b/modules/ppcp-api-client/src/Entity/SellerStatus.php @@ -81,8 +81,12 @@ class SellerStatus { return $this->capabilities; } + public function country() : string { + return $this->country; + } + /** - * Returns the enitity as array. + * Returns the entity as array. * * @return array */ diff --git a/modules/ppcp-settings/src/SettingsModule.php b/modules/ppcp-settings/src/SettingsModule.php index 1e6c1f818..785d28a41 100644 --- a/modules/ppcp-settings/src/SettingsModule.php +++ b/modules/ppcp-settings/src/SettingsModule.php @@ -10,6 +10,7 @@ declare( strict_types = 1 ); namespace WooCommerce\PayPalCommerce\Settings; use WC_Payment_Gateway; +use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PartnersEndpoint; use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies; use WooCommerce\PayPalCommerce\Applepay\Assets\AppleProductStatus; use WooCommerce\PayPalCommerce\Googlepay\Helper\ApmProductStatus; @@ -302,8 +303,12 @@ class SettingsModule implements ServiceModule, ExecutableModule { $flags = new ConfigurationFlagsDTO(); - // TODO: Get the merchant country from PayPal here! - $flags->country_code = 'US'; + $partners_endpoint = $container->get( 'api.endpoint.partners' ); + assert( $partners_endpoint instanceof PartnersEndpoint ); + + $seller_status = $partners_endpoint->seller_status(); + + $flags->country_code = $seller_status->country() ?: 'US'; $flags->is_business_seller = $general_settings->is_business_seller(); $flags->use_card_payments = $onboarding_profile->get_accept_card_payments(); $flags->use_subscriptions = in_array( ProductChoicesEnum::SUBSCRIPTIONS, $onboarding_profile->get_products(), true );