🚧 Refactor the eligible-feature REST response

This commit is contained in:
Philipp Stracker 2025-01-08 16:50:38 +01:00
parent 33bd9ecce8
commit 6591889079
No known key found for this signature in database
8 changed files with 49 additions and 31 deletions

View file

@ -550,16 +550,12 @@ class WCGatewayModule implements ServiceModule, ExtendingModule, ExecutableModul
add_filter(
'woocommerce_paypal_payments_rest_common_merchant_data',
function( array $merchant_data ) use ( $c ): array {
if ( ! isset( $merchant_data['features'] ) ) {
$merchant_data['features'] = array();
}
function( array $features ) use ( $c ): array {
$billing_agreements_endpoint = $c->get( 'api.endpoint.billing-agreements' );
assert( $billing_agreements_endpoint instanceof BillingAgreementsEndpoint );
$reference_transactions_enabled = $billing_agreements_endpoint->reference_transaction_enabled();
$merchant_data['features']['save_paypal_and_venmo'] = array(
$features['save_paypal_and_venmo'] = array(
'enabled' => $reference_transactions_enabled,
);
@ -567,11 +563,11 @@ class WCGatewayModule implements ServiceModule, ExtendingModule, ExecutableModul
assert( $dcc_product_status instanceof DCCProductStatus );
$dcc_enabled = $dcc_product_status->dcc_is_active();
$merchant_data['features']['advanced_credit_and_debit_cards'] = array(
$features['advanced_credit_and_debit_cards'] = array(
'enabled' => $dcc_enabled,
);
return $merchant_data;
return $features;
}
);