Fix code duplication

This commit is contained in:
Alex P 2023-06-15 10:01:05 +03:00
parent 8de593018f
commit c97df85c57
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -9,6 +9,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Checkout;
use WooCommerce\PayPalCommerce\Button\Helper\ContextTrait;
use WooCommerce\PayPalCommerce\Session\SessionHandler;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
@ -20,6 +21,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Helper\SettingsStatus;
* Class DisableGateways
*/
class DisableGateways {
use ContextTrait;
/**
* The Session Handler.
@ -124,20 +126,6 @@ class DisableGateways {
* @return bool
*/
private function needs_to_disable_gateways(): bool {
$order = $this->session_handler->order();
if ( ! $order ) {
return false;
}
$source = $order->payment_source();
if ( $source && $source->card() ) {
return false; // DCC.
}
if ( 'card' === $this->session_handler->funding_source() ) {
return false; // Card buttons.
}
return true;
return $this->is_paypal_continuation();
}
}