Merge branch 'trunk' into PCP-1393-update-to-vault-v-3

This commit is contained in:
Emili Castells Guasch 2023-11-02 12:10:27 +01:00
commit d35f7598ed
37 changed files with 1815 additions and 658 deletions

View file

@ -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'
);
}

View file

@ -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.
*