diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js index 4b0a4cbd3..9968a3249 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js @@ -24,17 +24,12 @@ export default class MollieApplePayPaymentMethod extends Plugin { this.hideApplePay('.payment-method-input.applepay'); // support for >= Shopware 6.4 - // we have to find the dynamic ID and use that - // one as a selector to hide it - const client = new HttpClient(); - client.get( - shopUrl + '/mollie/apple-pay/applepay-id', - (data) => { - me.hideApplePay('#paymentMethod' + data.id); - } - ); - + this.hideApplePay('#paymentMethod' + this.options.applePayId) + // hide cart apple pay select option + if (this.options.hideApplePayOption) { + this.hideApplePaySelect(this.options.applePayId); + } } /** @@ -50,6 +45,15 @@ export default class MollieApplePayPaymentMethod extends Plugin { } } + /** + * + * @param applePayId + */ + hideApplePaySelect(applePayId) { + const option = document.querySelector('option[value="' + applePayId + '"]'); + option.remove(); + } + /** * * @returns {*} @@ -107,4 +111,4 @@ export default class MollieApplePayPaymentMethod extends Plugin { return null; } -} \ No newline at end of file +} diff --git a/src/Resources/views/storefront/page/account/payment/index.html.twig b/src/Resources/views/storefront/page/account/payment/index.html.twig index eb67c69ef..ac28f052b 100644 --- a/src/Resources/views/storefront/page/account/payment/index.html.twig +++ b/src/Resources/views/storefront/page/account/payment/index.html.twig @@ -4,7 +4,9 @@ {% if mollie_applepay_enabled %}
{% endif %} @@ -78,4 +80,4 @@ {% endblock %} {{ parent() }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/Resources/views/storefront/page/checkout/cart/index.html.twig b/src/Resources/views/storefront/page/checkout/cart/index.html.twig index 536dffa58..320518a22 100644 --- a/src/Resources/views/storefront/page/checkout/cart/index.html.twig +++ b/src/Resources/views/storefront/page/checkout/cart/index.html.twig @@ -1,5 +1,19 @@ {% sw_extends '@Storefront/storefront/page/checkout/cart/index.html.twig' %} +{% block page_checkout_cart %} + {% if mollie_applepay_enabled %} +
+ {% endif %} + + {{ parent() }} +{% endblock %} + {% block page_checkout_cart_shipping_costs_form_group_payment_method %}
diff --git a/src/Subscriber/ApplePayDirectSubscriber.php b/src/Subscriber/ApplePayDirectSubscriber.php index ea78eadc8..03a9dace9 100644 --- a/src/Subscriber/ApplePayDirectSubscriber.php +++ b/src/Subscriber/ApplePayDirectSubscriber.php @@ -53,9 +53,12 @@ public function onStorefrontRender(StorefrontRenderEvent $event): void $shoPhoneNumberField = $settings->isPhoneNumberFieldRequired() || $settings->isPhoneNumberFieldShown(); + $applePayPaymentMethodId = $this->applePay->getActiveApplePayID($event->getSalesChannelContext()); + $event->setParameter('mollie_applepaydirect_phonenumber_required', (int)$shoPhoneNumberField); $event->setParameter('mollie_applepaydirect_enabled', $applePayDirectEnabled); $event->setParameter('mollie_applepaydirect_restrictions', $settings->getRestrictApplePayDirect()); $event->setParameter('mollie_express_required_data_protection', $settings->isRequireDataProtectionCheckbox() && $event->getSalesChannelContext()->getCustomer() == null); + $event->setParameter('apple_pay_payment_method_id', $applePayPaymentMethodId); } }