From a416033c6012ba073aaa420cff884d424a5abd94 Mon Sep 17 00:00:00 2001 From: Alex P Date: Wed, 25 Oct 2023 09:36:56 +0300 Subject: [PATCH 1/2] Fix card button subscription support declaration --- .../src/Gateway/CardButtonGateway.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Gateway/CardButtonGateway.php b/modules/ppcp-wc-gateway/src/Gateway/CardButtonGateway.php index fecb495b6..010df9e9b 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/CardButtonGateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/CardButtonGateway.php @@ -171,13 +171,17 @@ class CardButtonGateway extends \WC_Payment_Gateway { $this->payment_token_repository = $payment_token_repository; $this->logger = $logger; - if ( $this->onboarded ) { - $this->supports = array( 'refunds' ); - } - if ( $this->gateways_enabled() ) { - $this->supports = array( - 'refunds', - 'products', + $this->supports = array( + 'refunds', + 'products', + ); + + if ( + ( $this->config->has( 'vault_enabled' ) && $this->config->get( 'vault_enabled' ) ) + || ( $this->config->has( 'subscriptions_mode' ) && $this->config->get( 'subscriptions_mode' ) === 'subscriptions_api' ) + ) { + array_push( + $this->supports, 'subscriptions', 'subscription_cancellation', 'subscription_suspension', @@ -187,7 +191,7 @@ class CardButtonGateway extends \WC_Payment_Gateway { 'subscription_payment_method_change', 'subscription_payment_method_change_customer', 'subscription_payment_method_change_admin', - 'multiple_subscriptions', + 'multiple_subscriptions' ); } From 251d6c6053948f961d6227c60519c84abe98737b Mon Sep 17 00:00:00 2001 From: Alex P Date: Wed, 25 Oct 2023 10:45:56 +0300 Subject: [PATCH 2/2] Remove unused --- .../src/Gateway/ProcessPaymentTrait.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Gateway/ProcessPaymentTrait.php b/modules/ppcp-wc-gateway/src/Gateway/ProcessPaymentTrait.php index 7f752ef18..3cf401b29 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/ProcessPaymentTrait.php +++ b/modules/ppcp-wc-gateway/src/Gateway/ProcessPaymentTrait.php @@ -18,21 +18,6 @@ use WooCommerce\PayPalCommerce\WcGateway\Exception\GatewayGenericException; * Trait ProcessPaymentTrait */ trait ProcessPaymentTrait { - /** - * Checks if PayPal or Credit Card gateways are enabled. - * - * @return bool Whether any of the gateways is enabled. - */ - protected function gateways_enabled(): bool { - if ( $this->config->has( 'enabled' ) && $this->config->get( 'enabled' ) ) { - return true; - } - if ( $this->config->has( 'dcc_enabled' ) && $this->config->get( 'dcc_enabled' ) ) { - return true; - } - return false; - } - /** * Handles the payment failure. *