Commit 43fea9bace for woocommerce
commit 43fea9bace8c2d38755508fadac6ab5b615ab1bc
Author: Mayisha <33387139+Mayisha@users.noreply.github.com>
Date: Fri Dec 5 22:12:24 2025 +0600
PayPal Standard: Show unsupported currency notice (#62171)
* show currency unsupported notice
* add tests
* add aria-label
* Add changefile(s) from automation for the following project(s): woocommerce
* fix lint
* add comment with lint fixes
* update docblock
* fix lint
* add @since tag
diff --git a/plugins/woocommerce/changelog/62171-task-paypal-standard-unsupported-currency-notice b/plugins/woocommerce/changelog/62171-task-paypal-standard-unsupported-currency-notice
new file mode 100644
index 0000000000..92d281ed42
--- /dev/null
+++ b/plugins/woocommerce/changelog/62171-task-paypal-standard-unsupported-currency-notice
@@ -0,0 +1,4 @@
+Significance: minor
+Type: add
+
+Display an admin notice when the store's currency is not supported by PayPal Standard.
\ No newline at end of file
diff --git a/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php b/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php
index 662571cf85..231d9d9ef3 100644
--- a/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php
+++ b/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php
@@ -563,7 +563,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
public function admin_options() {
if ( $this->is_valid_for_use() ) {
parent::admin_options();
- } else {
+ } elseif ( ! $this->should_use_orders_v2() ) {
?>
<div class="inline error">
<p>
diff --git a/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-notices.php b/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-notices.php
index 757a1e34fa..dbc49c290e 100644
--- a/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-notices.php
+++ b/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-notices.php
@@ -15,11 +15,14 @@ require_once __DIR__ . '/class-wc-gateway-paypal-helper.php';
/**
* Class WC_Gateway_Paypal_Notices.
+ *
+ * @since 10.3.0
*/
class WC_Gateway_Paypal_Notices {
/**
* The name of the notice for PayPal migration.
*
+ * @since 10.4.0
* @var string
*/
private const PAYPAL_MIGRATION_NOTICE = 'paypal_migration_completed';
@@ -27,13 +30,23 @@ class WC_Gateway_Paypal_Notices {
/**
* The name of the notice for PayPal account restriction.
*
+ * @since 10.4.0
* @var string
*/
private const PAYPAL_ACCOUNT_RESTRICTED_NOTICE = 'paypal_account_restricted';
+ /**
+ * The name of the notice for PayPal unsupported currency.
+ *
+ * @since 10.4.0
+ * @var string
+ */
+ private const PAYPAL_UNSUPPORTED_CURRENCY_NOTICE = 'paypal_unsupported_currency';
+
/**
* PayPal account restriction issue codes from PayPal API.
*
+ * @since 10.4.0
* @var array
*/
protected const PAYPAL_ACCOUNT_RESTRICTION_ISSUES = array(
@@ -72,6 +85,7 @@ class WC_Gateway_Paypal_Notices {
/**
* Add PayPal Standard notices.
*
+ * @since 10.4.0
* @return void
*/
public function add_paypal_notices() {
@@ -87,11 +101,13 @@ class WC_Gateway_Paypal_Notices {
$this->add_paypal_migration_notice();
$this->add_paypal_account_restricted_notice();
+ $this->add_paypal_unsupported_currency_notice();
}
/**
* Add PayPal notices on the payments settings page.
*
+ * @since 10.4.0
* @return void
*/
public function add_paypal_notices_on_payments_settings_page() {
@@ -124,6 +140,7 @@ class WC_Gateway_Paypal_Notices {
/**
* Add notice warning about the migration to PayPal Payments.
*
+ * @since 10.3.0
* @return void
*/
public function add_paypal_migration_notice() {
@@ -152,6 +169,7 @@ class WC_Gateway_Paypal_Notices {
/**
* Add notice warning about PayPal account restriction.
*
+ * @since 10.4.0
* @return void
*/
private function add_paypal_account_restricted_notice() {
@@ -183,9 +201,44 @@ class WC_Gateway_Paypal_Notices {
echo wp_kses_post( $notice_html );
}
+ /**
+ * Add notice warning when PayPal does not support the store's currency.
+ *
+ * @since 10.4.0
+ * @return void
+ */
+ private function add_paypal_unsupported_currency_notice() {
+ $currency = get_woocommerce_currency();
+
+ // Skip if the currency is supported by PayPal.
+ if ( $this->gateway->is_valid_for_use() ) {
+ return;
+ }
+
+ // Skip if the notice has been dismissed.
+ if ( $this->is_notice_dismissed( self::PAYPAL_UNSUPPORTED_CURRENCY_NOTICE ) ) {
+ return;
+ }
+
+ $dismiss_url = $this->get_dismiss_url( self::PAYPAL_UNSUPPORTED_CURRENCY_NOTICE );
+ $message = sprintf(
+ /* translators: %s: Currency code */
+ esc_html__( 'PayPal Standard does not support your store currency (%s).', 'woocommerce' ),
+ $currency
+ );
+
+ $notice_html = '<div class="notice notice-error is-dismissible">'
+ . '<a class="woocommerce-message-close notice-dismiss" style="text-decoration: none;" href="' . esc_url( $dismiss_url ) . '" aria-label="' . esc_attr__( 'Dismiss this notice', 'woocommerce' ) . '"></a>'
+ . '<p>' . $message . '</p>'
+ . '</div>';
+
+ echo wp_kses_post( $notice_html );
+ }
+
/**
* Get the dismiss URL for a notice.
*
+ * @since 10.4.0
* @param string $notice_name The name of the notice.
* @return string
*/
@@ -200,6 +253,14 @@ class WC_Gateway_Paypal_Notices {
/**
* Check if the notice has been dismissed.
*
+ * User meta keys for notice dismissals:
+ * - dismissed_paypal_migration_completed_notice
+ * - dismissed_paypal_account_restricted_notice
+ * - dismissed_paypal_unsupported_currency_notice
+ *
+ * The meta keys are set by WC_Admin_Notices when the notice is dismissed by the user.
+ *
+ * @since 10.4.0
* @param string $notice_name The name of the notice.
* @return bool
*/
@@ -221,6 +282,7 @@ class WC_Gateway_Paypal_Notices {
/**
* Check if there's a flag indicating PayPal account restriction.
*
+ * @since 10.4.0
* @return bool
*/
private function has_account_restriction_flag(): bool {
@@ -230,6 +292,7 @@ class WC_Gateway_Paypal_Notices {
/**
* Set the flag indicating PayPal account restriction.
*
+ * @since 10.4.0
* @return void
*/
public static function set_account_restriction_flag(): void {
@@ -241,6 +304,7 @@ class WC_Gateway_Paypal_Notices {
/**
* Clear the flag indicating PayPal account restriction.
*
+ * @since 10.4.0
* @return void
*/
public static function clear_account_restriction_flag(): void {
@@ -252,6 +316,7 @@ class WC_Gateway_Paypal_Notices {
/**
* Handle PayPal order response to manage account restriction notices.
*
+ * @since 10.4.0
* @param int|string $http_code The HTTP status code from the PayPal API response.
* @param array $response_data The decoded response data from the PayPal API.
* @param WC_Order $order The WooCommerce order object.
diff --git a/plugins/woocommerce/tests/php/includes/gateways/paypal/class-wc-gateway-paypal-notices-test.php b/plugins/woocommerce/tests/php/includes/gateways/paypal/class-wc-gateway-paypal-notices-test.php
new file mode 100644
index 0000000000..3bac86538b
--- /dev/null
+++ b/plugins/woocommerce/tests/php/includes/gateways/paypal/class-wc-gateway-paypal-notices-test.php
@@ -0,0 +1,559 @@
+<?php
+/**
+ * Unit tests for WC_Gateway_Paypal_Notices class.
+ *
+ * @package WooCommerce\Tests\Paypal.
+ */
+
+declare(strict_types=1);
+
+require_once WC_ABSPATH . 'includes/gateways/paypal/includes/class-wc-gateway-paypal-notices.php';
+
+/**
+ * Class WC_Gateway_Paypal_Notices_Test.
+ */
+class WC_Gateway_Paypal_Notices_Test extends \WC_Unit_Test_Case {
+
+ /**
+ * The PayPal gateway instance.
+ *
+ * @var WC_Gateway_Paypal
+ */
+ private $gateway;
+
+ /**
+ * Admin user ID.
+ *
+ * @var int
+ */
+ private $admin_user_id;
+
+ /**
+ * Shop manager user ID.
+ *
+ * @var int
+ */
+ private $shop_manager_user_id;
+
+ /**
+ * Customer user ID.
+ *
+ * @var int
+ */
+ private $customer_user_id;
+
+ /**
+ * Set up test fixtures.
+ */
+ public function setUp(): void {
+ parent::setUp();
+
+ // Create test users.
+ $this->admin_user_id = $this->factory->user->create(
+ array(
+ 'role' => 'administrator',
+ )
+ );
+ $this->shop_manager_user_id = $this->factory->user->create(
+ array(
+ 'role' => 'shop_manager',
+ )
+ );
+ $this->customer_user_id = $this->factory->user->create(
+ array(
+ 'role' => 'customer',
+ )
+ );
+
+ $this->gateway = $this->create_mock_gateway();
+ $this->mock_gateway_available();
+
+ wp_set_current_user( $this->admin_user_id );
+ set_current_screen( 'admin.php' );
+ }
+
+ /**
+ * Tear down test fixtures.
+ */
+ public function tearDown(): void {
+ // Clean up users.
+ if ( $this->admin_user_id ) {
+ wp_delete_user( $this->admin_user_id );
+ }
+ if ( $this->shop_manager_user_id ) {
+ wp_delete_user( $this->shop_manager_user_id );
+ }
+ if ( $this->customer_user_id ) {
+ wp_delete_user( $this->customer_user_id );
+ }
+
+ // Clear user meta for all notice dismissals.
+ delete_user_meta( get_current_user_id(), 'dismissed_paypal_migration_completed_notice' );
+ delete_user_meta( get_current_user_id(), 'dismissed_paypal_account_restricted_notice' );
+ delete_user_meta( get_current_user_id(), 'dismissed_paypal_unsupported_currency_notice' );
+
+ // Reset options.
+ delete_option( 'woocommerce_paypal_settings' );
+ delete_option( 'woocommerce_paypal_account_restricted_status' );
+
+ // Reset the gateway singleton to null.
+ WC_Gateway_Paypal::set_instance( null );
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test that hooks are added during construction.
+ */
+ public function test_constructor_adds_hooks() {
+ // Remove existing hooks.
+ remove_all_actions( 'admin_notices' );
+ remove_all_actions( 'admin_head' );
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ $this->assertNotFalse( has_action( 'admin_notices', array( $notices, 'add_paypal_notices' ) ) );
+ $this->assertNotFalse( has_action( 'admin_head', array( $notices, 'add_paypal_notices_on_payments_settings_page' ) ) );
+ }
+
+ /**
+ * Data provider for user capability tests.
+ *
+ * @return array
+ */
+ public function user_capability_data_provider() {
+ return array(
+ 'admin can see notices' => array(
+ 'user_role' => 'administrator',
+ 'should_display' => true,
+ ),
+ 'shop_manager can see notices' => array(
+ 'user_role' => 'shop_manager',
+ 'should_display' => true,
+ ),
+ 'customer cannot see notices' => array(
+ 'user_role' => 'customer',
+ 'should_display' => false,
+ ),
+ );
+ }
+
+ /**
+ * Test that notices respect user capabilities.
+ *
+ * @dataProvider user_capability_data_provider
+ * @param string $user_role The role of the user.
+ * @param bool $should_display Whether the notice should display.
+ */
+ public function test_notices_respect_user_capabilities( string $user_role, bool $should_display ) {
+ $user_id_map = array(
+ 'administrator' => $this->admin_user_id,
+ 'shop_manager' => $this->shop_manager_user_id,
+ 'customer' => $this->customer_user_id,
+ );
+ wp_set_current_user( $user_id_map[ $user_role ] );
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices();
+ $output = ob_get_clean();
+
+ if ( $should_display ) {
+ $this->assertStringContainsString( 'WooCommerce has upgraded your PayPal integration from PayPal Standard to PayPal Payments (PPCP), for a more reliable and modern checkout experience.', $output );
+ } else {
+ $this->assertEmpty( $output );
+ }
+ }
+
+ /**
+ * Test that migration notice is displayed when not dismissed.
+ */
+ public function test_migration_notice_displayed_when_not_dismissed() {
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices();
+ $output = ob_get_clean();
+
+ $this->assertStringContainsString( 'WooCommerce has upgraded your PayPal integration from PayPal Standard to PayPal Payments (PPCP), for a more reliable and modern checkout experience.', $output );
+ $this->assertStringContainsString( 'notice notice-warning', $output );
+ $this->assertStringContainsString( 'wc-hide-notice=paypal_migration_completed', $output );
+ }
+
+ /**
+ * Test that migration notice is not displayed when dismissed.
+ */
+ public function test_migration_notice_not_displayed_when_dismissed() {
+ update_user_meta( $this->admin_user_id, 'dismissed_paypal_migration_completed_notice', true );
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices();
+ $output = ob_get_clean();
+
+ $this->assertStringNotContainsString( 'PayPal integration from PayPal Standard to PayPal Payments', $output );
+ }
+
+ /**
+ * Test that account restricted notice is displayed when flag is set.
+ */
+ public function test_account_restricted_notice_displayed_when_flag_set() {
+ update_option( 'woocommerce_paypal_account_restricted_status', 'yes' );
+ $this->mock_gateway_available();
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices();
+ $output = ob_get_clean();
+
+ $this->assertStringContainsString( 'PayPal Account Restricted', $output );
+ $this->assertStringContainsString( 'notice notice-error', $output );
+ $this->assertStringContainsString( 'https://www.paypal.com/smarthelp/contact-us', $output );
+ }
+
+ /**
+ * Test that account restricted notice is not displayed when flag is not set.
+ */
+ public function test_account_restricted_notice_not_displayed_when_flag_not_set() {
+ $this->mock_gateway_available();
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices();
+ $output = ob_get_clean();
+
+ $this->assertStringNotContainsString( 'PayPal Account Restricted', $output );
+ }
+
+ /**
+ * Test that account restricted notice is not displayed when dismissed.
+ */
+ public function test_account_restricted_notice_not_displayed_when_dismissed() {
+ // Set account restriction flag.
+ update_option( 'woocommerce_paypal_account_restricted_status', 'yes' );
+ $this->create_mock_gateway();
+ update_user_meta( $this->admin_user_id, 'dismissed_paypal_account_restricted_notice', true );
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices();
+ $output = ob_get_clean();
+
+ $this->assertStringNotContainsString( 'PayPal Account Restricted', $output );
+ }
+
+ /**
+ * Data provider for supported currencies.
+ *
+ * @return array
+ */
+ public function currency_support_data_provider() {
+ return array(
+ 'USD is supported' => array(
+ 'currency' => 'USD',
+ 'should_display' => false,
+ ),
+ 'EUR is supported' => array(
+ 'currency' => 'EUR',
+ 'should_display' => false,
+ ),
+ 'INR is not supported' => array(
+ 'currency' => 'INR',
+ 'should_display' => true,
+ ),
+ 'Invalid currency code not supported' => array(
+ 'currency' => 'XYZ',
+ 'should_display' => true,
+ ),
+ );
+ }
+
+ /**
+ * Test unsupported currency notice display based on currency.
+ *
+ * @dataProvider currency_support_data_provider
+ * @param string $currency The currency code.
+ * @param bool $should_display Whether the notice should display.
+ */
+ public function test_unsupported_currency_notice_respects_currency( $currency, $should_display ) {
+ $store_currency = get_option( 'woocommerce_currency' );
+ // Set the currency.
+ update_option( 'woocommerce_currency', $currency );
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices();
+ $output = ob_get_clean();
+
+ if ( $should_display ) {
+ $this->assertStringContainsString( 'PayPal Standard does not support your store currency', $output );
+ $this->assertStringContainsString( $currency, $output );
+ } else {
+ $this->assertStringNotContainsString( 'PayPal Standard does not support your store currency', $output );
+ }
+
+ // Reset currency.
+ update_option( 'woocommerce_currency', $store_currency );
+ }
+
+ /**
+ * Test that unsupported currency notice is not displayed when dismissed.
+ */
+ public function test_unsupported_currency_notice_not_displayed_when_dismissed() {
+ $store_currency = get_option( 'woocommerce_currency' );
+ // Set the currency.
+ update_option( 'woocommerce_currency', 'TRY' );
+ update_user_meta( $this->admin_user_id, 'dismissed_paypal_unsupported_currency_notice', true );
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices();
+ $output = ob_get_clean();
+
+ $this->assertStringNotContainsString( 'PayPal Standard does not support your store currency', $output );
+
+ // Reset currency.
+ update_option( 'woocommerce_currency', $store_currency );
+ }
+
+ /**
+ * Test setting account restriction flag.
+ */
+ public function test_set_account_restriction_flag() {
+ // Ensure the flag is not set initially.
+ update_option( 'woocommerce_paypal_account_restricted_status', 'no' );
+
+ WC_Gateway_Paypal_Notices::set_account_restriction_flag();
+
+ // Verify the flag was set.
+ $this->assertEquals( 'yes', get_option( 'woocommerce_paypal_account_restricted_status', 'no' ) );
+ }
+
+ /**
+ * Test that setting account restriction flag when already set does not update.
+ */
+ public function test_set_account_restriction_flag_when_already_set() {
+ // Set the flag initially.
+ update_option( 'woocommerce_paypal_account_restricted_status', 'yes' );
+
+ // Track calls to update_option for this specific option.
+ $update_calls = 0;
+ $track_updates = function ( $value, $old_value, $option ) use ( &$update_calls ) {
+ if ( 'woocommerce_paypal_account_restricted_status' === $option ) {
+ ++$update_calls;
+ }
+ return $value;
+ };
+ add_filter( 'pre_update_option_woocommerce_paypal_account_restricted_status', $track_updates, 10, 3 );
+
+ // Call set again - should not change the value.
+ WC_Gateway_Paypal_Notices::set_account_restriction_flag();
+
+ // Verify update_option was not called (the filter would have been triggered).
+ $this->assertEquals( 0, $update_calls, 'update_option should not be called when flag is already set' );
+
+ // Verify the flag is still 'yes'.
+ $this->assertEquals( 'yes', get_option( 'woocommerce_paypal_account_restricted_status', 'no' ) );
+
+ // Clean up.
+ remove_filter( 'pre_update_option_woocommerce_paypal_account_restricted_status', $track_updates );
+ }
+
+ /**
+ * Test clearing account restriction flag.
+ */
+ public function test_clear_account_restriction_flag() {
+ // Set the flag initially.
+ update_option( 'woocommerce_paypal_account_restricted_status', 'yes' );
+
+ WC_Gateway_Paypal_Notices::clear_account_restriction_flag();
+
+ // Verify the flag was cleared.
+ $this->assertEquals( 'no', get_option( 'woocommerce_paypal_account_restricted_status', 'no' ) );
+ }
+
+ /**
+ * Test that clearing account restriction flag when already cleared does not update.
+ */
+ public function test_clear_account_restriction_flag_when_already_cleared() {
+ // Ensure the flag is not set initially.
+ update_option( 'woocommerce_paypal_account_restricted_status', 'no' );
+
+ // Track calls to update_option for this specific option.
+ $update_calls = 0;
+ $track_updates = function ( $value, $old_value, $option ) use ( &$update_calls ) {
+ if ( 'woocommerce_paypal_account_restricted_status' === $option ) {
+ ++$update_calls;
+ }
+ return $value;
+ };
+ add_filter( 'pre_update_option_woocommerce_paypal_account_restricted_status', $track_updates, 10, 3 );
+
+ // Call clear again - should not change the value.
+ WC_Gateway_Paypal_Notices::clear_account_restriction_flag();
+
+ // Verify update_option was not called (the filter would have been triggered).
+ $this->assertEquals( 0, $update_calls, 'update_option should not be called when flag is already cleared' );
+
+ // Verify the flag is still 'no'.
+ $this->assertEquals( 'no', get_option( 'woocommerce_paypal_account_restricted_status', 'no' ) );
+
+ // Clean up.
+ remove_filter( 'pre_update_option_woocommerce_paypal_account_restricted_status', $track_updates );
+ }
+
+ /**
+ * Test that notices are not displayed when gateway is not available.
+ */
+ public function test_notices_not_displayed_when_gateway_not_available() {
+ $this->mock_gateway_not_available();
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices();
+ $output = ob_get_clean();
+
+ $this->assertEmpty( $output );
+ }
+
+ /**
+ * Test that notices are not displayed when Orders v2 is not enabled.
+ */
+ public function test_notices_not_displayed_when_orders_v2_not_enabled() {
+ $mock_gateway = $this->getMockBuilder( WC_Gateway_Paypal::class )
+ ->onlyMethods( array( 'should_use_orders_v2' ) )
+ ->getMock();
+ $mock_gateway->method( 'should_use_orders_v2' )->willReturn( false );
+ WC_Gateway_Paypal::set_instance( $mock_gateway );
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices();
+ $output = ob_get_clean();
+
+ $this->assertEmpty( $output );
+ }
+
+ /**
+ * Test that notices on payment settings page only display on correct page.
+ */
+ public function test_notices_on_payments_settings_page_only_on_correct_page() {
+ $this->mock_gateway_available();
+
+ // Mock the screen.
+ set_current_screen( 'woocommerce_page_wc-settings' );
+ global $current_tab, $current_section;
+ $current_tab = 'checkout';
+ $current_section = '';
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices_on_payments_settings_page();
+ $output = ob_get_clean();
+
+ $this->assertStringContainsString( 'PayPal', $output );
+ }
+
+ /**
+ * Test that notices on payment settings page don't display on wrong tab.
+ */
+ public function test_notices_not_displayed_on_wrong_tab() {
+ wp_set_current_user( $this->admin_user_id );
+ $this->mock_gateway_available();
+
+ // Mock the screen with wrong tab.
+ set_current_screen( 'woocommerce_page_wc-settings' );
+ global $current_tab, $current_section;
+ $current_tab = 'general';
+ $current_section = '';
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices_on_payments_settings_page();
+ $output = ob_get_clean();
+
+ $this->assertEmpty( $output );
+ }
+
+ /**
+ * Test that multiple notices can be displayed simultaneously.
+ */
+ public function test_multiple_notices_displayed_simultaneously() {
+ update_option( 'woocommerce_paypal_account_restricted_status', 'yes' );
+ $this->mock_gateway_available();
+
+ $store_currency = get_option( 'woocommerce_currency' );
+ update_option( 'woocommerce_currency', 'TRY' );
+
+ $notices = new WC_Gateway_Paypal_Notices();
+
+ ob_start();
+ $notices->add_paypal_notices();
+ $output = ob_get_clean();
+
+ // Should contain migration notice.
+ $this->assertStringContainsString( 'PayPal integration from PayPal Standard to PayPal Payments', $output );
+ // Should contain account restricted notice.
+ $this->assertStringContainsString( 'PayPal Account Restricted', $output );
+ // Should contain unsupported currency notice.
+ $this->assertStringContainsString( 'PayPal Standard does not support your store currency', $output );
+
+ // Reset currency.
+ update_option( 'woocommerce_currency', $store_currency );
+ }
+
+ /**
+ * Mock gateway as available.
+ */
+ private function mock_gateway_available() {
+ update_option(
+ 'woocommerce_paypal_settings',
+ array(
+ 'enabled' => 'yes',
+ '_should_load' => 'yes',
+ )
+ );
+ }
+
+ /**
+ * Mock gateway as not available.
+ */
+ private function mock_gateway_not_available() {
+ update_option(
+ 'woocommerce_paypal_settings',
+ array(
+ 'enabled' => 'no',
+ '_should_load' => 'no',
+ )
+ );
+ }
+
+ /**
+ * Create a mock gateway instance.
+ *
+ * @return WC_Gateway_Paypal|\PHPUnit\Framework\MockObject\MockObject
+ */
+ private function create_mock_gateway() {
+ $mock_gateway = $this->getMockBuilder( WC_Gateway_Paypal::class )
+ ->onlyMethods( array( 'should_use_orders_v2' ) )
+ ->getMock();
+
+ $mock_gateway->method( 'should_use_orders_v2' )->willReturn( true );
+
+ // Inject the mock gateway as the singleton instance.
+ WC_Gateway_Paypal::set_instance( $mock_gateway );
+
+ return $mock_gateway;
+ }
+}