Skip to content

Commit

Permalink
Get filtered express checkout payment methods
Browse files Browse the repository at this point in the history
AD4CR22I-9
  • Loading branch information
Tamara committed Jan 8, 2025
1 parent 841083f commit 19f2b25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
data-country-code="{{ adyenFrontendData.countryCode }}"
data-amount="{{ adyenFrontendData.amount }}"
data-currency="{{ adyenFrontendData.currency }}"
data-payment-methods-response="{{ adyenFrontendData.paymentMethodsResponse }}",
data-payment-methods-response="{{ adyenFrontendData.paymentMethodsResponse }}"
data-user-logged-in="{{ adyenFrontendData.userLoggedIn }}"
data-shipping-methods-response="{{ adyenFrontendData.shippingMethodsResponse }}"
></div>
Expand Down
7 changes: 4 additions & 3 deletions src/Service/PaymentMethodsFilterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,16 @@ public function getAvailableExpressCheckoutPaymentMethods(
$applePayAvailable ? $allowedMethods['applepay'] = true : false;

// Filter methods by type and configuration
$filteredMethods =
array_filter($paymentMethods, function ($method) use ($allowedMethods, $salesChannelContext) {
$filteredMethods = array_values(
array_filter($paymentMethods, function ($method) use ($allowedMethods) {
$type = $method['type'];
if (!isset($allowedMethods[$type])) {
return false;
}

return $method;
});
})
);

$paymentMethodsResponse = new PaymentMethodsResponse();
$paymentMethodsResponse->setPaymentMethods($filteredMethods);
Expand Down

0 comments on commit 19f2b25

Please sign in to comment.