Files
scha/schasite/static/main.js
2025-03-07 12:15:48 -06:00

24 lines
675 B
JavaScript

// static/main.js
console.log("Sanity Check");
fetch("/schasite/config/")
.then((result) => {return result.json(); })
.then((data) => {
const stripe = Stripe(data.publicKey);
// Event Handler
document.querySelector("#submitBtn").addEventListener("click", () => {
// Get Checkout Session ID
fetch("/schasite/create-checkout-session/")
.then((result) => { return result.json(); })
.then((data) => {
console.log(data);
// Redirect to Stripe Checkout
return stripe.redirectToCheckout({sessionId: data.sessionId})
})
.then((res) => {
console.log(res);
});
});
});