我不知道为什么我的请求失败了,我正在尝试使用订阅模式创建一个结帐会话并收取费用。这是我从 Stripe 返回的错误消息。
{message: 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).}
我没有使用我的主平台帐户 ID,我使用 express 创建了一个新的连接用户。我将新用户连接的 accountID 传递到我的服务器以创建会话。
这是我的服务器代码:
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [{
price: 'price_Xxxxxxxxxxxx',
quantity: 1,
}],
subscription_data: {
application_fee_percent: 10,
transfer_data: {
destination: accountId,
},
},
mode: 'subscription',
success_url: 'http://localhost:49430/stripesub?session_id={CHECKOUT_SESSION_ID}',
cancel_url: 'http://localhost:49430/stripesubcanceled',
});
res.status(200).json({
'sessionId': session.id
});
订阅产品或 line_items -> price
是我使用主平台帐户创建的产品,而不是使用 express 创建的关联帐户。
我的使命是创建一项服务,让企业可以通过 express 注册、选择订阅级别,并让他们的用户/会员通过支付订阅费用来注册他们的平台并获得访问权限。
答案 0 :(得分:0)
所以在与 Stripe 支持人员交谈一段时间后,我发现这是错误的:
subscription_data: {
application_fee_percent: 10,
transfer_data: {
destination: accountId,
},
},
它应该是这样的:
subscription_data: {
transfer_data: {
amount_percent: 90,
destination: accountId,
},
},