Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes Sofort from settings and checkout #9820

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/update-deprecating-sofort-from-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

Removes Sofort payment method from settings and checkout, permanently deprecates Sofort from settings.
1 change: 0 additions & 1 deletion includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -4114,7 +4114,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;
Expand Down
5 changes: 3 additions & 2 deletions includes/class-wc-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,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';
Expand All @@ -678,7 +678,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.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' ] );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Class Giropay_Deprecation_Settings_Update
* Class Payment_Method_Deprecation_Settings_Update
*
* @package WooCommerce\Payments
*/
Expand All @@ -12,19 +12,11 @@
defined( 'ABSPATH' ) || exit;

/**
* Class Delete_Active_WooPay_Webhook
* Class Payment_Method_Deprecation_Settings_Update
*
* Aligns settings object for every gateway to support new approach of settings handling without the need of using the settings controller.
*/
class Giropay_Deprecation_Settings_Update {

/**
* Version in which this migration was introduced.
*
* @var string
*/
const VERSION_SINCE = '7.9.0';

class Payment_Method_Deprecation_Settings_Update {
/**
* WCPay gateway.
*
Expand All @@ -39,23 +31,41 @@ class Giropay_Deprecation_Settings_Update {
*/
private $all_registered_gateways;

/**
* Payment method type ID.
*
* @var string
*/
private $payment_method_id;

/**
* Version in which this migration was introduced.
*
* @var string
*/
private $migration_version;

/**
* Gateway_Settings_Sync constructor.
*
* @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 ) {
public function __construct( WC_Payment_Gateway_WCPay $main_gateway, $all_registered_gateways, $payment_method_id, $migration_version ) {
$this->main_gateway = $main_gateway;
$this->all_registered_gateways = $all_registered_gateways;
$this->payment_method_id = $payment_method_id;
$this->migration_version = $migration_version;
}

/**
* Checks whether we should trigger the event.
*/
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();
}
}
Expand All @@ -69,12 +79,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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,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,
Expand Down
Loading