mollie / magento2-hyva-checkout

8 stars 7 forks source link

Apple Pay Button not displayed in Cart/Minicart #34

Open webDaMedienGmbH20 opened 4 days ago

webDaMedienGmbH20 commented 4 days ago

We're using hyvä themes with hyvä checkout and the Mollie compatibillity module. We set up ApplePay in external mode and it worked as expected in the checkout. But when chainging to internal mode, the Apple Pay button is not displayed. The issue persists when we switch the store to Hyva_Default and Magento_Luma themes. Contact with mollie support directed us to create a github issue.

For debugging, we set a fixed size on the div containing initMollieApplePayMinicart(), which to our understanding should be where the button is displayed. Triggering it causes a call to {base_url}/mollie/checkout/applePayValidation, which returns the following error:

Exception #0 (Mollie\Api\Exceptions\ApiException): Error executing API call (422: Unprocessable Entity): The 'validationUrl' field is missing. Field: validationUrl. Documentation: https://docs.mollie.com/overview/handling-errors

The Validation URL seems to be passed from the Frontend in a callback defined in Mollie_HyvaCompatibility/view/frontend/templates/Mollie_Payment/applepay/minicart/applepay-button.phtml:

session.onvalidatemerchant = (event) => {
            fetch(
                `${BASE_URL}mollie/checkout/applePayValidation?form_key=${hyva.getFormKey()}`,
                {
                    method: 'POST',
                    headers: {
                        'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
                    },
                    body: mollieObjectToFormData({validationURL: event.validationURL}),
                }
            )

If we console.log event we get:

Event { isTrusted:true }

Environment:

PHP: 8.2.13 Magento: 2.4.6-p4 hyva-themes/magento2-default-theme: 1.3.9 hyva-themes/magento2-hyva-checkout: 1.1.17 mollie/magento2: 2.42.0 mollie/magento2-hyva-checkout: 1.5.1 mollie/magento2-hyva-compatibility: 2.1.1

Our site currently requires HTTP authentification, but we've whitelisted Apple's IPs and have been able to provide merchant validation, so this appears to not be the cause of the issue.

Frank-Magmodules commented 2 days ago

Thank you for raising this issue, @webDaMedienGmbH20. We will look into it and get back to you soon.