英文:
Firebase stripe extension can't make two subscription prices
问题
Firebase,Stripe扩展集成。
我在Stripe上有一个产品,以及两个循环定价(订阅选项)。
问题出现在我尝试在“line-items”中添加年度和月度订阅选项时,之前我只使用了一个订阅选项,它通过“price”参数发送。
现在,当我想在Stripe端为同一产品发送两个订阅价格时,我无法生成Stripe结帐会话...因为“payload”不正确。
这是生成结帐会话的代码。
- 我在Stripe上创建了一个产品
- 创建了两个循环价格
- 获取这些ID并将它们包含在line-items中
- 由于响应结帐会话未创建
注意:如果我删除line-items并只包含一个价格,然后使用“price: priceId”发送它,它可以工作。
const checkoutSessionRef = collection(
firestore,
`users/${uid}/checkout_sessions`,
);
const docData = {
success_url: url,
cancel_url: url,
line_items: [
{
price: montlyPriceId,
quantity: 1,
},
{
price: yearlyPriceId,
quantity: 1,
},
],
};
}
await addDoc(checkoutSessionRef, docData);
关于在结帐会话中包含多个订阅选项的文档说明:
英文:
Firebase, Stripe extension integration.
I have one product on Stripe, and two recurring prices (subscription options)
The problem is appearing when I try to add yearly and monthly subscription options, in line-items
, before that I used one subscription option it was sent via the "price" param.
Now When I want to send two subscription prices for the same product on the stripe side, I cannot generate the stripe checkout session... cus "payload" is not good.
This is the code that generated the checkout session.
- I created a product on stripe
- Created two recurring prices
- Take those IDs and included them in line-items
- as the Response checkout session is not created
Note: If I remove line-items and include just one price, and send it with "price: priceId" it works
const checkoutSessionRef = collection(
firestore,
`users/${uid}/checkout_sessions`,
);
const docData = {
success_url: url,
cancel_url: url,
line_items: [
{
price: montlyPriceId,
quantity: 1,
},
{
price: yearlyPriceId,
quantity: 1,
},
],
};
}
await addDoc(checkoutSessionRef, docData);
Documentation explanation on including multiple subscription options in checkout sessions:
答案1
得分: 1
无法在单个订阅中使用具有不同结算周期的两个重复价格,例如年度和月度。您只能组合具有相同结算周期的价格,例如都是月度或都是年度。如果您希望同一客户拥有月度和年度订阅,您需要创建两个单独的订阅,或者在您的情况下,创建两个结账会话。
英文:
You can’t use 2 recurring prices with different billing periods - e.g. annual and monthly - in a single Subscription. You can only combine prices that have the same billing periods - e.g. both monthly, or both annual. If you want the same Customer to have both monthly and annual subscriptions, you will need to create 2 separate Subscriptions, or, in your case, two Checkout Sessions.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论