Skip to content

Commit

Permalink
Add server-side WooPay direct checkout eligibility flag (#8300)
Browse files Browse the repository at this point in the history
Co-authored-by: Rafael Zaleski <[email protected]>
  • Loading branch information
2 people authored and Jinksi committed Mar 28, 2024
1 parent d0fed4b commit 7ea9b63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions changelog/add-woopay-direct-checkout-eligibility-flag
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Add WooPay direct checkout flow behind a server-side feature flag.
6 changes: 5 additions & 1 deletion includes/class-wc-payments-features.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down

0 comments on commit 7ea9b63

Please sign in to comment.