From fd05fe6d70cd8c71a74ed59968ed8ba1908a2995 Mon Sep 17 00:00:00 2001 From: Tamara Date: Thu, 9 Jan 2025 01:40:05 +0100 Subject: [PATCH] Get filtered express checkout payment methods AD4CR22I-9 --- .../express-checkout/express-checkout.plugin.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Resources/app/storefront/src/express-checkout/express-checkout.plugin.js b/src/Resources/app/storefront/src/express-checkout/express-checkout.plugin.js index 4b924869..fd286be6 100755 --- a/src/Resources/app/storefront/src/express-checkout/express-checkout.plugin.js +++ b/src/Resources/app/storefront/src/express-checkout/express-checkout.plugin.js @@ -215,11 +215,19 @@ export default class ExpressCheckoutPlugin extends Plugin { return; } + let availableTypes = []; + let paymentMethods = data.paymentMethodsResponse.paymentMethods || []; + for (let i = 0; i < paymentMethods.length; i++) { + availableTypes[i] = paymentMethods[i].type; + } + for (let i = 0; i < checkoutElements.length; i++) { let type = checkoutElements[i].getElementsByClassName('adyen-type')[0].value; - this.initializeCheckoutComponent(data).then(function (checkoutInstance) { - this.mountElement(type, checkoutInstance, checkoutElements[i]); - }.bind(this)); + if (availableTypes.includes(type)){ + this.initializeCheckoutComponent(data).then(function (checkoutInstance) { + this.mountElement(type, checkoutInstance, checkoutElements[i]); + }.bind(this)); + } } }