我正在构建 Amazon 克隆,当我尝试将 stripe 与克隆集成时,出现以下错误。有人可以帮帮我吗?我指的是这个视频:https://www.youtube.com/watch ?v=4E0WOUYF-QI&t=4092s
错误片段:
错误 - StripeInvalidRequestError:您不能在此 API 版本中使用
line_items.amount、line_items.currency、line_items.name、line_items.description或 。line_items.images请使用line_items.price或line_items.price_data。请参阅 https://stripe.com/docs/ payments/ checkout/migration-prices 了解更多信息。
代码片段:
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 …Run Code Online (Sandbox Code Playgroud)