diff --git a/BTCPayServer/Views/Shared/PayButton/PayButton.cshtml b/BTCPayServer/Views/Shared/PayButton/PayButton.cshtml index 149c389e2..62f23074f 100644 --- a/BTCPayServer/Views/Shared/PayButton/PayButton.cshtml +++ b/BTCPayServer/Views/Shared/PayButton/PayButton.cshtml @@ -1,14 +1,7 @@ -@inject Security.ContentSecurityPolicies csp @using BTCPayServer.Views.Stores @model BTCPayServer.Plugins.PayButton.Models.PayButtonViewModel @{ ViewData.SetActivePage(StoreNavPages.PayButton, "Pay Button", Context.GetStoreData().Id); - csp.AllowUnsafeHashes("onBTCPayFormSubmit(event);return false"); - csp.AllowUnsafeHashes("handleSliderChange(event);return false"); - csp.AllowUnsafeHashes("handleSliderInput(event);return false"); - csp.AllowUnsafeHashes("handlePriceSlider(event);return false"); - csp.AllowUnsafeHashes("handlePriceInput(event);return false"); - csp.AllowUnsafeHashes("handlePlusMinus(event);return false"); } @section PageHeadContent { @@ -27,7 +20,7 @@ script.src = @(Safe.Json(Model.UrlRoot + "modal/btcpay.js")); document.getElementsByTagName('head')[0].append(script); } - function onBTCPayFormSubmit(event) { + function handleFormSubmit(event) { event.preventDefault(); var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { @@ -38,6 +31,12 @@ xhttp.open('POST', event.target.getAttribute('action'), true); xhttp.send(new FormData(event.target)); } + document.querySelectorAll(".btcpay-form").forEach(function(el) { + if (!el.dataset.initialized) { + el.addEventListener('submit', handleFormSubmit); + el.dataset.initialized = true; + } + }); -