import {createCheckoutSession} from 'backend/stripe.jsw'; // Import backend function $w.onReady(function () { // Assuming the amount is passed via the URL, e.g., ?amount=5000 const urlParams = new URLSearchParams(window.location.search); const amount = urlParams.get('amount'); // Get the amount from the URL // Check if the amount is valid if (amount && !isNaN(amount)) { // Attach click event to the button $w('#payButton').onClick(async () => { try { const checkoutUrl = await createCheckoutSession(parseInt(amount)); // Create Checkout session // Redirect to the Stripe Checkout page window.location.href = checkoutUrl; } catch (error) { console.error('Error during Stripe Checkout session creation:', error); // Handle errors (e.g., show a message to the user) } }); } else { console.error('Invalid or missing amount parameter.'); } });
top of page
1
2
bottom of page