diff --git a/changelog/fix-migration-script-for-newly-onboarded-stores b/changelog/fix-migration-script-for-newly-onboarded-stores new file mode 100644 index 00000000000..dd3bae8f261 --- /dev/null +++ b/changelog/fix-migration-script-for-newly-onboarded-stores @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Ensure card gateway is not running through the settings migration. diff --git a/includes/migrations/class-gateway-settings-sync.php b/includes/migrations/class-gateway-settings-sync.php index 5f1c32abcc6..9b9ad3d4a2d 100644 --- a/includes/migrations/class-gateway-settings-sync.php +++ b/includes/migrations/class-gateway-settings-sync.php @@ -62,17 +62,20 @@ public function maybe_sync() { } /** - * Deletes the active webhook. + * Syncs gateway setting objects. */ private function sync() { $enabled_payment_methods = $this->main_gateway->get_option( 'upe_enabled_payment_method_ids', [] ); foreach ( $this->all_registered_gateways as $gateway ) { - if ( in_array( $gateway->get_stripe_id(), $enabled_payment_methods, true ) ) { - $gateway->enable(); - $gateway->update_option( 'upe_enabled_payment_method_ids', $enabled_payment_methods ); - } else { - $gateway->update_option( 'upe_enabled_payment_method_ids', $enabled_payment_methods ); + // Skip the main gateway as it's settings are already in sync. + if ( 'card' !== $gateway->get_stripe_id() ) { + if ( in_array( $gateway->get_stripe_id(), $enabled_payment_methods, true ) ) { + $gateway->enable(); + $gateway->update_option( 'upe_enabled_payment_method_ids', $enabled_payment_methods ); + } else { + $gateway->update_option( 'upe_enabled_payment_method_ids', $enabled_payment_methods ); + } } } }