[英]How to pass existing subscription details on stripe during checkout
I've different subscription plan on stripe starting from Zero.从零开始,我有不同的条带订阅计划。 When customer sign up, I'm creating a subscription with free plan by default.
当客户注册时,我默认创建一个带有免费计划的订阅。
In the future, customer want to upgrade the plan through checkout session, how can I pass my existing subscription details to the checkout session to update the plan tagged to the subscription ID instead of creating multiple subscriptions.将来,客户希望通过结帐 session 升级计划,如何将我现有的订阅详细信息传递给结帐 session 以更新标记为订阅 ID 的计划,而不是创建多个订阅。
I gone through the stripe create checkout session Doc but I couldn't find a way to pass subscription ID in checkout session.我浏览了条带创建结帐 session 文档,但我找不到在结帐 session 中传递订阅 ID 的方法。
Any help would be much appreciated任何帮助将非常感激
You are trying to update an existing Subscription through a CheckoutSession, that is not supported.您正在尝试通过CheckoutSession 更新现有订阅,这是不受支持的。
If a customer uses Checkout to sign up for a new Price, that creates a completely new Subscription object.如果客户使用 Checkout 注册新价格,则会创建一个全新的订阅 object。 You cannot pass an existing Subscription ID as Checkout cannot modify that.
您无法传递现有的订阅 ID,因为 Checkout 无法修改它。
You should use Checkout in mode: setup
to collect card details from your customer.您应该在
mode: setup
从您的客户那里收集卡详细信息。 This setup
mode only collects card details but does not charge or create a Subscription on that Customer.此
setup
模式仅收集卡详细信息,但不会对该客户收费或创建订阅。
Then in your server-side code after you receive the checkout.session.completed
webhook event, update the existing Subscription to switch from the "free" Price to the "paid" Price: https://stripe.com/docs/api/subscriptions/update然后在您的服务器端代码中收到
checkout.session.completed
webhook 事件后,更新现有订阅以从“免费”价格切换到“付费”价格: https://stripe.com/docs/api/订阅/更新
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.