I just generated a buy button via online checkout and there's a bug in it.
There are two attempts to create a reference to the pay button:
On line 46:
const url = document.getElementById('embedded-checkout-modal-checkout-button').getAttribute('data-url');
On line 72:
document.getElementById('embedded-checkout-modal-checkout-button').addEventListener('click', function (e) {
The button is defined on line 25 but it is not given an id.
As a result, Javascript throws an error when when trying to assign the event listener. Clicking the button is then treated as a normal link which opens the payment dialogue in a new page replacing our payment page, instead of in a modal window.
The problem is corrected by adding:
id="embedded-checkout-modal-checkout-button" in the a tag.
Andy
I should have said it opens the payment dialogue in a new window in the browser instead of a modal one.
Hey @AndyHenderson, thanks for flagging this here.
Sorry to hear you are running into this and for the delayed response.
Can you let me know how to set up your buy button - I'd imagine you followed the steps in this article but I'd just like to confirm.
From there can you please share a link to your site with the buy buttons here so our team can take a look?
Thanks, I'll keep an eye out for your response.
Square Community
Square Products