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

Disable WooPay first party auth when using adapted extensions #7455

Merged
merged 4 commits into from
Oct 11, 2023
Merged
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/fix-disable-woopay-first-party
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Set WooPay first party feature flag to off when incompatible extensions are active.
6 changes: 6 additions & 0 deletions includes/woopay/class-woopay-scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ public function update_compatibility_and_maybe_show_incompatibility_warning() {
public function update_enabled_adapted_extensions( $active_plugins, $adapted_extensions ) {
$enabled_adapted_extensions = $this->get_extensions_in_list( $active_plugins, $adapted_extensions );

if ( count( $enabled_adapted_extensions ) > 0 ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: No changes necessary, but we could also do something like the following:

// ...
$is_first_party_auth_enabled = \WC_Payments_Features::is_woopay_first_party_auth_enabled();
if ( count( $enabled_adapted_extensions ) > 0 && $is_first_party_auth_enabled ) {
  update_option( \WC_Payments_Features::WOOPAY_FIRST_PARTY_AUTH_FLAG_NAME, 0 );
} else if ( count( $enabled_adapted_extensions ) === 0 && ! $is_first_party_auth_enabled ) {
  update_option( \WC_Payments_Features::WOOPAY_FIRST_PARTY_AUTH_FLAG_NAME, 1 );
}
// ...

This way, we only update the option if it's necessary. Although, this is not necessary since this block of code only executes when plugins are activated/deactivated.

update_option( '_wcpay_feature_woopay_first_party_auth', 0 );
} else {
update_option( '_wcpay_feature_woopay_first_party_auth', 1 );
}

update_option( self::ENABLED_ADAPTED_EXTENSIONS_OPTION_NAME, $enabled_adapted_extensions );
}

Expand Down
Loading