Consolidate ACDC logic in CardFieldsModule

This commit is contained in:
Philipp Stracker 2025-03-14 18:05:21 +01:00
parent 433e7f7c8b
commit 901e7761e1
No known key found for this signature in database
2 changed files with 19 additions and 1 deletions

View file

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

View file

@ -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',
/**