diff --git a/web/Dockerfile.auis b/web/Dockerfile.auis index 1c67b25..6d350af 100644 --- a/web/Dockerfile.auis +++ b/web/Dockerfile.auis @@ -33,7 +33,6 @@ ENV VITE_API_URL="https://auis-api.fly.dev" ENV VITE_STRAPI_URL="https://auis-strapi.fly.dev" ENV VITE_APP_URL="https://auis.fly.dev" ENV VITE_APP_NAME="AUIS" -ENV VITE_STRIPE_PUBLISHABLE_KEY=pk_test_51PPclyP464csY2UpQPZ4cpWlyupAwPXfvWZRIG0zy9BhlYE8GmR4LYEytjFKOjMS6o5oXF5I0QMB8RWcc0TqsNxC00Nz3UAH14 # Mount secrets into Dockerfile and set environment variables RUN yarn run build diff --git a/web/src/screens/CheckoutScreen.tsx b/web/src/screens/CheckoutScreen.tsx index 67c7508..7c2581c 100644 --- a/web/src/screens/CheckoutScreen.tsx +++ b/web/src/screens/CheckoutScreen.tsx @@ -1,18 +1,19 @@ import { useCallback } from "react"; +import { loadStripe } from "@stripe/stripe-js"; import { EmbeddedCheckoutProvider, EmbeddedCheckout, } from "@stripe/react-stripe-js"; import { useLocation } from "react-router"; -import { stripeKey } from "../stripe/stripe"; import { fetchEventOrMembershipCheckoutSecret } from "../api/apiRequests"; import CheckoutError from "@components/checkout-page/CheckoutError"; +const STRIPE_PUBLISHABLE_KEY = import.meta.env.VITE_STRIPE_PUBLISHABLE_KEY; + // Make sure to call `loadStripe` outside of a component’s render to avoid // recreating the `Stripe` object on every render. -const stripePromise = stripeKey; +const stripePromise = loadStripe(`${STRIPE_PUBLISHABLE_KEY}`); let bodyData: { priceId: string; userTicketId: number }; - export default function CheckoutScreen() { const location = useLocation(); // ensure data required for checkout is here diff --git a/web/src/stripe/stripe.ts b/web/src/stripe/stripe.ts deleted file mode 100644 index 5f7a8e1..0000000 --- a/web/src/stripe/stripe.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { loadStripe } from "@stripe/stripe-js"; - -//import the key from the env -const STRIPE_PUBLISHABLE_KEY = import.meta.env.VITE_STRIPE_PUBLISHABLE_KEY; - -//This is where we load the stripe key, then export it. -export const stripeKey = await loadStripe(`${STRIPE_PUBLISHABLE_KEY}`);