The function itself works fine, but it never makes it past the await on stripPromise.
import { loadStripe } from '@stripe/stripe-js';
// Make sure to call `loadStripe` outside of a component’s render to avoid
// recreating the `Stripe` object on every render.
const stripePromise = loadStripe('key');
const purchaseClick = async (event) =>
{
// Get Stripe.js instance
const stripe = await stripePromise;
console.log("stripe promise")
// Call your backend to create the Checkout Session
const response = await fetch('/create-checkout-session', { method: 'POST' });
const session = await response.json();
// When the customer clicks on the button, redirect them to Checkout.
const result = await stripe.redirectToCheckout(
{
sessionId: session.id,
});
if (result.error)
{
// If `redirectToCheckout` fails due to a browser or network
// error, display the localized error message to your customer
// using `result.error.message`.
}
};
The function itself works fine, but it never makes it past the await on stripPromise.