问题描述
我正在使用Ruby on Rails开发SaaS应用程序.每个用户都必须订阅一个特定的计划才能开始使用该应用程序.此步骤已使用Stripe完成
I am developing a SaaS application using Ruby on Rails. Each user has to subscribe to a specific plan to start using the application. This step has been done using Stripe
问题是,如果自动付款订阅失败(他更换了信用卡等),我不知道如何阻止该用户使用我的应用程序.我正在考虑在用户"模型中使用一列将该用户标记为非活动状态并阻止其登录.但是,此操作不符合我的预期,因为我希望该用户能够登录,但他将不得不更新其订阅继续.
The problem is I don't know how to prevent this user from using my application if the auto payment subscription is failed (he change his credit card, etc...). I am thinking of using a column in User model to mark this user as inactive and prevent him from signing in. But it does not work as I expected because I want this user to be able to sign in but he will have to update his subscription to continue.
顺便说一下,我在Rails上看到了许多SaaS示例,例如 https://github .com/RailsApps/rails-stripe-membership-saas 或 https://github.com/railscasts/289-paypal-recurring-billing ,但似乎每当发生故障时,它们都不会处理来自提供商(Stripe或Paypal)的回发.
By the way, I saw many SaaS example on Rails such as https://github.com/RailsApps/rails-stripe-membership-saas or https://github.com/railscasts/289-paypal-recurring-billing but it seems that they don't handle the postback from provider (Stripe or Paypal) whenever there is failure occurs.
请让我知道您的想法以及您在类似项目中如何处理此问题.
Please let me know what do you think and how you guys deal with this issue in your similar projects.
预先感谢
推荐答案
Stripe会定期为您收费.您的应用程序不负责为订阅了您的服务的用户创建新费用.
Stripe charges the card on a recurring basis for you. Your application isn't responsible for creating new charges for users who have subscribed for your service.
来自 文档
From the docs
我可能会在我的User
模型上跟踪一个:subscription_active
布尔值或类似值.用户登录后,您可以检查API以查看用户订阅的状态. API文档 的内容是关于(强调我自己)
I might track a :subscription_active
boolean or similar on my User
model. When a user logs in, you can check against the API to see the status of a user's subscription. The API docs have this to say about the status
of a subscription in the response (emphasis my own):
如果响应以上述粗体状态之一返回,请为用户标记:subscription_active
至false
.在需要为用户有条件地启用应用程序功能的任何地方,请选中user.subscription_active?
.
If the response comes back as one of the above bolded states, mark the :subscription_active
to false
for the user. Check user.subscription_active?
wherever you need to conditionally enable features of your application for a user.
这篇关于付款失败后防止用户使用SaaS应用的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!