diff --git a/changelog/add-woopay-direct-checkout-eligibility-flag b/changelog/add-woopay-direct-checkout-eligibility-flag new file mode 100644 index 00000000000..dc736bf3648 --- /dev/null +++ b/changelog/add-woopay-direct-checkout-eligibility-flag @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Add WooPay direct checkout flow behind a server-side feature flag. diff --git a/includes/class-wc-payments-features.php b/includes/class-wc-payments-features.php index 715b38b2872..57dbad4a32f 100644 --- a/includes/class-wc-payments-features.php +++ b/includes/class-wc-payments-features.php @@ -262,7 +262,11 @@ public static function is_woopay_first_party_auth_enabled() { * @return bool */ public static function is_woopay_direct_checkout_enabled() { - return '1' === get_option( self::WOOPAY_DIRECT_CHECKOUT_FLAG_NAME, '0' ) && self::is_woopay_first_party_auth_enabled(); + $account_cache = WC_Payments::get_database_cache()->get( WCPay\Database_Cache::ACCOUNT_KEY, true ); + $is_direct_checkout_eligible = is_array( $account_cache ) && ( $account_cache['platform_direct_checkout_eligible'] ?? false ); + $is_direct_checkout_flag_enabled = '1' === get_option( self::WOOPAY_DIRECT_CHECKOUT_FLAG_NAME, '0' ); + + return ( $is_direct_checkout_eligible || $is_direct_checkout_flag_enabled ) && self::is_woopay_first_party_auth_enabled(); } /**