From 99da2128d15dad3d5863af93b70cdf139aa4b837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Wed, 18 Aug 2021 17:48:02 +0200 Subject: [PATCH] Fixes for Javascript --- .../ninja2020/gateways/square/credit_card/pay.blade.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/resources/views/portal/ninja2020/gateways/square/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/square/credit_card/pay.blade.php index ec4ade5214bd..e6f8d956e425 100644 --- a/resources/views/portal/ninja2020/gateways/square/credit_card/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/square/credit_card/pay.blade.php @@ -68,6 +68,7 @@ constructor() { this.appId = document.querySelector('meta[name=square-appId]').content; this.locationId = document.querySelector('meta[name=square-locationId]').content; + this.isLoaded = false; } async init() { @@ -77,6 +78,8 @@ await this.card.attach('#card-container'); + this.isLoaded = true; + let iframeContainer = document.querySelector('.sq-card-iframe-container'); if (iframeContainer) { @@ -151,11 +154,13 @@ document .getElementById('toggle-payment-with-credit-card') .addEventListener('click', async (element) => { - await this.init(); - document.getElementById('card-container').classList.remove('hidden'); document.getElementById('save-card--container').style.display = 'grid'; document.querySelector('input[name=token]').value = ""; + + if (!this.isLoaded) { + await this.init(); + } }); let toggleWithToken = document.querySelector('.toggle-payment-with-token');