From c1287eb7c8845f40776a24bbf7ceed2600bea055 Mon Sep 17 00:00:00 2001 From: Samir Merchant Date: Wed, 27 Nov 2024 00:32:08 -0500 Subject: [PATCH 01/10] removes sofort from settings and checkout --- includes/class-wc-payment-gateway-wcpay.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/class-wc-payment-gateway-wcpay.php b/includes/class-wc-payment-gateway-wcpay.php index e68cc4469d7..e3ce7c9bc21 100644 --- a/includes/class-wc-payment-gateway-wcpay.php +++ b/includes/class-wc-payment-gateway-wcpay.php @@ -4085,7 +4085,6 @@ public function get_upe_available_payment_methods() { $available_methods[] = Bancontact_Payment_Method::PAYMENT_METHOD_STRIPE_ID; $available_methods[] = Eps_Payment_Method::PAYMENT_METHOD_STRIPE_ID; $available_methods[] = Ideal_Payment_Method::PAYMENT_METHOD_STRIPE_ID; - $available_methods[] = Sofort_Payment_Method::PAYMENT_METHOD_STRIPE_ID; $available_methods[] = Sepa_Payment_Method::PAYMENT_METHOD_STRIPE_ID; $available_methods[] = P24_Payment_Method::PAYMENT_METHOD_STRIPE_ID; $available_methods[] = Link_Payment_Method::PAYMENT_METHOD_STRIPE_ID; From 580448619c5988b29ff8e7e94fc24a4a26cad138 Mon Sep 17 00:00:00 2001 From: Samir Merchant Date: Wed, 27 Nov 2024 00:46:32 -0500 Subject: [PATCH 02/10] adds plugin update hook to migrate settings and remove sofort --- includes/class-wc-payments.php | 3 +- ...nt-method-deprecation-settings-update.php} | 38 +++++++++++-------- 2 files changed, 25 insertions(+), 16 deletions(-) rename includes/migrations/{class-giropay-deprecation-settings-update.php => class-payment-method-deprecation-settings-update.php} (74%) diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php index 66e72bb8dbf..277b962674f 100644 --- a/includes/class-wc-payments.php +++ b/includes/class-wc-payments.php @@ -675,7 +675,8 @@ function () { add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Link_WooPay_Mutual_Exclusion_Handler( self::get_gateway() ), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Gateway_Settings_Sync( self::get_gateway(), self::get_payment_gateway_map() ), 'maybe_sync' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ '\WCPay\Migrations\Delete_Active_WooPay_Webhook', 'maybe_delete' ] ); - add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Giropay_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map() ), 'maybe_migrate' ] ); + add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Payment_Method_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map(), Giropay_Payment_Method::PAYMENT_METHOD_STRIPE_ID, '7.9.0' ), 'maybe_migrate' ] ); + add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Payment_Method_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map(), Sofort_Payment_Method::PAYMENT_METHOD_STRIPE_ID, '8.5.1' ), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Erase_Bnpl_Announcement_Meta(), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Erase_Deprecated_Flags_And_Options(), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Manual_Capture_Payment_Method_Settings_Update( self::get_gateway(), self::get_payment_gateway_map() ), 'maybe_migrate' ] ); diff --git a/includes/migrations/class-giropay-deprecation-settings-update.php b/includes/migrations/class-payment-method-deprecation-settings-update.php similarity index 74% rename from includes/migrations/class-giropay-deprecation-settings-update.php rename to includes/migrations/class-payment-method-deprecation-settings-update.php index b5b2568eb97..3fecea0f7c5 100644 --- a/includes/migrations/class-giropay-deprecation-settings-update.php +++ b/includes/migrations/class-payment-method-deprecation-settings-update.php @@ -1,6 +1,6 @@ main_gateway = $main_gateway; $this->all_registered_gateways = $all_registered_gateways; + $this->payment_method_id = $payment_method_id; + $this->migration_version = $migration_version; } /** @@ -55,7 +63,7 @@ public function __construct( WC_Payment_Gateway_WCPay $main_gateway, $all_regist */ public function maybe_migrate() { $previous_version = get_option( 'woocommerce_woocommerce_payments_version' ); - if ( version_compare( self::VERSION_SINCE, $previous_version, '>' ) ) { + if ( version_compare( $this->migration_version, $previous_version, '>' ) ) { $this->migrate(); } } @@ -69,12 +77,12 @@ private function migrate() { $filtered_payment_methods = array_filter( $enabled_payment_methods, function ( $method ) { - return 'giropay' !== $method; + return $this->payment_method_id !== $method; } ); foreach ( $this->all_registered_gateways as $gateway ) { - if ( 'giropay' === $gateway->get_stripe_id() ) { + if ( $this->payment_method_id === $gateway->get_stripe_id() ) { if ( in_array( $gateway->get_stripe_id(), $enabled_payment_methods, true ) ) { $gateway->disable(); $gateway->update_option( 'upe_enabled_payment_method_ids', $filtered_payment_methods ); From 7fbaa51b75fcc594fab46a4f7f4c3ed069d9e0d2 Mon Sep 17 00:00:00 2001 From: Samir Merchant Date: Wed, 27 Nov 2024 00:47:58 -0500 Subject: [PATCH 03/10] adds changelog --- changelog/update-deprecating-sofort-from-checkout | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/update-deprecating-sofort-from-checkout diff --git a/changelog/update-deprecating-sofort-from-checkout b/changelog/update-deprecating-sofort-from-checkout new file mode 100644 index 00000000000..f20bd92fc28 --- /dev/null +++ b/changelog/update-deprecating-sofort-from-checkout @@ -0,0 +1,4 @@ +Significance: minor +Type: update + +Removes Sofort payment method from settings and checkout, permanently deprecates Sofort from settings. From 405a955fc890486f4a4a8e910f0c395e124e6156 Mon Sep 17 00:00:00 2001 From: Samir Merchant Date: Wed, 27 Nov 2024 01:05:37 -0500 Subject: [PATCH 04/10] fixes broken require statement --- includes/class-wc-payments.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php index 277b962674f..524920e341b 100644 --- a/includes/class-wc-payments.php +++ b/includes/class-wc-payments.php @@ -664,7 +664,7 @@ function () { require_once __DIR__ . '/migrations/class-link-woopay-mutual-exclusion-handler.php'; require_once __DIR__ . '/migrations/class-gateway-settings-sync.php'; require_once __DIR__ . '/migrations/class-delete-active-woopay-webhook.php'; - require_once __DIR__ . '/migrations/class-giropay-deprecation-settings-update.php'; + require_once __DIR__ . '/migrations/class-payment-method-deprecation-settings-update.php'; require_once __DIR__ . '/migrations/class-erase-bnpl-announcement-meta.php'; require_once __DIR__ . '/migrations/class-erase-deprecated-flags-and-options.php'; require_once __DIR__ . '/migrations/class-manual-capture-payment-method-settings-update.php'; From 27aba38984ca9479b92d3a7d593e1cf86b6dc70b Mon Sep 17 00:00:00 2001 From: Samir Merchant Date: Wed, 27 Nov 2024 01:10:15 -0500 Subject: [PATCH 05/10] adds missing doc comment to migration class constructor --- .../class-payment-method-deprecation-settings-update.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/migrations/class-payment-method-deprecation-settings-update.php b/includes/migrations/class-payment-method-deprecation-settings-update.php index 3fecea0f7c5..bf56717641b 100644 --- a/includes/migrations/class-payment-method-deprecation-settings-update.php +++ b/includes/migrations/class-payment-method-deprecation-settings-update.php @@ -50,6 +50,8 @@ class Payment_Method_Deprecation_Settings_Update { * * @param WC_Payment_Gateway_WCPay $main_gateway WCPay gateway. * @param array $all_registered_gateways All registered gateways. + * @param string $payment_method_id Stripe payment method ID of payment method to deprecate. + * @param string $migration_version Plugin version after which migration should run. */ public function __construct( WC_Payment_Gateway_WCPay $main_gateway, $all_registered_gateways, $payment_method_id, $migration_version ) { $this->main_gateway = $main_gateway; From fc112ca518a265fc03619f9cbc0f99fe600b24bc Mon Sep 17 00:00:00 2001 From: Samir Merchant Date: Wed, 27 Nov 2024 01:12:28 -0500 Subject: [PATCH 06/10] removes superfluous space in class parameters --- includes/class-wc-payments.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php index 524920e341b..15b9909469d 100644 --- a/includes/class-wc-payments.php +++ b/includes/class-wc-payments.php @@ -675,7 +675,7 @@ function () { add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Link_WooPay_Mutual_Exclusion_Handler( self::get_gateway() ), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Gateway_Settings_Sync( self::get_gateway(), self::get_payment_gateway_map() ), 'maybe_sync' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ '\WCPay\Migrations\Delete_Active_WooPay_Webhook', 'maybe_delete' ] ); - add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Payment_Method_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map(), Giropay_Payment_Method::PAYMENT_METHOD_STRIPE_ID, '7.9.0' ), 'maybe_migrate' ] ); + add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Payment_Method_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map(), Giropay_Payment_Method::PAYMENT_METHOD_STRIPE_ID, '7.9.0' ), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Payment_Method_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map(), Sofort_Payment_Method::PAYMENT_METHOD_STRIPE_ID, '8.5.1' ), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Erase_Bnpl_Announcement_Meta(), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Erase_Deprecated_Flags_And_Options(), 'maybe_migrate' ] ); From be1e063be648f1b018bbfda8b6f11f04d3b76b4c Mon Sep 17 00:00:00 2001 From: Samir Merchant Date: Wed, 27 Nov 2024 01:21:56 -0500 Subject: [PATCH 07/10] fixes broken test that I done broke --- .../admin/test-class-wc-rest-payments-settings-controller.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/admin/test-class-wc-rest-payments-settings-controller.php b/tests/unit/admin/test-class-wc-rest-payments-settings-controller.php index d68c5c1f82e..247e301bd37 100644 --- a/tests/unit/admin/test-class-wc-rest-payments-settings-controller.php +++ b/tests/unit/admin/test-class-wc-rest-payments-settings-controller.php @@ -247,7 +247,6 @@ public function test_get_settings_returns_available_payment_method_ids() { Payment_Method::BANCONTACT, Payment_Method::EPS, Payment_Method::IDEAL, - Payment_Method::SOFORT, Payment_Method::SEPA, Payment_Method::P24, Payment_Method::LINK, From 08332624fdf248e5d3607680078b363c3ca87966 Mon Sep 17 00:00:00 2001 From: Samir Merchant Date: Fri, 20 Dec 2024 04:38:28 -0500 Subject: [PATCH 08/10] updates previous migration version --- includes/class-wc-payments.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php index b7c49bcbdec..18dafa6f2f4 100644 --- a/includes/class-wc-payments.php +++ b/includes/class-wc-payments.php @@ -679,7 +679,7 @@ function () { add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Gateway_Settings_Sync( self::get_gateway(), self::get_payment_gateway_map() ), 'maybe_sync' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ '\WCPay\Migrations\Delete_Active_WooPay_Webhook', 'maybe_delete' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Payment_Method_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map(), Giropay_Payment_Method::PAYMENT_METHOD_STRIPE_ID, '7.9.0' ), 'maybe_migrate' ] ); - add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Payment_Method_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map(), Sofort_Payment_Method::PAYMENT_METHOD_STRIPE_ID, '8.5.1' ), 'maybe_migrate' ] ); + add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Payment_Method_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map(), Sofort_Payment_Method::PAYMENT_METHOD_STRIPE_ID, '8.6.1' ), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Erase_Bnpl_Announcement_Meta(), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Erase_Deprecated_Flags_And_Options(), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Manual_Capture_Payment_Method_Settings_Update( self::get_gateway(), self::get_payment_gateway_map() ), 'maybe_migrate' ] ); From 9b01776d80d8b4b4125fe0f38e3ad100f48c841f Mon Sep 17 00:00:00 2001 From: Samir Merchant Date: Wed, 22 Jan 2025 16:15:50 -0500 Subject: [PATCH 09/10] removes redundant imports, instantiations, and tests --- includes/class-duplicates-detection-service.php | 4 ---- includes/class-wc-payment-gateway-wcpay.php | 2 -- .../test-class-duplicates-detection-service.php | 6 +++--- tests/unit/test-class-wc-payments-checkout.php | 6 ------ 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/includes/class-duplicates-detection-service.php b/includes/class-duplicates-detection-service.php index c2ffe05385a..119972b68b4 100644 --- a/includes/class-duplicates-detection-service.php +++ b/includes/class-duplicates-detection-service.php @@ -18,12 +18,10 @@ use WCPay\Payment_Methods\Becs_Payment_Method; use WCPay\Payment_Methods\CC_Payment_Method; use WCPay\Payment_Methods\Eps_Payment_Method; -use WCPay\Payment_Methods\Giropay_Payment_Method; use WCPay\Payment_Methods\Ideal_Payment_Method; use WCPay\Payment_Methods\Klarna_Payment_Method; use WCPay\Payment_Methods\P24_Payment_Method; use WCPay\Payment_Methods\Sepa_Payment_Method; -use WCPay\Payment_Methods\Sofort_Payment_Method; /** * Class handling detection of payment methods enabled by multiple plugins simultaneously. @@ -96,8 +94,6 @@ private function search_for_additional_payment_methods() { $keywords = [ 'bancontact' => Bancontact_Payment_Method::PAYMENT_METHOD_STRIPE_ID, 'sepa' => Sepa_Payment_Method::PAYMENT_METHOD_STRIPE_ID, - 'giropay' => Giropay_Payment_Method::PAYMENT_METHOD_STRIPE_ID, - 'sofort' => Sofort_Payment_Method::PAYMENT_METHOD_STRIPE_ID, 'p24' => P24_Payment_Method::PAYMENT_METHOD_STRIPE_ID, 'przelewy24' => P24_Payment_Method::PAYMENT_METHOD_STRIPE_ID, 'ideal' => Ideal_Payment_Method::PAYMENT_METHOD_STRIPE_ID, diff --git a/includes/class-wc-payment-gateway-wcpay.php b/includes/class-wc-payment-gateway-wcpay.php index 4c1a26a1d60..71da8b3a311 100644 --- a/includes/class-wc-payment-gateway-wcpay.php +++ b/includes/class-wc-payment-gateway-wcpay.php @@ -69,12 +69,10 @@ use WCPay\Payment_Methods\Becs_Payment_Method; use WCPay\Payment_Methods\CC_Payment_Method; use WCPay\Payment_Methods\Eps_Payment_Method; -use WCPay\Payment_Methods\Giropay_Payment_Method; use WCPay\Payment_Methods\Ideal_Payment_Method; use WCPay\Payment_Methods\Klarna_Payment_Method; use WCPay\Payment_Methods\P24_Payment_Method; use WCPay\Payment_Methods\Sepa_Payment_Method; -use WCPay\Payment_Methods\Sofort_Payment_Method; use WCPay\Payment_Methods\UPE_Payment_Method; /** diff --git a/tests/unit/duplicate-detection/test-class-duplicates-detection-service.php b/tests/unit/duplicate-detection/test-class-duplicates-detection-service.php index 23b696d751c..7b7433c49e1 100644 --- a/tests/unit/duplicate-detection/test-class-duplicates-detection-service.php +++ b/tests/unit/duplicate-detection/test-class-duplicates-detection-service.php @@ -7,7 +7,7 @@ use WCPay\Duplicates_Detection_Service; use WCPay\Payment_Methods\CC_Payment_Method; -use WCPay\Payment_Methods\Giropay_Payment_Method; +use WCPay\Payment_Methods\Ideal_Payment_Method; use WCPay\Payment_Methods\Klarna_Payment_Method; /** @@ -78,12 +78,12 @@ public function test_two_cc_one_enabled() { } public function test_two_apms_enabled() { - $this->set_duplicates( Giropay_Payment_Method::PAYMENT_METHOD_STRIPE_ID, 'yes', 'yes' ); + $this->set_duplicates( Ideal_Payment_Method::PAYMENT_METHOD_STRIPE_ID, 'yes', 'yes' ); $result = $this->service->find_duplicates(); $this->assertCount( 1, $result ); - $this->assertEquals( Giropay_Payment_Method::PAYMENT_METHOD_STRIPE_ID, array_keys( $result )[0] ); + $this->assertEquals( Ideal_Payment_Method::PAYMENT_METHOD_STRIPE_ID, array_keys( $result )[0] ); } public function test_two_bnpls_enabled() { diff --git a/tests/unit/test-class-wc-payments-checkout.php b/tests/unit/test-class-wc-payments-checkout.php index 1fcbe1093ff..dbb4aa9eb5e 100644 --- a/tests/unit/test-class-wc-payments-checkout.php +++ b/tests/unit/test-class-wc-payments-checkout.php @@ -9,16 +9,12 @@ use PHPUnit\Framework\MockObject\MockObject; use WCPay\Constants\Payment_Method; use WCPay\WooPay\WooPay_Utilities; -use WCPay\Fraud_Prevention\Fraud_Prevention_Service; use WCPay\Payment_Methods\Bancontact_Payment_Method; use WCPay\Payment_Methods\CC_Payment_Method; use WCPay\Payment_Methods\Eps_Payment_Method; -use WCPay\Payment_Methods\Giropay_Payment_Method; use WCPay\Payment_Methods\Ideal_Payment_Method; use WCPay\Payment_Methods\Link_Payment_Method; use WCPay\Payment_Methods\P24_Payment_Method; -use WCPay\Payment_Methods\Sepa_Payment_Method; -use WCPay\Payment_Methods\Sofort_Payment_Method; /** * Class WC_Payments_Checkout_Test @@ -430,10 +426,8 @@ public function non_reusable_payment_method_provider() { return [ [ Payment_Method::BANCONTACT, Bancontact_Payment_Method::class ], [ Payment_Method::EPS, Eps_Payment_Method::class ], - [ Payment_Method::GIROPAY, Giropay_Payment_Method::class ], [ Payment_Method::IDEAL, Ideal_Payment_Method::class ], [ Payment_Method::P24, P24_Payment_Method::class ], - [ Payment_Method::SOFORT, Sofort_Payment_Method::class ], ]; } From 5479913ced8f99f9a14660722339737fbdc109c8 Mon Sep 17 00:00:00 2001 From: Samir Merchant Date: Wed, 22 Jan 2025 16:31:03 -0500 Subject: [PATCH 10/10] updates woopayments version migration trigger --- includes/class-wc-payments.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php index 18dafa6f2f4..54ca82f71f2 100644 --- a/includes/class-wc-payments.php +++ b/includes/class-wc-payments.php @@ -679,7 +679,7 @@ function () { add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Gateway_Settings_Sync( self::get_gateway(), self::get_payment_gateway_map() ), 'maybe_sync' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ '\WCPay\Migrations\Delete_Active_WooPay_Webhook', 'maybe_delete' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Payment_Method_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map(), Giropay_Payment_Method::PAYMENT_METHOD_STRIPE_ID, '7.9.0' ), 'maybe_migrate' ] ); - add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Payment_Method_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map(), Sofort_Payment_Method::PAYMENT_METHOD_STRIPE_ID, '8.6.1' ), 'maybe_migrate' ] ); + add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Payment_Method_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map(), Sofort_Payment_Method::PAYMENT_METHOD_STRIPE_ID, '8.9.0' ), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Erase_Bnpl_Announcement_Meta(), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Erase_Deprecated_Flags_And_Options(), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Manual_Capture_Payment_Method_Settings_Update( self::get_gateway(), self::get_payment_gateway_map() ), 'maybe_migrate' ] );