const calculatePrice = () => {
const width = parseFloat(widthInput.value);
const height = parseFloat(heightInput.value);
if (isNaN(width) || isNaN(height) || width <= 0 || height <= 0) {
priceDisplay.text = "Veuillez entrer des dimensions valides.";
return;
}
const pricePerSquareMeter = 5;
const totalPrice = width * height * pricePerSquareMeter;
priceDisplay.text = `Prix total : ${totalPrice.toFixed(2)} €`;
};
calculatePriceButton.onClick = () => {
calculatePrice();
};
payButton.onClick = async () => {
const width = parseFloat(widthInput.value);
const height = parseFloat(heightInput.value);
if (isNaN(width) || isNaN(height) || width <= 0 || height <= 0) {
alert('Veuillez entrer des dimensions valides.');
return;
}
const pricePerSquareMeter = 5;
const totalPrice = width * height * pricePerSquareMeter;
try {
window.location.href = `https://checkout.stripe.com/c/pay/cs_test_your_stripe_checkout_session_id?amount=${totalPrice * 100}¤cy=eur&description=Bache+${width}x${height}m`;
} catch (error) {
console.error("Erreur lors de la redirection vers Stripe", error);
alert("Une erreur s'est produite. Veuillez réessayer.");
}
};