import wixWindow from 'wix-window';
$w.onReady(function () {
// Set the button's onClick event handler
$w('#payButton').onClick(async () => {
try {
// Make an AJAX request to your server-side code
const response = await fetch('/generateEncryptedURL', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({}),
});
const data = await response.json();
// Open the encrypted URL in a new tab
wixWindow.openWindow(data.encryptedUrl, '_blank');
} catch (error) {
console.error('Error:', error);
}
});
});
top of page
bottom of page