#metalman247 - console errors
1 messages · Page 1 of 1 (latest)
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?
So you will need to pass "subscription" instead of "payment" here: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-mode
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I dont have payment anywhere in my code
Can you share your code where you're creating your session?
Can you just share the block of code where you are creating the session in here?
yes
Just plain text in the chat
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}
>
Right here: mode: "payment",
wait i see it
yup
Im sorry im dumb
No you're not!