Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Schneider-Swales committed Jul 2, 2024
1 parent 52e9935 commit cf19ea1
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ window.addEventListener("DOMContentLoaded", async () => {
}
});

window.addEventListener('beforeunload', function() {
const radios = document.querySelectorAll('input[type="radio"]');
radios.forEach(radio => {
if (radio.defaultChecked) {
radio.checked = true;
} else {
radio.checked = false;
}
});
});

function loadCheckoutWeb() {
const searchParams = new URLSearchParams(window.location.search);
const head = document.getElementsByTagName("head")[0];
Expand Down Expand Up @@ -216,10 +227,27 @@ async function initPayment() {
switch (componentName) {
case "cards":
showCardsPaymentMethod(false);
return new Promise((resolve) => {
const message = document.getElementById("custom-override-message");
message.innerHTML = `onBeforeError called in Cards`;
message.style = "background-color: #FF4800; display: flex;";
setTimeout(() => {
message.style = "background-color: orange; display: none;";
resolve(true);
}, 1500);
});
break;
case "afterpay":
showAfterpayPaymentMethod(false);
break;
return new Promise((resolve) => {
const message = document.getElementById("custom-override-message");
message.innerHTML = `onBeforeError called in Afterpay`;
message.style = "background-color: #FF4800; display: flex;";
setTimeout(() => {
message.style = "background-color: orange; display: none;";
resolve(true);
}, 1500);
});
default:
document.getElementById("payment-methods").style.display = "none";
const message = document.getElementById("custom-override-message");
Expand Down Expand Up @@ -384,6 +412,10 @@ async function initPayment() {
}
}

function showError() {

}

async function getListResult() {
// Calculates payment amount based on payment outcome query parameter
const amount = getAmount();
Expand Down

0 comments on commit cf19ea1

Please sign in to comment.