我正在尝试通过已连接的帐户使用 Stripe Checkout。我可以在其中使用 transfer_data["destination"] 和 application_fee_percent 创建订阅。
预期流量:
- 创建结帐 session (服务器端)
checkout_session = stripe.checkout.Session.create(
success_url=domain_url + "/success.html",
cancel_url=domain_url + "/canceled.html",
payment_method_types=["card"],
mode="subscription",
line_items=[
{
"price": priceId,
"quantity": 1
}
],
customer=customerId)
- 将用户重定向到 Stripe 结帐页面
- 用户输入卡详细信息并订阅
我尝试使用 subscription_data["application_fee_percent"] 和 Stripe-Account 设置。 但这不起作用,因为找不到客户。因为我猜所有客户都是在平台帐户上创建的,而不是在连接的帐户(我想保留的)上创建的
所以我的问题:使用 Checkout 执行此操作的方法是什么?
我的另一个选择是:
- 收集卡信息以创建付款方式
- 使用 application_fee_percent 和 transfer_data[destination] 创建订阅。
但我更喜欢使用 Checkout 来收集卡详细信息,这在我看来是更好、更简单的用户流程...
所有建议将不胜感激。谢谢。
最佳答案
我认为这完全符合你的假设,但遇到了错误:
Error: Can only apply a subscription application_fee_percent when the Checkout Session is made on behalf of another account (using an OAuth key or the Stripe-Account header).
我想这就是你遇到的情况。我毫不犹豫地查看了docs然后是 changelog (对于我使用的 stripe-node
),并找到了我需要的提示:
Add
transfer_data[amount_percent]
on Subscription
经过我的测试,我可以确认您可以执行此操作,您只需使用amount_percent
( API ref ),使用 95% 的转账而不是 5%申请费(但要注意费用如何影响资金流)。
底线,你可以这样做:
checkout_session = stripe.checkout.Session.create(
success_url=domain_url + "/success.html",
cancel_url=domain_url + "/canceled.html",
payment_method_types=["card"],
mode="subscription",
line_items=[
{
"price": priceId,
"quantity": 1
}
],
customer=customerId),
subscription_data={
transfer_data={
destination='acct_1234',
amount_percent=95
}
}
关于stripe-payments - 我可以使用 strip 结账来支付订阅和目的地费用(关联帐户)吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66723211/