im building a amazon clone and im getting the following error when i try to integrate stripe with the clone can someone please help me. the video im referring to is this one :https://www.youtube.com/watch?v=4E0WOUYF-QI&t=4092s
the error snippet:
error - StripeInvalidRequestError: You cannot use line_items.amount, line_items.currency, line_items.name, line_items.description, or line_items.images in this API version. Please use line_items.price or line_items.price_data. Please see https://stripe.com/docs/payments/checkout/migrating-prices for more information.
the code snippet:
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY);
export default async (req, res) => { const { items, email } = req.body;
const transformedItems = items.map((item) => ({
description: item.description,
quantity: 1,
price_data: {
currency: "gbp",
unit_amount: item.price * 100,
product_data: {
name: item.title,
images: [item.image],
},
},
}));
const session = await stripe.checkout.sessions.create({
payment_method_types: ["card"],
shipping_rates: ["shr_1LkVMHSArY9HEMGlxjejfRWf"],
shipping_address_collection: {
allowed_countries: ["GB", "US", "CA"],
},
line_items: transformedItems,
mode: "payment",
success_url: `${process.env.HOST}/success`,
cancel_url: `${process.env.HOST}/checkout`,
metadata: {
email,
images: JSON.stringify(items.map((item) => item.image)),
},
});
res.status(200).json({ id: session.id });
};
thank you