付款失败后防止用户使用SaaS应用的最佳方法是什么 [英] What is the best way to prevent user from using SaaS app after failed payment

查看:118
本文介绍了付款失败后防止用户使用SaaS应用的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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

条带使处理失败的付款变得容易. Stripe可以在失败后自动重试定期付款,如果重复失败则可以自动取消客户的订阅.您可以在帐户设置中轻松设置等待时间和重试次数.

Stripe makes handling failed payments easy. Stripe can automatically retry a recurring payment after it fails, and can automatically cancel the customer's subscription if it repeatedly fails. How long to wait, and how many times to retry, can be easily set in your account settings.

我可能会在我的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):

可能的值为trialingactive past_due canceled unpaid .试用期仍为trialing的订阅,试用期结束后将移至active. 续订订阅的付款失败时,订阅将变为past_due.在Stripe用尽所有付款重试尝试后,根据您的重试设置,订阅最终的状态为canceledunpaid.请注意,当订阅的状态为未付款时,将来的任何发票都会在更新客户的卡详细信息之前,请勿尝试.

Possible values are trialing, active, past_due, canceled, or unpaid. A subscription still in its trial period is trialing and moves to active when the trial period is over. When payment to renew the subscription fails, the subscription becomes past_due. After Stripe has exhausted all payment retry attempts, the subscription ends up with a status of either canceled or unpaid depending on your retry settings. Note that when a subscription has a status of unpaid, any future invoices will not be attempted until the customer’s card details are updated.

如果响应以上述粗体状态之一返回,请为用户标记:subscription_activefalse.在需要为用户有条件地启用应用程序功能的任何地方,请选中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应用的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆