-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
58 lines (45 loc) · 1.63 KB
/
Copy pathapp.js
File metadata and controls
58 lines (45 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// FortressCodeAI Marketplace – front-end logic
const PAYPAL_ME_BASE = "https://www.paypal.me/FortressCodeAI";
let selectedPack = null;
function initPackSelection() {
const cards = document.querySelectorAll(".pack-card");
const nameEl = document.getElementById("selected-pack-name");
const priceEl = document.getElementById("selected-pack-price");
const payBtn = document.getElementById("pay-button");
function updatePayButton() {
if (!selectedPack) {
payBtn.classList.add("disabled");
payBtn.href = "#";
return;
}
payBtn.classList.remove("disabled");
const amount = selectedPack.price;
// PayPal.Me supports /amount at the end
const url = amount > 0 ? `${PAYPAL_ME_BASE}/${amount}` : PAYPAL_ME_BASE;
payBtn.href = url;
}
cards.forEach(card => {
card.addEventListener("click", () => {
cards.forEach(c => c.classList.remove("selected"));
card.classList.add("selected");
const packId = card.getAttribute("data-pack-id");
const price = parseFloat(card.getAttribute("data-price"));
const title = card.querySelector("h3").textContent;
selectedPack = { id: packId, title, price };
nameEl.textContent = title;
priceEl.textContent = price > 0 ? `· CA$${price.toFixed(2)}` : "· Free";
updatePayButton();
});
});
// Initial state
payBtn.classList.add("disabled");
payBtn.addEventListener("click", (e) => {
if (!selectedPack) {
e.preventDefault();
alert("Please select a governance artifact before proceeding to payment.");
}
});
}
document.addEventListener("DOMContentLoaded", () => {
initPackSelection();
});