【发布时间】:2021-12-02 02:12:42
【问题描述】:
我有一个带有条带结账功能的 React 应用程序。但我需要在结账时通过多个项目来付款。现在再次它只适用于一项。但是我有一组称为“项目”的对象,需要一次性支付。处理这个问题的最佳方法是什么?所以如果你在我的代码中看到它是描述 Bounce House A 但项目数组可以有 [{description: 'Bounce House A', amount:200,qty:2},{description: 'Bounce House B', amount:250 ,数量:1}。
这是我当前的代码:
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY)
export default async (req, res) => {
const { id, amount } = req.body
try {
const payment = await stripe.paymentIntents.create({
amount,
currency: 'USD',
description: 'Bounce House A',
payment_method: id,
confirm: true,
})
console.log(payment)
return res.status(200).json({
confirm: 'abc123',
})
} catch (error) {}
}
【问题讨论】:
标签: reactjs next.js stripe-payments