import React, { useState, useEffect } from "react"; import type { Stripe } from "@stripe/stripe-js"; import { EmbeddedCheckoutProvider, EmbeddedCheckout, } from "@stripe/react-stripe-js"; //! Unsure whether this component is used/needed in the project // export const Return: React.FC = () => { // const [status, setStatus] = useState(null); // const [customerEmail, setCustomerEmail] = useState(""); // useEffect(() => { // const queryString = window.location.search; // const urlParams = new URLSearchParams(queryString); // const sessionId = urlParams.get("session_id"); // if (sessionId) { // console.log("1"); // fetch(`/api/session-status?session_id=${sessionId}`) // .then((res) => res.json()) // .then((data) => { // console.log("Response Data:", data); // setStatus(data.status); // setCustomerEmail(data.customer_email); // }); // } // }, []); // if (status === "open") { // return ; // } // if (status === "complete") { // return ( //
//

// We appreciate your business! A confirmation email will be sent to{" "} // {customerEmail}. If you have any questions, please email{" "} // orders@example.com. //

//
// ); // } // return null; // }; interface CheckoutFormProps { streamerID: number; onClose: () => void; } const CheckoutForm: React.FC = ({ streamerID, onClose }) => { const [stripePromise, setStripePromise] = useState | null>(null); useEffect(() => { const initializeStripe = async () => { const { loadStripe } = await import("@stripe/stripe-js"); setStripePromise(loadStripe(import.meta.env.VITE_STRIPE_PUBLISHABLE_KEY)); }; initializeStripe(); }, []); const fetchClientSecret = () => { return fetch(`/api/create-checkout-session?streamer_id=${streamerID}`, { method: "POST", }) .then((res) => res.json()) .then((data) => data.clientSecret); }; const options = { fetchClientSecret }; return ( <>
); }; export default CheckoutForm;