Files
portal_v3/admin/services/stripe/app1/client/register.js
equippedcoding-master e2c98790b2 initial commit
2025-09-17 09:37:06 -05:00

32 lines
1.0 KiB
JavaScript

document.addEventListener('DOMContentLoaded', async () => {
const signupForm = document.querySelector('#signup-form');
if (signupForm) {
signupForm.addEventListener('submit', async (e) => {
e.preventDefault();
// Grab reference to the emailInput. The email address
// entered will be passed to the server and used to create
// a customer. Email addresses do NOT uniquely identify
// customers in Stripe.
const emailInput = document.querySelector('#email');
// Create a customer. This will also set a cookie on the server
// to simulate having a logged in user.
const {customer} = await fetch('/create-customer', {
method: 'post',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
email: emailInput.value,
}),
}).then(r => r.json());
// Redirect to the pricing page.
window.location.href = '/prices.html';
});
} else {
alert("No sign up form with ID `signup-form` found on the page.");
}
});