From 00d8ef5a76178b4612017ede8af14c18bfd24598 Mon Sep 17 00:00:00 2001 From: Danny Date: Fri, 16 Feb 2024 11:56:07 +0100 Subject: [PATCH] AM-119: added check for applepay, remove element if it is not available --- views/frontend/tpl/payment/adyen_assets.tpl | 29 +++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/views/frontend/tpl/payment/adyen_assets.tpl b/views/frontend/tpl/payment/adyen_assets.tpl index 48b0ebc..d497d15 100644 --- a/views/frontend/tpl/payment/adyen_assets.tpl +++ b/views/frontend/tpl/payment/adyen_assets.tpl @@ -59,7 +59,23 @@ [{if $isLog}] console.log(checkout.paymentMethodsResponse); [{/if}] - [{if $isPaymentPage && $oView->isAvailablePayment($adyenCreditCard)}] + [{if $isPaymentPage}] + const apple = checkout.create( + 'applepay', + { + } + ); + apple.isAvailable() + .then(() => { }) + .catch(e => { + [{if $isLog}] + console.error('Apple Pay not available'); + console.error(e); + [{/if}] + hidePaymentOption(); + }); + [{/if}] + [{if $isPaymentPage && $oView->isAvailablePayment($adyenCreditCard)}] const cardComponent = checkout.create( 'card', { @@ -162,6 +178,15 @@ // Call adyenAsync adyenAsync(); + function hidePaymentOption() { + var inputElement = document.getElementById('payment_oscadyenapplepay'); + if (inputElement) { + var parentElement = inputElement.closest('.well.well-sm'); + if (parentElement) { + parentElement.remove(); // remove parent-block + } + } + } [{/capture}] [{if $phpStorm}][{/if}] -[{oxscript add=$adyenJS}] \ No newline at end of file +[{oxscript add=$adyenJS}]