Merge pull request #1796 from woocommerce/PCP-1852-card-button-subs

Fix card button subscription support declaration
This commit is contained in:
Emili Castells 2023-10-31 10:45:01 +01:00 committed by GitHub
commit 96aaed5a5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 23 deletions

View file

@ -171,13 +171,17 @@ class CardButtonGateway extends \WC_Payment_Gateway {
$this->payment_token_repository = $payment_token_repository; $this->payment_token_repository = $payment_token_repository;
$this->logger = $logger; $this->logger = $logger;
if ( $this->onboarded ) { $this->supports = array(
$this->supports = array( 'refunds' ); 'refunds',
} 'products',
if ( $this->gateways_enabled() ) { );
$this->supports = array(
'refunds', if (
'products', ( $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', 'subscriptions',
'subscription_cancellation', 'subscription_cancellation',
'subscription_suspension', 'subscription_suspension',
@ -187,7 +191,7 @@ class CardButtonGateway extends \WC_Payment_Gateway {
'subscription_payment_method_change', 'subscription_payment_method_change',
'subscription_payment_method_change_customer', 'subscription_payment_method_change_customer',
'subscription_payment_method_change_admin', 'subscription_payment_method_change_admin',
'multiple_subscriptions', 'multiple_subscriptions'
); );
} }

View file

@ -18,21 +18,6 @@ use WooCommerce\PayPalCommerce\WcGateway\Exception\GatewayGenericException;
* Trait ProcessPaymentTrait * Trait ProcessPaymentTrait
*/ */
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. * Handles the payment failure.
* *