From 901e7761e17e2ced5d8037bcedcef37e31097981 Mon Sep 17 00:00:00 2001 From: Philipp Stracker Date: Fri, 14 Mar 2025 18:05:21 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Consolidate=20ACDC=20logic=20in=20C?= =?UTF-8?q?ardFieldsModule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Helper/DisabledFundingSources.php | 2 +- .../ppcp-card-fields/src/CardFieldsModule.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/ppcp-button/src/Helper/DisabledFundingSources.php b/modules/ppcp-button/src/Helper/DisabledFundingSources.php index 7d24974a9..343823bef 100644 --- a/modules/ppcp-button/src/Helper/DisabledFundingSources.php +++ b/modules/ppcp-button/src/Helper/DisabledFundingSources.php @@ -225,7 +225,7 @@ class DisabledFundingSources { * Filters the final list of disabled funding sources. */ $disable_funding = apply_filters( - 'woocommerce_paypal_payments_disabled_funding_sources', + 'woocommerce_paypal_payments_sdk_disabled_funding_hook', $disable_funding ); diff --git a/modules/ppcp-card-fields/src/CardFieldsModule.php b/modules/ppcp-card-fields/src/CardFieldsModule.php index 1fb2a6ddf..45d1d6b51 100644 --- a/modules/ppcp-card-fields/src/CardFieldsModule.php +++ b/modules/ppcp-card-fields/src/CardFieldsModule.php @@ -72,6 +72,24 @@ class CardFieldsModule implements ServiceModule, ExtendingModule, ExecutableModu } ); + add_filter( + 'woocommerce_paypal_payments_sdk_disabled_funding_hook', + static function ( array $disable_funding ) use ( $c ) { + $dcc_config = $c->get( 'wcgateway.configuration.card-configuration' ); + assert( $dcc_config instanceof CardPaymentsConfiguration ); + + if ( ! $dcc_config->is_acdc_enabled() ) { + return $disable_funding; + } + + // For ACDC payments we need the funding source "card"! + return array_filter( + $disable_funding, + static fn( string $funding_source ) => $funding_source !== 'card' + ); + } + ); + add_filter( 'woocommerce_credit_card_form_fields', /**