My attempts to attach an event listener to the close button in stripe checkout form (the default one) have been unsuccessful, as I keep getting the error message "Cannot read property 'addEventListener' of null". Here is the code snippet I am using:
<script>
var pay = document.querySelector(".Header-navClose");
var pay2 = document.querySelector(".close");
var modal = document.querySelector(".ReactModal__Content")
pay.addEventListener("click",()=>{
pay.style.display="none";
modal.style.display = "block";
})
</script>
For your information, I am working with version v2 of stripe checkout.js.