问题描述
在使用 \Stripe\Checkout\Session::create 创建用于结帐的 Stripe 会话时,当我尝试添加金额为 0 美元(免费)的订单项时,我得到一个无效整数.我正在使用 PHP 服务器端集成.
When creating a Stripe Session for Checkout using \Stripe\Checkout\Session::create I get an invalid integer when I try to add a line item with an amount of $0 (free). I am using PHP Server side integration.
所有其他订单项的总金额超过了 0.50 美元的最低收费金额,如果我 (i) 将 0 美元的项目全部移除,或 (ii) 给该项目的金额为 0.01 美元,则一切正常,并且会话创建成功.
The total of all the other line items exceeds the minimum charge amount of $0.50 and if I either (i) remove the $0 item all together, or (ii) give the item an amount of $0.01, then all works good and the session is successfully created.
场景应该是这样的:
数量 1 x 成人票 @ $10.00
Qty 1 x Adult Ticket @ $10.00
1 x 儿童票(6 岁以上)@ $5.00
Qty 1 x Child Ticket (age 6+) @ $5.00
1 x 儿童票(6 岁以下)@ $0.00(免费)
Qty 1 x Child Ticket (under age 6) @ $0.00 (FREE)
由于在这种情况下所有订单项的总金额为 15.00 美元,高于 0.50 美元的最低收费金额,因此所有这三个订单项都应显示在结帐页面上,包括 0.00 美元的免费项目.
Since the TOTAL of ALL line items in this case would be $15.00, which is greater than the minimum charge amount of $0.50, all three of these line items should show up on the checkout page, including the FREE item at $0.00.
这是 Stripe 的限制,不允许 0 美元的商品,还是我遗漏了什么?
Is this a limitation on Stripe's part, not allowing a $0 item, or am I missing something?
\Stripe\Checkout\Session::create([
'customer_email' => '[email protected]',
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel',
'payment_method_types' => ['card'],
'line_items' = [
["name"=>"Adult Ticket", "description"=>"Full price Adult Ticket", "amount"=>"1000", "currency"=>"usd", "quantity"=>"1" ],
[ "name"=>"Child Ticket (age 6+)", "description"=>"Full price Child Ticket", "amount"=>"500", "currency"=>"usd", "quantity"=>"1" ],
[ "name"=>"Child Ticket (under age 6)", "description"=>"FREE Child Ticket", "amount"=>"0", "currency"=>"usd", "quantity"=>"1" ]
]
])
推荐答案
就目前而言,据 Stripe 称,他们不允许在结帐会话中使用 $0 行项目.
So as it stands right now, according to Stripe, they do not allow $0 line items in a Checkout Session.
我已经向他们提出了添加此功能的功能请求.
I have made a feature request for them to add this functionality.
这篇关于向 Stripe Checkout 会话添加 0 美元的免费商品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!