#metalman247 - console errors

1 messages · Page 1 of 1 (latest)

woeful juniper
#

Hi there. The error message shows that you are using the wrong price type. Are you trying to create a checkout session for a subscription payment?

zinc juniper
#

Yes I am

#

The checkout is just for a annual subscription

woeful juniper
zinc juniper
#

I dont have payment anywhere in my code

woeful juniper
#

Can you share your code where you're creating your session?

zinc juniper
#

Here is the zip

woeful juniper
#

Can you just share the block of code where you are creating the session in here?

zinc juniper
#

yes

woeful juniper
#

Just plain text in the chat

zinc juniper
#

let stripePromise;

console.log(process.env.REACT_APP_STRIPE_KEY)
const getStripe = () => {
if (!stripePromise) {
console.log(process.env.REACT_APP_STRIPE_KEY)
stripePromise = loadStripe(${process.env.REACT_APP_STRIPE_KEY});

}

return stripePromise;
};

const Checkout = () => {
const [stripeError, setStripeError] = useState(null);
const [isLoading, setLoading] = useState(false);
const item = {
price: "price_1LICvvEz5p7B7heW0zmzBWzD",
quantity: 1
};

const checkoutOptions = {
lineItems: [item],
mode: "payment",
successUrl: ${window.location.origin}/success,
cancelUrl: ${window.location.origin}/cancel
};

const redirectToCheckout = async () => {
setLoading(true);
console.log("redirectToCheckout");

const stripe = await getStripe();
const { error } = await stripe.redirectToCheckout(checkoutOptions);
console.log("Stripe checkout error", error);

if (error) setStripeError(error.message);
setLoading(false);

};

if (stripeError) alert(stripeError);

return (
<div className="checkout">
<h1>Stripe Checkout</h1>
<p className="checkout-title">Buy Annual Subscription</p>
<p className="checkout-description">
Access a Database with any College Coach
</p>
<h1 className="checkout-price">$1,100</h1>

  <button
    className="checkout-button"
    onClick={redirectToCheckout}
    disabled={isLoading}
  >
woeful juniper
#

Right here: mode: "payment",

zinc juniper
#

wait i see it

woeful juniper
#

yup

zinc juniper
#

Im sorry im dumb

woeful juniper
#

No you're not!