Skip to content

Commit

Permalink
skip main gateway from updates on migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
Timur Karimov committed Mar 19, 2024
1 parent 67e989e commit 3944a99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Empty file added docker-compose-override.yml
Empty file.
15 changes: 9 additions & 6 deletions includes/migrations/class-gateway-settings-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
}
}
Expand Down

0 comments on commit 3944a99

Please sign in to comment.