Stripe Checkout会话总价,而不是Unit_price
我目前正在从事一个项目。而且我正在利用Stripe.checkout.session.treate功能完美效果。
const session = await stripe.checkout.sessions.create({
line_items: [
{
price_data: {
currency: "usd",
unit_amount: 500,
product_data: {
name: "name of the product",
},
},
quantity: 1,
},
],
mode: "payment",
success_url: "http://example.com/success",
cancel_url: "http://example.com/",
});
但是我唯一的问题是它仅收到单价。
但是我想要一个只能通过总价,原因是我的代码,如果用户将折扣应用到产品中,则它将其从产品总价中扣除,同时每种产品的单价稳定。
我的问题基本上是有一个我可以通过总价的领域。
I'm working on a project currently. and I'm making use of stripe, the stripe.checkout.session.create function works perfectly.
const session = await stripe.checkout.sessions.create({
line_items: [
{
price_data: {
currency: "usd",
unit_amount: 500,
product_data: {
name: "name of the product",
},
},
quantity: 1,
},
],
mode: "payment",
success_url: "http://example.com/success",
cancel_url: "http://example.com/",
});
but the only issue i have is it receives only unit price.
but i want a field where i can pass only total Price, cause in my code , if the users applys a discount to a product , it deducts it from the product total price meanwhile the unit price for each product is stable.
My question is basically is there a field where i can pass total price.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短的答案是您不能。您需要使用
line_items
并通过价格对象ID(PRISE_XXX
)或使用Price_data
参数使用临时定价。然后,结帐将计算所有订单项中的总数,以任何您提供的。您有几个选项可以实现所需的行为:
PRICE_DATA.UNIT_AMOUNT
值,以反映客户所应用的折扣。Short answer is that you can't. You need to use the
line_items
parameter and either pass a Price object ID (price_xxx
) or use ad-hoc pricing with theprice_data
parameter. Checkout will then compute the total from all line items, factoring in any discounts that you provide.You have a couple of options to achieve the behaviour you want:
price_data.unit_amount
value to reflect the discount applied by your customers.