diff --git a/modules/ppcp-api-client/services.php b/modules/ppcp-api-client/services.php index 50434c467..707d2e24d 100644 --- a/modules/ppcp-api-client/services.php +++ b/modules/ppcp-api-client/services.php @@ -39,6 +39,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Factory\ShippingFactory; use WooCommerce\PayPalCommerce\ApiClient\Factory\WebhookEventFactory; use WooCommerce\PayPalCommerce\ApiClient\Factory\WebhookFactory; use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache; +use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencySupport; use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies; use WooCommerce\PayPalCommerce\ApiClient\Repository\ApplicationContextRepository; use WooCommerce\PayPalCommerce\ApiClient\Repository\CartRepository; @@ -301,4 +302,7 @@ return array( 'api.helpers.dccapplies' => static function ( ContainerInterface $container ) : DccApplies { return new DccApplies(); }, + 'api.helpers.currency-support' => static function ( ContainerInterface $container ) : CurrencySupport { + return new CurrencySupport(); + }, ); diff --git a/modules/ppcp-api-client/src/Helper/CurrencySupport.php b/modules/ppcp-api-client/src/Helper/CurrencySupport.php new file mode 100644 index 000000000..925ee4386 --- /dev/null +++ b/modules/ppcp-api-client/src/Helper/CurrencySupport.php @@ -0,0 +1,70 @@ +supported_currencies, true ); + } + + /** + * Returns whether the current WC currency is supported. + * + * @return bool + */ + public function supports_wc_currency(): bool { + return $this->supports_currency( get_woocommerce_currency() ); + } +} diff --git a/modules/ppcp-status-report/src/StatusReportModule.php b/modules/ppcp-status-report/src/StatusReportModule.php index 96cb51f5d..e00c842b2 100644 --- a/modules/ppcp-status-report/src/StatusReportModule.php +++ b/modules/ppcp-status-report/src/StatusReportModule.php @@ -16,6 +16,7 @@ use Psr\Container\ContainerInterface; use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer; use WooCommerce\PayPalCommerce\ApiClient\Authentication\PayPalBearer; use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; +use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencySupport; use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies; use WooCommerce\PayPalCommerce\Button\Helper\MessagesApply; use WooCommerce\PayPalCommerce\Onboarding\State; @@ -53,6 +54,9 @@ class StatusReportModule implements ModuleInterface { /* @var Bearer $bearer The bearer. */ $bearer = $c->get( 'api.bearer' ); + $currency_support = $c->get( 'api.helpers.currency-support' ); + assert( $currency_support instanceof CurrencySupport ); + /* @var DccApplies $dcc_applies The ddc applies. */ $dcc_applies = $c->get( 'api.helpers.dccapplies' ); @@ -75,6 +79,13 @@ class StatusReportModule implements ModuleInterface { 'description' => esc_html__( 'Country / State value on Settings / General / Store Address.', 'woocommerce-paypal-payments' ), 'value' => wc_get_base_location()['country'], ), + array( + 'label' => esc_html__( 'WooCommerce currency supported', 'woocommerce-paypal-payments' ), + 'description' => esc_html__( 'Whether PayPal supports the default store currency or not.', 'woocommerce-paypal-payments' ), + 'value' => $this->bool_to_text( + $currency_support->supports_wc_currency() + ), + ), array( 'label' => esc_html__( 'PayPal card processing available in country', 'woocommerce-paypal-payments' ), 'description' => esc_html__( 'Whether PayPal card processing is available in country or not.', 'woocommerce-paypal-payments' ),